-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[RISCV] Clang 19.1 Compiler segfaults in 'RISC-V Assembly Printer' pass #108612
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
Comments
@llvm/issue-subscribers-backend-risc-v Author: Khem Raj (kraj)
attached testcase reproduces the following problem on latest from `release/19.x` branch
|
Reduced compilation flags: |
Looks like the call to Fixups.clear() in |
Possible fix
|
@kraj did you add -mrelax-all to the command line yourself? |
I am working to provide a reproducer. |
|
So it exists for a long time? |
Yes. And -mrelax-all is broken on RISC-V. See #87127 for more details. |
Reproducer:
LLVM version: 387bee9 |
IR reproducer: https://godbolt.org/z/nchh5qdo9 |
No, infact on the contrary we use to use |
@topperc I could trace this issue happening to this commit f15266e
|
I suspect you might have meant -mno-relax. -mno-relax disables generating RISCV_RELAX relocations. -m[no-]relax-all is for branch relaxation not linker relaxation. For RISC-V -mrelax-all causes the assembler stage to convert all conditional branches into
Unconditional jmp can reach targets a lot further than a conditional branch. Unfortunately, jmp also has a limited range so sometimes needs to be converted to an indirect jump which requires a scratch register. We do all branch relaxation early for RISC-V during the compilation stage so we can allocate the scratch register. If the assembler also does branch relaxation it will increase the size of the function and may cause unconditional jmps to go out of range. If this happens, linking will fail. For some reason, libjxl is forcing -mrelax-all in its CMakeLists.txt. It's been there for at least 5 years and I was unable to find any explanation for it. Whatever the reason, it might have been X86 specific. I highly recommend not using -mrelax-all for RISC-V. |
The Fixups vector passed into this function may already have fixups in it from earlier instructions. We should not erase those. We just want to erase fixups added by this function. Fixes llvm#108612.
@topperc are there any plans to cherry-pick this fix to the release/19.x branch? It seems to be merged to the main branch, but we still observe similar test failures on the release branch |
/cherry-pick c3d3cef |
/pull-request #114089 |
I'll do the cherry-pick, but I really think you should remove -mrelax-all from the build. It's bad for performance on RISC-V. |
…Br. (llvm#109513) The Fixups vector passed into this function may already have fixups in it from earlier instructions. We should not erase those. We just want to erase fixups added by this function. Fixes llvm#108612. (cherry picked from commit c3d3cef)
…Br. (llvm#109513) The Fixups vector passed into this function may already have fixups in it from earlier instructions. We should not erase those. We just want to erase fixups added by this function. Fixes llvm#108612. (cherry picked from commit c3d3cef)
…Br. (llvm#109513) The Fixups vector passed into this function may already have fixups in it from earlier instructions. We should not erase those. We just want to erase fixups added by this function. Fixes llvm#108612. (cherry picked from commit c3d3cef)
attached testcase reproduces the following problem on latest from
release/19.x
branchac_strategy-555195.zip
The text was updated successfully, but these errors were encountered: