[cfe-commits] r134966 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/CodeGen/call.c

Chris Lattner sabre at nondot.org
Mon Jul 11 21:53:39 PDT 2011


Author: lattner
Date: Mon Jul 11 23:53:39 2011
New Revision: 134966

URL: http://llvm.org/viewvc/llvm-project?rev=134966&view=rev
Log:
fix PR10335 by watching out for IR type compatibility in call argument lists.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/test/CodeGen/call.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=134966&r1=134965&r2=134966&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jul 11 23:53:39 2011
@@ -1568,9 +1568,13 @@
         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;
       }

Modified: cfe/trunk/test/CodeGen/call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/call.c?rev=134966&r1=134965&r2=134966&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/call.c (original)
+++ cfe/trunk/test/CodeGen/call.c Mon Jul 11 23:53:39 2011
@@ -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 @@
 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
+}
+





More information about the cfe-commits mailing list