143 lines · plain
1# RUN: llc -o - %s -mtriple=x86_64-pc-windows-msvc -run-pass=machinelicm | FileCheck %s2# RUN: llc -o - %s -mtriple=x86_64-pc-windows-msvc -passes=machinelicm | FileCheck %s3#4# This test checks that MachineLICM doesn't hoist loads out of funclets.5# Manually modified from the IR of the following C++ function by running6# llc -stop-after=machine-cp.7#8# void may_throw();9# void use(int);10#11# void test(int n, int arg)12# {13# for (int i = 0 ; i < n ; i++)14# try {15# may_throw();16# }17# catch (...) {18# // Two uses to get 'arg' allocated to a register19# use(arg);20# use(arg);21# }22# }23 24--- |25 target triple = "x86_64-pc-windows-msvc"26 27 define void @test(i32 %n, i32 %arg) personality ptr @__CxxFrameHandler3 {28 entry:29 %cmp3 = icmp sgt i32 %n, 030 br i1 %cmp3, label %for.body.preheader, label %for.cond.cleanup31 32 for.body.preheader: ; preds = %entry33 br label %for.body34 35 for.cond.cleanup: ; preds = %for.inc, %entry36 ret void37 38 for.body: ; preds = %for.body.preheader, %for.inc39 %lsr.iv = phi i32 [ %n, %for.body.preheader ], [ %lsr.iv.next, %for.inc ]40 invoke void @may_throw()41 to label %for.inc unwind label %catch.dispatch42 43 catch.dispatch: ; preds = %for.body44 %0 = catchswitch within none [label %catch] unwind to caller45 46 catch: ; preds = %catch.dispatch47 %1 = catchpad within %0 [ptr null, i32 64, ptr null]48 call void @use(i32 %arg) [ "funclet"(token %1) ]49 call void @use(i32 %arg) [ "funclet"(token %1) ]50 catchret from %1 to label %for.inc51 52 for.inc: ; preds = %catch, %for.body53 %lsr.iv.next = add i32 %lsr.iv, -154 %exitcond.not = icmp eq i32 %lsr.iv.next, 055 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body56 }57 58 declare i32 @__CxxFrameHandler3(...)59 60 declare void @may_throw()61 62 declare void @use(i32)63 64...65---66name: test67alignment: 1668tracksRegLiveness: true69hasEHContTarget: true70hasEHScopes: true71hasEHFunclets: true72debugInstrRef: true73tracksDebugUserValues: true74liveins:75 - { reg: '$ecx' }76 - { reg: '$edx' }77frameInfo:78 maxAlignment: 879 hasCalls: true80 hasOpaqueSPAdjustment: true81stack:82 - { id: 0, type: spill-slot, size: 4, alignment: 4 }83 - { id: 1, type: spill-slot, size: 4, alignment: 4 }84machineFunctionInfo: {}85body: |86 bb.0.entry:87 successors: %bb.1, %bb.288 liveins: $ecx, $edx89 90 MOV32mr %stack.1, 1, $noreg, 0, $noreg, $edx :: (store (s32) into %stack.1)91 TEST32rr renamable $ecx, renamable $ecx, implicit-def $eflags92 JCC_1 %bb.2, 14, implicit killed $eflags93 94 bb.1:95 liveins: $ecx96 97 JMP_1 %bb.398 99 bb.2.for.cond.cleanup:100 RET 0101 102 bb.3.for.body:103 successors: %bb.5, %bb.4104 liveins: $ecx105 106 EH_LABEL <mcsymbol .Leh1>107 MOV32mr %stack.0, 1, $noreg, 0, $noreg, killed renamable $ecx :: (store (s32) into %stack.0)108 ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp109 CALL64pcrel32 @may_throw, csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp110 ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp111 EH_LABEL <mcsymbol .Leh2>112 JMP_1 %bb.5113 114 bb.4.catch (landing-pad, ehfunclet-entry):115 successors: %bb.5116 117 ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp118 renamable $esi = MOV32rm %stack.1, 1, $noreg, 0, $noreg :: (load (s32) from %stack.1)119 $ecx = COPY renamable $esi120 CALL64pcrel32 @use, csr_win64, implicit $rsp, implicit $ssp, implicit $ecx, implicit-def $rsp, implicit-def $ssp121 ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp122 ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp123 $ecx = COPY killed renamable $esi124 CALL64pcrel32 @use, csr_win64, implicit $rsp, implicit $ssp, implicit $ecx, implicit-def $rsp, implicit-def $ssp125 ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp126 CATCHRET %bb.5, %bb.0127 128 bb.5.for.inc:129 successors: %bb.2, %bb.3130 131 renamable $ecx = MOV32rm %stack.0, 1, $noreg, 0, $noreg :: (load (s32) from %stack.0)132 renamable $ecx = DEC32r killed renamable $ecx, implicit-def $eflags133 JCC_1 %bb.2, 4, implicit killed $eflags134 JMP_1 %bb.3135 136...137#138# CHECK: bb.4.catch139# CHECK: ADJCALLSTACKDOWN64140# CHECK-NEXT: renamable [[REG:\$[a-z0-9]+]] = MOV32rm %stack.1141# CHECK-NEXT: $ecx = COPY renamable [[REG]]142# CHECK-NEXT: CALL64pcrel32 @use143