forked from OSchip/llvm-project
At -O0, emit an @llvm.trap() call at the end of a value-returning function which
fails to return a value, to make debugging this issue easier. llvm-svn: 165914
This commit is contained in:
parent
feea5d6fb4
commit
6b4ebcc653
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue