Skip to content
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

[RegBankSelect] Assertion `N < NumContainedTys && "Element number out of range!"' #92062

Closed
DianQK opened this issue May 14, 2024 · 6 comments · Fixed by #92072
Closed

[RegBankSelect] Assertion `N < NumContainedTys && "Element number out of range!"' #92062

DianQK opened this issue May 14, 2024 · 6 comments · Fixed by #92072

Comments

@DianQK
Copy link
Member

DianQK commented May 14, 2024

I tried the following code:

target triple = "arm64"

@p = external global { {}, { ptr } }

define void @foo() {
bb:
  %i1 = load ptr, ptr @p, align 8
  store ptr %i1, ptr null, align 8
  ret void
}

When using llc in LLVM 18, the following error occurs:

llc: /root/llvm-project/llvm/include/llvm/IR/DerivedTypes.h:343: llvm::Type* llvm::StructType::getElementType(unsigned int) const: Assertion `N < NumContainedTys && "Element number out of range!"' 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 -O0 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'RegBankSelect' on function '@foo'
...
 #8 0x0000000000b27667 llvm::AArch64RegisterBankInfo::isLoadFromFPType(llvm::MachineInstr const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xb27667)
 #9 0x0000000000b2b155 llvm::AArch64RegisterBankInfo::getInstrMapping(llvm::MachineInstr const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xb2b155)
#10 0x0000000004203f47 llvm::RegBankSelect::assignInstr(llvm::MachineInstr&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x4203f47)
#11 0x00000000042044d3 llvm::RegBankSelect::assignRegisterBanks(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x42044d3)
...
Compiler returned: 139

https://llvm.godbolt.org/z/a4h1abfKc

@llvmbot
Copy link
Collaborator

llvmbot commented May 14, 2024

@llvm/issue-subscribers-backend-arm

Author: DianQK (DianQK)

I tried the following code:
target triple = "arm64"

@<!-- -->p = external global { {}, { ptr } }

define void @<!-- -->foo() {
bb:
  %i1 = load ptr, ptr @<!-- -->p, align 8
  store ptr %i1, ptr null, align 8
  ret void
}

When using llc in LLVM 18, the following error occurs:

llc: /root/llvm-project/llvm/include/llvm/IR/DerivedTypes.h:343: llvm::Type* llvm::StructType::getElementType(unsigned int) const: Assertion `N &lt; NumContainedTys &amp;&amp; "Element number out of range!"' 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 -O0 &lt;source&gt;
1.	Running pass 'Function Pass Manager' on module '&lt;source&gt;'.
2.	Running pass 'RegBankSelect' on function '@<!-- -->foo'
...
 #<!-- -->8 0x0000000000b27667 llvm::AArch64RegisterBankInfo::isLoadFromFPType(llvm::MachineInstr const&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xb27667)
 #<!-- -->9 0x0000000000b2b155 llvm::AArch64RegisterBankInfo::getInstrMapping(llvm::MachineInstr const&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xb2b155)
#<!-- -->10 0x0000000004203f47 llvm::RegBankSelect::assignInstr(llvm::MachineInstr&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x4203f47)
#<!-- -->11 0x00000000042044d3 llvm::RegBankSelect::assignRegisterBanks(llvm::MachineFunction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x42044d3)
...
Compiler returned: 139

https://llvm.godbolt.org/z/a4h1abfKc

@llvmbot
Copy link
Collaborator

llvmbot commented May 14, 2024

@llvm/issue-subscribers-backend-aarch64

Author: DianQK (DianQK)

I tried the following code:
target triple = "arm64"

@<!-- -->p = external global { {}, { ptr } }

define void @<!-- -->foo() {
bb:
  %i1 = load ptr, ptr @<!-- -->p, align 8
  store ptr %i1, ptr null, align 8
  ret void
}

When using llc in LLVM 18, the following error occurs:

llc: /root/llvm-project/llvm/include/llvm/IR/DerivedTypes.h:343: llvm::Type* llvm::StructType::getElementType(unsigned int) const: Assertion `N &lt; NumContainedTys &amp;&amp; "Element number out of range!"' 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 -O0 &lt;source&gt;
1.	Running pass 'Function Pass Manager' on module '&lt;source&gt;'.
2.	Running pass 'RegBankSelect' on function '@<!-- -->foo'
...
 #<!-- -->8 0x0000000000b27667 llvm::AArch64RegisterBankInfo::isLoadFromFPType(llvm::MachineInstr const&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xb27667)
 #<!-- -->9 0x0000000000b2b155 llvm::AArch64RegisterBankInfo::getInstrMapping(llvm::MachineInstr const&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xb2b155)
#<!-- -->10 0x0000000004203f47 llvm::RegBankSelect::assignInstr(llvm::MachineInstr&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x4203f47)
#<!-- -->11 0x00000000042044d3 llvm::RegBankSelect::assignRegisterBanks(llvm::MachineFunction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x42044d3)
...
Compiler returned: 139

https://llvm.godbolt.org/z/a4h1abfKc

@tschuett
Copy link
Member

EltTy = StructEltTy->getTypeAtIndex(0U);

It does not check for empty structs.

@DianQK
Copy link
Member Author

DianQK commented May 14, 2024

EltTy = StructEltTy->getTypeAtIndex(0U);

It does not check for empty structs.

Great. Will you fix it?

@DianQK
Copy link
Member Author

DianQK commented May 14, 2024

/cherry-pick d422e90

llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue May 14, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 14, 2024

/pull-request #92129

tstellar pushed a commit to llvmbot/llvm-project that referenced this issue May 15, 2024
tstellar pushed a commit to llvmbot/llvm-project that referenced this issue May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

4 participants