[clang] [clang-repl] Emit an AMDGPU object for the HIP device module (PR #234498)

Aditya Sinha via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 22 02:23:42 PDT 2026


================
@@ -123,6 +123,33 @@ TEST(DeviceOffloadBuilderTest, MultipleOffloadArchsAreRejected) {
                               "supported. Pass a single --offload-arch"));
 }
 
+TEST(DeviceOffloadHIPTest, DeviceObjectIsGenerated) {
+  llvm::InitializeAllTargets();
+  llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllAsmPrinters();
+  std::string Err;
+  if (!llvm::TargetRegistry::lookupTarget(llvm::Triple("amdgcn-amd-amdhsa"),
+                                          Err))
+    GTEST_SKIP() << Err;
+
+  IncrementalCompilerBuilder CB;
+  CB.SetCompilerArgs({"--offload-arch=gfx1100", "-nogpulib", "-nogpuinc"});
+  auto DeviceCI = CB.CreateDevice(OffloadType::HIP);
+  ASSERT_THAT_EXPECTED(DeviceCI, llvm::Succeeded());
+  auto HostCI = CB.CreateHost(OffloadType::HIP);
+  ASSERT_THAT_EXPECTED(HostCI, llvm::Succeeded());
+  auto Interp = Interpreter::createWithDevice(
+      std::move(*HostCI), std::move(*DeviceCI), OffloadType::HIP);
+  ASSERT_THAT_EXPECTED(Interp, llvm::Succeeded());
+
+  // FIXME: Replace this with a check of the embedded bundle once the offload
----------------
AdityaSinha149 wrote:

Currently the `hip-not-supported.hip` is the equivalent lit test for this. Because we don't have a functionality of checking the module as of now, it also depends on execution. I also wanted to have some proper checks in between whole parser flow, So i was planning later we can add a/several dump option/s in clang-repl and test all the steps rather than just the flow.

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


More information about the cfe-commits mailing list