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

2007-06-28 Thread Lauro Ramos Venancio


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.142 -> 1.143
---
Log message:

Fix a bug in my previous patch.



---
Diffs of the changes:  (+2 -3)

 LinkModules.cpp |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.142 
llvm/lib/Linker/LinkModules.cpp:1.143
--- llvm/lib/Linker/LinkModules.cpp:1.142   Thu Jun 28 14:02:54 2007
+++ llvm/lib/Linker/LinkModules.cpp Thu Jun 28 15:06:38 2007
@@ -578,9 +578,8 @@
 // FIXME: we should handle the bitcast alias.
 assert(NewAliased && "Can't find the aliased GV.");
 
-GlobalAlias *NewGA = new GlobalAlias(GA->getType()->getElementType(),
- GA->getLinkage(), GA->getName(),
- NewAliased, Dest);
+GlobalAlias *NewGA = new GlobalAlias(GA->getType(), GA->getLinkage(),
+ GA->getName(), NewAliased, Dest);
 CopyGVAttributes(NewGA, GA);
   }
   return false;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-06-28 Thread Lauro Ramos Venancio


Changes in directory llvm/lib/Linker:

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

When linking two modules, we should copy the alias.



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

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


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.141 
llvm/lib/Linker/LinkModules.cpp:1.142
--- llvm/lib/Linker/LinkModules.cpp:1.141   Wed Jun  6 17:01:12 2007
+++ llvm/lib/Linker/LinkModules.cpp Thu Jun 28 14:02:54 2007
@@ -561,6 +561,31 @@
   return false;
 }
 
+// LinkAlias - Loop through the alias in the src module and link them into the
+// dest module.
+static bool LinkAlias(Module *Dest, const Module *Src, std::string *Err) {
+  // Loop over all alias in the src module
+  for (Module::const_alias_iterator I = Src->alias_begin(),
+ E = Src->alias_end(); I != E; ++I) {
+const GlobalAlias *GA = I;
+
+GlobalValue *NewAliased = NULL;
+const GlobalValue *Aliased = GA->getAliasedGlobal();
+if (isa(*Aliased))
+  NewAliased = Dest->getGlobalVariable(Aliased->getName());
+else if (isa(*Aliased))
+  NewAliased = Dest->getFunction(Aliased->getName());
+// FIXME: we should handle the bitcast alias.
+assert(NewAliased && "Can't find the aliased GV.");
+
+GlobalAlias *NewGA = new GlobalAlias(GA->getType()->getElementType(),
+ GA->getLinkage(), GA->getName(),
+ NewAliased, Dest);
+CopyGVAttributes(NewGA, GA);
+  }
+  return false;
+}
+
 
 // LinkGlobalInits - Update the initializers in the Dest module now that all
 // globals that may be referenced are in Dest.
@@ -1005,6 +1030,9 @@
   // If there were any appending global variables, link them together now.
   if (LinkAppendingVars(Dest, AppendingVars, ErrorMsg)) return true;
 
+  // If there were any alias, link them now.
+  if (LinkAlias(Dest, Src, ErrorMsg)) return true;
+
   // If the source library's module id is in the dependent library list of the
   // destination library, remove it since that module is now linked in.
   sys::Path modId;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-06-06 Thread Lauro Ramos Venancio


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(G1->getInitializer())) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-29 Thread Anton Korobeynikov


Changes in directory llvm/lib/Linker:

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

Implement visibility checking during linking. Also implement protected 
visibility support for bitcode.


---
Diffs of the changes:  (+14 -1)

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


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.139 
llvm/lib/Linker/LinkModules.cpp:1.140
--- llvm/lib/Linker/LinkModules.cpp:1.139   Thu Apr 12 13:32:50 2007
+++ llvm/lib/Linker/LinkModules.cpp Sun Apr 29 15:56:48 2007
@@ -365,7 +365,9 @@
 /// the result will look like in the destination module.  In particular, it
 /// computes the resultant linkage type, computes whether the global in the
 /// source should be copied over to the destination (replacing the existing
-/// one), and computes whether this linkage is an error or not.
+/// one), and computes whether this linkage is an error or not. It also 
performs
+/// visibility checks: we cannot link together two symbols with different
+/// visibilities.
 static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src,
  GlobalValue::LinkageTypes <, bool &LinkFromSrc,
  std::string *Err) {
@@ -435,6 +437,11 @@
 return Error(Err, "Linking globals named '" + Src->getName() +
  "': symbol multiply defined!");
   }
+
+  // Check visibility
+  if (Dest && Src->getVisibility() != Dest->getVisibility())
+return Error(Err, "Linking globals named '" + Src->getName() +
+ "': symbols have different visibilities!");
   return false;
 }
 
@@ -617,6 +624,12 @@
 RecursiveResolveTypes(SF->getType(), DF->getType(), 
   &Dest->getTypeSymbolTable(), "");
 }
+
+// Check visibility
+if (DF && !DF->hasInternalLinkage() &&
+SF->getVisibility() != DF->getVisibility())
+  return Error(Err, "Linking functions named '" + SF->getName() +
+   "': symbols have different visibilities!");
 
 if (DF && DF->getType() != SF->getType()) {
   if (DF->isDeclaration() && !SF->isDeclaration()) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-12 Thread Lauro Ramos Venancio


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.138 -> 1.139
---
Log message:

Implement the "thread_local" keyword.


---
Diffs of the changes:  (+4 -3)

 LinkModules.cpp |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.138 
llvm/lib/Linker/LinkModules.cpp:1.139
--- llvm/lib/Linker/LinkModules.cpp:1.138   Wed Feb 14 20:26:10 2007
+++ llvm/lib/Linker/LinkModules.cpp Thu Apr 12 13:32:50 2007
@@ -477,7 +477,7 @@
   GlobalVariable *NewDGV =
 new GlobalVariable(SGV->getType()->getElementType(),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
-   SGV->getName(), Dest);
+   SGV->getName(), Dest, SGV->isThreadLocal());
   // Propagate alignment, visibility and section info.
   CopyGVAttributes(NewDGV, SGV);
 
@@ -500,7 +500,7 @@
   GlobalVariable *NewDGV =
 new GlobalVariable(SGV->getType()->getElementType(),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
-   "", Dest);
+   "", Dest, SGV->isThreadLocal());
 
   // Propagate alignment, section and visibility  info.
   NewDGV->setAlignment(DGV->getAlignment());
@@ -522,6 +522,7 @@
 GlobalVariable *NewDGV =
   new GlobalVariable(SGV->getType()->getElementType(),
  DGV->isConstant(), DGV->getLinkage());
+NewDGV->setThreadLocal(DGV->isThreadLocal());
 CopyGVAttributes(NewDGV, DGV);
 Dest->getGlobalList().insert(DGV, NewDGV);
 DGV->replaceAllUsesWith(
@@ -821,7 +822,7 @@
   // Create the new global variable...
   GlobalVariable *NG =
 new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(),
-   /*init*/0, First->first, M);
+   /*init*/0, First->first, M, G1->isThreadLocal());
 
   // Merge the initializer...
   Inits.reserve(NewSize);



___
llvm-commits mailing list
[EMAIL PROTECTED]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-14 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.137 -> 1.138
---
Log message:

For PR1195: http://llvm.org/PR1195 :
Rename PackedType -> VectorType, ConstantPacked -> ConstantVector, and
PackedTyID -> VectorTyID. No functional changes.


---
Diffs of the changes:  (+2 -2)

 LinkModules.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.137 
llvm/lib/Linker/LinkModules.cpp:1.138
--- llvm/lib/Linker/LinkModules.cpp:1.137   Sat Feb 10 18:39:38 2007
+++ llvm/lib/Linker/LinkModules.cpp Wed Feb 14 20:26:10 2007
@@ -295,11 +295,11 @@
   Result = ConstantStruct::get(cast(CPS->getType()), Operands);
 } else if (isa(CPV) || isa(CPV)) {
   Result = const_cast(CPV);
-} else if (const ConstantPacked *CP = dyn_cast(CPV)) {
+} else if (const ConstantVector *CP = dyn_cast(CPV)) {
   std::vector Operands(CP->getNumOperands());
   for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
 Operands[i] = cast(RemapOperand(CP->getOperand(i), 
ValueMap));
-  Result = ConstantPacked::get(Operands);
+  Result = ConstantVector::get(Operands);
 } else if (const ConstantExpr *CE = dyn_cast(CPV)) {
   std::vector Ops;
   for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-10 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.136 -> 1.137
---
Log message:

simplify this code by using value::takename


---
Diffs of the changes:  (+5 -8)

 LinkModules.cpp |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.136 
llvm/lib/Linker/LinkModules.cpp:1.137
--- llvm/lib/Linker/LinkModules.cpp:1.136   Mon Feb  5 14:47:20 2007
+++ llvm/lib/Linker/LinkModules.cpp Sat Feb 10 18:39:38 2007
@@ -337,18 +337,15 @@
   ValueSymbolTable &ST = GV->getParent()->getValueSymbolTable();
 
   // If there is a conflict, rename the conflict.
-  GlobalValue *ConflictGV = cast_or_null(ST.lookup(Name));
-  if (ConflictGV) {
+  if (GlobalValue *ConflictGV = cast_or_null(ST.lookup(Name))) {
 assert(ConflictGV->hasInternalLinkage() &&
"Not conflicting with a static global, should link instead!");
-ConflictGV->setName("");// Eliminate the conflict
-  }
-  GV->setName(Name);  // Force the name back
-  if (ConflictGV) {
-ConflictGV->setName(Name);  // This will cause ConflictGV to get 
renamed
+GV->takeName(ConflictGV);
+ConflictGV->setName(Name);// This will cause ConflictGV to get renamed
 assert(ConflictGV->getName() != Name && "ForceRenaming didn't work");
+  } else {
+GV->setName(Name);  // Force the name back
   }
-  assert(GV->getName() == Name && "ForceRenaming didn't work");
 }
 
 /// CopyGVAttributes - copy additional attributes (those not needed to 
construct



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-05 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.135 -> 1.136
---
Log message:

For PR411: http://llvm.org/PR411 :
This patch replaces the SymbolTable class with ValueSymbolTable which does
not support types planes. This means that all symbol names in LLVM must now
be unique. The patch addresses the necessary changes to deal with this and
removes code no longer needed as a result. This completes the bulk of the
changes for this PR. Some cleanup patches will follow.


---
Diffs of the changes:  (+99 -87)

 LinkModules.cpp |  186 +---
 1 files changed, 99 insertions(+), 87 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.135 
llvm/lib/Linker/LinkModules.cpp:1.136
--- llvm/lib/Linker/LinkModules.cpp:1.135   Sat Feb  3 22:43:17 2007
+++ llvm/lib/Linker/LinkModules.cpp Mon Feb  5 14:47:20 2007
@@ -20,8 +20,8 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/SymbolTable.h"
 #include "llvm/TypeSymbolTable.h"
+#include "llvm/ValueSymbolTable.h"
 #include "llvm/Instructions.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Support/Streams.h"
@@ -273,7 +273,8 @@
 static Value *RemapOperand(const Value *In,
std::map &ValueMap) {
   std::map::const_iterator I = ValueMap.find(In);
-  if (I != ValueMap.end()) return I->second;
+  if (I != ValueMap.end()) 
+return I->second;
 
   // Check to see if it's a constant that we are interested in transforming.
   Value *Result = 0;
@@ -333,20 +334,34 @@
 /// through the trouble to force this back.
 static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
   assert(GV->getName() != Name && "Can't force rename to self");
-  SymbolTable &ST = GV->getParent()->getValueSymbolTable();
+  ValueSymbolTable &ST = GV->getParent()->getValueSymbolTable();
 
   // If there is a conflict, rename the conflict.
-  Value *ConflictVal = ST.lookup(GV->getType(), Name);
-  assert(ConflictVal&&"Why do we have to force rename if there is no 
conflic?");
-  GlobalValue *ConflictGV = cast(ConflictVal);
-  assert(ConflictGV->hasInternalLinkage() &&
- "Not conflicting with a static global, should link instead!");
-
-  ConflictGV->setName("");  // Eliminate the conflict
-  GV->setName(Name);// Force the name back
-  ConflictGV->setName(Name);// This will cause ConflictGV to get 
renamed
-  assert(GV->getName() == Name && ConflictGV->getName() != Name &&
- "ForceRenaming didn't work");
+  GlobalValue *ConflictGV = cast_or_null(ST.lookup(Name));
+  if (ConflictGV) {
+assert(ConflictGV->hasInternalLinkage() &&
+   "Not conflicting with a static global, should link instead!");
+ConflictGV->setName("");// Eliminate the conflict
+  }
+  GV->setName(Name);  // Force the name back
+  if (ConflictGV) {
+ConflictGV->setName(Name);  // This will cause ConflictGV to get 
renamed
+assert(ConflictGV->getName() != Name && "ForceRenaming didn't work");
+  }
+  assert(GV->getName() == Name && "ForceRenaming didn't work");
+}
+
+/// CopyGVAttributes - copy additional attributes (those not needed to 
construct
+/// a GlobalValue) from the SrcGV to the DestGV. 
+static void CopyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) {
+  // Propagate alignment, visibility and section info.
+  DestGV->setAlignment(std::max(DestGV->getAlignment(), 
SrcGV->getAlignment()));
+  DestGV->setSection(SrcGV->getSection());
+  DestGV->setVisibility(SrcGV->getVisibility());
+  if (const Function *SrcF = dyn_cast(SrcGV)) {
+Function *DestF = cast(DestGV);
+DestF->setCallingConv(SrcF->getCallingConv());
+  }
 }
 
 /// GetLinkageResult - This analyzes the two global values and determines what
@@ -431,29 +446,20 @@
 static bool LinkGlobals(Module *Dest, Module *Src,
 std::map &ValueMap,
 std::multimap 
&AppendingVars,
-std::map &GlobalsByName,
 std::string *Err) {
-  // We will need a module level symbol table if the src module has a module
-  // level symbol table...
-  TypeSymbolTable *TST = &Dest->getTypeSymbolTable();
-
   // Loop over all of the globals in the src module, mapping them over as we go
   for (Module::global_iterator I = Src->global_begin(), E = Src->global_end();
I != E; ++I) {
 GlobalVariable *SGV = I;
 GlobalVariable *DGV = 0;
 // Check to see if may have to link the global.
-if (SGV->hasName() && !SGV->hasInternalLinkage())
-  if (!(DGV = Dest->getGlobalVariable(SGV->getName(),
-  SGV->getType()->getElementType( {
-std::map::iterator EGV =
-  GlobalsByName.find(SGV->getName());
-if (EGV != GlobalsByName.end())
-  DGV = dyn_cast(EGV->second);
-if (DGV)
-  // If types don't agre

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

2007-02-03 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.134 -> 1.135
---
Log message:

Fix some comments and other minor sundry things.


---
Diffs of the changes:  (+13 -12)

 LinkModules.cpp |   25 +
 1 files changed, 13 insertions(+), 12 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.134 
llvm/lib/Linker/LinkModules.cpp:1.135
--- llvm/lib/Linker/LinkModules.cpp:1.134   Sat Feb  3 22:30:33 2007
+++ llvm/lib/Linker/LinkModules.cpp Sat Feb  3 22:43:17 2007
@@ -269,15 +269,13 @@
 }
 
 
-// RemapOperand - Use ValueMap to convert references from one module to 
another.
-// This is somewhat sophisticated in that it can automatically handle constant
-// references correctly as well.
+// RemapOperand - Use ValueMap to convert constants from one module to another.
 static Value *RemapOperand(const Value *In,
std::map &ValueMap) {
   std::map::const_iterator I = ValueMap.find(In);
   if (I != ValueMap.end()) return I->second;
 
-  // Check to see if it's a constant that we are interesting in transforming.
+  // Check to see if it's a constant that we are interested in transforming.
   Value *Result = 0;
   if (const Constant *CPV = dyn_cast(In)) {
 if ((!isa(CPV->getType()) && !isa(CPV)) ||
@@ -296,8 +294,6 @@
   Result = ConstantStruct::get(cast(CPS->getType()), Operands);
 } else if (isa(CPV) || isa(CPV)) {
   Result = const_cast(CPV);
-} else if (isa(CPV)) {
-  Result = cast(RemapOperand(CPV, ValueMap));
 } else if (const ConstantPacked *CP = dyn_cast(CPV)) {
   std::vector Operands(CP->getNumOperands());
   for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
@@ -308,6 +304,8 @@
   for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)
 
Ops.push_back(cast(RemapOperand(CE->getOperand(i),ValueMap)));
   Result = CE->getWithOperands(Ops);
+} else if (isa(CPV)) {
+  assert(0 && "Unmapped global?");
 } else {
   assert(0 && "Unknown type of derived type constant value!");
 }
@@ -315,7 +313,7 @@
 Result = const_cast(In);
   }
   
-  // Cache the mapping in our local map structure...
+  // Cache the mapping in our local map structure
   if (Result) {
 ValueMap.insert(std::make_pair(In, Result));
 return Result;
@@ -393,7 +391,8 @@
 LinkFromSrc = true; // Special cased.
 LT = Src->getLinkage();
   } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage()) {
-// At this point we know that Dest has LinkOnce, External*, Weak, DLL* 
linkage.
+// At this point we know that Dest has LinkOnce, External*, Weak, or
+// DLL* linkage.
 if ((Dest->hasLinkOnceLinkage() && Src->hasWeakLinkage()) ||
 Dest->hasExternalWeakLinkage()) {
   LinkFromSrc = true;
@@ -613,8 +612,7 @@
std::string *Err) {
   TypeSymbolTable *TST = &Dest->getTypeSymbolTable();
 
-  // Loop over all of the functions in the src module, mapping them over as we
-  // go
+  // Loop over all of the functions in the src module, mapping them over
   for (Module::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) {
 const Function *SF = I;   // SrcFunction
 Function *DF = 0;
@@ -745,7 +743,7 @@
   // Loop over all of the functions in the src module, mapping them over as we
   // go
   for (Module::iterator SF = Src->begin(), E = Src->end(); SF != E; ++SF) {
-if (!SF->isDeclaration()) {  // No body if function is 
external
+if (!SF->isDeclaration()) {   // No body if function is 
external
   Function *DF = cast(ValueMap[SF]); // Destination function
 
   // DF not external SF external?
@@ -877,6 +875,7 @@
 }
   }
 
+  // COpy the target triple from the source to dest if the dest's is empty
   if (Dest->getTargetTriple().empty() && !Src->getTargetTriple().empty())
 Dest->setTargetTriple(Src->getTargetTriple());
   
@@ -887,6 +886,7 @@
   Dest->getTargetTriple() != Src->getTargetTriple())
 cerr << "WARNING: Linking two modules of different target triples!\n";
 
+  // Append the module inline asm string
   if (!Src->getModuleInlineAsm().empty()) {
 if (Dest->getModuleInlineAsm().empty())
   Dest->setModuleInlineAsm(Src->getModuleInlineAsm());
@@ -908,7 +908,8 @@
   // LinkTypes - Go through the symbol table of the Src module and see if any
   // types are named in the src module that are not named in the Dst module.
   // Make sure there are no type name conflicts.
-  if (LinkTypes(Dest, Src, ErrorMsg)) return true;
+  if (LinkTypes(Dest, Src, ErrorMsg)) 
+return true;
 
   // ValueMap - Mapping of values from what they used to be in Src, to what 
they
   // are now in Dest.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-03 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.133 -> 1.134
---
Log message:

Ensure that visibility and section are properly propagated.


---
Diffs of the changes:  (+8 -9)

 LinkModules.cpp |   17 -
 1 files changed, 8 insertions(+), 9 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.133 
llvm/lib/Linker/LinkModules.cpp:1.134
--- llvm/lib/Linker/LinkModules.cpp:1.133   Sat Feb  3 22:29:21 2007
+++ llvm/lib/Linker/LinkModules.cpp Sat Feb  3 22:30:33 2007
@@ -476,11 +476,10 @@
 new GlobalVariable(SGV->getType()->getElementType(),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
SGV->getName(), Dest);
-  // Propagate alignment info.
+  // Propagate alignment, visibility and section info.
   NewDGV->setAlignment(SGV->getAlignment());
-
-  // Propagate section info.
   NewDGV->setSection(SGV->getSection());
+  NewDGV->setVisibility(SGV->getVisibility());
 
   // If the LLVM runtime renamed the global, but it is an externally 
visible
   // symbol, DGV must be an existing global with internal linkage.  Rename
@@ -503,11 +502,10 @@
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
"", Dest);
 
-  // Propagate alignment info.
+  // Propagate alignment, section and visibility  info.
   NewDGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
-
-  // Propagate section info.
   NewDGV->setSection(SGV->getSection());
+  NewDGV->setVisibility(SGV->getVisibility());
 
   // Make sure to remember this mapping...
   ValueMap.insert(std::make_pair(SGV, NewDGV));
@@ -515,11 +513,10 @@
   // Keep track that this is an appending variable...
   AppendingVars.insert(std::make_pair(SGV->getName(), NewDGV));
 } else {
-  // Propagate alignment info.
+  // Propagate alignment, section, and visibility info.
   DGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
-
-  // Propagate section info.
   DGV->setSection(SGV->getSection());
+  DGV->setVisibility(SGV->getVisibility());
 
   // Otherwise, perform the mapping as instructed by GetLinkageResult.  If
   // the types don't match, and if we are to link from the source, nuke DGV
@@ -529,6 +526,8 @@
   new GlobalVariable(SGV->getType()->getElementType(),
  DGV->isConstant(), DGV->getLinkage());
 NewDGV->setAlignment(DGV->getAlignment());
+NewDGV->setSection(DGV->getSection());
+NewDGV->setVisibility(DGV->getVisibility());
 Dest->getGlobalList().insert(DGV, NewDGV);
 DGV->replaceAllUsesWith(
 ConstantExpr::getBitCast(NewDGV, DGV->getType()));



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-03 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.132 -> 1.133
---
Log message:

Back out last revision which was committed by accident.


---
Diffs of the changes:  (+86 -102)

 LinkModules.cpp |  188 +---
 1 files changed, 86 insertions(+), 102 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.132 
llvm/lib/Linker/LinkModules.cpp:1.133
--- llvm/lib/Linker/LinkModules.cpp:1.132   Sat Feb  3 22:28:18 2007
+++ llvm/lib/Linker/LinkModules.cpp Sat Feb  3 22:29:21 2007
@@ -20,7 +20,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/ValueSymbolTable.h"
+#include "llvm/SymbolTable.h"
 #include "llvm/TypeSymbolTable.h"
 #include "llvm/Instructions.h"
 #include "llvm/Assembly/Writer.h"
@@ -270,14 +270,14 @@
 
 
 // RemapOperand - Use ValueMap to convert references from one module to 
another.
-// This is somewhat sophisticated in that it can automatically handle constants
-// correctly as well.
+// This is somewhat sophisticated in that it can automatically handle constant
+// references correctly as well.
 static Value *RemapOperand(const Value *In,
std::map &ValueMap) {
   std::map::const_iterator I = ValueMap.find(In);
   if (I != ValueMap.end()) return I->second;
 
-  // Check to see if it's a constant that we are interested in transforming.
+  // Check to see if it's a constant that we are interesting in transforming.
   Value *Result = 0;
   if (const Constant *CPV = dyn_cast(In)) {
 if ((!isa(CPV->getType()) && !isa(CPV)) ||
@@ -296,6 +296,8 @@
   Result = ConstantStruct::get(cast(CPS->getType()), Operands);
 } else if (isa(CPV) || isa(CPV)) {
   Result = const_cast(CPV);
+} else if (isa(CPV)) {
+  Result = cast(RemapOperand(CPV, ValueMap));
 } else if (const ConstantPacked *CP = dyn_cast(CPV)) {
   std::vector Operands(CP->getNumOperands());
   for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
@@ -306,10 +308,6 @@
   for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)
 
Ops.push_back(cast(RemapOperand(CE->getOperand(i),ValueMap)));
   Result = CE->getWithOperands(Ops);
-} else if (isa(CPV)) {
-  Result = const_cast(CPV);// Functions map to themselves.
-} else if (isa(CPV)) {
-  assert(0 && "Unmapped global?");
 } else {
   assert(0 && "Unknown type of derived type constant value!");
 }
@@ -317,11 +315,12 @@
 Result = const_cast(In);
   }
   
-  // Cache the mapping in our local map structure
+  // Cache the mapping in our local map structure...
   if (Result) {
 ValueMap.insert(std::make_pair(In, Result));
 return Result;
   }
+  
 
   cerr << "LinkModules ValueMap: \n";
   PrintMap(ValueMap);
@@ -331,22 +330,25 @@
   return 0;
 }
 
-/// ForceRenaming - The LLVM ValueSymbolTable class autorenames globals that 
-/// conflict in the symbol table.  This is good for all clients except for us.
-/// Go through the trouble to force this back.
+/// ForceRenaming - The LLVM SymbolTable class autorenames globals that 
conflict
+/// in the symbol table.  This is good for all clients except for us.  Go
+/// through the trouble to force this back.
 static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
   assert(GV->getName() != Name && "Can't force rename to self");
-  ValueSymbolTable &ST = GV->getParent()->getValueSymbolTable();
+  SymbolTable &ST = GV->getParent()->getValueSymbolTable();
 
   // If there is a conflict, rename the conflict.
-  GlobalValue *ConflictGV = cast(ST.lookup(Name));
-  if (ConflictGV) {
-ConflictGV->setName("");  // Eliminate the conflict
-GV->setName(Name);// Force the name back
-ConflictGV->setName(Name);// This will cause ConflictGV to get renamed
-assert(GV->getName() == Name && ConflictGV->getName() != Name &&
-   "ForceRenaming didn't work");
-  }
+  Value *ConflictVal = ST.lookup(GV->getType(), Name);
+  assert(ConflictVal&&"Why do we have to force rename if there is no 
conflic?");
+  GlobalValue *ConflictGV = cast(ConflictVal);
+  assert(ConflictGV->hasInternalLinkage() &&
+ "Not conflicting with a static global, should link instead!");
+
+  ConflictGV->setName("");  // Eliminate the conflict
+  GV->setName(Name);// Force the name back
+  ConflictGV->setName(Name);// This will cause ConflictGV to get 
renamed
+  assert(GV->getName() == Name && ConflictGV->getName() != Name &&
+ "ForceRenaming didn't work");
 }
 
 /// GetLinkageResult - This analyzes the two global values and determines what
@@ -391,8 +393,7 @@
 LinkFromSrc = true; // Special cased.
 LT = Src->getLinkage();
   } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage()) {
-// At this point we know that Dest has LinkOnce, External*, Weak, DLL* 
-// linkage.
+// At this point we

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

2007-02-03 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.131 -> 1.132
---
Log message:

Make sure that section and visibility are properly propagated.


---
Diffs of the changes:  (+102 -86)

 LinkModules.cpp |  188 ++--
 1 files changed, 102 insertions(+), 86 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.131 
llvm/lib/Linker/LinkModules.cpp:1.132
--- llvm/lib/Linker/LinkModules.cpp:1.131   Thu Feb  1 11:12:54 2007
+++ llvm/lib/Linker/LinkModules.cpp Sat Feb  3 22:28:18 2007
@@ -20,7 +20,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/SymbolTable.h"
+#include "llvm/ValueSymbolTable.h"
 #include "llvm/TypeSymbolTable.h"
 #include "llvm/Instructions.h"
 #include "llvm/Assembly/Writer.h"
@@ -270,14 +270,14 @@
 
 
 // RemapOperand - Use ValueMap to convert references from one module to 
another.
-// This is somewhat sophisticated in that it can automatically handle constant
-// references correctly as well.
+// This is somewhat sophisticated in that it can automatically handle constants
+// correctly as well.
 static Value *RemapOperand(const Value *In,
std::map &ValueMap) {
   std::map::const_iterator I = ValueMap.find(In);
   if (I != ValueMap.end()) return I->second;
 
-  // Check to see if it's a constant that we are interesting in transforming.
+  // Check to see if it's a constant that we are interested in transforming.
   Value *Result = 0;
   if (const Constant *CPV = dyn_cast(In)) {
 if ((!isa(CPV->getType()) && !isa(CPV)) ||
@@ -296,8 +296,6 @@
   Result = ConstantStruct::get(cast(CPS->getType()), Operands);
 } else if (isa(CPV) || isa(CPV)) {
   Result = const_cast(CPV);
-} else if (isa(CPV)) {
-  Result = cast(RemapOperand(CPV, ValueMap));
 } else if (const ConstantPacked *CP = dyn_cast(CPV)) {
   std::vector Operands(CP->getNumOperands());
   for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
@@ -308,6 +306,10 @@
   for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)
 
Ops.push_back(cast(RemapOperand(CE->getOperand(i),ValueMap)));
   Result = CE->getWithOperands(Ops);
+} else if (isa(CPV)) {
+  Result = const_cast(CPV);// Functions map to themselves.
+} else if (isa(CPV)) {
+  assert(0 && "Unmapped global?");
 } else {
   assert(0 && "Unknown type of derived type constant value!");
 }
@@ -315,12 +317,11 @@
 Result = const_cast(In);
   }
   
-  // Cache the mapping in our local map structure...
+  // Cache the mapping in our local map structure
   if (Result) {
 ValueMap.insert(std::make_pair(In, Result));
 return Result;
   }
-  
 
   cerr << "LinkModules ValueMap: \n";
   PrintMap(ValueMap);
@@ -330,25 +331,22 @@
   return 0;
 }
 
-/// ForceRenaming - The LLVM SymbolTable class autorenames globals that 
conflict
-/// in the symbol table.  This is good for all clients except for us.  Go
-/// through the trouble to force this back.
+/// ForceRenaming - The LLVM ValueSymbolTable class autorenames globals that 
+/// conflict in the symbol table.  This is good for all clients except for us.
+/// Go through the trouble to force this back.
 static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
   assert(GV->getName() != Name && "Can't force rename to self");
-  SymbolTable &ST = GV->getParent()->getValueSymbolTable();
+  ValueSymbolTable &ST = GV->getParent()->getValueSymbolTable();
 
   // If there is a conflict, rename the conflict.
-  Value *ConflictVal = ST.lookup(GV->getType(), Name);
-  assert(ConflictVal&&"Why do we have to force rename if there is no 
conflic?");
-  GlobalValue *ConflictGV = cast(ConflictVal);
-  assert(ConflictGV->hasInternalLinkage() &&
- "Not conflicting with a static global, should link instead!");
-
-  ConflictGV->setName("");  // Eliminate the conflict
-  GV->setName(Name);// Force the name back
-  ConflictGV->setName(Name);// This will cause ConflictGV to get 
renamed
-  assert(GV->getName() == Name && ConflictGV->getName() != Name &&
- "ForceRenaming didn't work");
+  GlobalValue *ConflictGV = cast(ST.lookup(Name));
+  if (ConflictGV) {
+ConflictGV->setName("");  // Eliminate the conflict
+GV->setName(Name);// Force the name back
+ConflictGV->setName(Name);// This will cause ConflictGV to get renamed
+assert(GV->getName() == Name && ConflictGV->getName() != Name &&
+   "ForceRenaming didn't work");
+  }
 }
 
 /// GetLinkageResult - This analyzes the two global values and determines what
@@ -393,7 +391,8 @@
 LinkFromSrc = true; // Special cased.
 LT = Src->getLinkage();
   } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage()) {
-// At this point we know that Dest has LinkOnce, External*, Weak, DLL* 
linkage.
+// At this point we 

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

2007-02-01 Thread Andrew Lenharth


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.130 -> 1.131
---
Log message:

preserve sections of globals

---
Diffs of the changes:  (+10 -1)

 LinkModules.cpp |   11 ++-
 1 files changed, 10 insertions(+), 1 deletion(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.130 
llvm/lib/Linker/LinkModules.cpp:1.131
--- llvm/lib/Linker/LinkModules.cpp:1.130   Tue Jan 30 14:08:37 2007
+++ llvm/lib/Linker/LinkModules.cpp Thu Feb  1 11:12:54 2007
@@ -478,7 +478,10 @@
SGV->getName(), Dest);
   // Propagate alignment info.
   NewDGV->setAlignment(SGV->getAlignment());
-  
+
+  // Propagate section info.
+  NewDGV->setSection(SGV->getSection());
+
   // If the LLVM runtime renamed the global, but it is an externally 
visible
   // symbol, DGV must be an existing global with internal linkage.  Rename
   // it.
@@ -503,6 +506,9 @@
   // Propagate alignment info.
   NewDGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
 
+  // Propagate section info.
+  NewDGV->setSection(SGV->getSection());
+
   // Make sure to remember this mapping...
   ValueMap.insert(std::make_pair(SGV, NewDGV));
 
@@ -512,6 +518,9 @@
   // Propagate alignment info.
   DGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
 
+  // Propagate section info.
+  DGV->setSection(SGV->getSection());
+
   // Otherwise, perform the mapping as instructed by GetLinkageResult.  If
   // the types don't match, and if we are to link from the source, nuke DGV
   // and create a new one of the appropriate type.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-28 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

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

Read from the right place.


---
Diffs of the changes:  (+1 -1)

 LinkModules.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.128 
llvm/lib/Linker/LinkModules.cpp:1.129
--- llvm/lib/Linker/LinkModules.cpp:1.128   Sun Jan 28 18:21:34 2007
+++ llvm/lib/Linker/LinkModules.cpp Sun Jan 28 20:18:13 2007
@@ -851,7 +851,7 @@
 
   if (Dest->getDataLayout().empty()) {
 if (!Src->getDataLayout().empty()) {
-  Dest->setDataLayout(Src->getTargetTriple());
+  Dest->setDataLayout(Src->getDataLayout());
 } else {
   std::string DataLayout;
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-28 Thread Chris Lattner


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())



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-26 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

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

For PR761: http://llvm.org/PR761 :
The Module::setEndianness and Module::setPointerSize methods have been
removed. Instead you can get/set the DataLayout. Adjust thise accordingly.


---
Diffs of the changes:  (+14 -8)

 LinkModules.cpp |   22 ++
 1 files changed, 14 insertions(+), 8 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.126 
llvm/lib/Linker/LinkModules.cpp:1.127
--- llvm/lib/Linker/LinkModules.cpp:1.126   Fri Jan 12 01:05:13 2007
+++ llvm/lib/Linker/LinkModules.cpp Fri Jan 26 02:11:39 2007
@@ -849,19 +849,25 @@
   assert(Dest != 0 && "Invalid Destination module");
   assert(Src  != 0 && "Invalid Source Module");
 
+  std::string DataLayout;
+
   if (Dest->getEndianness() == Module::AnyEndianness)
-Dest->setEndianness(Src->getEndianness());
+if (Src->getEndianness() == Module::BigEndian)
+  DataLayout.append("E");
+else if (Src->getEndianness() == Module::LittleEndian)
+  DataLayout.append("e");
   if (Dest->getPointerSize() == Module::AnyPointerSize)
-Dest->setPointerSize(Src->getPointerSize());
+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())
 Dest->setTargetTriple(Src->getTargetTriple());
+  Dest->setDataLayout(DataLayout);
 
-  if (Src->getEndianness() != Module::AnyEndianness &&
-  Dest->getEndianness() != Src->getEndianness())
-cerr << "WARNING: Linking two modules of different endianness!\n";
-  if (Src->getPointerSize() != Module::AnyPointerSize &&
-  Dest->getPointerSize() != Src->getPointerSize())
-cerr << "WARNING: Linking two modules of different pointer size!\n";
+  if (Src->getDataLayout().length() > 0 && Dest->getDataLayout().length() > 0 
&&
+  Src->getDataLayout().compare(Dest->getDataLayout()) != 0)
+cerr << "WARNING: Linking two modules of different data layouts!\n";
   if (!Src->getTargetTriple().empty() &&
   Dest->getTargetTriple() != Src->getTargetTriple())
 cerr << "WARNING: Linking two modules of different target triples!\n";



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-11 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.125 -> 1.126
---
Log message:

For PR1064: http://llvm.org/PR1064 :
Implement the arbitrary bit-width integer feature. The feature allows
integers of any bitwidth (up to 64) to be defined instead of just 1, 8, 
16, 32, and 64 bit integers.  

This change does several things:
1. Introduces a new Derived Type, IntegerType, to represent the number of
   bits in an integer. The Type classes SubclassData field is used to
   store the number of bits. This allows 2^23 bits in an integer type. 
2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and
   64-bit integers. These are replaced with just IntegerType which is not
   a primitive any more. 
3. Adjust the rest of LLVM to account for this change.

Note that while this incremental change lays the foundation for arbitrary
bit-width integers, LLVM has not yet been converted to actually deal with 
them in any significant way. Most optimization passes, for example, will 
still only deal with the byte-width integer types.  Future increments
will rectify this situation.



---
Diffs of the changes:  (+7 -1)

 LinkModules.cpp |8 +++-
 1 files changed, 7 insertions(+), 1 deletion(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.125 
llvm/lib/Linker/LinkModules.cpp:1.126
--- llvm/lib/Linker/LinkModules.cpp:1.125   Sat Jan  6 01:24:43 2007
+++ llvm/lib/Linker/LinkModules.cpp Fri Jan 12 01:05:13 2007
@@ -111,6 +111,12 @@
 
   // Otherwise, resolve the used type used by this derived type...
   switch (DestTyT->getTypeID()) {
+  case Type::IntegerTyID: {
+if (cast(DestTyT)->getBitWidth() !=
+cast(SrcTyT)->getBitWidth())
+  return true;
+return false;
+  }
   case Type::FunctionTyID: {
 if (cast(DestTyT)->isVarArg() !=
 cast(SrcTyT)->isVarArg() ||
@@ -275,7 +281,7 @@
   Value *Result = 0;
   if (const Constant *CPV = dyn_cast(In)) {
 if ((!isa(CPV->getType()) && !isa(CPV)) ||
-isa(CPV))
+isa(CPV) || isa(CPV))
   return const_cast(CPV);   // Simple constants stay identical.
 
 if (const ConstantArray *CPA = dyn_cast(CPV)) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-05 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.124 -> 1.125
---
Log message:

For PR411: http://llvm.org/PR411 :
Take an incremental step towards type plane elimination. This change 
separates types from values in the symbol tables by finally making use
of the TypeSymbolTable class. This yields more natural interfaces for
dealing with types and unclutters the SymbolTable class.


---
Diffs of the changes:  (+22 -18)

 LinkModules.cpp |   40 ++--
 1 files changed, 22 insertions(+), 18 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.124 
llvm/lib/Linker/LinkModules.cpp:1.125
--- llvm/lib/Linker/LinkModules.cpp:1.124   Fri Dec 15 11:35:32 2006
+++ llvm/lib/Linker/LinkModules.cpp Sat Jan  6 01:24:43 2007
@@ -21,6 +21,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
 #include "llvm/Instructions.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Support/Streams.h"
@@ -61,7 +62,7 @@
 //  false - No errors.
 //
 static bool ResolveTypes(const Type *DestTy, const Type *SrcTy,
- SymbolTable *DestST, const std::string &Name) {
+ TypeSymbolTable *DestST, const std::string &Name) {
   if (DestTy == SrcTy) return false;   // If already equal, noop
 
   // Does the type already exist in the module?
@@ -93,7 +94,8 @@
 // are compatible.
 static bool RecursiveResolveTypesI(const PATypeHolder &DestTy,
const PATypeHolder &SrcTy,
-   SymbolTable *DestST, const std::string 
&Name,
+   TypeSymbolTable *DestST, 
+   const std::string &Name,
 std::vector > &Pointers) 
{
   const Type *SrcTyT = SrcTy.get();
   const Type *DestTyT = DestTy.get();
@@ -164,7 +166,8 @@
 
 static bool RecursiveResolveTypes(const PATypeHolder &DestTy,
   const PATypeHolder &SrcTy,
-  SymbolTable *DestST, const std::string 
&Name){
+  TypeSymbolTable *DestST, 
+  const std::string &Name){
   std::vector > PointerTypes;
   return RecursiveResolveTypesI(DestTy, SrcTy, DestST, Name, PointerTypes);
 }
@@ -174,12 +177,12 @@
 // types are named in the src module that are not named in the Dst module.
 // Make sure there are no type name conflicts.
 static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) {
-  SymbolTable   *DestST = &Dest->getSymbolTable();
-  const SymbolTable *SrcST  = &Src->getSymbolTable();
+TypeSymbolTable *DestST = &Dest->getTypeSymbolTable();
+  const TypeSymbolTable *SrcST  = &Src->getTypeSymbolTable();
 
   // Look for a type plane for Type's...
-  SymbolTable::type_const_iterator TI = SrcST->type_begin();
-  SymbolTable::type_const_iterator TE = SrcST->type_end();
+  TypeSymbolTable::const_iterator TI = SrcST->begin();
+  TypeSymbolTable::const_iterator TE = SrcST->end();
   if (TI == TE) return false;  // No named types, do nothing.
 
   // Some types cannot be resolved immediately because they depend on other
@@ -192,7 +195,7 @@
 const Type *RHS = TI->second;
 
 // Check to see if this type name is already in the dest module...
-Type *Entry = DestST->lookupType(Name);
+Type *Entry = DestST->lookup(Name);
 
 if (ResolveTypes(Entry, RHS, DestST, Name)) {
   // They look different, save the types 'till later to resolve.
@@ -208,8 +211,8 @@
 // Try direct resolution by name...
 for (unsigned i = 0; i != DelayedTypesToResolve.size(); ++i) {
   const std::string &Name = DelayedTypesToResolve[i];
-  Type *T1 = SrcST->lookupType(Name);
-  Type *T2 = DestST->lookupType(Name);
+  Type *T1 = SrcST->lookup(Name);
+  Type *T2 = DestST->lookup(Name);
   if (!ResolveTypes(T2, T1, DestST, Name)) {
 // We are making progress!
 DelayedTypesToResolve.erase(DelayedTypesToResolve.begin()+i);
@@ -223,8 +226,8 @@
   // two types: { int* } and { opaque* }
   for (unsigned i = 0, e = DelayedTypesToResolve.size(); i != e; ++i) {
 const std::string &Name = DelayedTypesToResolve[i];
-PATypeHolder T1(SrcST->lookupType(Name));
-PATypeHolder T2(DestST->lookupType(Name));
+PATypeHolder T1(SrcST->lookup(Name));
+PATypeHolder T2(DestST->lookup(Name));
 
 if (!RecursiveResolveTypes(T2, T1, DestST, Name)) {
   // We are making progress!
@@ -326,7 +329,7 @@
 /// through the trouble to force this back.
 static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
   assert(GV->getName() != Name && "Can't force rename to self");
-  SymbolTable &ST = GV->getParent()->getSymbolTable();
+  SymbolTable &ST = GV->getParent()->getValueSymbolTable();
 
   // If there is a conflict, rename the c

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

2006-12-15 Thread Andrew Lenharth


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.123 -> 1.124
---
Log message:

extern_weak linkage.  fixes PR1038: http://llvm.org/PR1038 

---
Diffs of the changes:  (+5 -1)

 LinkModules.cpp |6 +-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.123 
llvm/lib/Linker/LinkModules.cpp:1.124
--- llvm/lib/Linker/LinkModules.cpp:1.123   Mon Dec 11 23:04:59 2006
+++ llvm/lib/Linker/LinkModules.cpp Fri Dec 15 11:35:32 2006
@@ -365,6 +365,10 @@
 LinkFromSrc = true;
 LT = Src->getLinkage();
   }  
+} else if (Dest->hasExternalWeakLinkage()) {
+  //If the Dest is weak, use the source linkage
+  LinkFromSrc = true;
+  LT = Src->getLinkage();
 } else {
   LinkFromSrc = false;
   LT = Dest->getLinkage();
@@ -446,7 +450,7 @@
 if (DGV && DGV->hasInternalLinkage())
   DGV = 0;
 
-assert(SGV->hasInitializer() ||
+assert(SGV->hasInitializer() || SGV->hasExternalWeakLinkage() ||
SGV->hasExternalLinkage() || SGV->hasDLLImportLinkage() &&
"Global must either be external or have an initializer!");
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-12-11 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.122 -> 1.123
---
Log message:

Change inferred getCast into specific getCast. Passes all tests.


---
Diffs of the changes:  (+6 -6)

 LinkModules.cpp |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.122 
llvm/lib/Linker/LinkModules.cpp:1.123
--- llvm/lib/Linker/LinkModules.cpp:1.122   Thu Dec  7 17:41:45 2006
+++ llvm/lib/Linker/LinkModules.cpp Mon Dec 11 23:04:59 2006
@@ -508,7 +508,8 @@
  DGV->isConstant(), DGV->getLinkage());
 NewDGV->setAlignment(DGV->getAlignment());
 Dest->getGlobalList().insert(DGV, NewDGV);
-DGV->replaceAllUsesWith(ConstantExpr::getCast(NewDGV, DGV->getType()));
+DGV->replaceAllUsesWith(
+ConstantExpr::getBitCast(NewDGV, DGV->getType()));
 DGV->eraseFromParent();
 NewDGV->setName(SGV->getName());
 DGV = NewDGV;
@@ -529,9 +530,8 @@
 SGV->setInitializer(0);
   }
 
-  ValueMap.insert(std::make_pair(SGV,
- ConstantExpr::getCast(DGV,
-   SGV->getType(;
+  ValueMap.insert(
+std::make_pair(SGV, ConstantExpr::getBitCast(DGV, SGV->getType(;
 }
   }
   return false;
@@ -807,8 +807,8 @@
 
   // FIXME: This should rewrite simple/straight-forward uses such as
   // getelementptr instructions to not use the Cast!
-  G1->replaceAllUsesWith(ConstantExpr::getCast(NG, G1->getType()));
-  G2->replaceAllUsesWith(ConstantExpr::getCast(NG, G2->getType()));
+  G1->replaceAllUsesWith(ConstantExpr::getBitCast(NG, G1->getType()));
+  G2->replaceAllUsesWith(ConstantExpr::getBitCast(NG, G2->getType()));
 
   // Remove the two globals from the module now...
   M->getGlobalList().erase(G1);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-12-07 Thread Bill Wendling


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.121 -> 1.122
---
Log message:

Don't use  in Streams.h but  instead.


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

 LinkModules.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.121 
llvm/lib/Linker/LinkModules.cpp:1.122
--- llvm/lib/Linker/LinkModules.cpp:1.121   Wed Dec  6 19:30:31 2006
+++ llvm/lib/Linker/LinkModules.cpp Thu Dec  7 17:41:45 2006
@@ -25,6 +25,7 @@
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/System/Path.h"
+#include 
 using namespace llvm;
 
 // Error - Simple wrapper function to conditionally assign to E and return 
true.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-12-06 Thread Bill Wendling


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.120 -> 1.121
Linker.cpp updated: 1.12 -> 1.13
---
Log message:

Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.


---
Diffs of the changes:  (+11 -12)

 LinkModules.cpp |   17 -
 Linker.cpp  |6 +++---
 2 files changed, 11 insertions(+), 12 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.120 
llvm/lib/Linker/LinkModules.cpp:1.121
--- llvm/lib/Linker/LinkModules.cpp:1.120   Thu Nov 30 18:25:12 2006
+++ llvm/lib/Linker/LinkModules.cpp Wed Dec  6 19:30:31 2006
@@ -25,7 +25,6 @@
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/System/Path.h"
-#include 
 using namespace llvm;
 
 // Error - Simple wrapper function to conditionally assign to E and return 
true.
@@ -251,11 +250,11 @@
 static void PrintMap(const std::map &M) {
   for (std::map::const_iterator I = M.begin(), E 
=M.end();
I != E; ++I) {
-llvm_cerr << " Fr: " << (void*)I->first << " ";
+cerr << " Fr: " << (void*)I->first << " ";
 I->first->dump();
-llvm_cerr << " To: " << (void*)I->second << " ";
+cerr << " To: " << (void*)I->second << " ";
 I->second->dump();
-llvm_cerr << "\n";
+cerr << "\n";
   }
 }
 
@@ -313,10 +312,10 @@
   }
   
 
-  llvm_cerr << "LinkModules ValueMap: \n";
+  cerr << "LinkModules ValueMap: \n";
   PrintMap(ValueMap);
 
-  llvm_cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n";
+  cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n";
   assert(0 && "Couldn't remap value!");
   return 0;
 }
@@ -844,13 +843,13 @@
 
   if (Src->getEndianness() != Module::AnyEndianness &&
   Dest->getEndianness() != Src->getEndianness())
-llvm_cerr << "WARNING: Linking two modules of different endianness!\n";
+cerr << "WARNING: Linking two modules of different endianness!\n";
   if (Src->getPointerSize() != Module::AnyPointerSize &&
   Dest->getPointerSize() != Src->getPointerSize())
-llvm_cerr << "WARNING: Linking two modules of different pointer size!\n";
+cerr << "WARNING: Linking two modules of different pointer size!\n";
   if (!Src->getTargetTriple().empty() &&
   Dest->getTargetTriple() != Src->getTargetTriple())
-llvm_cerr << "WARNING: Linking two modules of different target triples!\n";
+cerr << "WARNING: Linking two modules of different target triples!\n";
 
   if (!Src->getModuleInlineAsm().empty()) {
 if (Dest->getModuleInlineAsm().empty())


Index: llvm/lib/Linker/Linker.cpp
diff -u llvm/lib/Linker/Linker.cpp:1.12 llvm/lib/Linker/Linker.cpp:1.13
--- llvm/lib/Linker/Linker.cpp:1.12 Mon Nov 27 04:09:12 2006
+++ llvm/lib/Linker/Linker.cpp  Wed Dec  6 19:30:31 2006
@@ -45,7 +45,7 @@
 Linker::error(const std::string& message) {
   Error = message;
   if (!(Flags&QuietErrors))
-llvm_cerr << ProgramName << ": error: " << message << "\n";
+cerr << ProgramName << ": error: " << message << "\n";
   return true;
 }
 
@@ -53,14 +53,14 @@
 Linker::warning(const std::string& message) {
   Error = message;
   if (!(Flags&QuietErrors))
-llvm_cerr << ProgramName << ": warning: " << message << "\n";
+cerr << ProgramName << ": warning: " << message << "\n";
   return false;
 }
 
 void
 Linker::verbose(const std::string& message) {
   if (Flags&Verbose)
-llvm_cerr << "  " << message << "\n";
+cerr << "  " << message << "\n";
 }
 
 void



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-11-30 Thread Anton Korobeynikov


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.119 -> 1.120
---
Log message:

Introducing external weak linkage. Darwin codegen should be added later.


---
Diffs of the changes:  (+24 -12)

 LinkModules.cpp |   36 
 1 files changed, 24 insertions(+), 12 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.119 
llvm/lib/Linker/LinkModules.cpp:1.120
--- llvm/lib/Linker/LinkModules.cpp:1.119   Mon Nov 27 04:09:12 2006
+++ llvm/lib/Linker/LinkModules.cpp Thu Nov 30 18:25:12 2006
@@ -360,6 +360,7 @@
 // If Src is external or if both Src & Drc are external..  Just link the
 // external globals, we aren't adding anything.
 if (Src->hasDLLImportLinkage()) {
+  // If one of GVs has DLLImport linkage, result should be dllimport'ed.
   if (Dest->isExternal()) {
 LinkFromSrc = true;
 LT = Src->getLinkage();
@@ -379,8 +380,9 @@
 LinkFromSrc = true; // Special cased.
 LT = Src->getLinkage();
   } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage()) {
-// At this point we know that Dest has LinkOnce, External, Weak, DLL* 
linkage.
-if (Dest->hasLinkOnceLinkage() && Src->hasWeakLinkage()) {
+// At this point we know that Dest has LinkOnce, External*, Weak, DLL* 
linkage.
+if ((Dest->hasLinkOnceLinkage() && Src->hasWeakLinkage()) ||
+Dest->hasExternalWeakLinkage()) {
   LinkFromSrc = true;
   LT = Src->getLinkage();
 } else {
@@ -388,16 +390,23 @@
   LT = Dest->getLinkage();
 }
   } else if (Dest->hasWeakLinkage() || Dest->hasLinkOnceLinkage()) {
-// At this point we know that Src has External or DLL* linkage.
-LinkFromSrc = true;
-LT = GlobalValue::ExternalLinkage;
+// At this point we know that Src has External* or DLL* linkage.
+if (Src->hasExternalWeakLinkage()) {
+  LinkFromSrc = false;
+  LT = Dest->getLinkage();
+} else {
+  LinkFromSrc = true;
+  LT = GlobalValue::ExternalLinkage;
+}
   } else {
 assert((Dest->hasExternalLinkage() ||
 Dest->hasDLLImportLinkage() ||
-Dest->hasDLLExportLinkage()) &&
+Dest->hasDLLExportLinkage() ||
+Dest->hasExternalWeakLinkage()) &&
(Src->hasExternalLinkage() ||
 Src->hasDLLImportLinkage() ||
-Src->hasDLLExportLinkage()) &&
+Src->hasDLLExportLinkage() ||
+Src->hasExternalWeakLinkage()) &&
"Unexpected linkage type!");
 return Error(Err, "Linking globals named '" + Src->getName() +
  "': symbol multiply defined!");
@@ -631,19 +640,22 @@
   ValueMap.insert(std::make_pair(SF, DF));
   DF->setLinkage(SF->getLinkage());
 } else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage()) {
-  // At this point we know that DF has LinkOnce, Weak, or External linkage.
+  // At this point we know that DF has LinkOnce, Weak, or External* 
linkage.
   ValueMap.insert(std::make_pair(SF, DF));
 
   // Linkonce+Weak = Weak
-  if (DF->hasLinkOnceLinkage() && SF->hasWeakLinkage())
+  // *+External Weak = *
+  if ((DF->hasLinkOnceLinkage() && SF->hasWeakLinkage()) ||
+  DF->hasExternalWeakLinkage())
 DF->setLinkage(SF->getLinkage());
 
+
 } else if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage()) {
-  // At this point we know that SF has LinkOnce or External linkage.
+  // At this point we know that SF has LinkOnce or External* linkage.
   ValueMap.insert(std::make_pair(SF, DF));
-  if (!SF->hasLinkOnceLinkage())   // Don't inherit linkonce linkage
+  if (!SF->hasLinkOnceLinkage() && !SF->hasExternalWeakLinkage())
+// Don't inherit linkonce & external weak linkage
 DF->setLinkage(SF->getLinkage());
-
 } else if (SF->getLinkage() != DF->getLinkage()) {
   return Error(Err, "Functions named '" + SF->getName() +
"' have different linkage specifiers!");



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-11-27 Thread Bill Wendling


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.118 -> 1.119
Linker.cpp updated: 1.11 -> 1.12
---
Log message:

Removed #include  and replaced with llvm_* streams.


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

 LinkModules.cpp |   18 +-
 Linker.cpp  |   18 +++---
 2 files changed, 16 insertions(+), 20 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.118 
llvm/lib/Linker/LinkModules.cpp:1.119
--- llvm/lib/Linker/LinkModules.cpp:1.118   Wed Nov  8 23:18:12 2006
+++ llvm/lib/Linker/LinkModules.cpp Mon Nov 27 04:09:12 2006
@@ -23,8 +23,8 @@
 #include "llvm/SymbolTable.h"
 #include "llvm/Instructions.h"
 #include "llvm/Assembly/Writer.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/System/Path.h"
-#include 
 #include 
 using namespace llvm;
 
@@ -251,11 +251,11 @@
 static void PrintMap(const std::map &M) {
   for (std::map::const_iterator I = M.begin(), E 
=M.end();
I != E; ++I) {
-std::cerr << " Fr: " << (void*)I->first << " ";
+llvm_cerr << " Fr: " << (void*)I->first << " ";
 I->first->dump();
-std::cerr << " To: " << (void*)I->second << " ";
+llvm_cerr << " To: " << (void*)I->second << " ";
 I->second->dump();
-std::cerr << "\n";
+llvm_cerr << "\n";
   }
 }
 
@@ -313,10 +313,10 @@
   }
   
 
-  std::cerr << "LinkModules ValueMap: \n";
+  llvm_cerr << "LinkModules ValueMap: \n";
   PrintMap(ValueMap);
 
-  std::cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n";
+  llvm_cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n";
   assert(0 && "Couldn't remap value!");
   return 0;
 }
@@ -832,13 +832,13 @@
 
   if (Src->getEndianness() != Module::AnyEndianness &&
   Dest->getEndianness() != Src->getEndianness())
-std::cerr << "WARNING: Linking two modules of different endianness!\n";
+llvm_cerr << "WARNING: Linking two modules of different endianness!\n";
   if (Src->getPointerSize() != Module::AnyPointerSize &&
   Dest->getPointerSize() != Src->getPointerSize())
-std::cerr << "WARNING: Linking two modules of different pointer size!\n";
+llvm_cerr << "WARNING: Linking two modules of different pointer size!\n";
   if (!Src->getTargetTriple().empty() &&
   Dest->getTargetTriple() != Src->getTargetTriple())
-std::cerr << "WARNING: Linking two modules of different target triples!\n";
+llvm_cerr << "WARNING: Linking two modules of different target triples!\n";
 
   if (!Src->getModuleInlineAsm().empty()) {
 if (Dest->getModuleInlineAsm().empty())


Index: llvm/lib/Linker/Linker.cpp
diff -u llvm/lib/Linker/Linker.cpp:1.11 llvm/lib/Linker/Linker.cpp:1.12
--- llvm/lib/Linker/Linker.cpp:1.11 Fri Jul 28 17:52:11 2006
+++ llvm/lib/Linker/Linker.cpp  Mon Nov 27 04:09:12 2006
@@ -15,8 +15,7 @@
 #include "llvm/Module.h"
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Config/config.h"
-#include 
-
+#include "llvm/Support/Streams.h"
 using namespace llvm;
 
 Linker::Linker(const std::string& progname, const std::string& modname, 
unsigned flags)
@@ -45,26 +44,23 @@
 bool
 Linker::error(const std::string& message) {
   Error = message;
-  if (!(Flags&QuietErrors)) {
-std::cerr << ProgramName << ": error: " << message << "\n";
-  }
+  if (!(Flags&QuietErrors))
+llvm_cerr << ProgramName << ": error: " << message << "\n";
   return true;
 }
 
 bool
 Linker::warning(const std::string& message) {
   Error = message;
-  if (!(Flags&QuietErrors)) {
-std::cerr << ProgramName << ": warning: " << message << "\n";
-  }
+  if (!(Flags&QuietErrors))
+llvm_cerr << ProgramName << ": warning: " << message << "\n";
   return false;
 }
 
 void
 Linker::verbose(const std::string& message) {
-  if (Flags&Verbose) {
-std::cerr << "  " << message << "\n";
-  }
+  if (Flags&Verbose)
+llvm_cerr << "  " << message << "\n";
 }
 
 void



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-11-08 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.117 -> 1.118
---
Log message:

silence warnings


---
Diffs of the changes:  (+2 -2)

 LinkModules.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.117 
llvm/lib/Linker/LinkModules.cpp:1.118
--- llvm/lib/Linker/LinkModules.cpp:1.117   Thu Sep 14 13:23:26 2006
+++ llvm/lib/Linker/LinkModules.cpp Wed Nov  8 23:18:12 2006
@@ -441,8 +441,8 @@
SGV->hasExternalLinkage() || SGV->hasDLLImportLinkage() &&
"Global must either be external or have an initializer!");
 
-GlobalValue::LinkageTypes NewLinkage;
-bool LinkFromSrc;
+GlobalValue::LinkageTypes NewLinkage = GlobalValue::InternalLinkage;
+bool LinkFromSrc = false;
 if (GetLinkageResult(DGV, SGV, NewLinkage, LinkFromSrc, Err))
   return true;
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-07-14 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.115 -> 1.116
---
Log message:

eliminate some ugly code, using ConstantExpr::getWithOperands instead.



---
Diffs of the changes:  (+4 -51)

 LinkModules.cpp |   55 ---
 1 files changed, 4 insertions(+), 51 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.115 
llvm/lib/Linker/LinkModules.cpp:1.116
--- llvm/lib/Linker/LinkModules.cpp:1.115   Thu Jun 15 20:24:04 2006
+++ llvm/lib/Linker/LinkModules.cpp Fri Jul 14 17:21:31 2006
@@ -295,57 +295,10 @@
 Operands[i] = cast(RemapOperand(CP->getOperand(i), 
ValueMap));
   Result = ConstantPacked::get(Operands);
 } else if (const ConstantExpr *CE = dyn_cast(CPV)) {
-  if (CE->getOpcode() == Instruction::GetElementPtr) {
-Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);
-std::vector Indices;
-Indices.reserve(CE->getNumOperands()-1);
-for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
-  Indices.push_back(cast(RemapOperand(CE->getOperand(i),
-ValueMap)));
-
-Result = ConstantExpr::getGetElementPtr(cast(Ptr), Indices);
-  } else if (CE->getOpcode() == Instruction::ExtractElement) {
-Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);
-Value *Idx = RemapOperand(CE->getOperand(1), ValueMap);
-Result = ConstantExpr::getExtractElement(cast(Ptr),
- cast(Idx));
-  } else if (CE->getOpcode() == Instruction::InsertElement) {
-Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);
-Value *Elt = RemapOperand(CE->getOperand(1), ValueMap);
-Value *Idx = RemapOperand(CE->getOperand(2), ValueMap);
-Result = ConstantExpr::getInsertElement(cast(Ptr),
-cast(Elt),
-cast(Idx));
-  } else if (CE->getOpcode() == Instruction::ShuffleVector) {
-Value *V1 = RemapOperand(CE->getOperand(0), ValueMap);
-Value *V2 = RemapOperand(CE->getOperand(1), ValueMap);
-Result = ConstantExpr::getShuffleVector(cast(V1),
-cast(V2),
- 
cast(CE->getOperand(2)));
-  } else if (CE->getNumOperands() == 1) {
-// Cast instruction
-assert(CE->getOpcode() == Instruction::Cast);
-Value *V = RemapOperand(CE->getOperand(0), ValueMap);
-Result = ConstantExpr::getCast(cast(V), CE->getType());
-  } else if (CE->getNumOperands() == 3) {
-// Select instruction
-assert(CE->getOpcode() == Instruction::Select);
-Value *V1 = RemapOperand(CE->getOperand(0), ValueMap);
-Value *V2 = RemapOperand(CE->getOperand(1), ValueMap);
-Value *V3 = RemapOperand(CE->getOperand(2), ValueMap);
-Result = ConstantExpr::getSelect(cast(V1), 
cast(V2),
- cast(V3));
-  } else if (CE->getNumOperands() == 2) {
-// Binary operator...
-Value *V1 = RemapOperand(CE->getOperand(0), ValueMap);
-Value *V2 = RemapOperand(CE->getOperand(1), ValueMap);
-
-Result = ConstantExpr::get(CE->getOpcode(), cast(V1),
-   cast(V2));
-  } else {
-assert(0 && "Unknown constant expr type!");
-  }
-
+  std::vector Ops;
+  for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)
+
Ops.push_back(cast(RemapOperand(CE->getOperand(i),ValueMap)));
+  Result = CE->getWithOperands(Ops);
 } else {
   assert(0 && "Unknown type of derived type constant value!");
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-06-15 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.114 -> 1.115
---
Log message:

Fix Regression/Linker/2006-06-15-GlobalVarAnment.ll


---
Diffs of the changes:  (+18 -5)

 LinkModules.cpp |   23 ++-
 1 files changed, 18 insertions(+), 5 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.114 
llvm/lib/Linker/LinkModules.cpp:1.115
--- llvm/lib/Linker/LinkModules.cpp:1.114   Thu Jun  1 14:14:22 2006
+++ llvm/lib/Linker/LinkModules.cpp Thu Jun 15 20:24:04 2006
@@ -452,7 +452,8 @@
   SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable();
 
   // Loop over all of the globals in the src module, mapping them over as we go
-  for (Module::global_iterator I = Src->global_begin(), E = Src->global_end(); 
I != E; ++I) {
+  for (Module::global_iterator I = Src->global_begin(), E = Src->global_end();
+   I != E; ++I) {
 GlobalVariable *SGV = I;
 GlobalVariable *DGV = 0;
 // Check to see if may have to link the global.
@@ -487,7 +488,9 @@
 new GlobalVariable(SGV->getType()->getElementType(),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
SGV->getName(), Dest);
-
+  // Propagate alignment info.
+  NewDGV->setAlignment(SGV->getAlignment());
+  
   // If the LLVM runtime renamed the global, but it is an externally 
visible
   // symbol, DGV must be an existing global with internal linkage.  Rename
   // it.
@@ -509,12 +512,18 @@
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
"", Dest);
 
+  // Propagate alignment info.
+  NewDGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
+
   // Make sure to remember this mapping...
   ValueMap.insert(std::make_pair(SGV, NewDGV));
 
   // Keep track that this is an appending variable...
   AppendingVars.insert(std::make_pair(SGV->getName(), NewDGV));
 } else {
+  // Propagate alignment info.
+  DGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
+
   // Otherwise, perform the mapping as instructed by GetLinkageResult.  If
   // the types don't match, and if we are to link from the source, nuke DGV
   // and create a new one of the appropriate type.
@@ -522,6 +531,7 @@
 GlobalVariable *NewDGV =
   new GlobalVariable(SGV->getType()->getElementType(),
  DGV->isConstant(), DGV->getLinkage());
+NewDGV->setAlignment(DGV->getAlignment());
 Dest->getGlobalList().insert(DGV, NewDGV);
 DGV->replaceAllUsesWith(ConstantExpr::getCast(NewDGV, DGV->getType()));
 DGV->eraseFromParent();
@@ -560,7 +570,8 @@
 std::string *Err) {
 
   // Loop over all of the globals in the src module, mapping them over as we go
-  for (Module::const_global_iterator I = Src->global_begin(), E = 
Src->global_end(); I != E; ++I){
+  for (Module::const_global_iterator I = Src->global_begin(),
+   E = Src->global_end(); I != E; ++I) {
 const GlobalVariable *SGV = I;
 
 if (SGV->hasInitializer()) {  // Only process initialized GV's
@@ -709,7 +720,8 @@
   *OI = RemapOperand(*OI, GlobalMap);
 
   // There is no need to map the arguments anymore.
-  for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end(); I != 
E; ++I)
+  for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();
+   I != E; ++I)
 GlobalMap.erase(I);
 
   return false;
@@ -892,7 +904,8 @@
   // it's functionality here.
   std::map GlobalsByName;
 
-  for (Module::global_iterator I = Dest->global_begin(), E = 
Dest->global_end(); I != E; ++I) {
+  for (Module::global_iterator I = Dest->global_begin(), E = 
Dest->global_end();
+   I != E; ++I) {
 // Add all of the appending globals already in the Dest module to
 // AppendingVars.
 if (I->hasAppendingLinkage())



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-06-01 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.113 -> 1.114
---
Log message:

Fix linking of inline asm objects.


---
Diffs of the changes:  (+9 -5)

 LinkModules.cpp |   14 +-
 1 files changed, 9 insertions(+), 5 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.113 
llvm/lib/Linker/LinkModules.cpp:1.114
--- llvm/lib/Linker/LinkModules.cpp:1.113   Fri Apr  7 20:19:47 2006
+++ llvm/lib/Linker/LinkModules.cpp Thu Jun  1 14:14:22 2006
@@ -262,20 +262,19 @@
 
 // RemapOperand - Use ValueMap to convert references from one module to 
another.
 // This is somewhat sophisticated in that it can automatically handle constant
-// references correctly as well...
+// references correctly as well.
 static Value *RemapOperand(const Value *In,
std::map &ValueMap) {
   std::map::const_iterator I = ValueMap.find(In);
   if (I != ValueMap.end()) return I->second;
 
   // Check to see if it's a constant that we are interesting in transforming.
+  Value *Result = 0;
   if (const Constant *CPV = dyn_cast(In)) {
 if ((!isa(CPV->getType()) && !isa(CPV)) ||
 isa(CPV))
   return const_cast(CPV);   // Simple constants stay identical.
 
-Constant *Result = 0;
-
 if (const ConstantArray *CPA = dyn_cast(CPV)) {
   std::vector Operands(CPA->getNumOperands());
   for (unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i)
@@ -350,11 +349,16 @@
 } else {
   assert(0 && "Unknown type of derived type constant value!");
 }
-
-// Cache the mapping in our local map structure...
+  } else if (isa(In)) {
+Result = const_cast(In);
+  }
+  
+  // Cache the mapping in our local map structure...
+  if (Result) {
 ValueMap.insert(std::make_pair(In, Result));
 return Result;
   }
+  
 
   std::cerr << "LinkModules ValueMap: \n";
   PrintMap(ValueMap);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-04-07 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.112 -> 1.113
---
Log message:

Add shufflevector support


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

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


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.112 
llvm/lib/Linker/LinkModules.cpp:1.113
--- llvm/lib/Linker/LinkModules.cpp:1.112   Thu Apr  6 20:27:42 2006
+++ llvm/lib/Linker/LinkModules.cpp Fri Apr  7 20:19:47 2006
@@ -317,6 +317,12 @@
 Result = ConstantExpr::getInsertElement(cast(Ptr),
 cast(Elt),
 cast(Idx));
+  } else if (CE->getOpcode() == Instruction::ShuffleVector) {
+Value *V1 = RemapOperand(CE->getOperand(0), ValueMap);
+Value *V2 = RemapOperand(CE->getOperand(1), ValueMap);
+Result = ConstantExpr::getShuffleVector(cast(V1),
+cast(V2),
+ 
cast(CE->getOperand(2)));
   } else if (CE->getNumOperands() == 1) {
 // Cast instruction
 assert(CE->getOpcode() == Instruction::Cast);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-04-06 Thread Evan Cheng


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.111 -> 1.112
---
Log message:

Add code to RemapOperand() to handle Instruction::ExtractElement and
Instruction::InsertElement.


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

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


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.111 
llvm/lib/Linker/LinkModules.cpp:1.112
--- llvm/lib/Linker/LinkModules.cpp:1.111   Mon Jan 23 22:14:29 2006
+++ llvm/lib/Linker/LinkModules.cpp Thu Apr  6 20:27:42 2006
@@ -305,6 +305,18 @@
 ValueMap)));
 
 Result = ConstantExpr::getGetElementPtr(cast(Ptr), Indices);
+  } else if (CE->getOpcode() == Instruction::ExtractElement) {
+Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);
+Value *Idx = RemapOperand(CE->getOperand(1), ValueMap);
+Result = ConstantExpr::getExtractElement(cast(Ptr),
+ cast(Idx));
+  } else if (CE->getOpcode() == Instruction::InsertElement) {
+Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);
+Value *Elt = RemapOperand(CE->getOperand(1), ValueMap);
+Value *Idx = RemapOperand(CE->getOperand(2), ValueMap);
+Result = ConstantExpr::getInsertElement(cast(Ptr),
+cast(Elt),
+cast(Idx));
   } else if (CE->getNumOperands() == 1) {
 // Cast instruction
 assert(CE->getOpcode() == Instruction::Cast);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-01-23 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.110 -> 1.111
---
Log message:

Rename method


---
Diffs of the changes:  (+5 -4)

 LinkModules.cpp |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.110 
llvm/lib/Linker/LinkModules.cpp:1.111
--- llvm/lib/Linker/LinkModules.cpp:1.110   Mon Jan 23 17:08:37 2006
+++ llvm/lib/Linker/LinkModules.cpp Mon Jan 23 22:14:29 2006
@@ -833,11 +833,12 @@
   Dest->getTargetTriple() != Src->getTargetTriple())
 std::cerr << "WARNING: Linking two modules of different target triples!\n";
 
-  if (!Src->getInlineAsm().empty()) {
-if (Dest->getInlineAsm().empty())
-  Dest->setInlineAsm(Src->getInlineAsm());
+  if (!Src->getModuleInlineAsm().empty()) {
+if (Dest->getModuleInlineAsm().empty())
+  Dest->setModuleInlineAsm(Src->getModuleInlineAsm());
 else
-  Dest->setInlineAsm(Dest->getInlineAsm()+"\n"+Src->getInlineAsm());
+  Dest->setModuleInlineAsm(Dest->getModuleInlineAsm()+"\n"+
+   Src->getModuleInlineAsm());
   }
   
   // Update the destination module's dependent libraries list with the 
libraries



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-01-23 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.109 -> 1.110
---
Log message:

Add support for linking inline asm


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

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


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.109 
llvm/lib/Linker/LinkModules.cpp:1.110
--- llvm/lib/Linker/LinkModules.cpp:1.109   Thu Jan 19 17:15:58 2006
+++ llvm/lib/Linker/LinkModules.cpp Mon Jan 23 17:08:37 2006
@@ -833,6 +833,13 @@
   Dest->getTargetTriple() != Src->getTargetTriple())
 std::cerr << "WARNING: Linking two modules of different target triples!\n";
 
+  if (!Src->getInlineAsm().empty()) {
+if (Dest->getInlineAsm().empty())
+  Dest->setInlineAsm(Src->getInlineAsm());
+else
+  Dest->setInlineAsm(Dest->getInlineAsm()+"\n"+Src->getInlineAsm());
+  }
+  
   // Update the destination module's dependent libraries list with the 
libraries
   // from the source module. There's no opportunity for duplicates here as the
   // Module ensures that duplicate insertions are discarded.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-01-19 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.108 -> 1.109
---
Log message:

add support for ConstantPacked to the linker


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

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


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.108 
llvm/lib/Linker/LinkModules.cpp:1.109
--- llvm/lib/Linker/LinkModules.cpp:1.108   Tue Dec  6 11:30:58 2005
+++ llvm/lib/Linker/LinkModules.cpp Thu Jan 19 17:15:58 2006
@@ -290,6 +290,11 @@
   Result = const_cast(CPV);
 } else if (isa(CPV)) {
   Result = cast(RemapOperand(CPV, ValueMap));
+} else if (const ConstantPacked *CP = dyn_cast(CPV)) {
+  std::vector Operands(CP->getNumOperands());
+  for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
+Operands[i] = cast(RemapOperand(CP->getOperand(i), 
ValueMap));
+  Result = ConstantPacked::get(Operands);
 } else if (const ConstantExpr *CE = dyn_cast(CPV)) {
   if (CE->getOpcode() == Instruction::GetElementPtr) {
 Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2005-12-06 Thread Chris Lattner


Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.107 -> 1.108
---
Log message:

Fix test/Regression/Linker/2005-12-06-AppendingZeroLengthArrays.ll and
PR662: http://llvm.cs.uiuc.edu/PR662 .  Thanks to Markus for providing me with 
a ton of files to
reproduce the problem!


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

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


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.107 
llvm/lib/Linker/LinkModules.cpp:1.108
--- llvm/lib/Linker/LinkModules.cpp:1.107   Thu Jul  7 18:21:43 2005
+++ llvm/lib/Linker/LinkModules.cpp Tue Dec  6 11:30:58 2005
@@ -748,6 +748,8 @@
   unsigned NewSize = T1->getNumElements() + T2->getNumElements();
   ArrayType *NewType = ArrayType::get(T1->getElementType(), NewSize);
 
+  G1->setName("");   // Clear G1's name in case of a conflict!
+  
   // Create the new global variable...
   GlobalVariable *NG =
 new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(),



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits