-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[SystemZ] LLVM ERROR: Error while trying to spill R14D from class ADDR64Bit: Cannot scavenge register without an emergency spill slot! #79046
Comments
This function has two objects in the frame:
where The problem occurs when finalizing the following instruction:
where That's when LLVM is now looking to scavenge an address register to hold SP + 4232 (actually, SP + 4096, and keep the extra 136 as displacement), and does not find any. The reason for this is that back-end does not allocate any emergency scavenge slots, because it assumes they cannot be needed as the total stack frame size of this function is < 4096 bytes. Now, where does the large offset come frome? In fact, even These offsets are set up as a result of the Loop Strength Reduction pass - not sure why it thinks this transformation useful:
It's unclear how to fix this - all other targets also seem to never allocate an emergency scavenge slot for functions with small total frame size, and it has always seemed to work so far. |
I see this in the debug output from LSR:
It seems it is deciding on the IV that will end on 0 which is good for the ICmpZero and that also works with the Address uses, all with a single IV increment. I guess that is useful generally, but in this test case it is no real improvement. The fact that the Address uses end going out of range seems to be due to SystemZTargetLowering::isLegalAddressingMode() not requesting a 12-bit displacement for i128 as it does for vector types. So LSR thinks that the VST will be in range which is not correct. Patch for isLegalAddressingMode(): #79221. This seems to fix this in a way, but the backend should have probably still have been able to cope with this regardless. |
I am not sure if #79221 is a full handling of this or not. In one way, the backend should/could be able to handle this, but on the other hand the TargetLowering isLegalAddressingMode() should reflect if the addressing is legal or not, so one could perhaps argue that all addressing must conform to this after lowering. A further handling in the backend looks like doing a full scan of instructions after frame objects have been ordered in calculateFrameObjectOffsets(). This could be done in processFunctionBeforeFrameIndicesReplaced(). The immediate offset of e.g. a VST + the offset of the FI could be checked then. |
I'm a bit reluctant to add additional compile time overhead, in particular given that no other target seems to do anything along those lines. Let's add the fix in #79221 (which is necessary anyway), and then see if there's any further problems ... |
tc_regscav.tar.gz
llc -mtriple=s390x-linux-gnu -mcpu=z16 ./tc_regscav.ll -misched=shuffle
LLVM ERROR: Error while trying to spill R14D from class ADDR64Bit: Cannot scavenge register without an emergency spill slot!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./bin/llc -mtriple=s390x-linux-gnu -mcpu=z16 ./tc_regscav.ll -misched=shuffle
@uweigand This test case has i128 registers, but it is an ADDR64 that needs scavenging...
The text was updated successfully, but these errors were encountered: