llvm-project/clang/test/CodeGen/ignore-exceptions.cpp
jasonliu 55e2678fcd [clang] Add -fignore-exceptions
Summary:

This is trying to implement the functionality proposed in:
http://lists.llvm.org/pipermail/cfe-dev/2017-April/053417.html
An exception can throw, but no cleanup is going to happen.
A module compiled with exceptions on, can catch the exception throws
from module compiled with -fignore-exceptions.

The use cases for enabling this option are:
1. Performance analysis of EH instrumentation overhead
2. The ability to QA non EH functionality when EH functionality is not available.
3. User of EH enabled headers knows the calls won't throw in their program and
   wants the performance gain from ignoring EH construct.

The implementation tried to accomplish that by removing any landing pad code
 that might get generated.

Reviewed by: aaron.ballman

Differential Revision: https://reviews.llvm.org/D72644
2020-02-12 09:56:18 +00:00

26 lines
727 B
C++

// RUN: %clang_cc1 %s -triple powerpc64-linux -fexceptions -fcxx-exceptions -fignore-exceptions -emit-llvm -o - | FileCheck %s
struct A {
~A(){}
};
void f(void) {
// CHECK-NOT: personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
A a;
try {
throw 1;
} catch(...) {
}
// CHECK: %a = alloca %struct.A, align 1
// CHECK: %exception = call i8* @__cxa_allocate_exception(i64 4) #1
// CHECK: %0 = bitcast i8* %exception to i32*
// CHECK: store i32 1, i32* %0, align 16
// CHECK: call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #2
// CHECK: unreachable
// CHECK-NOT: invoke
// CHECK-NOT: landingpad
// CHECK-NOT: __cxa_begin_catch
// CHECK-NOT: __cxa_end_catch
}