-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FinalizelSel] Re-scan the MachineFunction if we insert a new MBB by custom insertion #96046
base: main
Are you sure you want to change the base?
Conversation
llvm/lib/CodeGen/FinalizeISel.cpp
Outdated
if (InsertNewMBB) { | ||
I = MF.begin(); | ||
InsertNewMBB = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just handle missed MIs correctly instead of iterating from begin again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it insert more than 1 MBB? I am not sure how should we set the MF iterator to make it at the first inserted MBB's iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with RISCV, IIUC the old behavior may skip the rest MIs in I
if new blocks are inserted after I
, and skipped MIs may need expansion. If so, can we check the next BB is the new BB to set iterators correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change to continue scan current MBB.
…m insertion Current logic may skip some MI and has wrong adjustsStack flag.
0375027
to
14ea4e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLDB and some LoongArch tests failed, but doesn't look relevant to this pull request.
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
Should call be included? A call could contain loads, stores, or unmodelled side effects. Adding @asb as well |
I dug into this some more. The emitInstrWithCustomInsert interface dates back to a time when it was called from InstrEmitter.cpp as MachineInstrs were created from SelectionDAG. There was nothing later in the block. The MBB returned was used to reset the position for where future instructions should be inserted. Maybe a better interface today would return the iterator where to resume scanning. |
Yes, change |
Thanks, I will try this way. |
Hi @jacquesguan @topperc . You have mentioned that breaking at calls in Thank you. |
Current logic may skip some MI and would have wrong adjustsStack flag.