[clang] [NFC][clang][Driver] Restructure doOnEachDeviceDependence (PR #239492)
Aditya Sinha via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 5 22:51:44 PST 2026
https://github.com/AdityaSinha149 created https://github.com/llvm/llvm-project/pull/239492
This PR is an NFC change. It restructures the `OffloadAction::doOnEachDeviceDependence` function to be a bit concise and more readable.
>From 680c311b2be00965e3bcdde2dbc51d1946419ef7 Mon Sep 17 00:00:00 2001
From: AdityaSinha149 <adsinha at amd.com>
Date: Fri, 6 Nov 2026 12:16:12 +0530
Subject: [PATCH] [NFC][clang][Driver] Restructure doOnEachDeviceDependence
---
clang/lib/Driver/Action.cpp | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/clang/lib/Driver/Action.cpp b/clang/lib/Driver/Action.cpp
index 59bb8aa913933e..2944eaa7052062 100644
--- a/clang/lib/Driver/Action.cpp
+++ b/clang/lib/Driver/Action.cpp
@@ -250,24 +250,20 @@ void OffloadAction::doOnHostDependence(const OffloadActionWorkTy &Work) const {
void OffloadAction::doOnEachDeviceDependence(
const OffloadActionWorkTy &Work) const {
- auto I = getInputs().begin();
- auto E = getInputs().end();
- if (I == E)
- return;
-
// We expect to have the same number of input dependences and device tool
// chains, except if we also have a host dependence. In that case we have one
// more dependence than we have device tool chains.
assert(getInputs().size() == DevToolChains.size() + (HostTC ? 1 : 0) &&
"Sizes of action dependences and toolchains are not consistent!");
- // Skip host action
- if (HostTC)
- ++I;
-
auto TI = DevToolChains.begin();
- for (; I != E; ++I, ++TI)
+ for (auto I = getInputs().begin(), E = getInputs().end(); I != E; ++I) {
+ // The host action, if any, is the first input. Skip it.
+ if (I == getInputs().begin() && HostTC)
+ continue;
Work(*I, *TI, (*I)->getOffloadingArch());
+ ++TI;
+ }
}
void OffloadAction::doOnEachDependence(const OffloadActionWorkTy &Work) const {
More information about the cfe-commits
mailing list