[PATCH] D45524: Fix incorrect choice of callee-saved registers save/restore points

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 11 10:12:00 PDT 2018


thegameg added a comment.

Thanks for this! If it's possible, could you also write a MIR test for this?



================
Comment at: lib/CodeGen/ShrinkWrap.cpp:262
+  // for save/restore placement even if they use SP.
+  if (MI.isCall() && MI.isReturn())
+    return false;
----------------
I think this is incorrect if the instruction calls a function with a different calling convention, right? In that case some CSRs would be clobbered while otherwise they were expected to be preserved.

IIUC, the issue here is that some instructions are marked as `let Uses = [SP]`, like calls and returns, but are safe to skip during the analysis.

If I'm not missing anything, to handle all the cases I think it's better to verify all the register operands and reg masks, then only skip the instruction if it only uses SP and `isCall` or something similar. I'm not sure if `isCall` would handle all the cases, but from a quick glance over *InstrInfo.td, other instructions that have `Uses = [SP]` should definitely affect the placement of the save/restore blocks.


Repository:
  rL LLVM

https://reviews.llvm.org/D45524





More information about the llvm-commits mailing list