[cfe-commits] r108657 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/CodeGen/atomic.c

Chandler Carruth chandlerc at gmail.com
Sun Jul 18 13:54:12 PDT 2010


Author: chandlerc
Date: Sun Jul 18 15:54:12 2010
New Revision: 108657

URL: http://llvm.org/viewvc/llvm-project?rev=108657&view=rev
Log:
Fix a goof in my previous patch -- not all of the builtins return a value, some
fixed return types.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/CodeGen/atomic.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=108657&r1=108656&r2=108657&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Jul 18 15:54:12 2010
@@ -419,6 +419,10 @@
     return ExprError();
   }
 
+  // The majority of builtins return a value, but a few have special return
+  // types, so allow them to override appropriately below.
+  QualType ResultType = ValType;
+
   // We need to figure out which concrete builtin this maps onto.  For example,
   // __sync_fetch_and_add with a 2 byte object turns into
   // __sync_fetch_and_add_2.
@@ -487,11 +491,13 @@
   case Builtin::BI__sync_bool_compare_and_swap:
     BuiltinIndex = 11;
     NumFixed = 2;
+    ResultType = Context.BoolTy;
     break;
   case Builtin::BI__sync_lock_test_and_set: BuiltinIndex = 12; break;
   case Builtin::BI__sync_lock_release:
     BuiltinIndex = 13;
     NumFixed = 0;
+    ResultType = Context.VoidTy;
     break;
   }
 
@@ -558,7 +564,7 @@
   // Change the result type of the call to match the original value type. This
   // is arbitrary, but the codegen for these builtins ins design to handle it
   // gracefully.
-  TheCall->setType(ValType);
+  TheCall->setType(ResultType);
 
   return move(TheCallResult);
 }

Modified: cfe/trunk/test/CodeGen/atomic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomic.c?rev=108657&r1=108656&r2=108657&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/atomic.c (original)
+++ cfe/trunk/test/CodeGen/atomic.c Sun Jul 18 15:54:12 2010
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 > %t1
-// RUN: grep @llvm.memory.barrier %t1 | count 40
+// RUN: grep @llvm.memory.barrier %t1 | count 42
 // RUN: grep @llvm.atomic.load.add.i32 %t1 | count 3
 // RUN: grep @llvm.atomic.load.sub.i8 %t1 | count 2
 // RUN: grep @llvm.atomic.load.min.i32 %t1
@@ -7,7 +7,7 @@
 // RUN: grep @llvm.atomic.load.umin.i32 %t1
 // RUN: grep @llvm.atomic.load.umax.i32 %t1
 // RUN: grep @llvm.atomic.swap.i32 %t1
-// RUN: grep @llvm.atomic.cmp.swap.i32 %t1 | count 4
+// RUN: grep @llvm.atomic.cmp.swap.i32 %t1 | count 5
 // RUN: grep @llvm.atomic.load.and.i32 %t1
 // RUN: grep @llvm.atomic.load.or.i8 %t1
 // RUN: grep @llvm.atomic.load.xor.i8 %t1
@@ -47,10 +47,15 @@
   if ( __sync_val_compare_and_swap(&valb, 0, 1)) {
     old = 42;
   }
-
+  __sync_bool_compare_and_swap((void **)0, (void *)0, (void *)0);
   
   __sync_lock_release(&val);
   __sync_synchronize ();
 
   return old;
 }
+
+void release_return(int *lock) {
+  // Ensure this is actually returning void all the way through.
+  return __sync_lock_release(lock);
+}





More information about the cfe-commits mailing list