[OpenMP] Don't use bound architecture when checking cache on the host
authorJoseph Huber <jhuber6@vols.utk.edu>
Thu, 3 Feb 2022 00:07:39 +0000 (19:07 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 3 Feb 2022 22:17:38 +0000 (17:17 -0500)
When we are creating jobs for the new driver we first check the cache to
see if the job was already created as a part of the offloading
toolchain. This would sometimes fail if the bound architecture was set
for the host during offloading. We want to ingore this because it is not
relevant for looking up host actions. Previously it was set on some
machines and would cause the cache lookup to fail.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D118858

clang/lib/Driver/Driver.cpp
clang/test/Driver/openmp-offload-gpu.c

index 3bfddee..18dc656 100644 (file)
@@ -4828,9 +4828,11 @@ InputInfoList Driver::BuildJobsForActionNoCache(
 
     // We may have already built this action as a part of the offloading
     // toolchain, return the cached input if so.
+    StringRef Arch =
+        (TargetDeviceOffloadKind == Action::OFK_Host) ? StringRef() : BoundArch;
     std::pair<const Action *, std::string> ActionTC = {
         OA->getHostDependence(),
-        GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
+        GetTriplePlusArchString(TC, Arch, TargetDeviceOffloadKind)};
     if (CachedResults.find(ActionTC) != CachedResults.end()) {
       InputInfoList Inputs = CachedResults[ActionTC];
       Inputs.append(OffloadDependencesInputInfo);
index af7ba7c..a9fc3e7 100644 (file)
 // NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_INPUT:.+]]"], output: "[[HOST_BC:.+]]" 
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[DEVICE_INPUT:.+]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.+]]"
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_ASM]]"], output: "[[DEVICE_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_BC]]", "[[DEVICE_OBJ]]"], output: "[[HOST_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "[[LINKER:.+]]", inputs: ["[[HOST_OBJ]]"], output: "openmp-offload-gpu"
 
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:          --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc \