[clang] [llvm] Reland - [Driver][SYCL] Add initial SYCL offload compilation support … (PR #117268)

Tom Honermann via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 22 09:08:07 PST 2024


================
@@ -6591,6 +6681,18 @@ const ToolChain &Driver::getOffloadingDeviceToolChain(
                                                            HostTC, Args);
       break;
     }
+    case Action::OFK_SYCL:
+      switch (Target.getArch()) {
+      case llvm::Triple::spir:
+      case llvm::Triple::spir64:
+      case llvm::Triple::spirv32:
+      case llvm::Triple::spirv64:
+        TC = std::make_unique<toolchains::SYCLToolChain>(*this, Target, HostTC,
+                                                         Args);
+        break;
+      default:
+        break;
+      }
     default:
       break;
----------------
tahonermann wrote:

There is an unconditional dereference of `TC` below and `TC` is known to be null in these default cases (as well as when neither of the `if` branches is taken for the `Action::OFK_HIP` case above). I think we should at least assert that `TC` is non-null below. Presumably these default cases (as well as the control flow path that doesn't assign `TC` in the `OFK_HIP` case) are intended to be unreachable, so an alternative is to add `llvm_unreachable()` calls in these locations.

https://github.com/llvm/llvm-project/pull/117268


More information about the llvm-commits mailing list