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

Chris Lattner sabre at nondot.org
Sun Jan 28 16:21:50 PST 2007



Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.127 -> 1.128
---
Log message:

Fix PR1139: http://llvm.org/PR1139 


---
Diffs of the changes:  (+23 -16)

 LinkModules.cpp |   39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.127 llvm/lib/Linker/LinkModules.cpp:1.128
--- llvm/lib/Linker/LinkModules.cpp:1.127	Fri Jan 26 02:11:39 2007
+++ llvm/lib/Linker/LinkModules.cpp	Sun Jan 28 18:21:34 2007
@@ -849,24 +849,31 @@
   assert(Dest != 0 && "Invalid Destination module");
   assert(Src  != 0 && "Invalid Source Module");
 
-  std::string DataLayout;
+  if (Dest->getDataLayout().empty()) {
+    if (!Src->getDataLayout().empty()) {
+      Dest->setDataLayout(Src->getTargetTriple());
+    } else {
+      std::string DataLayout;
+
+      if (Dest->getEndianness() == Module::AnyEndianness)
+        if (Src->getEndianness() == Module::BigEndian)
+          DataLayout.append("E");
+        else if (Src->getEndianness() == Module::LittleEndian)
+          DataLayout.append("e");
+      if (Dest->getPointerSize() == Module::AnyPointerSize)
+        if (Src->getPointerSize() == Module::Pointer64)
+          DataLayout.append(DataLayout.length() == 0 ? "p:64:64" : "-p:64:64");
+        else if (Src->getPointerSize() == Module::Pointer32)
+          DataLayout.append(DataLayout.length() == 0 ? "p:32:32" : "-p:32:32");
+      Dest->setDataLayout(DataLayout);
+    }
+  }
 
-  if (Dest->getEndianness() == Module::AnyEndianness)
-    if (Src->getEndianness() == Module::BigEndian)
-      DataLayout.append("E");
-    else if (Src->getEndianness() == Module::LittleEndian)
-      DataLayout.append("e");
-  if (Dest->getPointerSize() == Module::AnyPointerSize)
-    if (Src->getPointerSize() == Module::Pointer64)
-      DataLayout.append(DataLayout.length() == 0 ? "p:64:64" : "-p:64:64");
-    else if (Src->getPointerSize() == Module::Pointer32)
-      DataLayout.append(DataLayout.length() == 0 ? "p:32:32" : "-p:32:32");
-  if (Dest->getTargetTriple().empty())
+  if (Dest->getTargetTriple().empty() && !Src->getTargetTriple().empty())
     Dest->setTargetTriple(Src->getTargetTriple());
-  Dest->setDataLayout(DataLayout);
-
-  if (Src->getDataLayout().length() > 0 && Dest->getDataLayout().length() > 0 &&
-      Src->getDataLayout().compare(Dest->getDataLayout()) != 0)
+      
+  if (!Src->getDataLayout().empty() && !Dest->getDataLayout().empty() &&
+      Src->getDataLayout() != Dest->getDataLayout())
     cerr << "WARNING: Linking two modules of different data layouts!\n";
   if (!Src->getTargetTriple().empty() &&
       Dest->getTargetTriple() != Src->getTargetTriple())






More information about the llvm-commits mailing list