[GlobalISel][IRTranslator] Fix a use-after-free bug when translating trap-func-name traps.

This was using MachineFunction::createExternalSymbolName() before, which seems
reasonable, but in fact this is freed before the asm emitter which tries to access
the function name string. Switching it to use the string returned by the attribute
seems to fix the problem.
This commit is contained in:
Amara Emerson 2021-10-07 23:26:35 -07:00
parent 08b3c0d995
commit 72ce310bf0
1 changed files with 1 additions and 2 deletions

View File

@ -2246,8 +2246,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
Info.OrigArgs.push_back({getOrCreateVRegs(*CI.getArgOperand(0)),
CI.getArgOperand(0)->getType(), 0});
}
Info.Callee =
MachineOperand::CreateES(MF->createExternalSymbolName(TrapFuncName));
Info.Callee = MachineOperand::CreateES(TrapFuncName.data());
Info.CB = &CI;
Info.OrigRet = {Register(), Type::getVoidTy(CI.getContext()), 0};
return CLI->lowerCall(MIRBuilder, Info);