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

Chris Lattner sabre at nondot.org
Tue Jul 12 20:59:32 PDT 2011


Author: lattner
Date: Tue Jul 12 22:59:32 2011
New Revision: 135030

URL: http://llvm.org/viewvc/llvm-project?rev=135030&view=rev
Log:
PR10337 reminds me that calls return values, lets handle them just
like arguments.  Thanks PR10337! :)

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=135030&r1=135029&r2=135030&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Jul 12 22:59:32 2011
@@ -1742,8 +1742,8 @@
 
   case ABIArgInfo::Extend:
   case ABIArgInfo::Direct: {
-    if (RetAI.getCoerceToType() == ConvertType(RetTy) &&
-        RetAI.getDirectOffset() == 0) {
+    llvm::Type *RetIRTy = ConvertType(RetTy);
+    if (RetAI.getCoerceToType() == RetIRTy && RetAI.getDirectOffset() == 0) {
       if (RetTy->isAnyComplexType()) {
         llvm::Value *Real = Builder.CreateExtractValue(CI, 0);
         llvm::Value *Imag = Builder.CreateExtractValue(CI, 1);
@@ -1760,7 +1760,13 @@
         BuildAggStore(*this, CI, DestPtr, DestIsVolatile, false);
         return RValue::getAggregate(DestPtr);
       }
-      return RValue::get(CI);
+      
+      // If the argument doesn't match, perform a bitcast to coerce it.  This
+      // can happen due to trivial type mismatches.
+      llvm::Value *V = CI;
+      if (V->getType() != RetIRTy)
+        V = Builder.CreateBitCast(V, RetIRTy);
+      return RValue::get(V);
     }
 
     llvm::Value *DestPtr = ReturnValue.getValue();

Modified: cfe/trunk/test/CodeGen/call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/call.c?rev=135030&r1=135029&r2=135030&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/call.c (original)
+++ cfe/trunk/test/CodeGen/call.c Tue Jul 12 22:59:32 2011
@@ -21,3 +21,19 @@
   // CHECK: call void ({{.*}}, ...)* @JS_ReportErrorNumber({{.*}}@js_GetErrorMessage
 }
 
+
+
+
+// PR10337
+struct sigaction { int (*_sa_handler)(int); };
+typedef int SigHandler ();
+typedef struct sigaction sighandler_cxt;
+SigHandler *rl_set_sighandler(ohandler)
+sighandler_cxt *ohandler;  {
+  return 0;
+}
+
+void rl_set_signals() {
+  SigHandler *oh;
+  oh = rl_set_sighandler(0);
+}





More information about the cfe-commits mailing list