Skip to content

Commit ed82d74

Browse files
committed
CloneFunction: Do not delete blocks with address taken
If a block with a single predecessor also had its address taken, it was getting deleted in this post-inline cleanup step. This would result in the blockaddress in the resulting function getting deleted and replaced with inttoptr 1. This fixes one of (at least?) two bugs required to permit inlining of functions with blockaddress uses. At the moment this is not testable (at least without an annoyingly complex unit test), and is a pre-bug fix for future patches. Functions with blockaddress uses are rejected in isInlineViable, so we don't get this far with the current InlineFunction uses (some of the existing cases seem to reproduce this part of the rejection logic, like PartialInliner). This will be tested in a pending llvm-reduce change. Prerequisite for #38908
1 parent 3140d51 commit ed82d74

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Transforms/Utils/CloneFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
928928
}
929929

930930
BasicBlock *Dest = BI->getSuccessor(0);
931-
if (!Dest->getSinglePredecessor()) {
931+
if (!Dest->getSinglePredecessor() || Dest->hasAddressTaken()) {
932932
++I;
933933
continue;
934934
}

0 commit comments

Comments
 (0)