Skip to content

Fix X86 selectAddr crash on non-MemSDNode parents for 32-bit Linux - #178

Open
gmh5225 wants to merge 3 commits into
devfrom
fix/issue176-selectaddr-memnode-guard
Open

Fix X86 selectAddr crash on non-MemSDNode parents for 32-bit Linux#178
gmh5225 wants to merge 3 commits into
devfrom
fix/issue176-selectaddr-memnode-guard

Conversation

@gmh5225

@gmh5225 gmh5225 commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Guard X86DAGToDAGISel::selectAddr with dyn_cast<MemSDNode> instead of assuming every parent with an addr operand is a memory node.
  • Fixes clang/llc crashes (0xC0000005) when compiling for 32-bit Linux/Android ELF targets at -O1+, e.g. void f() { __builtin_abort(); } with --target=i686-pc-linux-gnu.
  • Root cause: (X86call GR32, addr:$src2) passes X86ISD::CALL as the parent to selectAddr, but the old code used cast<MemSDNode>(Parent) on that node, which is undefined behavior.

Closes #176

Test plan


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Only read pointer address space when the parent SDNode is a MemSDNode.
The addr complex pattern is also used from X86ISD::CALL (e.g. i686 ELF
PIC calls), and casting those nodes to MemSDNode caused ISel to crash.

Closes #176
Parent may be null for inline asm addr matching; dyn_cast asserts on
null in debug builds. dyn_cast_if_present matches the API contract.
Run clang++/llc checks on Windows and Linux install prefixes downloaded
from the windows-llvm-msvc-build and android-llvm-msvc-build artifacts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash (0xC0000005) in TargetRegisterInfo::getNumSupportedRegs from X86DAGToDAGISel::selectAddr for 32-bit Linux target

2 participants