[PATCH] D12122: [CUDA] Add appropriate host/device attribute to target-specific builtins.

Eli Bendersky via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 18 16:05:30 PDT 2015


eliben added inline comments.

================
Comment at: include/clang/Basic/Builtins.h:85
@@ +84,3 @@
+  /// \brief Return true if this function is a target-specific builtin
+  bool isTSBuiltin(unsigned ID) const {
+    return ID >= Builtin::FirstTSBuiltin;
----------------
You can also use it in SemaChecking now

================
Comment at: lib/Sema/SemaDecl.cpp:11166
@@ +11165,3 @@
+        !FD->hasAttr<CUDADeviceAttr>() && !FD->hasAttr<CUDAHostAttr>()) {
+      if (getLangOpts().CUDAIsDevice)
+        FD->addAttr(CUDADeviceAttr::CreateImplicit(Context, FD->getLocation()));
----------------
It is not immediately clear why you would mark target-specific builtins as __host__ in host compilation mode. So for example __builtin_ptx_read_tid_x would be callable from a host function when compiling in host mode? Can you clarify this with a comment here, and also add a relevant test?


http://reviews.llvm.org/D12122





More information about the cfe-commits mailing list