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 i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
30__try.cont:
31  %__exception_code = alloca i32, align 4
32  call void (...) @llvm.localescape(i32* 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 i8* @llvm.frameaddress(i32 1)
41  %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @f to i8*), i8* %0)
42  %2 = tail call i8* @llvm.localrecover(i8* bitcast (void ()* @f to i8*), i8* %1, i32 0)
43  %__exception_code = bitcast i8* %2 to i32*
44  %3 = getelementptr inbounds i8, i8* %0, i32 -20
45  %4 = bitcast i8* %3 to { i32*, i8* }**
46  %5 = load { i32*, i8* }*, { i32*, i8* }** %4, align 4
47  %6 = getelementptr inbounds { i32*, i8* }, { i32*, i8* }* %5, i32 0, i32 0
48  %7 = load i32*, i32** %6, align 4
49  %8 = load i32, i32* %7, align 4
50  store i32 %8, i32* %__exception_code, align 4
51  ret i32 1
52}
53
54; Function Attrs: nounwind readnone
55declare i8* @llvm.frameaddress(i32) #2
56
57; Function Attrs: nounwind readnone
58declare i8* @llvm.eh.recoverfp(i8*, i8*) #2
59
60; Function Attrs: nounwind readnone
61declare i8* @llvm.localrecover(i8*, i8*, i32) #2
62
63declare i32 @_except_handler3(...)
64
65; Function Attrs: nounwind
66declare void @llvm.localescape(...) #3
67
68attributes #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" }
69attributes #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" }
70attributes #2 = { nounwind readnone }
71attributes #3 = { nounwind }
72
73!llvm.ident = !{!0}
74
75!0 = !{!"clang version 4.0.0 (trunk 282900) (llvm/trunk 282903)"}
76!1 = !{i32 48}
77