brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 713d015 Raw
145 lines · plain
1; RUN: llc < %s | FileCheck %s2 3; Based on this code:4;5; extern "C" int array[4];6; extern "C" void global_array(int idx1, int idx2, int idx3) {7;   try {8;     array[idx1] = 111;9;     throw;10;   } catch (...) {11;     array[idx2] = 222;12;   }13;   array[idx3] = 333;14; }15; extern "C" __declspec(dllimport) int imported;16; extern "C" void access_imported() {17;   try {18;     imported = 111;19;     throw;20;   } catch (...) {21;     imported = 222;22;   }23;   imported = 333;24; }25 26target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"27target triple = "x86_64-pc-windows-msvc18.0.0"28 29%eh.ThrowInfo = type { i32, i32, i32, i32 }30 31@array = external global [4 x i32], align 1632@imported = external dllimport global i32, align 433 34; Function Attrs: uwtable35define void @global_array(i32 %idx1, i32 %idx2, i32 %idx3) #0 personality ptr @__CxxFrameHandler3 {36entry:37  %idxprom = sext i32 %idx1 to i6438  %arrayidx = getelementptr inbounds [4 x i32], ptr @array, i64 0, i64 %idxprom39  store i32 111, ptr %arrayidx, align 4, !tbaa !240  invoke void @_CxxThrowException(ptr null, ptr null) #141          to label %unreachable unwind label %catch.dispatch42 43catch.dispatch:                                   ; preds = %entry44  %cs1 = catchswitch within none [label %catch] unwind to caller45 46catch:                                            ; preds = %catch.dispatch47  %0 = catchpad within %cs1 [ptr null, i32 64, ptr null]48  %idxprom1 = sext i32 %idx2 to i6449  %arrayidx2 = getelementptr inbounds [4 x i32], ptr @array, i64 0, i64 %idxprom150  store i32 222, ptr %arrayidx2, align 4, !tbaa !251  catchret from %0 to label %try.cont52 53try.cont:                                         ; preds = %catch54  %idxprom3 = sext i32 %idx3 to i6455  %arrayidx4 = getelementptr inbounds [4 x i32], ptr @array, i64 0, i64 %idxprom356  store i32 333, ptr %arrayidx4, align 4, !tbaa !257  ret void58 59unreachable:                                      ; preds = %entry60  unreachable61}62 63; CHECK-LABEL: global_array: # @global_array64; CHECK: pushq %rbp65; 	First array access66; CHECK: movslq  %ecx, %[[idx:[^ ]*]]67; CHECK: leaq    array(%rip), %[[base:[^ ]*]]68; CHECK: movl    $111, (%[[base]],%[[idx]],4)69;	Might throw an exception and return to below...70; CHECK: callq   _CxxThrowException71; 	Third array access must remat the address of array72; CHECK: movslq  {{.*}}, %[[idx:[^ ]*]]73; CHECK: leaq    array(%rip), %[[base:[^ ]*]]74; CHECK: movl    $333, (%[[base]],%[[idx]],4)75; CHECK: popq %rbp76; CHECK: retq77 78; CHECK: "?catch${{[0-9]+}}@?0?global_array@4HA":79; CHECK: pushq   %rbp80; CHECK: movslq  {{.*}}, %[[idx:[^ ]*]]81; CHECK: leaq    array(%rip), %[[base:[^ ]*]]82; CHECK: movl    $222, (%[[base]],%[[idx]],4)83; CHECK: popq    %rbp84; CHECK: retq                            # CATCHRET85 86declare void @_CxxThrowException(ptr, ptr)87 88declare i32 @__CxxFrameHandler3(...)89 90; Function Attrs: uwtable91define void @access_imported() #0 personality ptr @__CxxFrameHandler3 {92entry:93  store i32 111, ptr @imported, align 4, !tbaa !294  invoke void @_CxxThrowException(ptr null, ptr null) #195          to label %unreachable unwind label %catch.dispatch96 97catch.dispatch:                                   ; preds = %entry98  %cs1 = catchswitch within none [label %catch] unwind to caller99 100catch:                                            ; preds = %catch.dispatch101  %0 = catchpad within %cs1 [ptr null, i32 64, ptr null]102  store i32 222, ptr @imported, align 4, !tbaa !2103  catchret from %0 to label %try.cont104 105try.cont:                                         ; preds = %catch106  store i32 333, ptr @imported, align 4, !tbaa !2107  ret void108 109unreachable:                                      ; preds = %entry110  unreachable111}112 113; CHECK-LABEL: access_imported: # @access_imported114; CHECK: pushq %rbp115; CHECK: movq    __imp_imported(%rip), %[[base:[^ ]*]]116; CHECK: movl    $111, (%[[base]])117;	Might throw an exception and return to below...118; CHECK: callq   _CxxThrowException119; 	Third access must reload the address of imported120; CHECK: movq    __imp_imported(%rip), %[[base:[^ ]*]]121; CHECK: movl    $333, (%[[base]])122; CHECK: popq %rbp123; CHECK: retq124 125; CHECK: "?catch${{[0-9]+}}@?0?access_imported@4HA":126; CHECK: pushq   %rbp127; CHECK: movq    __imp_imported(%rip), %[[base:[^ ]*]]128; CHECK: movl    $222, (%[[base]])129; CHECK: popq    %rbp130; CHECK: retq                            # CATCHRET131 132 133attributes #0 = { uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "use-soft-float"="false" }134attributes #1 = { noreturn }135 136!llvm.module.flags = !{!0}137!llvm.ident = !{!1}138 139!0 = !{i32 1, !"PIC Level", i32 2}140!1 = !{!"clang version 3.8.0 "}141!2 = !{!3, !3, i64 0}142!3 = !{!"int", !4, i64 0}143!4 = !{!"omnipotent char", !5, i64 0}144!5 = !{!"Simple C/C++ TBAA"}145