[cfe-commits] r127616 - in /cfe/trunk: lib/CodeGen/CGBuiltin.cpp test/CodeGen/arm-clear.c
Eric Christopher
echristo at apple.com
Mon Mar 14 13:30:34 PDT 2011
Author: echristo
Date: Mon Mar 14 15:30:34 2011
New Revision: 127616
URL: http://llvm.org/viewvc/llvm-project?rev=127616&view=rev
Log:
__clear_cache() is varargs and people will occasionally write it without
arguments. Process only the arguments that people write, but process
all of them.
Fixes rdar://8900346
Added:
cfe/trunk/test/CodeGen/arm-clear.c
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=127616&r1=127615&r2=127616&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Mar 14 15:30:34 2011
@@ -1116,13 +1116,16 @@
const CallExpr *E) {
if (BuiltinID == ARM::BI__clear_cache) {
const FunctionDecl *FD = E->getDirectCallee();
- Value *a = EmitScalarExpr(E->getArg(0));
- Value *b = EmitScalarExpr(E->getArg(1));
+ // Oddly people write this call without args on occasion and gcc accepts
+ // it - it's also marked as varargs in the description file.
+ llvm::SmallVector<Value*, 2> Ops;
+ for (unsigned i = 0; i < E->getNumArgs(); i++)
+ Ops.push_back(EmitScalarExpr(E->getArg(i)));
const llvm::Type *Ty = CGM.getTypes().ConvertType(FD->getType());
const llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty);
llvm::StringRef Name = FD->getName();
- return Builder.CreateCall2(CGM.CreateRuntimeFunction(FTy, Name),
- a, b);
+ return Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ Ops.begin(), Ops.end());
}
llvm::SmallVector<Value*, 4> Ops;
Added: cfe/trunk/test/CodeGen/arm-clear.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-clear.c?rev=127616&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/arm-clear.c (added)
+++ cfe/trunk/test/CodeGen/arm-clear.c Mon Mar 14 15:30:34 2011
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s
+
+void clear0(void *ptr) {
+ // CHECK: clear0
+ // CHECK-NOT: load i8**
+ __clear_cache();
+}
+
+void clear1(void *ptr) {
+ // CHECK: clear1
+ // CHECK: load i8**
+ // CHECK-NOT: load i8**
+ __clear_cache(ptr);
+}
+
+void clear2(void *ptr, void *ptr2) {
+ // CHECK: clear2
+ // CHECK: load i8**
+ // CHECK: load i8**
+ __clear_cache(ptr, ptr2);
+}
More information about the cfe-commits
mailing list