Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 48 additions & 16 deletions llvm/test/CodeGen/X86/call-graph-section-assembly.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
;; call sites annotated with !callee_type metadata.
;; Test if the .callgraph section contains unique direct callees.

; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -o - < %s | FileCheck %s
; REQUIRES: x86-registered-target
; REQUIRES: arm-registered-target

; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -o - < %s | FileCheck --check-prefix=X64 %s
; RUN: llc -mtriple=arm-unknown-linux --call-graph-section -o - < %s | FileCheck --check-prefix=ARM32 %s

declare !type !0 void @direct_foo()
declare !type !1 i32 @direct_bar(i8)
declare !type !2 ptr @direct_baz(ptr)

; CHECK: ball:
; CHECK-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]:
; X64: ball:
; X64-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]:
; ARM32: ball:
; ARM32-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]:
define ptr @ball() {
entry:
call void @direct_foo()
Expand All @@ -36,24 +42,50 @@ entry:
!4 = !{!5}
!5 = !{i64 0, !"_ZTSFPvS_E.generalized"}

; CHECK: .section .callgraph,"o",@progbits,.text
; X64: .section .callgraph,"o",@progbits,.text
;; Version
; X64-NEXT: .byte 0
;; Flags
; X64-NEXT: .byte 7
;; Function Entry PC
; X64-NEXT: .quad [[LABEL_FUNC]]
;; Function type ID -- set to 0 as no type metadata attached to function.
; X64-NEXT: .quad 0
;; Number of unique direct callees.
; X64-NEXT: .byte 3
;; Direct callees.
; X64-NEXT: .quad direct_foo
; X64-NEXT: .quad direct_bar
; X64-NEXT: .quad direct_baz
;; Number of unique indirect target type IDs.
; X64-NEXT: .byte 3
;; Indirect type IDs.
; X64-NEXT: .quad 4524972987496481828
; X64-NEXT: .quad 3498816979441845844
; X64-NEXT: .quad 8646233951371320954

; ARM32: .section .callgraph,"o",%progbits,.text
;; Version
; CHECK-NEXT: .byte 0
; ARM32-NEXT: .byte 0
;; Flags
; CHECK-NEXT: .byte 7
; ARM32-NEXT: .byte 7
;; Function Entry PC
; CHECK-NEXT: .quad [[LABEL_FUNC]]
; ARM32-NEXT: .long [[LABEL_FUNC]]
;; Function type ID -- set to 0 as no type metadata attached to function.
; CHECK-NEXT: .quad 0
; ARM32-NEXT: .long 0
; ARM32-NEXT: .long 0
;; Number of unique direct callees.
; CHECK-NEXT: .byte 3
; ARM32-NEXT: .byte 3
;; Direct callees.
; CHECK-NEXT: .quad direct_foo
; CHECK-NEXT: .quad direct_bar
; CHECK-NEXT: .quad direct_baz
; ARM32-NEXT: .long direct_foo
; ARM32-NEXT: .long direct_bar
; ARM32-NEXT: .long direct_baz
;; Number of unique indirect target type IDs.
; CHECK-NEXT: .byte 3
; ARM32-NEXT: .byte 3
;; Indirect type IDs.
; CHECK-NEXT: .quad 4524972987496481828
; CHECK-NEXT: .quad 3498816979441845844
; CHECK-NEXT: .quad 8646233951371320954
; ARM32-NEXT: .long 838288420
; ARM32-NEXT: .long 1053552373
; ARM32-NEXT: .long 1505527380
; ARM32-NEXT: .long 814631809
; ARM32-NEXT: .long 342417018
; ARM32-NEXT: .long 2013108216
23 changes: 17 additions & 6 deletions llvm/test/CodeGen/X86/call-graph-section-tailcall.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
;; Tests that we store the type identifiers in .callgraph section of the object file for tailcalls.

; REQUIRES: x86-registered-target
; REQUIRES: arm-registered-target

; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -filetype=obj -o - < %s | \
; RUN: llvm-readelf -x .callgraph - | FileCheck %s
; RUN: llvm-readelf -x .callgraph - | FileCheck --check-prefix=X64 %s
; RUN: llc -mtriple=arm-unknown-linux --call-graph-section -filetype=obj -o - < %s | \
; RUN: llvm-readelf -x .callgraph - | FileCheck --check-prefix=ARM32 %s

define i32 @check_tailcall(ptr %func, i8 %x) !type !0 {
entry:
Expand All @@ -27,9 +32,15 @@ declare !type !2 i32 @bar(i8 signext)
!2 = !{i64 0, !"_ZTSFicE.generalized"}
!3 = !{i64 0, !"_ZTSFiiE.generalized"}

; CHECK: Hex dump of section '.callgraph':
; CHECK-NEXT: 0x00000000 00050000 00000000 00008e19 0b7f3326
; CHECK-NEXT: 0x00000010 e3000154 86bc5981 4b8e3000 05000000
; X64: Hex dump of section '.callgraph':
; X64-NEXT: 0x00000000 00050000 00000000 00008e19 0b7f3326
; X64-NEXT: 0x00000010 e3000154 86bc5981 4b8e3000 05000000
;; Verify that the type id 0x308e4b8159bc8654 is in section.
; X64-NEXT: 0x00000020 00000000 00a150b8 3e0cfe3c b2015486
; X64-NEXT: 0x00000030 bc59814b 8e30

; ARM32: Hex dump of section '.callgraph':
; ARM32-NEXT: 0x00000000 00050000 00008e19 0b7f3326 e3000154
; ARM32-NEXT: 0x00000010 86bc5981 4b8e3000 05100000 00a150b8
;; Verify that the type id 0x308e4b8159bc8654 is in section.
; CHECK-NEXT: 0x00000020 00000000 00a150b8 3e0cfe3c b2015486
; CHECK-NEXT: 0x00000030 bc59814b 8e30
; ARM32-NEXT: 0x00000020 3e0cfe3c b2015486 bc59814b 8e30
22 changes: 17 additions & 5 deletions llvm/test/CodeGen/X86/call-graph-section.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
;; Tests that we store the type identifiers in .callgraph section of the object file.

; REQUIRES: x86-registered-target
; REQUIRES: arm-registered-target

; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -filetype=obj -o - < %s | \
; RUN: llvm-readelf -x .callgraph - | FileCheck %s
; RUN: llvm-readelf -x .callgraph - | FileCheck --check-prefix=X64 %s
; RUN: llc -mtriple=arm-unknown-linux --call-graph-section -filetype=obj -o - < %s | \
; RUN: llvm-readelf -x .callgraph - | FileCheck --check-prefix=ARM32 %s

declare !type !0 void @foo()

Expand Down Expand Up @@ -31,7 +36,14 @@ entry:

;; Make sure following type IDs are in call graph section
;; 0x5eecb3e2444f731f, 0x814b8e305486bc59, 0xf897fd777ade6814
; CHECK: Hex dump of section '.callgraph':
; CHECK-NEXT: 0x00000000 00050000 00000000 00000000 00000000
; CHECK-NEXT: 0x00000010 00000324 44f731f5 eecb3e54 86bc5981
; CHECK-NEXT: 0x00000020 4b8e307a de6814f8 97fd77
; X64: Hex dump of section '.callgraph':
; X64-NEXT: 0x00000000 00050000 00000000 00000000 00000000
; X64-NEXT: 0x00000010 00000324 44f731f5 eecb3e54 86bc5981
; X64-NEXT: 0x00000020 4b8e307a de6814f8 97fd77

;; Make sure following type IDs are in call graph section
;; 0x5eecb3e2444f731f, 0x814b8e305486bc59, 0xf897fd777ade6814
; ARM32: Hex dump of section '.callgraph':
; ARM32-NEXT: 0x00000000 00050000 00000000 00000000 00000324
; ARM32-NEXT: 0x00000010 44f731f5 eecb3e54 86bc5981 4b8e307a
; ARM32-NEXT: 0x00000020 de6814f8 97fd77