diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-12 04:53:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-12 04:53:39 +0000 |
commit | 3ce8668273c418a9f8c807e704d35f97e07a67a9 (patch) | |
tree | 5282fc7bfe3d443a283e89fd4b5ad353817a9e9d /clang | |
parent | 9b72b0c7d5818d4686f2390bfb0bb7fe6233c179 (diff) | |
download | bcm5719-llvm-3ce8668273c418a9f8c807e704d35f97e07a67a9.tar.gz bcm5719-llvm-3ce8668273c418a9f8c807e704d35f97e07a67a9.zip |
fix PR10335 by watching out for IR type compatibility in call argument lists.
llvm-svn: 134966
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 6 | ||||
-rw-r--r-- | clang/test/CodeGen/call.c | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index ab1ea69157a..c42571323ba 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1568,9 +1568,13 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, else V = Builder.CreateLoad(RV.getAggregateAddr()); + // If the argument doesn't match, perform a bitcast to coerce it. This + // can happen due to trivial type mismatches. + if (IRArgNo < IRFuncTy->getNumParams() && + V->getType() != IRFuncTy->getParamType(IRArgNo)) + V = Builder.CreateBitCast(V, IRFuncTy->getParamType(IRArgNo)); Args.push_back(V); - // Validate argument match. checkArgMatches(V, IRArgNo, IRFuncTy); break; } diff --git a/clang/test/CodeGen/call.c b/clang/test/CodeGen/call.c index 2e923b303cd..cd8bd519935 100644 --- a/clang/test/CodeGen/call.c +++ b/clang/test/CodeGen/call.c @@ -1,6 +1,6 @@ -// RUN: %clang %s -O0 -emit-llvm -S -o - | grep 'call.*rb_define_global_function' -// This should call rb_define_global_function, not rb_f_chop. +// RUN: %clang %s -O0 -emit-llvm -S -o - | FileCheck %s +// This should call rb_define_global_function, not rb_f_chop. void rb_define_global_function (const char*,void(*)(),int); static void rb_f_chop(); void Init_String() { @@ -9,3 +9,15 @@ void Init_String() { static void rb_f_chop() { } +// CHECK: call{{.*}}rb_define_global_function + +// PR10335 +typedef void (* JSErrorCallback)(void); +void js_GetErrorMessage(void); +void JS_ReportErrorNumber(JSErrorCallback errorCallback, ...); +void Interpret() { + JS_ReportErrorNumber(js_GetErrorMessage, 0); + + // CHECK: call void ({{.*}}, ...)* @JS_ReportErrorNumber({{.*}}@js_GetErrorMessage +} + |