From bd7370a78604e9a20d698bfe328c1e43f12a0613 Mon Sep 17 00:00:00 2001 From: John McCall Date: Thu, 28 Feb 2013 19:01:20 +0000 Subject: Use the actual ABI-determined C calling convention for runtime calls and declarations. LLVM has a default CC determined by the target triple. This is not always the actual default CC for the ABI we've been asked to target, and so we sometimes find ourselves annotating all user functions with an explicit calling convention. Since these calling conventions usually agree for the simple set of argument types passed to most runtime functions, using the LLVM-default CC in principle has no effect. However, the LLVM optimizer goes into histrionics if it sees this kind of formal CC mismatch, since it has no concept of CC compatibility. Therefore, if this module happens to define the "runtime" function, or got LTO'ed with such a definition, we can miscompile; so it's quite important to get this right. Defining runtime functions locally is quite common in embedded applications. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176286 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenFunction.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/CodeGen/CodeGenFunction.cpp') diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index e2a18d3eb9..973ee88086 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -258,9 +258,12 @@ void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) { llvm::ConstantInt::get(Int32Ty, 0), "callsite"); - Builder.CreateCall2(F, - llvm::ConstantExpr::getBitCast(CurFn, PointerTy), - CallSite); + llvm::Value *args[] = { + llvm::ConstantExpr::getBitCast(CurFn, PointerTy), + CallSite + }; + + EmitNounwindRuntimeCall(F, args); } void CodeGenFunction::EmitMCountInstrumentation() { @@ -268,7 +271,7 @@ void CodeGenFunction::EmitMCountInstrumentation() { llvm::Constant *MCountFn = CGM.CreateRuntimeFunction(FTy, Target.getMCountName()); - Builder.CreateCall(MCountFn); + EmitNounwindRuntimeCall(MCountFn); } // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument -- cgit v1.2.3-18-g5258