[llvm] 02f3e95 - [AutoUpgrade] Fix use after free
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 02:54:17 PDT 2025
Author: Nikita Popov
Date: 2025-08-08T11:54:09+02:00
New Revision: 02f3e95a42d0a9bf84ac5535b74e9f96ef22a8ca
URL: https://github.com/llvm/llvm-project/commit/02f3e95a42d0a9bf84ac5535b74e9f96ef22a8ca
DIFF: https://github.com/llvm/llvm-project/commit/02f3e95a42d0a9bf84ac5535b74e9f96ef22a8ca.diff
LOG: [AutoUpgrade] Fix use after free
Determine the intrinsic ID before the name is freed during renaming.
Added:
Modified:
llvm/lib/IR/AutoUpgrade.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 35f00aed41041..b91fd70bd9467 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;
More information about the llvm-commits
mailing list