[llvm-branch-commits] [llvm] Extend CallSiteInfo with TypeId (PR #87574)
Paul Kirth via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 11 09:19:31 PST 2024
================
@@ -0,0 +1,68 @@
+# Test MIR printer and parser for type id field in callSites. It is used
+# for propogating call site type identifiers to emit in the call graph section.
+
+# RUN: llc --call-graph-section %s -run-pass=none -o - | FileCheck %s
+# CHECK: name: main
+# CHECK: callSites:
+# CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], typeId:
+# CHECK-NEXT: 123456789 }
+
+--- |
+ ; ModuleID = 'test.ll'
+ source_filename = "test.ll"
+ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+ target triple = "x86_64-unknown-linux-gnu"
+
+ define dso_local void @foo(i8 signext %a) {
+ entry:
+ ret void
+ }
+
+ define dso_local i32 @main() {
+ entry:
+ %retval = alloca i32, align 4
+ %fp = alloca void (i8)*, align 8
+ store i32 0, i32* %retval, align 4
+ store void (i8)* @foo, void (i8)** %fp, align 8
+ %0 = load void (i8)*, void (i8)** %fp, align 8
+ call void %0(i8 signext 97)
+ ret i32 0
----------------
ilovepi wrote:
I think the input example can be simplified quite a bit. `main` doesn't need to have a return value. the alocas are also a bit redundant, and just adding extra MIR you're not testing.
```
❯ ~/llvm-fork/build/bin/opt test.ll -S | ~/llvm-fork/build/bin/llc -march=x86-64 -stop-after=machine-cp -simplify-mir
--- |
; ModuleID = '<stdin>'
source_filename = "test.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
declare void @foo(i8 signext)
define dso_local void @bar() {
entry:
%0 = load ptr, ptr @foo, align 8
call void %0(i8 signext 97)
ret void
}
...
---
name: bar
alignment: 16
tracksRegLiveness: true
noPhis: true
isSSA: false
noVRegs: true
hasFakeUses: false
debugInstrRef: true
tracksDebugUserValues: true
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo:
amxProgModel: None
body: |
bb.0.entry:
renamable $rax = MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @foo, $noreg :: (load (s64) from got)
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
$edi = MOV32ri 97
CALL64m killed renamable $rax, 1, $noreg, 0, $noreg, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit-def $rsp, implicit-def $ssp :: (load (s64) from @foo)
ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
RET 0
...
```
This may be something closer to a minimal test, though YMMV since I don't have the callgraph support locally. A bunch of those attributes can probably be dropped too, since they're unimportant for your test.
https://github.com/llvm/llvm-project/pull/87574
More information about the llvm-branch-commits
mailing list