diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:22 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:22 +0000 | 
| commit | 1b08b196ac845675036ac78f3ac927d0a37f707c (patch) | |
| tree | 1fbd923674e903831dc097fdb4fdfd64dd6e47b1 /lib/CodeGen/CodeGenModule.cpp | |
| parent | 551c698530debaae81139c7c76a29fb762793362 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 30 | 
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index dde8f2e36920..77adf7b441a2 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1026,9 +1026,25 @@ void CodeGenModule::setNonAliasAttributes(const Decl *D,                                            llvm::GlobalObject *GO) {    SetCommonAttributes(D, GO); -  if (D) +  if (D) { +    if (auto *GV = dyn_cast<llvm::GlobalVariable>(GO)) { +      if (auto *SA = D->getAttr<PragmaClangBSSSectionAttr>()) +        GV->addAttribute("bss-section", SA->getName()); +      if (auto *SA = D->getAttr<PragmaClangDataSectionAttr>()) +        GV->addAttribute("data-section", SA->getName()); +      if (auto *SA = D->getAttr<PragmaClangRodataSectionAttr>()) +        GV->addAttribute("rodata-section", SA->getName()); +    } + +    if (auto *F = dyn_cast<llvm::Function>(GO)) { +      if (auto *SA = D->getAttr<PragmaClangTextSectionAttr>()) +       if (!D->getAttr<SectionAttr>()) +         F->addFnAttr("implicit-section-name", SA->getName()); +    } +      if (const SectionAttr *SA = D->getAttr<SectionAttr>())        GO->setSection(SA->getName()); +  }    getTargetCodeGenInfo().setTargetAttributes(D, GO, *this);  } @@ -1127,6 +1143,10 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,    setLinkageAndVisibilityForGV(F, FD); +  if (FD->getAttr<PragmaClangTextSectionAttr>()) { +    F->addFnAttr("implicit-section-name"); +  } +    if (const SectionAttr *SA = FD->getAttr<SectionAttr>())      F->setSection(SA->getName()); @@ -2828,6 +2848,14 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context,    if (D->hasAttr<SectionAttr>())      return true; +  // A variable cannot be both common and exist in a section. +  // We dont try to determine which is the right section in the front-end. +  // If no specialized section name is applicable, it will resort to default. +  if (D->hasAttr<PragmaClangBSSSectionAttr>() || +      D->hasAttr<PragmaClangDataSectionAttr>() || +      D->hasAttr<PragmaClangRodataSectionAttr>()) +    return true; +    // Thread local vars aren't considered common linkage.    if (D->getTLSKind())      return true;  | 
