[PATCH] D44985: Remove initializer for CUDA shared varirable

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 29 13:54:53 PDT 2018


tra added inline comments.


================
Comment at: lib/CodeGen/CGDecl.cpp:235-240
+  if (Ty.getAddressSpace() != LangAS::opencl_local &&
+      !(getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+        D.hasAttr<CUDASharedAttr>()))
     Init = EmitNullConstant(Ty);
   else
     Init = llvm::UndefValue::get(LTy);
----------------
This is too hard to read. Inverting it makes it somewhat easier to understand -- `either opencl_local or device-side CUDA shared are undef`.
```
  if (Ty.getAddressSpace() == LangAS::opencl_local 
      || (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
          D.hasAttr<CUDASharedAttr>()))
    Init = llvm::UndefValue::get(LTy);
  else
    Init = EmitNullConstant(Ty);
```



https://reviews.llvm.org/D44985





More information about the cfe-commits mailing list