[clang] [CIR] Honor -fembed-bitcode (PR #231482)
Arseniy Obolenskiy via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 21:17:46 PDT 2026
https://github.com/aobolensk updated https://github.com/llvm/llvm-project/pull/231482
>From f6ea35d08b51aa76e2cb3c629e19497655bbb770 Mon Sep 17 00:00:00 2001
From: Arseniy Obolenskiy <arseniy.obolenskiy at amd.com>
Date: Tue, 13 Oct 2026 14:40:01 +0200
Subject: [PATCH] [CIR] Honor -fembed-bitcode
Runtime JIT reads flags like -O3 from the embedded command line, so without it, the runtime JIT compiles HIP SPIR-V at -O0
---
clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 2 ++
clang/test/CIR/CodeGenHIP/embed-bitcode-marker.hip | 9 +++++++++
2 files changed, 11 insertions(+)
create mode 100644 clang/test/CIR/CodeGenHIP/embed-bitcode-marker.hip
diff --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
index 71a7a17146af3d..99ba60e287dadf 100644
--- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
+++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
@@ -273,6 +273,8 @@ class CIRGenConsumer : public clang::ASTConsumer {
EmbedObject(LLVMModule.get(), CGO, CI.getVirtualFileSystem(),
CI.getDiagnostics());
+ EmbedBitcode(LLVMModule.get(), CGO, llvm::MemoryBufferRef());
+
BackendAction BEAction = getBackendActionFromOutputType(Action);
emitBackendOutput(CI, CI.getCodeGenOpts(), LLVMModule.get(), BEAction, FS,
std::move(OutputStream));
diff --git a/clang/test/CIR/CodeGenHIP/embed-bitcode-marker.hip b/clang/test/CIR/CodeGenHIP/embed-bitcode-marker.hip
new file mode 100644
index 00000000000000..5cf35d979b187d
--- /dev/null
+++ b/clang/test/CIR/CodeGenHIP/embed-bitcode-marker.hip
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple spirv64-amd-amdhsa -x hip -fclangir \
+// RUN: -fcuda-is-device -fembed-bitcode=marker -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// CHECK: @llvm.embedded.module = private addrspace(1) constant [0 x i8] zeroinitializer, section ".llvmbc", align 1
+// CHECK: @llvm.cmdline = private addrspace(1) constant [{{[0-9]+}} x i8] c"{{.*}}", section ".llvmcmd", align 1
+// CHECK: @llvm.compiler.used = {{.*}}@llvm.embedded.module{{.*}}@llvm.cmdline
+
+__attribute__((global)) void k() {}
More information about the cfe-commits
mailing list