Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Linker] Remove nocallback attribute while linking
GCC's leaf attribute is lowered to LLVM IR nocallback attribute. Clang conservatively treats this function attribute as a hint on the module level, and removes it while linking modules. More context can be found in: https://reviews.llvm.org/D131628. Differential Revision: https://reviews.llvm.org/D137360
- Loading branch information
1 parent
f5700e7
commit b956899
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,4 @@ | ||
define void @test_nocallback_declaration_definition_linked_in() { | ||
entry: | ||
ret void | ||
} |
This file contains 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,44 @@ | ||
; RUN: llvm-link %s %p/Inputs/drop-attribute.ll -S -o - | FileCheck %s | ||
|
||
; Test case that checks that nocallback attribute is dropped during linking. | ||
|
||
; CHECK: define i32 @main() | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: call void @test_nocallback_definition() | ||
; Test that checks that nocallback attribute on a call-site is dropped. | ||
; CHECK-NEXT: call void @test_nocallback_call_site(){{$}} | ||
; CHECK-NEXT: %0 = call float @llvm.sqrt.f32(float undef) | ||
; CHECK-NEXT: call void @test_nocallback_declaration_definition_not_linked_in() | ||
; CHECK-NEXT: call void @test_nocallback_declaration_definition_linked_in() | ||
define i32 @main() { | ||
entry: | ||
call void @test_nocallback_definition() | ||
call void @test_nocallback_call_site() nocallback | ||
call float @llvm.sqrt.f32(float undef) | ||
call void @test_nocallback_declaration_definition_not_linked_in() | ||
call void @test_nocallback_declaration_definition_linked_in() | ||
ret i32 0 | ||
} | ||
|
||
; Test that checks that nocallback attribute on a definition is dropped. | ||
; CHECK: define void @test_nocallback_definition() | ||
define void @test_nocallback_definition() nocallback { | ||
ret void | ||
} | ||
|
||
; Test that checks that nocallback attribute on a declaration when a definition is linked in is dropped. | ||
; CHECK: declare void @test_nocallback_call_site(){{$}} | ||
declare void @test_nocallback_call_site() | ||
|
||
; Test that checks that nocallback attribute on an intrinsic is NOT dropped. | ||
; CHECK: ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn | ||
; CHECK-NEXT: declare float @llvm.sqrt.f32(float) #0 | ||
declare float @llvm.sqrt.f32(float) nocallback | ||
|
||
; Test that checks that nocallback attribute on a declaration when a definition is not linked in is dropped. | ||
; CHECK: declare void @test_nocallback_declaration_definition_not_linked_in(){{$}} | ||
declare void @test_nocallback_declaration_definition_not_linked_in() nocallback | ||
|
||
; Test that checks that nocallback attribute on a declaration when a definition is linked in is dropped. | ||
; CHECK: define void @test_nocallback_declaration_definition_linked_in() {{{$}} | ||
declare void @test_nocallback_declaration_definition_linked_in() nocallback |