[clang] 67f189e - Make sure both cc1 and cc1as process -m[no-]code-object-v3
Konstantin Zhuravlyov via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 15 11:03:45 PDT 2020
Author: Konstantin Zhuravlyov
Date: 2020-10-15T14:03:26-04:00
New Revision: 67f189e93ce3c25db74697551a77831a72b34929
URL: https://github.com/llvm/llvm-project/commit/67f189e93ce3c25db74697551a77831a72b34929
DIFF: https://github.com/llvm/llvm-project/commit/67f189e93ce3c25db74697551a77831a72b34929.diff
LOG: Make sure both cc1 and cc1as process -m[no-]code-object-v3
Differential Revision: https://reviews.llvm.org/D89478
Added:
clang/test/Driver/amdgpu-features-as.s
Modified:
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/amdgpu-features.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 72ecc8cd9f3b..5df7236f0223 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -525,19 +525,6 @@ void AMDGPUToolChain::addClangTargetOptions(
CC1Args.push_back("hidden");
CC1Args.push_back("-fapply-global-visibility-to-externs");
}
-
- if (DriverArgs.hasArg(options::OPT_mcode_object_v3_legacy)) {
- getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
- "-mllvm --amdhsa-code-object-version=3";
- CC1Args.push_back("-mllvm");
- CC1Args.push_back("--amdhsa-code-object-version=3");
- }
- if (DriverArgs.hasArg(options::OPT_mno_code_object_v3_legacy)) {
- getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
- "-mllvm --amdhsa-code-object-version=2";
- CC1Args.push_back("-mllvm");
- CC1Args.push_back("--amdhsa-code-object-version=2");
- }
}
StringRef
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 39fcf240449c..d69dce650d94 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1073,6 +1073,25 @@ static const char *RelocationModelName(llvm::Reloc::Model Model) {
llvm_unreachable("Unknown Reloc::Model kind");
}
+static void HandleAmdgcnLegacyOptions(const Driver &D,
+ const ArgList &Args,
+ ArgStringList &CmdArgs) {
+ if (auto *CodeObjArg = Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ options::OPT_mno_code_object_v3_legacy)) {
+ if (CodeObjArg->getOption().getID() == options::OPT_mcode_object_v3_legacy) {
+ D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
+ "-mllvm --amdhsa-code-object-version=3";
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("--amdhsa-code-object-version=3");
+ } else {
+ D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
+ "-mllvm --amdhsa-code-object-version=2";
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("--amdhsa-code-object-version=2");
+ }
+ }
+}
+
void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs,
@@ -6122,6 +6141,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}
}
+ HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+
// For all the host OpenMP offloading compile jobs we need to pass the targets
// information using -fopenmp-targets= option.
if (JA.isHostOffloading(Action::OFK_OpenMP)) {
@@ -7085,6 +7106,8 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(SplitDebugName(JA, Args, Input, Output));
}
+ HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+
assert(Input.isFilename() && "Invalid input.");
CmdArgs.push_back(Input.getFilename());
diff --git a/clang/test/Driver/amdgpu-features-as.s b/clang/test/Driver/amdgpu-features-as.s
new file mode 100644
index 000000000000..850afe701740
--- /dev/null
+++ b/clang/test/Driver/amdgpu-features-as.s
@@ -0,0 +1,11 @@
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
+// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
+// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx900 -mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
+// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
+// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 -mno-code-object-v3 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=MUL-CODE-OBJECT-V3 %s
+// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
+// MUL-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
diff --git a/clang/test/Driver/amdgpu-features.c b/clang/test/Driver/amdgpu-features.c
index fb5ac073ed3d..a685870c764f 100644
--- a/clang/test/Driver/amdgpu-features.c
+++ b/clang/test/Driver/amdgpu-features.c
@@ -6,6 +6,10 @@
// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx700 -mcode-object-v3 -mno-code-object-v3 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=MUL-CODE-OBJECT-V3 %s
+// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
+// MUL-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
+
// RUN: %clang -### -target amdgcn-amdhsa -mcpu=gfx900:xnack+ %s 2>&1 | FileCheck --check-prefix=XNACK %s
// XNACK: "-target-feature" "+xnack"
More information about the cfe-commits
mailing list