[llvm-commits] [llvm] r144674 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/pr11202.ll
Rafael Espindola
rafael.espindola at gmail.com
Tue Nov 15 11:08:46 PST 2011
Author: rafael
Date: Tue Nov 15 13:08:46 2011
New Revision: 144674
URL: http://llvm.org/viewvc/llvm-project?rev=144674&view=rev
Log:
We currently use a callback to handle an IL pass deleting a BB that still
has a reference to it. Unfortunately, that doesn't work for codegen passes
since we don't get notified of MBB's being deleted (the original BB stays).
Use that fact to our advantage and after printing a function, check if
any of the IL BBs corresponds to a symbol that was not printed. This fixes
pr11202.
Added:
llvm/trunk/test/CodeGen/X86/pr11202.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=144674&r1=144673&r2=144674&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Nov 15 13:08:46 2011
@@ -736,6 +736,18 @@
OutStreamer.EmitRawText(StringRef("\tnop\n"));
}
+ const Function *F = MF->getFunction();
+ for (Function::const_iterator i = F->begin(), e = F->end(); i != e; ++i) {
+ const BasicBlock *BB = i;
+ if (!BB->hasAddressTaken())
+ continue;
+ MCSymbol *Sym = GetBlockAddressSymbol(BB);
+ if (Sym->isDefined())
+ continue;
+ OutStreamer.AddComment("Address of block that was removed by CodeGen");
+ OutStreamer.EmitLabel(Sym);
+ }
+
// Emit target-specific gunk after the function body.
EmitFunctionBodyEnd();
Added: llvm/trunk/test/CodeGen/X86/pr11202.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr11202.ll?rev=144674&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr11202.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr11202.ll Tue Nov 15 13:08:46 2011
@@ -0,0 +1,19 @@
+; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s
+
+ at bb = constant [1 x i8*] [i8* blockaddress(@main, %l2)]
+
+define void @main() {
+entry:
+ br label %l1
+
+l1: ; preds = %l2, %entry
+ %a = zext i1 false to i32
+ br label %l2
+
+l2: ; preds = %l1
+ %b = zext i1 false to i32
+ br label %l1
+}
+
+; CHECK: .Ltmp1: # Address of block that was removed by CodeGen
+; CHECK: .quad .Ltmp1
More information about the llvm-commits
mailing list