]> granicus.if.org Git - clang/commitdiff
fix PR10335 by watching out for IR type compatibility in call argument lists.
authorChris Lattner <sabre@nondot.org>
Tue, 12 Jul 2011 04:53:39 +0000 (04:53 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 12 Jul 2011 04:53:39 +0000 (04:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134966 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
test/CodeGen/call.c

index ab1ea69157a1b7c17fd1d834f85432bc256d13cc..c42571323ba5800a460ce4782a96b4d9c4e6a187 100644 (file)
@@ -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;
       }
index 2e923b303cd0cc076fee20d728574b65bb2d0448..cd8bd519935a067db1a7461792a9c4e09816e379 100644 (file)
@@ -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
+}
+