[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp

Anton Korobeynikov asl at math.spbu.ru
Sat Apr 28 06:45:48 PDT 2007



Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.157 -> 1.158
---
Log message:

Implement review feedback. Aliasees can be either GlobalValue's or 
bitcasts of them.


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

 AsmPrinter.cpp |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.157 llvm/lib/CodeGen/AsmPrinter.cpp:1.158
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.157	Wed Apr 25 09:27:10 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp	Sat Apr 28 08:44:59 2007
@@ -123,18 +123,29 @@
   }
 
   if (TAI->getSetDirective()) {
-    if (M.alias_size())
+    if (!M.alias_empty())
       SwitchToTextSection(TAI->getTextSection());
 
     O << "\n";
     for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
          I!=E; ++I) {
-      const GlobalValue *Aliasee = I->getAliasee();
-      assert(Aliasee && "Aliasee cannot be null!");
-      std::string Target   = Mang->getValueName(Aliasee);
-      std::string Name     = Mang->getValueName(I);
+      const Constant *Aliasee = dyn_cast_or_null<Constant>(I->getAliasee());
+      assert(Aliasee && "Aliasee cannot be null");
 
-      // Aliases with external weak linkage was emitted already
+      std::string Name = Mang->getValueName(I);
+      std::string Target;
+      
+      if (const GlobalValue *GV = dyn_cast<GlobalValue>(Aliasee))
+        Target = Mang->getValueName(GV);
+      else {
+        const ConstantExpr *CE = 0;
+        if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
+            (CE->getOpcode() == Instruction::BitCast))
+          Target = Mang->getValueName(CE->getOperand(0));
+        else
+          assert(0 && "Unsupported aliasee");
+      }
+      
       if (I->hasExternalLinkage())
         O << "\t.globl\t" << Name << "\n";
       else if (I->hasWeakLinkage())






More information about the llvm-commits mailing list