[llvm] [RegAllocFast] fold foldable inline asm (PR #74344)

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 16:05:05 PST 2023


MatzeB wrote:

Then going back to your original proposal would it at least be possible to eliminate the second pass over the basic block? Similar to this pseudo code?

```
void RegAllocFast::allocateBasicBlock(...) {
   ...
   for (const MachineInstr& MI : llvm::make_early_inc_range(MBB.rbegin(), MBB.rend())) {
      ...
      if (MI.isInlineAsm(..)) {
        preemptivelySpillInlineAsmOperands(MI);
      }
      
      allocateInstruction(MI);
      ...
  }
```
so that hopefully with the `early_inc` iterator style the "next" element has already advanced so you can freely remove and insert the InlineAsm instruction itself without disturbing the overal iterator?



Long term I still think some better integration into the spilling code is desirable; but I guess I could live with the pessimistic codegen for now.

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


More information about the llvm-commits mailing list