aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2025-04-03 23:52:25 +0700
committerGitHub <noreply@github.com>2025-04-03 23:52:25 +0700
commita54736afd5b8f8ed25550a9f456afd36e49c04e0 (patch)
tree120a0cdf8c5c7ffc93319104f337847ec866fc01 /llvm/lib/Transforms/Utils/CloneFunction.cpp
parent6ddf7cf7808e7e60314ed003d52c215dedc0924b (diff)
downloadllvm-a54736afd5b8f8ed25550a9f456afd36e49c04e0.zip
llvm-a54736afd5b8f8ed25550a9f456afd36e49c04e0.tar.gz
llvm-a54736afd5b8f8ed25550a9f456afd36e49c04e0.tar.bz2
CloneFunction: Do not delete blocks with address taken (#134209)
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 bug 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
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index e585857..9387797 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -928,7 +928,7 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
}
BasicBlock *Dest = BI->getSuccessor(0);
- if (!Dest->getSinglePredecessor()) {
+ if (!Dest->getSinglePredecessor() || Dest->hasAddressTaken()) {
++I;
continue;
}