xref: /llvm-project/llvm/test/CodeGen/X86/seh-no-invokes.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; RUN: llc < %s | FileCheck %s
2
3; Generated with this C source:
4; static __forceinline void __cpuid() { __asm__(""); }
5; void f() {
6;   __try {
7;     __cpuid();
8;   } __except (1) {
9;   }
10; }
11
12; When running clang at -O1, we can end up deleting unreachable SEH catchpads
13; without running GlobalDCE to remove the associated filter. This used to
14; result in references to undefined labels. Now we check that we emit the
15; label. This was PR30431.
16
17; CHECK-LABEL: _f:                                     # @f
18; CHECK: .set Lf$parent_frame_offset, 0
19; CHECK: retl
20
21; CHECK-LABEL: "?filt$0@0@f@@":                        # @"\01?filt$0@0@f@@"
22; CHECK: movl    $Lf$parent_frame_offset,
23
24; ModuleID = 't.c'
25source_filename = "t.c"
26target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
27target triple = "i386-pc-windows-msvc19.0.24210"
28
29define void @f() #0 personality ptr @_except_handler3 {
30__try.cont:
31  %__exception_code = alloca i32, align 4
32  call void (...) @llvm.localescape(ptr nonnull %__exception_code)
33  call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !1
34  ret void
35}
36
37; Function Attrs: nounwind
38define internal i32 @"\01?filt$0@0@f@@"() #1 {
39entry:
40  %0 = tail call ptr @llvm.frameaddress(i32 1)
41  %1 = tail call ptr @llvm.eh.recoverfp(ptr @f, ptr %0)
42  %2 = tail call ptr @llvm.localrecover(ptr @f, ptr %1, i32 0)
43  %3 = getelementptr inbounds i8, ptr %0, i32 -20
44  %4 = load ptr, ptr %3, align 4
45  %5 = getelementptr inbounds { ptr, ptr }, ptr %4, i32 0, i32 0
46  %6 = load ptr, ptr %5, align 4
47  %7 = load i32, ptr %6, align 4
48  store i32 %7, ptr %2, align 4
49  ret i32 1
50}
51
52; Function Attrs: nounwind readnone
53declare ptr @llvm.frameaddress(i32) #2
54
55; Function Attrs: nounwind readnone
56declare ptr @llvm.eh.recoverfp(ptr, ptr) #2
57
58; Function Attrs: nounwind readnone
59declare ptr @llvm.localrecover(ptr, ptr, i32) #2
60
61declare i32 @_except_handler3(...)
62
63; Function Attrs: nounwind
64declare void @llvm.localescape(...) #3
65
66attributes #0 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
67attributes #1 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
68attributes #2 = { nounwind readnone }
69attributes #3 = { nounwind }
70
71!llvm.ident = !{!0}
72
73!0 = !{!"clang version 4.0.0 (trunk 282900) (llvm/trunk 282903)"}
74!1 = !{i32 48}
75