[llvm-commits] CVS: llvm/tools/lto/lto.cpp

Devang Patel dpatel at apple.com
Fri Aug 4 12:10:45 PDT 2006



Changes in directory llvm/tools/lto:

lto.cpp updated: 1.2 -> 1.3
---
Log message:

Collect references from globals.


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

 lto.cpp |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)


Index: llvm/tools/lto/lto.cpp
diff -u llvm/tools/lto/lto.cpp:1.2 llvm/tools/lto/lto.cpp:1.3
--- llvm/tools/lto/lto.cpp:1.2	Thu Aug  3 12:25:36 2006
+++ llvm/tools/lto/lto.cpp	Fri Aug  4 14:10:26 2006
@@ -85,15 +85,16 @@
 // Find exeternal symbols referenced by VALUE. This is a recursive function.
 static void
 findExternalRefs(Value *value, std::set<const char *> &references) {
-  
-  if (ConstantExpr *ce = dyn_cast<ConstantExpr>(value))
-    for (unsigned i = 0, e = ce->getNumOperands(); i != e; ++i)
-      findExternalRefs(ce->getOperand(i), references);
-  else if (GlobalValue *gv = dyn_cast<GlobalValue>(value)) {
+
+  if (GlobalValue *gv = dyn_cast<GlobalValue>(value)) {
     LTOLinkageTypes lt = getLTOLinkageType(gv);
     if (lt != LTOInternalLinkage && strncmp (gv->getName().c_str(), "llvm.", 5))
       references.insert(addUnderscore(gv->getName().c_str()));
   }
+  else if (Constant *c = dyn_cast<Constant>(value))
+    // Handle ConstantExpr, ConstantStruct, ConstantArry etc..
+    for (unsigned i = 0, e = c->getNumOperands(); i != e; ++i)
+      findExternalRefs(c->getOperand(i), references);
 }
 
 /// InputFilename is a LLVM bytecode file. Read it using bytecode reader.
@@ -140,6 +141,11 @@
       const char *name = addUnderscore(v->getName().c_str());
       LLVMSymbol *newSymbol = new LLVMSymbol(lt,v);
       symbols[name] = newSymbol;
+
+      for (unsigned count = 0, total = v->getNumOperands(); 
+	   count != total; ++count)
+	findExternalRefs(v->getOperand(count), references);
+
     }
   }
   






More information about the llvm-commits mailing list