Skip to content

Commit c48f372

Browse files
nikicgithub-actions[bot]
authored andcommitted
Automerge: [AutoUpgrade] Fix use after free
Determine the intrinsic ID before the name is freed during renaming.
2 parents 69555e8 + 02f3e95 commit c48f372

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,12 +1314,12 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
13141314
if ((Name.starts_with("lifetime.start") ||
13151315
Name.starts_with("lifetime.end")) &&
13161316
F->arg_size() == 2) {
1317+
Intrinsic::ID IID = Name.starts_with("lifetime.start")
1318+
? Intrinsic::lifetime_start
1319+
: Intrinsic::lifetime_end;
13171320
rename(F);
1318-
NewFn = Intrinsic::getOrInsertDeclaration(
1319-
F->getParent(),
1320-
Name.starts_with("lifetime.start") ? Intrinsic::lifetime_start
1321-
: Intrinsic::lifetime_end,
1322-
F->getArg(0)->getType());
1321+
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID,
1322+
F->getArg(0)->getType());
13231323
return true;
13241324
}
13251325
break;

0 commit comments

Comments
 (0)