Skip to content

Commit 229e9d0

Browse files
committed
Add test for internal linkage with address taken regresstion test which also tests callback case.
1 parent 528c063 commit 229e9d0

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
;; Test if a potential indirect call target function which has internal linkage and
2+
;; address taken has its type ID emitted to callgraph section.
3+
;; This test also makes sure that callback functions which meet the above constraint
4+
;; are handled correctly.
5+
6+
; RUN: llc -mtriple=arm-unknown-linux --call-graph-section -o - < %s | FileCheck %s
7+
8+
declare !type !0 void @_Z6doWorkPFviE(ptr)
9+
10+
define i32 @_Z4testv() !type !1 {
11+
entry:
12+
call void @_Z6doWorkPFviE(ptr nonnull @_ZL10myCallbacki)
13+
ret i32 0
14+
}
15+
16+
define internal void @_ZL10myCallbacki(i32 %value) !type !2 {
17+
entry:
18+
%sink = alloca i32, align 4
19+
store volatile i32 %value, ptr %sink, align 4
20+
%i1 = load volatile i32, ptr %sink, align 4
21+
ret void
22+
}
23+
24+
!0 = !{i64 0, !"_ZTSFvPFviEE.generalized"}
25+
!1 = !{i64 0, !"_ZTSFivE.generalized"}
26+
!2 = !{i64 0, !"_ZTSFviE.generalized"}
27+
28+
; CHECK: .section .callgraph,"o",%progbits,.text
29+
;; Version
30+
; CHECK-NEXT: .byte 0
31+
;; Flags -- Potential indirect target so LSB is set to 1. Other bits are 0.
32+
; CHECK-NEXT: .byte 1
33+
;; Function Entry PC
34+
; CHECK-NEXT: .long [[LABEL_FUNC]]
35+
;; Function type ID -5212364466660467813
36+
; CHECK-NEXT: .long 1154849691
37+
; CHECK-NEXT: .long 3081369122
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
;; Test if a potential indirect call target function which has internal linkage and
2+
;; address taken has its type ID emitted to callgraph section.
3+
;; This test also makes sure that callback functions which meet the above constraint
4+
;; are handled correctly.
5+
6+
; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -o - < %s | FileCheck %s
7+
8+
declare !type !0 void @_Z6doWorkPFviE(ptr)
9+
10+
define i32 @_Z4testv() !type !1 {
11+
entry:
12+
call void @_Z6doWorkPFviE(ptr nonnull @_ZL10myCallbacki)
13+
ret i32 0
14+
}
15+
16+
define internal void @_ZL10myCallbacki(i32 %value) !type !2 {
17+
entry:
18+
%sink = alloca i32, align 4
19+
store volatile i32 %value, ptr %sink, align 4
20+
%i1 = load volatile i32, ptr %sink, align 4
21+
ret void
22+
}
23+
24+
!0 = !{i64 0, !"_ZTSFvPFviEE.generalized"}
25+
!1 = !{i64 0, !"_ZTSFivE.generalized"}
26+
!2 = !{i64 0, !"_ZTSFviE.generalized"}
27+
28+
; CHECK: .section .callgraph,"o",@progbits,.text
29+
;; Version
30+
; CHECK-NEXT: .byte 0
31+
;; Flags -- Potential indirect target so LSB is set to 1. Other bits are 0.
32+
; CHECK-NEXT: .byte 1
33+
;; Function Entry PC
34+
; CHECK-NEXT: .quad [[LABEL_FUNC]]
35+
;; Function type ID
36+
; CHECK-NEXT: .quad -5212364466660467813

0 commit comments

Comments
 (0)