[llvm] [MachineOutliner] Preserve regmasks in calls to outlined functions (PR #120940)
Kyungwoo Lee via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 22:44:45 PST 2025
kyulee-com wrote:
The effective set of Def and Use registers for the given range (the outlined instruction sequence) has already been computed by reverse traversing the instructions. Here, additionally it merges the reg masks that point to clobbering registers in call instructions. This ensures that all definitions are covered either in the Def registers or these combined reg masks. Conservatively, we could also set these bits for the Def registers in these masks, but I don't think it's necessary as we already have the Def registers mentioned above. @MatzeB Do you think the reg masks should have all Def register bits regardless?
It's worth nothing we need custom reg masks because the outlined function call does not follow a typical calling convention; instead, it's a naked call for the range of instructions without forming a frame. So, we should conservatively merge all clobbered register effects into the masks, which this PR seems to fix.
Regarding my suggestion, `MutableArrayRef<uint32_t> allocateRegMaskArray(uint8_t InitValue = 0);`, I didn't intend to modify the API of the existing `uint32_t *allocateRegMask();`. Instead, it can be implemented in a way that preserves the existing behavior while also providing the array size as needed in this context here. @MatzeB @aemerson What do you suggest here?
```
uint32_t *allocateRegMask() { return allocateRegMaskArray().data(); }
```
https://github.com/llvm/llvm-project/pull/120940
More information about the llvm-commits
mailing list