summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2018-09-28 16:17:59 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2018-09-28 16:17:59 +0000
commita5178f5369c499669055e546b87f23a7beb67f26 (patch)
tree94be0c2156739a668e51dd48c9ce80247bc6e76d /clang/lib
parentd22ee9461fd828b4afb6db331307416ab14e6b36 (diff)
downloadbcm5719-llvm-a5178f5369c499669055e546b87f23a7beb67f26.tar.gz
bcm5719-llvm-a5178f5369c499669055e546b87f23a7beb67f26.zip
[DRIVER][OFFLOAD] Do not invoke unbundler on unsupported file types.
clang-offload-bundler should not be invoked with the unbundling action when the input file type does not match the action type. For example, .so files should be unbundled during linking phase and should be linked only with the host code. llvm-svn: 343335
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Driver.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d3569836e0e..c5aed55eb94 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2568,6 +2568,8 @@ class OffloadingActionBuilder final {
getDeviceDependences(OffloadAction::DeviceDependences &DA,
phases::ID CurPhase, phases::ID FinalPhase,
PhasesTy &Phases) override {
+ if (OpenMPDeviceActions.empty())
+ return ABRT_Inactive;
// We should always have an action for each input.
assert(OpenMPDeviceActions.size() == ToolChains.size() &&
@@ -2611,6 +2613,17 @@ class OffloadingActionBuilder final {
// If this is an unbundling action use it as is for each OpenMP toolchain.
if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction)) {
OpenMPDeviceActions.clear();
+ auto *IA = cast<InputAction>(UA->getInputs().back());
+ std::string FileName = IA->getInputArg().getAsString(Args);
+ // Check if the type of the file is the same as the action. Do not
+ // unbundle it if it is not. Do not unbundle .so files, for example,
+ // which are not object files.
+ if (IA->getType() == types::TY_Object &&
+ (!llvm::sys::path::has_extension(FileName) ||
+ types::lookupTypeForExtension(
+ llvm::sys::path::extension(FileName).drop_front()) !=
+ types::TY_Object))
+ return ABRT_Inactive;
for (unsigned I = 0; I < ToolChains.size(); ++I) {
OpenMPDeviceActions.push_back(UA);
UA->registerDependentActionInfo(
@@ -2855,6 +2868,11 @@ public:
OffloadKind |= SB->getAssociatedOffloadKind();
}
+ // Do not use unbundler if the Host does not depend on device action.
+ if (OffloadKind == Action::OFK_None && CanUseBundler)
+ if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction))
+ HostAction = UA->getInputs().back();
+
return false;
}
OpenPOWER on IntegriCloud