Support chained aliases for LLVM IR printing. This fixes PR2145
authorAnton Korobeynikov <asl@math.spbu.ru>
Sat, 22 Mar 2008 08:17:17 +0000 (08:17 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sat, 22 Mar 2008 08:17:17 +0000 (08:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48684 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/AsmWriter.cpp
test/Feature/aliases.ll

index aba66c85a7654645311f65e6921e64bbe4c838eb..a2de5d99a057512a45ddaca56d61f2d80c07ddef 100644 (file)
@@ -1003,6 +1003,9 @@ void AssemblyWriter::printAlias(const GlobalAlias *GA) {
       Out << getLLVMName(F->getName(), GlobalPrefix);
     else
       Out << "@\"\"";
+  } else if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(Aliasee)) {
+    printType(GA->getType());
+    Out << " " << getLLVMName(GA->getName(), GlobalPrefix);
   } else {
     const ConstantExpr *CE = 0;
     if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
index fc5e7685ca6c047e9fdc2adcf09e2faa62937e60..d44dff4c43c6f0d3b887727823ea7c6ebbed95c4 100644 (file)
@@ -5,11 +5,13 @@
 @bar = external global i32
 @foo1 = alias i32* @bar
 @foo2 = alias i32* @bar
+@foo3 = alias i32* @foo2
 
 %FunTy = type i32()
 
 declare i32 @foo_f()
 @bar_f = alias weak %FunTy* @foo_f
+@bar_ff = alias i32()* @bar_f
 
 @bar_i = alias internal i32* @bar