From 6b4ebcc653b63c544a9eca39441e85a5a18f140f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 15 Oct 2012 00:23:07 +0000 Subject: 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 --- clang/lib/CodeGen/CodeGenFunction.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 8562d79..5f71af8 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/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()); + else if (CGM.getCodeGenOpts().OptimizationLevel == 0) + Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::trap)); Builder.CreateUnreachable(); Builder.ClearInsertionPoint(); } -- cgit v1.1