[PATCH] D12871: [OpenMP] Target directive host codegen - rebased
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 21:41:12 PDT 2015
ABataev added inline comments.
================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3044-3054
@@ +3043,13 @@
+ Sizes.push_back(Size);
+ MapTypes.push_back(MapType);
+ }
+
+ // Keep track on whether the host function has to be executed.
+ auto OffloadErrorQType =
+ CGF.getContext().getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true);
+ auto OffloadError = CGF.CreateMemTemp(OffloadErrorQType, ".run_host_version");
+ CGF.EmitStoreOfScalar(llvm::Constant::getNullValue(CGM.Int32Ty), OffloadError,
+ /*Volatile=*/false, OffloadErrorQType);
+
+ // Fill up the pointer arrays and transfer execution to the device.
+ auto &&ThenGen = [this, BasePointers, Pointers, Sizes, MapTypes,
----------------
Not quite. getVLASize() works only for VLA types, while getTypeSize() works for types with constant size too.
================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3050
@@ +3049,3 @@
+ CGF.getContext().getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true);
+ auto OffloadError = CGF.CreateMemTemp(OffloadErrorQType, ".run_host_version");
+ CGF.EmitStoreOfScalar(llvm::Constant::getNullValue(CGM.Int32Ty), OffloadError,
----------------
Turn this to LValue like CGF.MakeAddrLValue(CGF.CreateMemTemp(OffloadErrorQType, ".run_host_version"), OffloadErrorQType); and use this Lvalue rather than Address.
================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3055-3057
@@ +3054,5 @@
+ // Fill up the pointer arrays and transfer execution to the device.
+ auto &&ThenGen = [this, BasePointers, Pointers, Sizes, MapTypes,
+ hasVLACaptures, Device, OffloadError,
+ OffloadErrorQType](CodeGenFunction &CGF) {
+ unsigned PointerNumVal = BasePointers.size();
----------------
Pointers, Sizes, MapTypes must be captured by reference.
================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3198-3204
@@ +3197,9 @@
+
+ // Notify that the host version must be executed.
+ auto &&ElseGen = [this, OffloadError,
+ OffloadErrorQType](CodeGenFunction &CGF) {
+ CGF.EmitStoreOfScalar(llvm::ConstantInt::get(CGM.Int32Ty, /*V=*/-1u),
+ OffloadError, /*Volatile=*/false, OffloadErrorQType);
+ };
+
+ if (IfCond) {
----------------
Move this to 'then' branch of the next if-stmt.
http://reviews.llvm.org/D12871
More information about the cfe-commits
mailing list