-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AsmPrinter] Always emit global equivalents if there is non-global uses #145648
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
Merged
+53
−7
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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,36 @@ | ||
; RUN: llc < %s | FileCheck %s | ||
|
||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Check that we emit the `@bar_*` symbols, and that we don't emit multiple symbols. | ||
|
||
; CHECK-LABEL: .Lrel_0: | ||
; CHECK: .long foo_0@GOTPCREL+0 | ||
; CHECK-LABEL: .Lrel_1_failed: | ||
; CHECK: .long bar_1-foo_0 | ||
; CHECK-LABEL: .Lrel_2: | ||
; CHECK: .long foo_2@GOTPCREL+0 | ||
|
||
; CHECK: bar_0: | ||
; CHECK: bar_1: | ||
; CHECK: bar_2_indirect: | ||
|
||
@rel_0 = private unnamed_addr constant [1 x i32] [ | ||
i32 trunc (i64 sub (i64 ptrtoint (ptr @bar_0 to i64), i64 ptrtoint (ptr @rel_0 to i64)) to i32)] | ||
@rel_1_failed = private unnamed_addr constant [1 x i32] [ | ||
i32 trunc (i64 sub (i64 ptrtoint (ptr @bar_1 to i64), i64 ptrtoint (ptr @foo_0 to i64)) to i32)] | ||
@rel_2 = private unnamed_addr constant [1 x i32] [ | ||
i32 trunc (i64 sub (i64 ptrtoint (ptr @bar_2_indirect to i64), i64 ptrtoint (ptr @rel_2 to i64)) to i32)] | ||
@bar_0 = internal unnamed_addr constant ptr @foo_0, align 8 | ||
@bar_1 = internal unnamed_addr constant ptr @foo_1, align 8 | ||
@bar_2_indirect = internal unnamed_addr constant ptr @foo_2, align 8 | ||
@foo_0 = external global ptr, align 8 | ||
@foo_1 = external global ptr, align 8 | ||
@foo_2 = external global ptr, align 8 | ||
|
||
define void @foo(ptr %arg0, ptr %arg1) { | ||
store ptr @bar_0, ptr %arg0, align 8 | ||
store ptr @bar_1, ptr %arg1, align 8 | ||
store ptr getelementptr (i8, ptr @bar_2_indirect, i32 1), ptr %arg1, align 8 | ||
ret void | ||
} |
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.
I'd directly handle the case where the dyn_cast failed in the users loop instead of adding this out argument
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 think you'd still need it for the recursive case. It would be good to add a test where the extra uses are in getelementptr constant expressions.
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.
added in cd85ee4.