summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorSamuel Antao <sfantao@us.ibm.com>2016-10-27 18:00:51 +0000
committerSamuel Antao <sfantao@us.ibm.com>2016-10-27 18:00:51 +0000
commitfab4f37ef7e81dfa25070cf6f5488980a0c687bf (patch)
treef43cd013e6b346b3fb2ae5f8a88ae7d514922fd8 /clang/lib/Driver/Driver.cpp
parent69d6f31f744a8b3dcb1a3fecae41a9d6f667b476 (diff)
downloadbcm5719-llvm-fab4f37ef7e81dfa25070cf6f5488980a0c687bf.tar.gz
bcm5719-llvm-fab4f37ef7e81dfa25070cf6f5488980a0c687bf.zip
[Driver][OpenMP] Update actions builder to create unbundling action when necessary.
Summary: Each time that offloading support is requested by the user and the input file is not a source file, an action `OffloadUnbundlingAction` is created to signal that the input file may contain bundles, so that the proper tool is then invoked to attempt to extract the components of the bundle. This patch adds the logic to create that action in offload action builder. The job creation for the new action will be proposed in a separate patch. Reviewers: echristo, tra, jlebar, ABataev, hfinkel Subscribers: whchung, mehdi_amini, cfe-commits, Hahnfeld, andreybokhanko, arpith-jacob, carlo.bertolli, caomhin Differential Revision: https://reviews.llvm.org/D21853 llvm-svn: 285324
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8d96284a69b..2712efb0ffe 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1891,6 +1891,17 @@ class OffloadingActionBuilder final {
return ABRT_Success;
}
+ // If this is an unbundling action use it as is for each OpenMP toolchain.
+ if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction)) {
+ OpenMPDeviceActions.clear();
+ for (unsigned I = 0; I < ToolChains.size(); ++I) {
+ OpenMPDeviceActions.push_back(UA);
+ UA->registerDependentActionInfo(
+ ToolChains[I], /*BoundArch=*/StringRef(), Action::OFK_OpenMP);
+ }
+ return ABRT_Success;
+ }
+
// When generating code for OpenMP we use the host compile phase result as
// a dependence to the device compile phase so that it can learn what
// declarations should be emitted. However, this is not the only use for
@@ -2081,11 +2092,28 @@ public:
/// Generate an action that adds a host dependence to a device action. The
/// results will be kept in this action builder. Return true if an error was
/// found.
- bool addHostDependenceToDeviceActions(Action *HostAction,
+ bool addHostDependenceToDeviceActions(Action *&HostAction,
const Arg *InputArg) {
if (!IsValid)
return true;
+ // If we are supporting bundling/unbundling and the current action is an
+ // input action of non-source file, we replace the host action by the
+ // unbundling action. The bundler tool has the logic to detect if an input
+ // is a bundle or not and if the input is not a bundle it assumes it is a
+ // host file. Therefore it is safe to create an unbundling action even if
+ // the input is not a bundle.
+ if (CanUseBundler && isa<InputAction>(HostAction) &&
+ InputArg->getOption().getKind() == llvm::opt::Option::InputClass &&
+ !types::isSrcFile(HostAction->getType())) {
+ auto UnbundlingHostAction =
+ C.MakeAction<OffloadUnbundlingJobAction>(HostAction);
+ UnbundlingHostAction->registerDependentActionInfo(
+ C.getSingleOffloadToolChain<Action::OFK_Host>(),
+ /*BoundArch=*/StringRef(), Action::OFK_Host);
+ HostAction = UnbundlingHostAction;
+ }
+
assert(HostAction && "Invalid host action!");
// Register the offload kinds that are used.
OpenPOWER on IntegriCloud