[llvm-commits] [llvm] r70079 - in /llvm/trunk/lib/VMCore: AsmWriter.cpp Verifier.cpp

Chris Lattner sabre at nondot.org
Sat Apr 25 14:23:19 PDT 2009


Author: lattner
Date: Sat Apr 25 16:23:19 2009
New Revision: 70079

URL: http://llvm.org/viewvc/llvm-project?rev=70079&view=rev
Log:
Allow aliasee to be a GEP or bitcast instead of just a bitcast.
The real fix for this whole mess is to require the operand of the
alias to be a *GlobalValue* (not a general constant, including 
constant exprs) but allow the operand and the alias type to be
unrelated.

This fixes PR4066

Modified:
    llvm/trunk/lib/VMCore/AsmWriter.cpp
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=70079&r1=70078&r2=70079&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Sat Apr 25 16:23:19 2009
@@ -1317,12 +1317,12 @@
     Out << ' ';
     PrintLLVMName(Out, GA);
   } else {
-    const ConstantExpr *CE = 0;
-    if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
-        (CE->getOpcode() == Instruction::BitCast)) {
-      writeOperand(CE, false);    
-    } else
-      assert(0 && "Unsupported aliasee");
+    const ConstantExpr *CE = cast<ConstantExpr>(Aliasee);
+    // The only valid GEP is an all zero GEP.
+    assert((CE->getOpcode() == Instruction::BitCast ||
+            CE->getOpcode() == Instruction::GetElementPtr) &&
+           "Unsupported aliasee");
+    writeOperand(CE, false);
   }
   
   printInfoComment(*GA);

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=70079&r1=70078&r2=70079&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Sat Apr 25 16:23:19 2009
@@ -427,7 +427,9 @@
 
   if (!isa<GlobalValue>(GA.getAliasee())) {
     const ConstantExpr *CE = dyn_cast<ConstantExpr>(GA.getAliasee());
-    Assert1(CE && CE->getOpcode() == Instruction::BitCast &&
+    Assert1(CE && 
+            (CE->getOpcode() == Instruction::BitCast ||
+             CE->getOpcode() == Instruction::GetElementPtr) &&
             isa<GlobalValue>(CE->getOperand(0)),
             "Aliasee should be either GlobalValue or bitcast of GlobalValue",
             &GA);





More information about the llvm-commits mailing list