summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/destructors.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-07-06 01:34:17 +0000
committerJohn McCall <rjmccall@apple.com>2010-07-06 01:34:17 +0000
commitbd30929e4d5b25dab42d87018fde4b25c8704af2 (patch)
tree48674d3258edc974ec120fee5961909dfaa28a09 /clang/test/CodeGenCXX/destructors.cpp
parentf894cfb44f0c5661f02ea09ca93115389e5dc65e (diff)
downloadbcm5719-llvm-bd30929e4d5b25dab42d87018fde4b25c8704af2.tar.gz
bcm5719-llvm-bd30929e4d5b25dab42d87018fde4b25c8704af2.zip
Validated by nightly-test runs on x86 and x86-64 darwin, including after
self-host. Hopefully these results hold up on different platforms. I tried to keep the GNU ObjC runtime happy, but it's hard for me to test. Reimplement how clang generates IR for exceptions. Instead of creating new invoke destinations which sequentially chain to the previous destination, push a more semantic representation of *why* we need the cleanup/catch/filter behavior, then collect that information into a single landing pad upon request. Also reorganizes how normal cleanups (i.e. cleanups triggered by non-exceptional control flow) are generated, since it's actually fairly closely tied in with the former. Remove the need to track which cleanup scope a block is associated with. Document a lot of previously poorly-understood (by me, at least) behavior. The new framework implements the Horrible Hack (tm), which requires every landing pad to have a catch-all so that inlining will work. Clang no longer requires the Horrible Hack just to make exceptions flow correctly within a function, however. The HH is an unfortunate requirement of LLVM's EH IR. llvm-svn: 107631
Diffstat (limited to 'clang/test/CodeGenCXX/destructors.cpp')
-rw-r--r--clang/test/CodeGenCXX/destructors.cpp58
1 files changed, 55 insertions, 3 deletions
diff --git a/clang/test/CodeGenCXX/destructors.cpp b/clang/test/CodeGenCXX/destructors.cpp
index ef3d4b9cb1a..ee8f1a5f543 100644
--- a/clang/test/CodeGenCXX/destructors.cpp
+++ b/clang/test/CodeGenCXX/destructors.cpp
@@ -187,15 +187,63 @@ namespace test3 {
// Checked at top of file:
// @_ZN5test312_GLOBAL__N_11CD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+ // More checks at end of file.
+
+}
+
+namespace test4 {
+ struct A { ~A(); };
+
+ // CHECK: define void @_ZN5test43fooEv()
+ // CHECK: call void @_ZN5test41AD1Ev
+ // CHECK: ret void
+ void foo() {
+ {
+ A a;
+ goto failure;
+ }
+
+ failure:
+ return;
+ }
+
+ // CHECK: define void @_ZN5test43barEi(
+ // CHECK: [[X:%.*]] = alloca i32
+ // CHECK-NEXT: [[A:%.*]] = alloca
+ // CHECK: br label
+ // CHECK: [[TMP:%.*]] = load i32* [[X]]
+ // CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[TMP]], 0
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN5test41AD1Ev(
+ // CHECK: br label
+ // CHECK: [[TMP:%.*]] = load i32* [[X]]
+ // CHECK: [[TMP2:%.*]] = add nsw i32 [[TMP]], -1
+ // CHECK: store i32 [[TMP2]], i32* [[X]]
+ // CHECK: br label
+ // CHECK: ret void
+ void bar(int x) {
+ for (A a; x; ) {
+ x--;
+ }
+ }
+}
+
+// Checks from test3:
+
// CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev(
// CHECK: call void @_ZN5test31BD2Ev(
// CHECK: call void @_ZN5test31AD2Ev(
// CHECK: ret void
// CHECK: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(
- // CHECK: call void @_ZN5test312_GLOBAL__N_11DD1Ev(
+ // CHECK: invoke void @_ZN5test312_GLOBAL__N_11DD1Ev(
// CHECK: call void @_ZdlPv(
// CHECK: ret void
+ // CHECK: call i8* @llvm.eh.exception(
+ // CHECK: invoke void @_ZdlPv
+ // CHECK: call void @_Unwind_Resume_or_Rethrow
+ // CHECK: call i8* @llvm.eh.exception(
+ // CHECK: call void @_ZSt9terminatev(
// Checked at top of file:
// @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev
@@ -215,9 +263,14 @@ namespace test3 {
// CHECK: declare void @_ZN5test31AD2Ev(
// CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD0Ev(
- // CHECK: call void @_ZN5test312_GLOBAL__N_11CD1Ev(
+ // CHECK: invoke void @_ZN5test312_GLOBAL__N_11CD1Ev(
// CHECK: call void @_ZdlPv(
// CHECK: ret void
+ // CHECK: call i8* @llvm.eh.exception()
+ // CHECK: invoke void @_ZdlPv(
+ // CHECK: call void @_Unwind_Resume_or_Rethrow(
+ // CHECK: call i8* @llvm.eh.exception()
+ // CHECK: call void @_ZSt9terminatev()
// CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev(
// CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
@@ -228,4 +281,3 @@ namespace test3 {
// CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
// CHECK: call void @_ZN5test312_GLOBAL__N_11CD0Ev(
// CHECK: ret void
-}
OpenPOWER on IntegriCloud