-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Bad machine code: Virtual register defs don't dominate all uses. #50858
Comments
assigned to @rampitec |
RA tries to rematerialize this instruction: 832B %56:gpr64sp = ADDXri %55:gpr64common, 648, 0 to the slot 1648e here: 1648B STRXui %22:gpr64common, %55:gpr64common, 81 :: (store (s64) into %ir.47) The use of %55 is checked by the LiveRangeEdit::allUsesAvailableAt(). Register is dead at the use slot: %55 [816r,1216B:0)[1456B,1520B:0)[1632B,1648r:0) 0@816r weight:1.443001e-03 The problem is that use index is right after the reg slot and then register is killed. allUsesAvailableAt() takes 1648e as a UseIdx, but the first thing it does: UseIdx = UseIdx.getRegSlot(true); which adjusts the index right before register is killed and function thinks it is alive. After the rematerialization we have an instruction with the dead use: 1648B STRXui %22:gpr64common, %55:gpr64common, 81 :: (store (s64) into %ir.47) %55 [816r,1216B:0)[1456B,1520B:0)[1632B,1648r:0) 0@816r weight:1.443001e-03 I believe the solution is to add a check li.liveAt(UseIdx) with the original index before it adjusted. Ideally I would want to reproduce it without the whole big change https://reviews.llvm.org/D106408, it shall be reproducible with AMDGPU BE. |
Reduced MIR testcase |
Proposed fix: https://reviews.llvm.org/D108475 |
Extended Description
This appears to have been introduced by https://reviews.llvm.org/D106408.
The error we see when running the attached Clang crash reproducer is:
The text was updated successfully, but these errors were encountered: