Fix X86 selectAddr crash on non-MemSDNode parents for 32-bit Linux - #178
Open
gmh5225 wants to merge 3 commits into
Open
Fix X86 selectAddr crash on non-MemSDNode parents for 32-bit Linux#178gmh5225 wants to merge 3 commits into
gmh5225 wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X86DAGToDAGISel::selectAddrwithdyn_cast<MemSDNode>instead of assuming every parent with anaddroperand is a memory node.-O1+, e.g.void f() { __builtin_abort(); }with--target=i686-pc-linux-gnu.(X86call GR32, addr:$src2)passesX86ISD::CALLas the parent toselectAddr, but the old code usedcast<MemSDNode>(Parent)on that node, which is undefined behavior.Closes #176
Test plan
llvm/test/CodeGen/X86/issue176-abort-i686-linux.llllc issue176-abort-i686-linux.ll -mtriple=i686-pc-linux-gnu -relocation-model=picclang++ --target=i686-pc-linux-gnu -O1 -c reduced_final.cpp(Windows repro from Crash (0xC0000005) in TargetRegisterInfo::getNumSupportedRegs from X86DAGToDAGISel::selectAddr for 32-bit Linux target #176)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.