[llvm] [MCA][X86] Pretend To Have a Stack Engine (PR #153348)
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 02:38:57 PDT 2025
================
@@ -36,11 +36,31 @@ void X86InstrPostProcess::setMemBarriers(std::unique_ptr<Instruction> &Inst,
}
}
+void X86InstrPostProcess::useStackEngine(std::unique_ptr<Instruction> &Inst,
+ const MCInst &MCI) {
+ if (X86::isPOP(MCI.getOpcode())) {
+ assert(Inst->getUses().size() == 1 &&
+ "Expected pop instruction to only use stack pointer register");
+ Inst->getUses().clear();
+ }
----------------
adibiagio wrote:
> I think I made a bit of a mountain out of a mole hill.
>
> <snip>
>
> This means that in MCA we can just clear writes to rsp in stack operation instructions.
I think it is reasonable. However, I wouldn't always the write always. Otherwise, you won't correctly simulate perf for the case where a sync is required.
Just to be clear: the idea of removing the write makes sense.
I think you should not remove a write to RSP if the next RSP user isn't also a stack operation. That way, you would simulate the sync. You still need to post-process instructions imho.
https://github.com/llvm/llvm-project/pull/153348
More information about the llvm-commits
mailing list