148 lines · plain
1# RUN: llc -start-after=machine-scheduler %s -o - | FileCheck %s2 3# C source:4# void escape(int *);5# extern int global;6# void f(int x) {7# escape(&x);8# x = 1;9# global = x;10# x = 2;11# escape(&x);12# }13 14# CHECK-LABEL: f: # @f15# CHECK: movl %ecx, [[OFF_X:[0-9]+]](%rsp)16# CHECK: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]]] [$rsp+0]17# CHECK: leaq [[OFF_X]](%rsp), %rsi18# CHECK: callq escape19# CHECK: #DEBUG_VALUE: f:x <- 120# CHECK: movl $1, global(%rip)21# CHECK: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]]] [$rsp+0]22# CHECK: movl $2, [[OFF_X]](%rsp)23# CHECK: callq escape24# CHECK: retq25 26 27--- |28 ; ModuleID = '<stdin>'29 source_filename = "dse.c"30 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"31 target triple = "x86_64-pc-windows-msvc19.0.24215"32 33 @global = external global i32, align 434 35 ; Function Attrs: nounwind readnone speculatable36 declare void @llvm.dbg.value(metadata, metadata, metadata) #037 38 declare void @escape(ptr)39 40 ; Function Attrs: nounwind uwtable41 define void @f(i32 %x) #1 !dbg !8 {42 entry:43 %x.addr = alloca i32, align 444 store i32 %x, ptr %x.addr, align 445 call void @llvm.dbg.value(metadata ptr %x.addr, metadata !13, metadata !DIExpression()), !dbg !1446 call void @escape(ptr %x.addr), !dbg !1547 call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()), !dbg !1648 store i32 1, ptr @global, align 4, !dbg !1749 call void @llvm.dbg.value(metadata ptr %x.addr, metadata !13, metadata !DIExpression()), !dbg !1850 store i32 2, ptr %x.addr, align 4, !dbg !1851 call void @escape(ptr %x.addr), !dbg !1952 ret void, !dbg !2053 }54 55 ; Function Attrs: nounwind56 declare void @llvm.stackprotector(ptr, ptr) #257 58 attributes #0 = { nounwind readnone speculatable }59 attributes #1 = { nounwind uwtable }60 attributes #2 = { nounwind }61 62 !llvm.dbg.cu = !{!0}63 !llvm.module.flags = !{!3, !4, !5, !6}64 !llvm.ident = !{!7}65 66 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)67 !1 = !DIFile(filename: "dse.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")68 !2 = !{}69 !3 = !{i32 2, !"Dwarf Version", i32 4}70 !4 = !{i32 2, !"Debug Info Version", i32 3}71 !5 = !{i32 1, !"wchar_size", i32 2}72 !6 = !{i32 7, !"PIC Level", i32 2}73 !7 = !{!"clang version 6.0.0 "}74 !8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)75 !9 = !DISubroutineType(types: !10)76 !10 = !{null, !11}77 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)78 !12 = !{!13}79 !13 = !DILocalVariable(name: "x", arg: 1, scope: !8, file: !1, line: 3, type: !11)80 !14 = !DILocation(line: 3, column: 12, scope: !8)81 !15 = !DILocation(line: 4, column: 3, scope: !8)82 !16 = !DILocation(line: 5, column: 5, scope: !8)83 !17 = !DILocation(line: 6, column: 10, scope: !8)84 !18 = !DILocation(line: 7, column: 5, scope: !8)85 !19 = !DILocation(line: 8, column: 3, scope: !8)86 !20 = !DILocation(line: 9, column: 1, scope: !8)87 88...89---90name: f91alignment: 1692exposesReturnsTwice: false93legalized: false94regBankSelected: false95selected: false96tracksRegLiveness: true97registers: 98 - { id: 0, class: gr32, preferred-register: '' }99 - { id: 1, class: gr64, preferred-register: '' }100liveins: 101 - { reg: '$ecx', virtual-reg: '%0' }102frameInfo: 103 isFrameAddressTaken: false104 isReturnAddressTaken: false105 hasStackMap: false106 hasPatchPoint: false107 stackSize: 0108 offsetAdjustment: 0109 maxAlignment: 8110 adjustsStack: true111 hasCalls: true112 stackProtector: ''113 maxCallFrameSize: 4294967295114 hasOpaqueSPAdjustment: false115 hasVAStart: false116 hasMustTailInVarArgFunc: false117 savePoint: []118 restorePoint: []119fixedStack: 120stack: 121 - { id: 0, name: x.addr, type: default, offset: 0, size: 4, alignment: 4, 122 stack-id: default, callee-saved-register: '', debug-info-variable: '',123 debug-info-expression: '', debug-info-location: '' }124constants: 125body: |126 bb.0.entry:127 liveins: $ecx128 129 %0 = COPY $ecx130 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 :: (store (s32) into %ir.x.addr)131 DBG_VALUE %stack.0.x.addr, 0, !13, !DIExpression(), debug-location !14132 ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15133 %1 = LEA64r %stack.0.x.addr, 1, _, 0, _134 $rcx = COPY %1, debug-location !15135 CALL64pcrel32 @escape, csr_win64, implicit $rsp, implicit $ssp, implicit $rcx, implicit-def $rsp, implicit-def $ssp, debug-location !15136 ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15137 DBG_VALUE 1, _, !13, !DIExpression(), debug-location !16138 MOV32mi $rip, 1, _, @global, _, 1, debug-location !17 :: (store (s32) into @global)139 DBG_VALUE %stack.0.x.addr, 0, !13, !DIExpression(), debug-location !18140 MOV32mi %stack.0.x.addr, 1, _, 0, _, 2, debug-location !18 :: (store (s32) into %ir.x.addr)141 ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !19142 $rcx = COPY %1, debug-location !19143 CALL64pcrel32 @escape, csr_win64, implicit $rsp, implicit $ssp, implicit $rcx, implicit-def $rsp, implicit-def $ssp, debug-location !19144 ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !19145 RET 0, debug-location !20146 147...148