Skip to content

virtual bool llvm::X86RegisterInfo::eliminateFrameIndex(llvm::MachineBasicBlock::iterator, int, unsigned int, llvm::RegScavenger*) const: Assertion `(!Is64Bit || isInt<32>((long long)FIOffset + Imm)) && "Requesting 64-bit offset in 32-bit immediate!"' failed. #87154

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

Closed
DigOrDog opened this issue Mar 30, 2024 · 4 comments · Fixed by #101840
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@DigOrDog
Copy link

Description

The following code crashes X86 backend with "Assertion `(!Is64Bit || isInt<32>((long long)FIOffset + Imm)) && "Requesting 64-bit offset in 32-bit immediate!"' failed."

Minimal Reproduction

https://godbolt.org/z/h57r6bMsq

code

define void @f(i16 %LGV2, i1 %LGV3) {
BB:
  %A = alloca i1, i33 2147483648, align 1
  %G = getelementptr i1, ptr %A, i16 %LGV2
  %G4 = getelementptr i1, ptr %G, i32 -2147483648
  store i1 %LGV3, ptr %G4, align 1
  ret void
}

Stack Trace

llc: /root/llvm-project/llvm/lib/Target/X86/X86RegisterInfo.cpp:950: virtual bool llvm::X86RegisterInfo::eliminateFrameIndex(llvm::MachineBasicBlock::iterator, int, unsigned int, llvm::RegScavenger*) const: Assertion `(!Is64Bit || isInt<32>((long long)FIOffset + Imm)) && "Requesting 64-bit offset in 32-bit immediate!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 -mattr=+avx512f -O=0 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@f'
 #0 0x000000000392d5d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x392d5d8)
 #1 0x000000000392ad2c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f2edc842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007f2edc8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007f2edc842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007f2edc8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007f2edc82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007f2edc839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000001cf0fb0 llvm::X86RegisterInfo::eliminateFrameIndex(llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, int, unsigned int, llvm::RegScavenger*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1cf0fb0)
 #9 0x0000000002ac734c (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) PrologEpilogInserter.cpp:0:0
#10 0x0000000002946051 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#11 0x0000000002f04a33 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f04a33)
#12 0x0000000002f04c71 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f04c71)
#13 0x0000000002f054d5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f054d5)
#14 0x0000000000823e0c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#15 0x0000000000722fd6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x722fd6)
#16 0x00007f2edc829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#17 0x00007f2edc829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#18 0x000000000081a92e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x81a92e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Mar 30, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 30, 2024

@llvm/issue-subscribers-backend-x86

Author: None (DigOrDog)

# Description The following code crashes X86 backend with "Assertion `(!Is64Bit || isInt<32>((long long)FIOffset + Imm)) && "Requesting 64-bit offset in 32-bit immediate!"' failed."

Minimal Reproduction

https://godbolt.org/z/h57r6bMsq

code

define void @<!-- -->f(i16 %LGV2, i1 %LGV3) {
BB:
  %A = alloca i1, i33 2147483648, align 1
  %G = getelementptr i1, ptr %A, i16 %LGV2
  %G4 = getelementptr i1, ptr %G, i32 -2147483648
  store i1 %LGV3, ptr %G4, align 1
  ret void
}

Stack Trace

llc: /root/llvm-project/llvm/lib/Target/X86/X86RegisterInfo.cpp:950: virtual bool llvm::X86RegisterInfo::eliminateFrameIndex(llvm::MachineBasicBlock::iterator, int, unsigned int, llvm::RegScavenger*) const: Assertion `(!Is64Bit || isInt&lt;32&gt;((long long)FIOffset + Imm)) &amp;&amp; "Requesting 64-bit offset in 32-bit immediate!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 -mattr=+avx512f -O=0 &lt;source&gt;
1.	Running pass 'Function Pass Manager' on module '&lt;source&gt;'.
2.	Running pass 'Prologue/Epilogue Insertion &amp; Frame Finalization' on function '@<!-- -->f'
 #<!-- -->0 0x000000000392d5d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x392d5d8)
 #<!-- -->1 0x000000000392ad2c SignalHandler(int) Signals.cpp:0:0
 #<!-- -->2 0x00007f2edc842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x00007f2edc8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->4 0x00007f2edc842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->5 0x00007f2edc8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->6 0x00007f2edc82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #<!-- -->7 0x00007f2edc839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #<!-- -->8 0x0000000001cf0fb0 llvm::X86RegisterInfo::eliminateFrameIndex(llvm::MachineInstrBundleIterator&lt;llvm::MachineInstr, false&gt;, int, unsigned int, llvm::RegScavenger*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1cf0fb0)
 #<!-- -->9 0x0000000002ac734c (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&amp;) PrologEpilogInserter.cpp:0:0
#<!-- -->10 0x0000000002946051 llvm::MachineFunctionPass::runOnFunction(llvm::Function&amp;) (.part.0) MachineFunctionPass.cpp:0:0
#<!-- -->11 0x0000000002f04a33 llvm::FPPassManager::runOnFunction(llvm::Function&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f04a33)
#<!-- -->12 0x0000000002f04c71 llvm::FPPassManager::runOnModule(llvm::Module&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f04c71)
#<!-- -->13 0x0000000002f054d5 llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f054d5)
#<!-- -->14 0x0000000000823e0c compileModule(char**, llvm::LLVMContext&amp;) llc.cpp:0:0
#<!-- -->15 0x0000000000722fd6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x722fd6)
#<!-- -->16 0x00007f2edc829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->17 0x00007f2edc829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->18 0x000000000081a92e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x81a92e)
Program terminated with signal: SIGSEGV
Compiler returned: 139

@RKSimon
Copy link
Collaborator

RKSimon commented Apr 3, 2024

This should be addressed when #84114 gets fixed + re-committed

@DigOrDog
Copy link
Author

DigOrDog commented Apr 9, 2024

This should be addressed when #84114 gets fixed + re-committed

Thank you for your previous response regarding the issue I reported. I noticed that #84114, which was anticipated to address my concern, has been fixed and re-committed. However, I'm still experiencing the original problem I reported.

Could you please take another look at it? Perhaps there might be another underlying cause that wasn't addressed by the fix for #84114. I'm happy to provide any additional information or assistance needed to help diagnose the issue further.

@RKSimon
Copy link
Collaborator

RKSimon commented Apr 9, 2024

AFAICT #84114 has not been recommitted - the PR is closed because github won't let us reopen PRs that have been committed.

@arsenm arsenm closed this as completed in 0abb779 Aug 19, 2024
zmodem added a commit that referenced this issue Aug 21, 2024
…rames (#101840)"

This casuses assertion failures targeting 32-bit x86:

  lib/Target/X86/X86RegisterInfo.cpp:989:
  virtual bool llvm::X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator, int, unsigned int, RegScavenger *) const:
  Assertion `(Is64Bit || FitsIn32Bits) && "Requesting 64-bit offset in 32-bit immediate!"' failed.

See comment on the PR.

> Fix 32-bit integer overflows in the X86 target frame layout when dealing
> with frames larger than 4gb. When this occurs, we'll scavenge a scratch
> register to be able to hold the correct stack offset for frame locals.
>
> This completes reapplying #84114.
>
> Fixes #48911
> Fixes #75944
> Fixes #87154

This reverts commit 0abb779.
cjdb pushed a commit to cjdb/llvm-project that referenced this issue Aug 23, 2024
…rames (llvm#101840)"

This casuses assertion failures targeting 32-bit x86:

  lib/Target/X86/X86RegisterInfo.cpp:989:
  virtual bool llvm::X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator, int, unsigned int, RegScavenger *) const:
  Assertion `(Is64Bit || FitsIn32Bits) && "Requesting 64-bit offset in 32-bit immediate!"' failed.

See comment on the PR.

> Fix 32-bit integer overflows in the X86 target frame layout when dealing
> with frames larger than 4gb. When this occurs, we'll scavenge a scratch
> register to be able to hold the correct stack offset for frame locals.
>
> This completes reapplying llvm#84114.
>
> Fixes llvm#48911
> Fixes llvm#75944
> Fixes llvm#87154

This reverts commit 0abb779.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants