1+ ; This test ensures that catch parameters are not instrumented on Windows.
2+
3+ ; This file was generated using the following source
4+ ;
5+ ; ```C++
6+ ; #include <exception>
7+ ; #include <cstdio>
8+ ;
9+ ; int main() {
10+ ; try {
11+ ; throw 1;
12+ ; } catch (const int ex) {
13+ ; printf("%d\n", ex);
14+ ; return -1;
15+ ; }
16+ ; return 0;
17+ ; }
18+ ;
19+ ; ```
20+ ; then running the following sequence of commands
21+ ;
22+ ; ```
23+ ; clang.exe -g0 -O0 -emit-llvm -c main.cpp -o main.bc
24+ ; llvm-extract.exe -func=main main.bc -o main_func.bc
25+ ; llvm-dis.exe main_func.bc -o main_func_dis.ll
26+ ; ```
27+ ; and finally manually trimming the resulting `.ll` file to remove
28+ ; unnecessary metadata, and manually adding the `sanitize_address` annotation;
29+ ; needed for the ASan pass to run.
30+
31+ ; RUN: opt < %s -passes=asan -S | FileCheck %s
32+ ; CHECK: %ex = alloca i32, align 4
33+ ; CHECK: catchpad within %{{.*}} [ptr @"??_R0H@8", i32 0, ptr %ex]
34+
35+ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
36+ target triple = "x86_64-pc-windows-msvc"
37+
38+ %rtti.TypeDescriptor2 = type { ptr , ptr , [3 x i8 ] }
39+ %eh.ThrowInfo = type { i32 , i32 , i32 , i32 }
40+
41+ @"??_R0H@8" = external global %rtti.TypeDescriptor2
42+ @_TI1H = external unnamed_addr constant %eh.ThrowInfo , section ".xdata"
43+ @"??_C@_03PMGGPEJJ@?$CFd?6?$AA@" = external dso_local unnamed_addr constant [4 x i8 ], align 1
44+
45+ ; Function Attrs: mustprogress noinline norecurse optnone uwtable sanitize_address
46+ define dso_local noundef i32 @main () #0 personality ptr @__CxxFrameHandler3 {
47+ entry:
48+ %retval = alloca i32 , align 4
49+ %tmp = alloca i32 , align 4
50+ %ex = alloca i32 , align 4
51+ store i32 0 , ptr %retval , align 4
52+ store i32 1 , ptr %tmp , align 4
53+ invoke void @_CxxThrowException (ptr %tmp , ptr @_TI1H ) #2
54+ to label %unreachable unwind label %catch.dispatch
55+
56+ catch.dispatch: ; preds = %entry
57+ %0 = catchswitch within none [label %catch ] unwind to caller
58+
59+ catch: ; preds = %catch.dispatch
60+ %1 = catchpad within %0 [ptr @"??_R0H@8" , i32 0 , ptr %ex ]
61+ %2 = load i32 , ptr %ex , align 4
62+ %call = call i32 (ptr , ...) @printf (ptr noundef @"??_C@_03PMGGPEJJ@?$CFd?6?$AA@" , i32 noundef %2 ) [ "funclet" (token %1 ) ]
63+ store i32 -1 , ptr %retval , align 4
64+ catchret from %1 to label %catchret.dest
65+
66+ catchret.dest: ; preds = %catch
67+ br label %return
68+
69+ try.cont: ; No predecessors!
70+ store i32 0 , ptr %retval , align 4
71+ br label %return
72+
73+ return: ; preds = %try.cont, %catchret.dest
74+ %3 = load i32 , ptr %retval , align 4
75+ ret i32 %3
76+
77+ unreachable: ; preds = %entry
78+ unreachable
79+ }
80+
81+ declare dso_local void @_CxxThrowException (ptr , ptr )
82+
83+ declare dso_local i32 @__CxxFrameHandler3 (...)
84+
85+ ; Function Attrs: mustprogress noinline optnone uwtable
86+ declare dso_local i32 @printf (ptr noundef, ...) #1
87+
88+ attributes #0 = { mustprogress noinline norecurse optnone uwtable sanitize_address }
89+ attributes #1 = { mustprogress noinline optnone uwtable }
90+ attributes #2 = { noreturn }
0 commit comments