Skip to content

Commit 67f189e

Browse files
committed
Make sure both cc1 and cc1as process -m[no-]code-object-v3
Differential Revision: https://reviews.llvm.org/D89478
1 parent 6abc15a commit 67f189e

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -525,19 +525,6 @@ void AMDGPUToolChain::addClangTargetOptions(
525525
CC1Args.push_back("hidden");
526526
CC1Args.push_back("-fapply-global-visibility-to-externs");
527527
}
528-
529-
if (DriverArgs.hasArg(options::OPT_mcode_object_v3_legacy)) {
530-
getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
531-
"-mllvm --amdhsa-code-object-version=3";
532-
CC1Args.push_back("-mllvm");
533-
CC1Args.push_back("--amdhsa-code-object-version=3");
534-
}
535-
if (DriverArgs.hasArg(options::OPT_mno_code_object_v3_legacy)) {
536-
getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
537-
"-mllvm --amdhsa-code-object-version=2";
538-
CC1Args.push_back("-mllvm");
539-
CC1Args.push_back("--amdhsa-code-object-version=2");
540-
}
541528
}
542529

543530
StringRef

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,25 @@ static const char *RelocationModelName(llvm::Reloc::Model Model) {
10731073
llvm_unreachable("Unknown Reloc::Model kind");
10741074
}
10751075

1076+
static void HandleAmdgcnLegacyOptions(const Driver &D,
1077+
const ArgList &Args,
1078+
ArgStringList &CmdArgs) {
1079+
if (auto *CodeObjArg = Args.getLastArg(options::OPT_mcode_object_v3_legacy,
1080+
options::OPT_mno_code_object_v3_legacy)) {
1081+
if (CodeObjArg->getOption().getID() == options::OPT_mcode_object_v3_legacy) {
1082+
D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
1083+
"-mllvm --amdhsa-code-object-version=3";
1084+
CmdArgs.push_back("-mllvm");
1085+
CmdArgs.push_back("--amdhsa-code-object-version=3");
1086+
} else {
1087+
D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
1088+
"-mllvm --amdhsa-code-object-version=2";
1089+
CmdArgs.push_back("-mllvm");
1090+
CmdArgs.push_back("--amdhsa-code-object-version=2");
1091+
}
1092+
}
1093+
}
1094+
10761095
void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
10771096
const Driver &D, const ArgList &Args,
10781097
ArgStringList &CmdArgs,
@@ -6122,6 +6141,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
61226141
}
61236142
}
61246143

6144+
HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
6145+
61256146
// For all the host OpenMP offloading compile jobs we need to pass the targets
61266147
// information using -fopenmp-targets= option.
61276148
if (JA.isHostOffloading(Action::OFK_OpenMP)) {
@@ -7085,6 +7106,8 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
70857106
CmdArgs.push_back(SplitDebugName(JA, Args, Input, Output));
70867107
}
70877108

7109+
HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
7110+
70887111
assert(Input.isFilename() && "Invalid input.");
70897112
CmdArgs.push_back(Input.getFilename());
70907113

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
2+
// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
3+
// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
4+
5+
// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx900 -mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
6+
// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
7+
// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
8+
9+
// 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
10+
// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
11+
// MUL-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"

clang/test/Driver/amdgpu-features.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
77
// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
88

9+
// 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
10+
// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
11+
// MUL-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
12+
913
// RUN: %clang -### -target amdgcn-amdhsa -mcpu=gfx900:xnack+ %s 2>&1 | FileCheck --check-prefix=XNACK %s
1014
// XNACK: "-target-feature" "+xnack"
1115

0 commit comments

Comments
 (0)