[llvm] [FinalizelSel] Re-scan the MachineFunction if we insert a new MBB by custom insertion (PR #96046)

Jianjian Guan via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 02:48:50 PDT 2024


jacquesguan wrote:

> If I'm reading the failing test right, we have a select before a call to memset and a select after the call. We merge them into a single control flow change. Is that really something we should be doing?
> 
> We already abort the scan for
> 
> ```
>     if (SequenceMBBI->hasUnmodeledSideEffects() ||                               
>         SequenceMBBI->mayLoadOrStore() ||                                        
>         SequenceMBBI->usesCustomInsertionHook())                                 
>       break;   
> ```
> 
> Should call be included? A call could contain loads, stores, or unmodelled side effects.
> 
> Adding @asb as well

Yes, change `emitSelectPseudo` would also resolve the problem, but I think the root reason of this issue is the scanning logic of `FinalizeISel`. 
When we insert one or some MBB, it assumes that the current MBB would be split in the custom insertion and `EmitInstrWithCustomInserter` should return the last MBB inserted.
The RISCV backend has different behavior, it will continue to scan the current MBB and try merge several select pseudo, so that it would skip some MIs.
I think changing the interface should be a better way.

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


More information about the llvm-commits mailing list