[llvm-commits] CVS: llvm/lib/Linker/LinkModules.cpp

Lauro Ramos Venancio lauro.venancio at gmail.com
Wed Jun 6 15:01:34 PDT 2007



Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.140 -> 1.141
---
Log message:

Propagate alignment, section name and visibility when linking "appending
global values". 
Fix noinline linkage.


---
Diffs of the changes:  (+15 -0)

 LinkModules.cpp |   15 +++++++++++++++
 1 files changed, 15 insertions(+)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.140 llvm/lib/Linker/LinkModules.cpp:1.141
--- llvm/lib/Linker/LinkModules.cpp:1.140	Sun Apr 29 15:56:48 2007
+++ llvm/lib/Linker/LinkModules.cpp	Wed Jun  6 17:01:12 2007
@@ -827,6 +827,18 @@
         return Error(ErrorMsg,
                      "Appending variables linked with different const'ness!");
 
+      if (G1->getAlignment() != G2->getAlignment())
+        return Error(ErrorMsg,
+         "Appending variables with different alignment need to be linked!");
+
+      if (G1->getVisibility() != G2->getVisibility())
+        return Error(ErrorMsg,
+         "Appending variables with different visibility need to be linked!");
+
+      if (G1->getSection() != G2->getSection())
+        return Error(ErrorMsg,
+         "Appending variables with different section name need to be linked!");
+      
       unsigned NewSize = T1->getNumElements() + T2->getNumElements();
       ArrayType *NewType = ArrayType::get(T1->getElementType(), NewSize);
 
@@ -837,6 +849,9 @@
         new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(),
                            /*init*/0, First->first, M, G1->isThreadLocal());
 
+      // Propagate alignment, visibility and section info.
+      CopyGVAttributes(NG, G1);
+
       // Merge the initializer...
       Inits.reserve(NewSize);
       if (ConstantArray *I = dyn_cast<ConstantArray>(G1->getInitializer())) {






More information about the llvm-commits mailing list