-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[RelLookupTableConverter] Drop unnamed_addr to avoid generating GOTPCREL relocations #142304
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
Merged
Changes from all commits
Commits
Show all changes
3 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
117 changes: 117 additions & 0 deletions
117
llvm/test/Transforms/RelLookupTableConverter/unnamed_addr.ll
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,117 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5 | ||
; RUN: opt < %s -passes=rel-lookup-table-converter -relocation-model=pic -mtriple=x86_64-apple-darwin -S | FileCheck -check-prefix=x86_64-apple-darwin %s | ||
; RUN: opt < %s -passes=rel-lookup-table-converter -relocation-model=pic -mtriple=aarch64 -S | FileCheck -check-prefix=aarch64 %s | ||
; RUN: opt < %s -passes=rel-lookup-table-converter -relocation-model=pic -mtriple=x86_64 -S | FileCheck -check-prefix=x86_64 %s | ||
|
||
@a0 = private unnamed_addr constant i32 0 | ||
@a1 = private unnamed_addr constant i32 1 | ||
@a2 = private unnamed_addr constant i32 2 | ||
@load_relative_1.table = private unnamed_addr constant [3 x ptr] [ptr @a0, ptr @a1, ptr @a2] | ||
|
||
@x0 = internal unnamed_addr constant i64 0 | ||
@x1 = internal unnamed_addr constant i64 1 | ||
@x2 = internal unnamed_addr constant i64 2 | ||
@x3 = internal unnamed_addr constant i64 3 | ||
@y0 = internal unnamed_addr constant ptr @x3 | ||
@y1 = internal unnamed_addr constant ptr @x2 | ||
@y2 = internal unnamed_addr constant ptr @x1 | ||
@y3 = internal unnamed_addr constant ptr @x0 | ||
@load_relative_2.table = private unnamed_addr constant [4 x ptr] [ptr @y3, ptr @y2, ptr @y1, ptr @y0] | ||
|
||
;. | ||
; x86_64-apple-darwin: @a0 = private constant i32 0 | ||
; x86_64-apple-darwin: @a1 = private constant i32 1 | ||
; x86_64-apple-darwin: @a2 = private constant i32 2 | ||
; x86_64-apple-darwin: @load_relative_1.table.rel = private unnamed_addr constant [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @a0 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @a1 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @a2 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32)], align 4 | ||
; x86_64-apple-darwin: @x0 = internal unnamed_addr constant i64 0 | ||
; x86_64-apple-darwin: @x1 = internal unnamed_addr constant i64 1 | ||
; x86_64-apple-darwin: @x2 = internal unnamed_addr constant i64 2 | ||
; x86_64-apple-darwin: @x3 = internal unnamed_addr constant i64 3 | ||
; x86_64-apple-darwin: @y0 = internal constant ptr @x3 | ||
; x86_64-apple-darwin: @y1 = internal constant ptr @x2 | ||
; x86_64-apple-darwin: @y2 = internal constant ptr @x1 | ||
; x86_64-apple-darwin: @y3 = internal constant ptr @x0 | ||
; x86_64-apple-darwin: @load_relative_2.table.rel = private unnamed_addr constant [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @y3 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y2 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y1 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y0 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32)], align 4 | ||
;. | ||
; aarch64: @a0 = private constant i32 0 | ||
; aarch64: @a1 = private constant i32 1 | ||
; aarch64: @a2 = private constant i32 2 | ||
; aarch64: @load_relative_1.table.rel = private unnamed_addr constant [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @a0 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @a1 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @a2 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32)], align 4 | ||
; aarch64: @x0 = internal unnamed_addr constant i64 0 | ||
; aarch64: @x1 = internal unnamed_addr constant i64 1 | ||
; aarch64: @x2 = internal unnamed_addr constant i64 2 | ||
; aarch64: @x3 = internal unnamed_addr constant i64 3 | ||
; aarch64: @y0 = internal constant ptr @x3 | ||
; aarch64: @y1 = internal constant ptr @x2 | ||
; aarch64: @y2 = internal constant ptr @x1 | ||
; aarch64: @y3 = internal constant ptr @x0 | ||
; aarch64: @load_relative_2.table.rel = private unnamed_addr constant [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @y3 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y2 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y1 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y0 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32)], align 4 | ||
;. | ||
; x86_64: @a0 = private unnamed_addr constant i32 0 | ||
; x86_64: @a1 = private unnamed_addr constant i32 1 | ||
; x86_64: @a2 = private unnamed_addr constant i32 2 | ||
; x86_64: @load_relative_1.table.rel = private unnamed_addr constant [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @a0 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @a1 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @a2 to i64), i64 ptrtoint (ptr @load_relative_1.table.rel to i64)) to i32)], align 4 | ||
; x86_64: @x0 = internal unnamed_addr constant i64 0 | ||
; x86_64: @x1 = internal unnamed_addr constant i64 1 | ||
; x86_64: @x2 = internal unnamed_addr constant i64 2 | ||
; x86_64: @x3 = internal unnamed_addr constant i64 3 | ||
; x86_64: @y0 = internal unnamed_addr constant ptr @x3 | ||
; x86_64: @y1 = internal unnamed_addr constant ptr @x2 | ||
; x86_64: @y2 = internal unnamed_addr constant ptr @x1 | ||
; x86_64: @y3 = internal unnamed_addr constant ptr @x0 | ||
; x86_64: @load_relative_2.table.rel = private unnamed_addr constant [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @y3 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y2 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y1 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @y0 to i64), i64 ptrtoint (ptr @load_relative_2.table.rel to i64)) to i32)], align 4 | ||
;. | ||
define ptr @load_relative_1(i64 %offset) { | ||
; x86_64-apple-darwin-LABEL: define ptr @load_relative_1( | ||
; x86_64-apple-darwin-SAME: i64 [[OFFSET:%.*]]) { | ||
; x86_64-apple-darwin-NEXT: [[RELTABLE_SHIFT:%.*]] = shl i64 [[OFFSET]], 2 | ||
; x86_64-apple-darwin-NEXT: [[RELTABLE_INTRINSIC:%.*]] = call ptr @llvm.load.relative.i64(ptr @load_relative_1.table.rel, i64 [[RELTABLE_SHIFT]]) | ||
; x86_64-apple-darwin-NEXT: ret ptr [[RELTABLE_INTRINSIC]] | ||
; | ||
; aarch64-LABEL: define ptr @load_relative_1( | ||
; aarch64-SAME: i64 [[OFFSET:%.*]]) { | ||
; aarch64-NEXT: [[RELTABLE_SHIFT:%.*]] = shl i64 [[OFFSET]], 2 | ||
; aarch64-NEXT: [[RELTABLE_INTRINSIC:%.*]] = call ptr @llvm.load.relative.i64(ptr @load_relative_1.table.rel, i64 [[RELTABLE_SHIFT]]) | ||
; aarch64-NEXT: ret ptr [[RELTABLE_INTRINSIC]] | ||
; | ||
; x86_64-LABEL: define ptr @load_relative_1( | ||
; x86_64-SAME: i64 [[OFFSET:%.*]]) { | ||
; x86_64-NEXT: [[RELTABLE_SHIFT:%.*]] = shl i64 [[OFFSET]], 2 | ||
; x86_64-NEXT: [[RELTABLE_INTRINSIC:%.*]] = call ptr @llvm.load.relative.i64(ptr @load_relative_1.table.rel, i64 [[RELTABLE_SHIFT]]) | ||
; x86_64-NEXT: ret ptr [[RELTABLE_INTRINSIC]] | ||
; | ||
%gep = getelementptr inbounds [3 x ptr], ptr @load_relative_1.table, i64 0, i64 %offset | ||
%load = load ptr, ptr %gep | ||
ret ptr %load | ||
} | ||
|
||
define ptr @load_relative_2(i64 %offset) { | ||
; x86_64-apple-darwin-LABEL: define ptr @load_relative_2( | ||
; x86_64-apple-darwin-SAME: i64 [[OFFSET:%.*]]) { | ||
; x86_64-apple-darwin-NEXT: [[RELTABLE_SHIFT:%.*]] = shl i64 [[OFFSET]], 2 | ||
; x86_64-apple-darwin-NEXT: [[RELTABLE_INTRINSIC:%.*]] = call ptr @llvm.load.relative.i64(ptr @load_relative_2.table.rel, i64 [[RELTABLE_SHIFT]]) | ||
; x86_64-apple-darwin-NEXT: ret ptr [[RELTABLE_INTRINSIC]] | ||
; | ||
; aarch64-LABEL: define ptr @load_relative_2( | ||
; aarch64-SAME: i64 [[OFFSET:%.*]]) { | ||
; aarch64-NEXT: [[RELTABLE_SHIFT:%.*]] = shl i64 [[OFFSET]], 2 | ||
; aarch64-NEXT: [[RELTABLE_INTRINSIC:%.*]] = call ptr @llvm.load.relative.i64(ptr @load_relative_2.table.rel, i64 [[RELTABLE_SHIFT]]) | ||
; aarch64-NEXT: ret ptr [[RELTABLE_INTRINSIC]] | ||
; | ||
; x86_64-LABEL: define ptr @load_relative_2( | ||
; x86_64-SAME: i64 [[OFFSET:%.*]]) { | ||
; x86_64-NEXT: [[RELTABLE_SHIFT:%.*]] = shl i64 [[OFFSET]], 2 | ||
; x86_64-NEXT: [[RELTABLE_INTRINSIC:%.*]] = call ptr @llvm.load.relative.i64(ptr @load_relative_2.table.rel, i64 [[RELTABLE_SHIFT]]) | ||
; x86_64-NEXT: ret ptr [[RELTABLE_INTRINSIC]] | ||
; | ||
%gep = getelementptr inbounds [4 x ptr], ptr @load_relative_2.table, i64 0, i64 %offset | ||
%load = load ptr, ptr %gep | ||
ret ptr %load | ||
} | ||
;. | ||
; x86_64-apple-darwin: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: read) } | ||
;. | ||
; aarch64: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: read) } | ||
;. | ||
; x86_64: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: read) } | ||
;. |
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.
Need
REQUIRES: x86-registered-target
andREQUIRES: aarch64-registered-target
.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.
Oops, added: de7f2fb