aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-08-08 11:53:28 +0200
committerNikita Popov <npopov@redhat.com>2025-08-08 11:54:09 +0200
commit02f3e95a42d0a9bf84ac5535b74e9f96ef22a8ca (patch)
treeaf2ab05015f11d950ca191636a21803e94debe6f /llvm/lib
parent69235d269b305e25798210d293969efb45ee3f1c (diff)
downloadllvm-02f3e95a42d0a9bf84ac5535b74e9f96ef22a8ca.zip
llvm-02f3e95a42d0a9bf84ac5535b74e9f96ef22a8ca.tar.gz
llvm-02f3e95a42d0a9bf84ac5535b74e9f96ef22a8ca.tar.bz2
[AutoUpgrade] Fix use after free
Determine the intrinsic ID before the name is freed during renaming.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/AutoUpgrade.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 35f00ae..b91fd70 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1314,12 +1314,12 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
if ((Name.starts_with("lifetime.start") ||
Name.starts_with("lifetime.end")) &&
F->arg_size() == 2) {
+ Intrinsic::ID IID = Name.starts_with("lifetime.start")
+ ? Intrinsic::lifetime_start
+ : Intrinsic::lifetime_end;
rename(F);
- NewFn = Intrinsic::getOrInsertDeclaration(
- F->getParent(),
- Name.starts_with("lifetime.start") ? Intrinsic::lifetime_start
- : Intrinsic::lifetime_end,
- F->getArg(0)->getType());
+ NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID,
+ F->getArg(0)->getType());
return true;
}
break;