diff options
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenCXX/return.cpp | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 8562d79ebf..5f71af8082 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -547,6 +547,8 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, EmitCheck(Builder.getFalse(), "missing_return", EmitCheckSourceLocation(FD->getLocation()), llvm::ArrayRef<llvm::Value*>()); + else if (CGM.getCodeGenOpts().OptimizationLevel == 0) + Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::trap)); Builder.CreateUnreachable(); Builder.ClearInsertionPoint(); } diff --git a/test/CodeGenCXX/return.cpp b/test/CodeGenCXX/return.cpp index 2af1a5266e..43d40ae986 100644 --- a/test/CodeGenCXX/return.cpp +++ b/test/CodeGenCXX/return.cpp @@ -1,6 +1,12 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O0 -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O -o - %s | FileCheck %s --check-prefix=CHECK-OPT -// CHECK: @_Z9no_return +// CHECK: @_Z9no_return +// CHECK-OPT: @_Z9no_return int no_return() { - // CHECK: unreachable + // CHECK: call void @llvm.trap + // CHECK-NEXT: unreachable + + // CHECK-OPT-NOT: call void @llvm.trap + // CHECK-OPT: unreachable } |