-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[Linker] Propagate nobuiltin
attributes when linking known libcalls
#89431
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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ add_llvm_component_library(LLVMLinker | |
intrinsics_gen | ||
|
||
LINK_COMPONENTS | ||
Analysis | ||
Core | ||
Object | ||
Support | ||
|
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,21 @@ | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
define i64 @strlen(ptr %s) #0 { | ||
entry: | ||
br label %for.cond | ||
|
||
for.cond: | ||
%s.addr.0 = phi ptr [ %s, %entry ], [ %incdec.ptr, %for.cond ] | ||
%0 = load i8, ptr %s.addr.0, align 1 | ||
%tobool.not = icmp eq i8 %0, 0 | ||
%incdec.ptr = getelementptr inbounds i8, ptr %s.addr.0, i64 1 | ||
br i1 %tobool.not, label %for.end, label %for.cond | ||
|
||
for.end: | ||
%sub.ptr.lhs.cast = ptrtoint ptr %s.addr.0 to i64 | ||
%sub.ptr.rhs.cast = ptrtoint ptr %s to i64 | ||
%sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast | ||
ret i64 %sub.ptr.sub | ||
} | ||
|
||
attributes #0 = { noinline } |
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,39 @@ | ||
; RUN: llvm-link %s %S/Inputs/strlen.ll -S -o - 2>%t.a.err | FileCheck %s --check-prefix=CHECK1 | ||
; RUN: llvm-link %S/Inputs/strlen.ll %s -S -o - 2>%t.a.err | FileCheck %s --check-prefix=CHECK2 | ||
|
||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
@.str = private unnamed_addr constant [7 x i8] c"string\00", align 1 | ||
@str = dso_local global ptr @.str, align 8 | ||
|
||
define void @foo() #0 { | ||
ret void | ||
} | ||
|
||
declare i64 @strlen(ptr) | ||
|
||
define void @bar() #0 { | ||
ret void | ||
} | ||
|
||
define i64 @baz() #0 { | ||
entry: | ||
%0 = load ptr, ptr @str, align 8 | ||
%call = call i64 @strlen(ptr noundef %0) | ||
ret i64 %call | ||
} | ||
|
||
attributes #0 = { noinline } | ||
|
||
; CHECK1: define void @foo() #[[ATTR0:[0-9]+]] | ||
; CHECK1: define void @bar() #[[ATTR0:[0-9]+]] | ||
; CHECK1: define i64 @baz() #[[ATTR0:[0-9]+]] | ||
; CHECK1: define i64 @strlen(ptr [[S:%.*]]) #[[ATTR0]] | ||
|
||
; CHECK2: define i64 @strlen(ptr [[S:%.*]]) #[[ATTR0:[0-9]+]] | ||
; CHECK2: define void @foo() #[[ATTR0:[0-9]+]] | ||
; CHECK2: define void @bar() #[[ATTR0:[0-9]+]] | ||
; CHECK2: define i64 @baz() #[[ATTR0]] | ||
|
||
; CHECK1: attributes #[[ATTR0]] = { nobuiltin noinline "no-builtins" } | ||
; CHECK2: attributes #[[ATTR0]] = { nobuiltin noinline "no-builtins" } |
Oops, something went wrong.
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.
Add another function here, so the order in the output should be
something
strlen
something
and all should be annotated.