-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86] Avoid crashing in PIC mode on narrowing to i8 followed by extension to i32 #145965
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
Open
Ralender
wants to merge
1
commit into
llvm:main
Choose a base branch
from
Ralender:FixCrashWith1BytePIC
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+29
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc -relocation-model=pic < %s | FileCheck %s | ||
|
||
target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" | ||
target triple = "i386-unknown-linux-gnu" | ||
|
||
@.str = external dso_local global i32 | ||
|
||
define i1 @test() { | ||
; CHECK-LABEL: test: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: calll .L0$pb | ||
; CHECK-NEXT: .cfi_adjust_cfa_offset 4 | ||
; CHECK-NEXT: .L0$pb: | ||
; CHECK-NEXT: popl %eax | ||
; CHECK-NEXT: .cfi_adjust_cfa_offset -4 | ||
; CHECK-NEXT: .Ltmp0: | ||
; CHECK-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax | ||
; CHECK-NEXT: movl $.str@GOTOFF, %ecx | ||
; CHECK-NEXT: addb %al, %cl | ||
; CHECK-NEXT: sete %al | ||
; CHECK-NEXT: retl | ||
%i = ptrtoint ptr @.str to i8 | ||
%p = zext i8 %i to i32 | ||
%c = icmp eq i32 %p, 0 | ||
ret i1 %c | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a workaround that just happens to work in this situation. If I run your test I see the "Node emitted out of order - late"" assert, which usually indicates there's a cycle in the DAG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we have a COPY_TO_REGCLASS of X86ISD::GlobalBaseReg. X86ISD::GlobalBaseReg is selected as virtual register %0. But I guess it wasn't added to the VRBaseMap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a cycle involved in this case.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I remember, there is no cycle and the issue is what topperc described.
arsenm, do you still think its the wrong fix ?
I am not familiar with this part of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still seems wrong. The value should already be in the map
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked around, it doesn't appear that
X86ISD::GlobalBaseReg
usually in the in theVRBaseMap
.it is usually handled by:
llvm-project/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
Line 408 in 372c808
or
llvm-project/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
Line 1264 in 372c808
So maybe it should be in the
VRBaseMap
but that is not the current behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a weird case where X86 invented a hack for a presumably constant register that avoids the chain use. Is there a reason this can't just use CopyFromReg for these in the first place? Alternatively we could have a TargetConstantRegister node type