summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGBuiltin.cpp
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2016-11-14 17:39:58 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2016-11-14 17:39:58 +0000
commit0df4ac3f94fc02df2d1263893a38a894e32078ea (patch)
tree60e22252168ce91bf30df1687f1e3709dd3fcc4d /clang/lib/CodeGen/CGBuiltin.cpp
parente1e344ed05bb83787ed90524154b7b04ddc49759 (diff)
downloadbcm5719-llvm-0df4ac3f94fc02df2d1263893a38a894e32078ea.tar.gz
bcm5719-llvm-0df4ac3f94fc02df2d1263893a38a894e32078ea.zip
[OpenCL] Fix for integer parameters of enqueue_kernel
Make handling integer parameters more flexible: - For the number of events argument allow to pass larger integers than 32 bits as soon as compiler can prove that the range fits in 32 bits. If not, the diagnostic will be given. - Change type of the arguments specifying the sizes of the corresponding block arguments to be size_t. Review: https://reviews.llvm.org/D26509 llvm-svn: 286849
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 162a02ee512..8aa831ab083 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2517,17 +2517,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
std::vector<llvm::Type *> ArgTys = {QueueTy, IntTy, RangeTy, Int8PtrTy,
IntTy};
- // Add the variadics.
- for (unsigned I = 4; I < NumArgs; ++I) {
- llvm::Value *ArgSize = EmitScalarExpr(E->getArg(I));
- unsigned TypeSizeInBytes =
- getContext()
- .getTypeSizeInChars(E->getArg(I)->getType())
- .getQuantity();
- Args.push_back(TypeSizeInBytes < 4
- ? Builder.CreateZExt(ArgSize, Int32Ty)
- : ArgSize);
- }
+ // Each of the following arguments specifies the size of the corresponding
+ // argument passed to the enqueued block.
+ for (unsigned I = 4/*Position of the first size arg*/; I < NumArgs; ++I)
+ Args.push_back(
+ Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)), SizeTy));
llvm::FunctionType *FTy = llvm::FunctionType::get(
Int32Ty, llvm::ArrayRef<llvm::Type *>(ArgTys), true);
@@ -2541,7 +2535,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
llvm::Type *EventPtrTy = EventTy->getPointerTo(
CGM.getContext().getTargetAddressSpace(LangAS::opencl_generic));
- llvm::Value *NumEvents = EmitScalarExpr(E->getArg(3));
+ llvm::Value *NumEvents =
+ Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(3)), Int32Ty);
llvm::Value *EventList =
E->getArg(4)->getType()->isArrayType()
? EmitArrayToPointerDecay(E->getArg(4)).getPointer()
@@ -2575,17 +2570,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
ArgTys.push_back(Int32Ty);
Name = "__enqueue_kernel_events_vaargs";
- // Add the variadics.
- for (unsigned I = 7; I < NumArgs; ++I) {
- llvm::Value *ArgSize = EmitScalarExpr(E->getArg(I));
- unsigned TypeSizeInBytes =
- getContext()
- .getTypeSizeInChars(E->getArg(I)->getType())
- .getQuantity();
- Args.push_back(TypeSizeInBytes < 4
- ? Builder.CreateZExt(ArgSize, Int32Ty)
- : ArgSize);
- }
+ // Each of the following arguments specifies the size of the corresponding
+ // argument passed to the enqueued block.
+ for (unsigned I = 7/*Position of the first size arg*/; I < NumArgs; ++I)
+ Args.push_back(
+ Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)), SizeTy));
+
llvm::FunctionType *FTy = llvm::FunctionType::get(
Int32Ty, llvm::ArrayRef<llvm::Type *>(ArgTys), true);
return RValue::get(
OpenPOWER on IntegriCloud