[PATCH] D38901: [CUDA] Require libdevice only if needed

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 13 12:57:24 PDT 2017


Hahnfeld created this revision.

If the user passes -nocudalib, we can live without it being present.
Simplify the code by just checking whether LibDeviceMap is empty.


https://reviews.llvm.org/D38901

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===================================================================
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -167,17 +167,9 @@
       }
     }
 
-    // This code prevents IsValid from being set when
-    // no libdevice has been found.
-    bool allEmpty = true;
-    std::string LibDeviceFile;
-    for (auto key : LibDeviceMap.keys()) {
-      LibDeviceFile = LibDeviceMap.lookup(key);
-      if (!LibDeviceFile.empty())
-        allEmpty = false;
-    }
-
-    if (allEmpty)
+    // Check that we have found at least one libdevice that we can link in if
+    // -nocudalib hasn't been specified.
+    if (LibDeviceMap.empty() && !Args.hasArg(options::OPT_nocudalib))
       continue;
 
     IsValid = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38901.118962.patch
Type: text/x-patch
Size: 781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171013/ca3b9565/attachment.bin>


More information about the cfe-commits mailing list