Copy externally_initialized in GlobalVariable::copyAttributesFrom.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 10 Nov 2014 18:41:59 +0000 (18:41 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 10 Nov 2014 18:41:59 +0000 (18:41 +0000)
Patch by Kevin Frei!

llvm-svn: 221620

llvm/lib/IR/Globals.cpp
llvm/test/Linker/lto-attributes.ll [new file with mode: 0644]

index cecd999..e181d62 100644 (file)
@@ -246,6 +246,7 @@ void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
   GlobalObject::copyAttributesFrom(Src);
   const GlobalVariable *SrcVar = cast<GlobalVariable>(Src);
   setThreadLocalMode(SrcVar->getThreadLocalMode());
+  setExternallyInitialized(SrcVar->isExternallyInitialized());
 }
 
 
diff --git a/llvm/test/Linker/lto-attributes.ll b/llvm/test/Linker/lto-attributes.ll
new file mode 100644 (file)
index 0000000..0dc78ad
--- /dev/null
@@ -0,0 +1,7 @@
+; RUN: llvm-link -S %s -o - | FileCheck %s
+
+; CHECK: @foo = private externally_initialized global i8* null
+@foo = private externally_initialized global i8* null
+; CHECK: @array = appending global [7 x i8] c"abcdefg", align 1
+@array = appending global [7 x i8] c"abcdefg", align 1
+