-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[IR] llvm.reloc.none intrinsic for no-op symbol references #147427
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
mysterymath
wants to merge
11
commits into
main
Choose a base branch
from
users/mysterymath/modular-printf/reloc.none
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.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
69e5e04
[IR] llvm.reloc.none intrinsic for no-op symbol references
mysterymath 3bad1c4
fake.use -> reloc.none
mysterymath 17e287e
Take symbol name by metadata arg rather than ptr to GlobalValue
mysterymath 18b324e
Add a generic reloc_none test
mysterymath 1c8e128
IR verifier check and test
mysterymath 3520505
Remove unneeded assertion from AsmPrinter
mysterymath 7f62e07
Use llvm-as for test
mysterymath 49b0e09
Rename reloc_none.ll to reloc-none.ll
mysterymath ce7b95e
Lower reloc.none in Global ISel
mysterymath 3206a40
Remove arg from emitRelocDirective call
mysterymath 657f659
Update tests
mysterymath 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
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
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
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
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
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
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,10 @@ | ||
; RUN: llc < %s | FileCheck %s | ||
|
||
; CHECK: .reloc {{.*}}, BFD_RELOC_NONE, foo | ||
|
||
define void @test_reloc_none() { | ||
call void @llvm.reloc.none(metadata !"foo") | ||
ret void | ||
} | ||
|
||
declare void @llvm.reloc.none(metadata) |
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,14 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=CHECK | ||
|
||
define void @test_reloc_none() { | ||
; CHECK-LABEL: test_reloc_none: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: .Lreloc_none0: | ||
; CHECK-NEXT: .reloc .Lreloc_none0, BFD_RELOC_NONE, foo | ||
; CHECK-NEXT: retq | ||
call void @llvm.reloc.none(metadata !"foo") | ||
ret void | ||
} | ||
|
||
declare void @llvm.reloc.none(metadata) |
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,13 @@ | ||
; RUN: not llvm-as -disable-output 2>&1 %s | FileCheck %s | ||
|
||
; CHECK: llvm.reloc.none argument must be a metadata string | ||
; CHECK-NEXT: call void @llvm.reloc.none(metadata !0) | ||
|
||
define void @test_reloc_none_bad_arg() { | ||
call void @llvm.reloc.none(metadata !0) | ||
ret void | ||
} | ||
|
||
declare void @llvm.reloc.none(metadata) | ||
|
||
!0 = !{} |
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.
You cannot modify the IR here
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.
This is because this occurs in a
MachineFunctionPass
right? In that case, I got bamboozled! I had unceremoniously copy-pasted this from the lowering ofIntrinsic::amdgcn_reloc_constant
inSIISelLowering.cpp
, which also runs in aMachineFunctionPass
. I'll admit that this completely slipped past me, although I was curious about theconst_cast
.AFAIK, converting an arbitrary symbol name metadata string to a GlobalValue reference instrinsically mutates the module. So, if we wanted to fix this, we could either go back to having this be a symbol reference to a pre-existing global value, or we could forward the metadata string to
RELOC_NONE
as a string (odd in the backend; unsure if this is even possible?) to be lowered to a symbol reference at assembly time. My preference would definitely be the former, since it has fewer unknowns.Whichever we choose, also I'd think either way we should give
amdgcn_reloc_constant
the same treatment, unless it's not possible to do so for backwards compatibility reasons.@arsenm Do you have preferences here?
EDIT: There is
Metadata
andMCSymbol
support inMachineOperand
, but it's tagged in the enum as "for debug info". We could probably use this forRELOC_NONE
's argument, but maybe that would cause problems? (Or be "weird"?) Unsure.