summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-09-26 23:42:34 +0000
committerErich Keane <erich.keane@intel.com>2017-09-26 23:42:34 +0000
commit99fdfb6a464467aeb8c8935b0aa8d68ba4f902a5 (patch)
tree45eb1f8ce300c44c8028490020f284b6c89dac54 /clang/lib/CodeGen/CodeGenModule.cpp
parent3bb50f6f7bdcf23f15cd6479e974de66754e3732 (diff)
downloadbcm5719-llvm-99fdfb6a464467aeb8c8935b0aa8d68ba4f902a5.tar.gz
bcm5719-llvm-99fdfb6a464467aeb8c8935b0aa8d68ba4f902a5.zip
Emit section information for extern variables.
Currently, if _attribute_((section())) is used for extern variables, section information is not emitted in generated IR when the variables are used. This is expected since sections are not generated for external linkage objects. However NiosII requires this information as it uses special GP-relative accesses for any objects that use attribute section (.sdata). GCC keeps this attribute in middle-end. This change emits the section information for all targets. Patch By: Elizabeth Andrews Differential Revision:https://reviews.llvm.org/D36487 llvm-svn: 314262
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 03a3e36b831..89185c89518 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2432,6 +2432,12 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
EmitGlobalVarDefinition(D);
}
+ // Emit section information for extern variables.
+ if (D->hasExternalStorage()) {
+ if (const SectionAttr *SA = D->getAttr<SectionAttr>())
+ GV->setSection(SA->getName());
+ }
+
// Handle XCore specific ABI requirements.
if (getTriple().getArch() == llvm::Triple::xcore &&
D->getLanguageLinkage() == CLanguageLinkage &&
OpenPOWER on IntegriCloud