[llvm] [BOLT][AArch64] Implement PLTCall optimization (PR #93584)
Pavel Samolysov via llvm-commits
llvm-commits at lists.llvm.org
Thu May 30 12:19:57 PDT 2024
================
@@ -61,18 +61,20 @@ Error PLTCall::runOnFunctions(BinaryContext &BC) {
if (opts::PLT == OT_HOT && !BB.getKnownExecutionCount())
continue;
- for (MCInst &Instr : BB) {
- if (!BC.MIB->isCall(Instr))
+ for (auto II = BB.begin(); II != BB.end(); II++) {
+ if (!BC.MIB->isCall(*II))
continue;
- const MCSymbol *CallSymbol = BC.MIB->getTargetSymbol(Instr);
+ const MCSymbol *CallSymbol = BC.MIB->getTargetSymbol(*II);
if (!CallSymbol)
continue;
const BinaryFunction *CalleeBF = BC.getFunctionForSymbol(CallSymbol);
if (!CalleeBF || !CalleeBF->isPLTFunction())
continue;
- BC.MIB->convertCallToIndirectCall(Instr, CalleeBF->getPLTSymbol(),
- BC.Ctx.get());
- BC.MIB->addAnnotation(Instr, "PLTCall", true);
+ const InstructionListType NewCode = BC.MIB->createIndirectPltCall(
+ *II, CalleeBF->getPLTSymbol(), BC.Ctx.get());
+ II = BB.replaceInstruction(II, NewCode);
----------------
samolisov wrote:
`std::advance()` after this line uses `NewCode.size() - 1` as the second argument. I think it may make sense to ensure that the size is not zero adding a corresponding `assert`.
https://github.com/llvm/llvm-project/pull/93584
More information about the llvm-commits
mailing list