xref: /llvm-project/llvm/test/CodeGen/X86/basic-block-address-map-mir-parse.mir (revision 7b7747dc1d3da1a829503ea9505b4cecce4f5bda)
1# Start after bbsections0-prepare and check that the BB address map is generated.
2# RUN: llc -mtriple x86_64-unknown-linux-gnu -start-after=bbsections-prepare -basic-block-address-map %s -o - | FileCheck %s -check-prefix=CHECK
3
4# How to generate the input:
5# foo.cc
6# int foo(bool k) {
7#  if (k) return 1;
8#  return 0;
9# }
10#
11# clang -O0 -S -emit-llvm foo.cc
12# llc < foo.ll -stop-after=bbsections-prepare -basic-block-address-map
13
14# CHECK: .section	.llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text
15--- |
16  ; ModuleID = '<stdin>'
17  source_filename = "/tmp/foo.cc"
18  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
19  target triple = "x86_64-pc-linux-gnu"
20
21  ; Function Attrs: mustprogress noinline nounwind optnone uwtable
22  define dso_local noundef i32 @_Z3foob(i1 noundef zeroext %0) #0 {
23    %2 = alloca i32, align 4
24    %3 = alloca i8, align 1
25    %4 = zext i1 %0 to i8
26    store i8 %4, ptr %3, align 1
27    %5 = load i8, ptr %3, align 1
28    %6 = trunc i8 %5 to i1
29    br i1 %6, label %7, label %8
30
31  7:                                                ; preds = %1
32    store i32 1, ptr %2, align 4
33    br label %9
34
35  8:                                                ; preds = %1
36    store i32 0, ptr %2, align 4
37    br label %9
38
39  9:                                                ; preds = %8, %7
40    %10 = load i32, ptr %2, align 4
41    ret i32 %10
42  }
43
44  attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
45
46  !llvm.module.flags = !{!0, !1, !2, !3, !4}
47  !llvm.ident = !{!5}
48
49  !0 = !{i32 1, !"wchar_size", i32 4}
50  !1 = !{i32 7, !"PIC Level", i32 2}
51  !2 = !{i32 7, !"PIE Level", i32 2}
52  !3 = !{i32 7, !"uwtable", i32 1}
53  !4 = !{i32 7, !"frame-pointer", i32 2}
54  !5 = !{!"Debian clang version 14.0.6-2"}
55
56...
57---
58name:            _Z3foob
59alignment:       16
60exposesReturnsTwice: false
61legalized:       false
62regBankSelected: false
63selected:        false
64failedISel:      false
65tracksRegLiveness: true
66hasWinCFI:       false
67callsEHReturn:   false
68callsUnwindInit: false
69hasEHCatchret:   false
70hasEHScopes:     false
71hasEHFunclets:   false
72failsVerification: false
73tracksDebugUserValues: true
74registers:       []
75liveins:
76  - { reg: '$edi', virtual-reg: '' }
77frameInfo:
78  isFrameAddressTaken: false
79  isReturnAddressTaken: false
80  hasStackMap:     false
81  hasPatchPoint:   false
82  stackSize:       8
83  offsetAdjustment: -8
84  maxAlignment:    4
85  adjustsStack:    false
86  hasCalls:        false
87  stackProtector:  ''
88  functionContext: ''
89  maxCallFrameSize: 0
90  cvBytesOfCalleeSavedRegisters: 0
91  hasOpaqueSPAdjustment: false
92  hasVAStart:      false
93  hasMustTailInVarArgFunc: false
94  hasTailCall:     false
95  localFrameSize:  0
96  savePoint:       ''
97  restorePoint:    ''
98fixedStack:
99  - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
100      callee-saved-register: '', callee-saved-restored: true, debug-info-variable: '',
101      debug-info-expression: '', debug-info-location: '' }
102stack:
103  - { id: 0, name: '', type: default, offset: -24, size: 4, alignment: 4,
104      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
105      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
106  - { id: 1, name: '', type: default, offset: -17, size: 1, alignment: 1,
107      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
108      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
109callSites:       []
110debugValueSubstitutions: []
111constants:       []
112machineFunctionInfo: {}
113body:             |
114  bb.0 (%ir-block.1, bb_id 0):
115    successors: %bb.2(0x40000000), %bb.1(0x40000000)
116    liveins: $edi
117
118    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
119    frame-setup CFI_INSTRUCTION def_cfa_offset 16
120    frame-setup CFI_INSTRUCTION offset $rbp, -16
121    $rbp = frame-setup MOV64rr $rsp
122    frame-setup CFI_INSTRUCTION def_cfa_register $rbp
123    renamable $dil = AND8ri renamable $dil, 1, implicit-def dead $eflags, implicit killed $edi, implicit-def $edi
124    MOV8mr $rbp, 1, $noreg, -1, $noreg, renamable $dil, implicit killed $edi :: (store (s8) into %ir.3)
125    TEST8mi $rbp, 1, $noreg, -1, $noreg, 1, implicit-def $eflags :: (load (s8) from %ir.3)
126    JCC_1 %bb.2, 4, implicit killed $eflags
127
128  bb.1 (%ir-block.7, bb_id 1):
129    successors: %bb.3(0x80000000)
130
131    MOV32mi $rbp, 1, $noreg, -8, $noreg, 1 :: (store (s32) into %ir.2)
132    JMP_1 %bb.3
133
134  bb.2 (%ir-block.8, bb_id 2):
135    successors: %bb.3(0x80000000)
136
137    MOV32mi $rbp, 1, $noreg, -8, $noreg, 0 :: (store (s32) into %ir.2)
138
139  bb.3 (%ir-block.9, bb_id 3 2):
140    renamable $eax = MOV32rm $rbp, 1, $noreg, -8, $noreg :: (load (s32) from %ir.2)
141    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
142    frame-destroy CFI_INSTRUCTION def_cfa $rsp, 8
143    RET64 implicit $eax
144
145...
146