[llvm] r265508 - ValueMapper: Fix delayed blockaddress handling after r265273
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 19:25:13 PDT 2016
Author: dexonsmith
Date: Tue Apr 5 21:25:12 2016
New Revision: 265508
URL: http://llvm.org/viewvc/llvm-project?rev=265508&view=rev
Log:
ValueMapper: Fix delayed blockaddress handling after r265273
r265273 added Mapper::mapBlockAddress, which delays mapping a
blockaddress value until the function has a body. The condition was
backwards, and should be checking Function::empty instead of
GlobalValue::isDeclaration.
Modified:
llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
llvm/trunk/test/Transforms/Inline/blockaddress.ll
Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=265508&r1=265507&r2=265508&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Tue Apr 5 21:25:12 2016
@@ -383,11 +383,11 @@ Value *Mapper::mapBlockAddress(const Blo
// dummy basic block for now, and replace it once we've materialized all
// the initializers.
BasicBlock *BB;
- if (F->isDeclaration()) {
- BB = cast_or_null<BasicBlock>(mapValue(BA.getBasicBlock()));
- } else {
+ if (F->empty()) {
DelayedBBs.push_back(DelayedBasicBlock(BA));
BB = DelayedBBs.back().TempBB.get();
+ } else {
+ BB = cast_or_null<BasicBlock>(mapValue(BA.getBasicBlock()));
}
return VM[&BA] = BlockAddress::get(F, BB ? BB : BA.getBasicBlock());
Modified: llvm/trunk/test/Transforms/Inline/blockaddress.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/blockaddress.ll?rev=265508&r1=265507&r2=265508&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/blockaddress.ll (original)
+++ llvm/trunk/test/Transforms/Inline/blockaddress.ll Tue Apr 5 21:25:12 2016
@@ -26,3 +26,25 @@ entry:
call void @doit(i8** @ptr1, i32 %cond)
ret void
}
+
+; PR27233: We can inline @run into @init. Don't crash on it.
+;
+; CHECK-LABEL: define void @init
+; CHECK: store i8* blockaddress(@run, %bb)
+; CHECK-SAME: @run.bb
+define void @init() {
+entry:
+ call void @run()
+ ret void
+}
+
+define void @run() {
+entry:
+ store i8* blockaddress(@run, %bb), i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @run.bb, i64 0, i64 0), align 8
+ ret void
+
+bb:
+ unreachable
+}
+
+ at run.bb = global [1 x i8*] zeroinitializer
More information about the llvm-commits
mailing list