llvm.org GIT mirror llvm / 45a188a
Merging r359496: ------------------------------------------------------------------------ r359496 | mstorsjo | 2019-04-29 13:25:51 -0700 (Mon, 29 Apr 2019) | 8 lines [X86] Run CFIInstrInserter on Windows if Dwarf is used This is necessary since SVN r330706, as tail merging can include CFI instructions since then. This fixes PR40322 and PR40012. Differential Revision: https://reviews.llvm.org/D61252 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@359952 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 months ago
2 changed file(s) with 169 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
3737 #include "llvm/IR/Attributes.h"
3838 #include "llvm/IR/DataLayout.h"
3939 #include "llvm/IR/Function.h"
40 #include "llvm/MC/MCAsmInfo.h"
4041 #include "llvm/Pass.h"
4142 #include "llvm/Support/CodeGen.h"
4243 #include "llvm/Support/CommandLine.h"
511512 // correct CFA calculation rule where needed by inserting appropriate CFI
512513 // instructions.
513514 const Triple &TT = TM->getTargetTriple();
514 if (!TT.isOSDarwin() && !TT.isOSWindows())
515 const MCAsmInfo *MAI = TM->getMCAsmInfo();
516 if (!TT.isOSDarwin() &&
517 (!TT.isOSWindows() ||
518 MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI))
515519 addPass(createCFIInstrInserter());
516520 }
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s -mtriple=i686-windows-gnu | FileCheck %s --check-prefix=CHECK-MINGW-X86
2
3 %struct.as = type { i32* }
4
5 @_ZZ2amiE2au = internal unnamed_addr global %struct.as zeroinitializer, align 4
6 @_ZGVZ2amiE2au = internal global i64 0, align 8
7 @_ZTIi = external constant i8*
8
9 define void @_Z2ami(i32) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
10 ; CHECK-MINGW-X86-LABEL: _Z2ami:
11 ; CHECK-MINGW-X86: # %bb.0: # %entry
12 ; CHECK-MINGW-X86-NEXT: pushl %edi
13 ; CHECK-MINGW-X86-NEXT: .cfi_def_cfa_offset 8
14 ; CHECK-MINGW-X86-NEXT: pushl %esi
15 ; CHECK-MINGW-X86-NEXT: .cfi_def_cfa_offset 12
16 ; CHECK-MINGW-X86-NEXT: .cfi_offset %esi, -12
17 ; CHECK-MINGW-X86-NEXT: .cfi_offset %edi, -8
18 ; CHECK-MINGW-X86-NEXT: movb __ZGVZ2amiE2au, %al
19 ; CHECK-MINGW-X86-NEXT: testb %al, %al
20 ; CHECK-MINGW-X86-NEXT: jne LBB0_4
21 ; CHECK-MINGW-X86-NEXT: # %bb.1: # %init.check
22 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
23 ; CHECK-MINGW-X86-NEXT: pushl $__ZGVZ2amiE2au
24 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
25 ; CHECK-MINGW-X86-NEXT: calll ___cxa_guard_acquire
26 ; CHECK-MINGW-X86-NEXT: addl $4, %esp
27 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset -4
28 ; CHECK-MINGW-X86-NEXT: testl %eax, %eax
29 ; CHECK-MINGW-X86-NEXT: je LBB0_4
30 ; CHECK-MINGW-X86-NEXT: # %bb.2: # %init
31 ; CHECK-MINGW-X86-NEXT: Ltmp0:
32 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
33 ; CHECK-MINGW-X86-NEXT: pushl $4
34 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
35 ; CHECK-MINGW-X86-NEXT: calll __Znwj
36 ; CHECK-MINGW-X86-NEXT: addl $4, %esp
37 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset -4
38 ; CHECK-MINGW-X86-NEXT: Ltmp1:
39 ; CHECK-MINGW-X86-NEXT: # %bb.3: # %invoke.cont
40 ; CHECK-MINGW-X86-NEXT: movl %eax, __ZZ2amiE2au
41 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
42 ; CHECK-MINGW-X86-NEXT: pushl $__ZGVZ2amiE2au
43 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
44 ; CHECK-MINGW-X86-NEXT: calll ___cxa_guard_release
45 ; CHECK-MINGW-X86-NEXT: addl $4, %esp
46 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset -4
47 ; CHECK-MINGW-X86-NEXT: LBB0_4: # %init.end
48 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
49 ; CHECK-MINGW-X86-NEXT: pushl $4
50 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
51 ; CHECK-MINGW-X86-NEXT: calll __Znwj
52 ; CHECK-MINGW-X86-NEXT: addl $4, %esp
53 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset -4
54 ; CHECK-MINGW-X86-NEXT: movl %eax, %esi
55 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
56 ; CHECK-MINGW-X86-NEXT: pushl $4
57 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
58 ; CHECK-MINGW-X86-NEXT: calll ___cxa_allocate_exception
59 ; CHECK-MINGW-X86-NEXT: addl $4, %esp
60 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset -4
61 ; CHECK-MINGW-X86-NEXT: movl $0, (%eax)
62 ; CHECK-MINGW-X86-NEXT: Ltmp3:
63 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x0c
64 ; CHECK-MINGW-X86-NEXT: movl .refptr.__ZTIi, %ecx
65 ; CHECK-MINGW-X86-NEXT: pushl $0
66 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
67 ; CHECK-MINGW-X86-NEXT: pushl %ecx
68 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
69 ; CHECK-MINGW-X86-NEXT: pushl %eax
70 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
71 ; CHECK-MINGW-X86-NEXT: calll ___cxa_throw
72 ; CHECK-MINGW-X86-NEXT: addl $12, %esp
73 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset -12
74 ; CHECK-MINGW-X86-NEXT: Ltmp4:
75 ; CHECK-MINGW-X86-NEXT: # %bb.8: # %unreachable
76 ; CHECK-MINGW-X86-NEXT: LBB0_5: # %lpad
77 ; CHECK-MINGW-X86-NEXT: Ltmp2:
78 ; CHECK-MINGW-X86-NEXT: movl %eax, %edi
79 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
80 ; CHECK-MINGW-X86-NEXT: pushl $__ZGVZ2amiE2au
81 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
82 ; CHECK-MINGW-X86-NEXT: calll ___cxa_guard_abort
83 ; CHECK-MINGW-X86-NEXT: jmp LBB0_7
84 ; CHECK-MINGW-X86-NEXT: LBB0_6: # %lpad1
85 ; CHECK-MINGW-X86-NEXT: .cfi_def_cfa_offset 12
86 ; CHECK-MINGW-X86-NEXT: Ltmp5:
87 ; CHECK-MINGW-X86-NEXT: movl %eax, %edi
88 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
89 ; CHECK-MINGW-X86-NEXT: pushl %esi
90 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
91 ; CHECK-MINGW-X86-NEXT: calll __ZdlPv
92 ; CHECK-MINGW-X86-NEXT: LBB0_7: # %eh.resume
93 ; CHECK-MINGW-X86-NEXT: addl $4, %esp
94 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset -4
95 ; CHECK-MINGW-X86-NEXT: .cfi_escape 0x2e, 0x04
96 ; CHECK-MINGW-X86-NEXT: pushl %edi
97 ; CHECK-MINGW-X86-NEXT: .cfi_adjust_cfa_offset 4
98 ; CHECK-MINGW-X86-NEXT: calll __Unwind_Resume
99 ; CHECK-MINGW-X86-NEXT: Lfunc_end0:
100 entry:
101 %1 = load atomic i8, i8* bitcast (i64* @_ZGVZ2amiE2au to i8*) acquire, align 8
102 %guard.uninitialized = icmp eq i8 %1, 0
103 br i1 %guard.uninitialized, label %init.check, label %init.end
104
105 init.check: ; preds = %entry
106 %2 = tail call i32 @__cxa_guard_acquire(i64* nonnull @_ZGVZ2amiE2au)
107 %tobool = icmp eq i32 %2, 0
108 br i1 %tobool, label %init.end, label %init
109
110 init: ; preds = %init.check
111 %call.i3 = invoke i8* @_Znwj(i32 4)
112 to label %invoke.cont unwind label %lpad
113
114 invoke.cont: ; preds = %init
115 store i8* %call.i3, i8** bitcast (%struct.as* @_ZZ2amiE2au to i8**), align 4
116 tail call void @__cxa_guard_release(i64* nonnull @_ZGVZ2amiE2au)
117 br label %init.end
118
119 init.end: ; preds = %init.check, %invoke.cont, %entry
120 %call.i = tail call i8* @_Znwj(i32 4)
121 %exception = tail call i8* @__cxa_allocate_exception(i32 4)
122 %3 = bitcast i8* %exception to i32*
123 store i32 0, i32* %3, align 16
124 invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
125 to label %unreachable unwind label %lpad1
126
127 lpad: ; preds = %init
128 %4 = landingpad { i8*, i32 }
129 cleanup
130 %5 = extractvalue { i8*, i32 } %4, 0
131 %6 = extractvalue { i8*, i32 } %4, 1
132 tail call void @__cxa_guard_abort(i64* nonnull @_ZGVZ2amiE2au) #1
133 br label %eh.resume
134
135 lpad1: ; preds = %init.end
136 %7 = landingpad { i8*, i32 }
137 cleanup
138 %8 = extractvalue { i8*, i32 } %7, 0
139 %9 = extractvalue { i8*, i32 } %7, 1
140 tail call void @_ZdlPv(i8* nonnull %call.i)
141 br label %eh.resume
142
143 eh.resume: ; preds = %lpad1, %lpad
144 %exn.slot.0 = phi i8* [ %8, %lpad1 ], [ %5, %lpad ]
145 %ehselector.slot.0 = phi i32 [ %9, %lpad1 ], [ %6, %lpad ]
146 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.0, 0
147 %lpad.val2 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.0, 1
148 resume { i8*, i32 } %lpad.val2
149
150 unreachable: ; preds = %init.end
151 unreachable
152 }
153
154 declare i32 @__cxa_guard_acquire(i64*)
155 declare i32 @__gxx_personality_v0(...)
156 declare void @__cxa_guard_abort(i64*)
157 declare void @__cxa_guard_release(i64*)
158 declare i8* @__cxa_allocate_exception(i32)
159 declare void @__cxa_throw(i8*, i8*, i8*)
160 declare noalias nonnull i8* @_Znwj(i32)
161 declare i8* @__cxa_begin_catch(i8*)
162 declare void @__cxa_end_catch()
163 declare void @_ZdlPv(i8*)