[clang] [Driver][HIP] Bundle AMDGPU -S output under the new offload driver (PR #188262)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 24 07:59:34 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang/include/clang/Driver/Driver.h clang/lib/Driver/Driver.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index e9a991464..5490e06b6 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -527,11 +527,11 @@ public:
/// \param HIPAsmBundleDeviceOut - If non-null, HIP non-RDC \c -S (AMDGCN)
/// device actions are appended here and \p HostAction is returned unchanged
/// so the caller can emit a bundled \c .s via \c OffloadBundlingJobAction.
- Action *BuildOffloadingActions(Compilation &C,
- llvm::opt::DerivedArgList &Args,
- const InputTy &Input, StringRef CUID,
- Action *HostAction,
- ActionList *HIPAsmBundleDeviceOut = nullptr) const;
+ Action *
+ BuildOffloadingActions(Compilation &C, llvm::opt::DerivedArgList &Args,
+ const InputTy &Input, StringRef CUID,
+ Action *HostAction,
+ ActionList *HIPAsmBundleDeviceOut = nullptr) const;
/// Returns the set of bound architectures active for this offload kind.
/// If there are no bound architctures we return a set containing only the
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0f4700947..424bf3af9 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4442,9 +4442,10 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
/// HIP non-RDC \c -S for AMDGCN: emit host and device assembly separately and
/// bundle with \c clang-offload-bundler (new offload driver), instead of
/// \c llvm-offload-binary / \c clang-linker-wrapper fatbin embedding.
-static bool shouldBundleHIPAsmWithNewDriver(const Compilation &C,
- const llvm::opt::DerivedArgList &Args,
- const Driver &D) {
+static bool
+shouldBundleHIPAsmWithNewDriver(const Compilation &C,
+ const llvm::opt::DerivedArgList &Args,
+ const Driver &D) {
if (!C.isOffloadingHostKind(Action::OFK_HIP))
return false;
if (!Args.hasArg(options::OPT_S) || Args.hasArg(options::OPT_emit_llvm))
@@ -4939,11 +4940,11 @@ Driver::getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
return Sorted;
}
-Action *Driver::BuildOffloadingActions(Compilation &C,
- llvm::opt::DerivedArgList &Args,
- const InputTy &Input, StringRef CUID,
- Action *HostAction,
- ActionList *HIPAsmBundleDeviceOut) const {
+Action *
+Driver::BuildOffloadingActions(Compilation &C, llvm::opt::DerivedArgList &Args,
+ const InputTy &Input, StringRef CUID,
+ Action *HostAction,
+ ActionList *HIPAsmBundleDeviceOut) const {
// Don't build offloading actions if explicitly disabled or we do not have a
// valid source input.
if (offloadHostOnly() || !types::isSrcFile(Input.first))
@@ -5147,7 +5148,8 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
*C.getOffloadToolChains<Action::OFK_HIP>().first->second, nullptr,
Action::OFK_HIP);
} else if (HIPNoRDC) {
- // Host + device assembly: defer to clang-offload-bundler (see BuildActions).
+ // Host + device assembly: defer to clang-offload-bundler (see
+ // BuildActions).
if (HIPAsmBundleDeviceOut &&
shouldBundleHIPAsmWithNewDriver(C, Args, C.getDriver())) {
for (Action *OA : OffloadActions)
@@ -5308,8 +5310,7 @@ Action *Driver::ConstructPhaseAction(
options::OPT_no_offload_new_driver,
C.getActiveOffloadKinds() != Action::OFK_None) &&
!offloadDeviceOnly() && !isSaveTempsEnabled() &&
- !(Args.hasArg(options::OPT_S) &&
- !Args.hasArg(options::OPT_emit_llvm)))
+ !(Args.hasArg(options::OPT_S) && !Args.hasArg(options::OPT_emit_llvm)))
return Input;
if (isUsingLTO() && TargetDeviceOffloadKind == Action::OFK_None) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/188262
More information about the cfe-commits
mailing list