[llvm] [CalcSpillWeights] don't mark live intervals with spillable inlineasm ops as having infinite spill weight (PR #70747)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 02:15:08 PDT 2023


================
@@ -146,6 +146,17 @@ void VirtRegAuxInfo::calculateSpillWeightAndHint(LiveInterval &LI) {
   LI.setWeight(Weight);
 }
 
+static bool canMemFoldInlineAsm(LiveInterval &LI,
+                                const MachineRegisterInfo &MRI) {
+  for (const MachineOperand &MO : MRI.reg_operands(LI.reg())) {
+    const MachineInstr *MI = MO.getParent();
+    if (MI->isInlineAsm() && MI->mayFoldInlineAsmMemOp(MI->getOperandNo(&MO)))
+      return true;
----------------
qcolombet wrote:

What happens if a register is both foldable and not foldable?
I.e., something like `asm "rm, r", %0, %0`.

Given the second constraints force `%0` to stay in register, we can't fold right.

In other words, depending on the semantic that we want, we may want to check all the operands.
Now, I still approved this PR because although the resulting `LI` won't actually be spillable in this case, regalloc will still handle it correctly.

https://github.com/llvm/llvm-project/pull/70747


More information about the llvm-commits mailing list