forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LLVM] Autoupgrade function attributes from Module attributes.
Refactoring llvm#82763 to cache module attributes.
- Loading branch information
1 parent
280c7a9
commit 8ecca58
Showing
7 changed files
with
160 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; REQUIRES: aarch64 | ||
;; Test verifies inlining happens cross module when module flags are upgraded | ||
;; by the thin-lto linker/IRMover. | ||
;; Regression test for #82763 | ||
|
||
; RUN: split-file %s %t | ||
; RUN: opt -thinlto-bc -thinlto-split-lto-unit -unified-lto %t/foo.s -o %t/foo.o | ||
; RUN: opt -thinlto-bc -thinlto-split-lto-unit -unified-lto %t/main.s -o %t/main.o | ||
; RUN: ld.lld -O2 --lto=thin --entry=main %t/main.o %t/foo.o -o %t/exe | ||
; RUN: llvm-objdump -d %t/exe | FileCheck %s | ||
|
||
|
||
; CHECK-LABEL: <main>: | ||
; CHECK-NEXT: pacibsp | ||
; CHECK-NEXT: mov w0, #0x22 | ||
; CHECK-NEXT: autibsp | ||
; CHECK-NEXT: ret | ||
|
||
;--- foo.s | ||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
target triple = "aarch64-unknown-linux-gnu" | ||
|
||
define dso_local noundef i32 @foo() local_unnamed_addr #0 { | ||
entry: | ||
ret i32 34 | ||
} | ||
|
||
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) } | ||
!llvm.module.flags = !{!0, !1, !2, !3 } | ||
!0 = !{i32 8, !"branch-target-enforcement", i32 1} | ||
!1 = !{i32 8, !"sign-return-address", i32 1} | ||
!2 = !{i32 8, !"sign-return-address-all", i32 1} | ||
!3 = !{i32 8, !"sign-return-address-with-bkey", i32 1} | ||
|
||
;--- main.s | ||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
target triple = "aarch64-unknown-linux-gnu" | ||
|
||
declare i32 @foo(); | ||
|
||
define i32 @main() { | ||
entry: | ||
%1 = call i32 @foo() | ||
ret i32 %1 | ||
} | ||
|
||
!llvm.module.flags = !{!0, !1, !2, !3 } | ||
!0 = !{i32 8, !"branch-target-enforcement", i32 1} | ||
!1 = !{i32 8, !"sign-return-address", i32 1} | ||
!2 = !{i32 8, !"sign-return-address-all", i32 1} | ||
!3 = !{i32 8, !"sign-return-address-with-bkey", i32 1} |
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
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
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,43 @@ | ||
; Testcase to check that module with different sign return address can | ||
; be mixed. | ||
; | ||
; RUN: llvm-as %s -o %t1.bc | ||
; RUN: llvm-as %p/Inputs/foo.ll -o %t2.bc | ||
; RUN: llvm-lto -exported-symbol main \ | ||
; RUN: -exported-symbol foo \ | ||
; RUN: -filetype=obj \ | ||
; RUN: %t2.bc %t1.bc \ | ||
; RUN: -o %t1.exe 2>&1 | ||
; RUN: llvm-objdump -d %t1.exe | FileCheck --check-prefix=CHECK-DUMP %s | ||
; RUN: llvm-readelf -n %t1.exe | FileCheck --allow-empty --check-prefix=CHECK-PROP %s | ||
|
||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
target triple = "aarch64-unknown-linux-gnu" | ||
|
||
declare i32 @foo(); | ||
|
||
define i32 @main() { | ||
entry: | ||
%add = call i32 @foo() | ||
ret i32 %add | ||
} | ||
|
||
!llvm.module.flags = !{!0, !1, !2, !3 } | ||
!0 = !{i32 8, !"branch-target-enforcement", i32 0} | ||
!1 = !{i32 8, !"sign-return-address", i32 0} | ||
!2 = !{i32 8, !"sign-return-address-all", i32 0} | ||
!3 = !{i32 8, !"sign-return-address-with-bkey", i32 0} | ||
|
||
; CHECK-DUMP: <foo>: | ||
; CHECK-DUMP: pacibsp | ||
; CHECK-DUMP: mov w0, #0x2a | ||
; CHECK-DUMP: autibsp | ||
; CHECK-DUMP: ret | ||
; CHECK-DUMP: <main>: | ||
; CHECK-DUMP-NOT: paciasp | ||
; CHECK-DUMP: str x30, | ||
; CHECK-DUMP: bl 0x14 <main+0x4> | ||
|
||
; `main` doesn't support PAC sign-return-address while `foo` does, so in the binary | ||
; we should not see anything. | ||
; CHECK-PROP-NOT: Properties: aarch64 feature: PAC |
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