After r303360, we initialize UsesCalleeSaves in runOnMachineFunction,
which runs after getRequiredProperties. UsesCalleeSaves was initialized
to 'false', so getRequiredProperties would always return an empty set.
We don't have a TargetMachine available early anymore after r303360.
Just removing the requirement of NoVRegs seems to make things work, so
let's do that.
Details
Diff Detail
- Build Status
Buildable 10898 Build 10898: arc lint + arc unit
Event Timeline
Removing the requirement works fine now because the passes are set up correctly. The original intention behind getRequiredProperties in this case was that if the pass configuration were to be changed and PEI were to be called before regalloc on a target which wasn't prepared for that, there would be an easy assertion to say what went wrong.
We could just add a conditional assertion in runOnMachineFunction to ensure things are correct; in fact my original patch to PEI for WebAssembly more or less did that. But my reviewer (@qcolombet ) really wanted a stronger mechanism to enforce that kind of invariant and IIRC that's why getRequiredProperties was born.
I guess if we don't have the target anymore at the right time, we can't really properly set getRequiredProperties. I'd be fine with going back to a simple assertion here, but I guess that risks re-opening the debate :)
llvm/lib/CodeGen/PrologEpilogInserter.cpp | ||
---|---|---|
82 | regardless of what we decide about getRequiredProperties we should do the rest of this change (i.e. this and below). There was some discussion about it after it originally landed and it was my intention to do more or less exactly this part of your patch, and I didn't get around to it :( |
llvm/lib/CodeGen/PrologEpilogInserter.cpp | ||
---|---|---|
155 | I'd name the variable UsesPhysRegsForPEI. | |
173 | With the std::function gone we can rename doSpillCalleeSavedRegs back to spillCalleeSavedRegs | |
198–200 | This feels wrong, we should only clearVirtRegs() when we actually scavenged them. Checking the code it seems that the clearing is already done in scavengeFrameVirtualRegs() nowadays so we can remove it here. Maybe we should also skip the whole if (UsesCalleeSaves) then too as it seems target can already control this bit via TRI::requiresRegisterScavenging`. |
llvm/lib/CodeGen/PrologEpilogInserter.cpp | ||
---|---|---|
198–200 | +1 in general. I'm ambivalent on removing if (UsesCalleeSaves) altogether. It's true that no target I can imagine would have UsesCalleeSaves be false and requiresRegisterScavenging be true, but having it explicit makes it a bit more obvious. I'd be OK either way I think. | |
482 | I think this is the right assertion, but there should be a comment here about why we are doing it manually instead of using getRequiredProperties, since that would be the expected thing. |
llvm/lib/CodeGen/PrologEpilogInserter.cpp | ||
---|---|---|
198–200 | I agree. Most targets don't need register scavenging, and wasm (the only target that uses vregs past this point) definitely doesn't need it either. |
I know I've only waited a day for @qcolombet and that's not much time, but I'm going to land this because the requirements checking change actually doesn't change our current functionality. Before this change, UsesCalleeSaves is initialized to false, so PEI doesn't require NoVRegs. This will actually give us better runtime checking.
Sorry Reid @rnk, I didn't know you were waiting for me. I saw already two people were saying it's good and I thought we didn't need a third one :).
It looks good to me too!
regardless of what we decide about getRequiredProperties we should do the rest of this change (i.e. this and below). There was some discussion about it after it originally landed and it was my intention to do more or less exactly this part of your patch, and I didn't get around to it :(