Skip to content

Commit 5603cbd

Browse files
author
Salinas, David
authored
[Driver][HIP] Do not pass -dependency-file flag for HIP Device offloading (llvm#125646) (llvm#903)
2 parents b7a320c + 2e45e53 commit 5603cbd

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,21 +1041,23 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
10411041
ArgM = ArgMD;
10421042

10431043
if (ArgM) {
1044-
// Determine the output location.
1045-
const char *DepFile;
1046-
if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
1047-
DepFile = MF->getValue();
1048-
C.addFailureResultFile(DepFile, &JA);
1049-
} else if (Output.getType() == types::TY_Dependencies) {
1050-
DepFile = Output.getFilename();
1051-
} else if (!ArgMD) {
1052-
DepFile = "-";
1053-
} else {
1054-
DepFile = getDependencyFileName(Args, Inputs);
1055-
C.addFailureResultFile(DepFile, &JA);
1044+
if (!JA.isDeviceOffloading(Action::OFK_HIP)) {
1045+
// Determine the output location.
1046+
const char *DepFile;
1047+
if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
1048+
DepFile = MF->getValue();
1049+
C.addFailureResultFile(DepFile, &JA);
1050+
} else if (Output.getType() == types::TY_Dependencies) {
1051+
DepFile = Output.getFilename();
1052+
} else if (!ArgMD) {
1053+
DepFile = "-";
1054+
} else {
1055+
DepFile = getDependencyFileName(Args, Inputs);
1056+
C.addFailureResultFile(DepFile, &JA);
1057+
}
1058+
CmdArgs.push_back("-dependency-file");
1059+
CmdArgs.push_back(DepFile);
10561060
}
1057-
CmdArgs.push_back("-dependency-file");
1058-
CmdArgs.push_back(DepFile);
10591061

10601062
bool HasTarget = false;
10611063
for (const Arg *A : Args.filtered(options::OPT_MT, options::OPT_MQ)) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang -### -nogpuinc -nogpulib --offload-arch=gfx1030 --offload-arch=gfx1100 --offload-arch=gfx1101 --target=x86_64-linux-gnu -MD -MF tmp.d %s 2>&1 | FileCheck %s
2+
3+
// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1030"{{.*}}"-dependency-file" "tmp.d"
4+
// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1030"
5+
// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1100"{{.*}}"-dependency-file" "tmp.d"
6+
// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1100"
7+
// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1101"{{.*}}"-dependency-file" "tmp.d"
8+
// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1101"
9+
// CHECK: {{.*}}clang-offload-bundler
10+
// CHECK: {{.*}}clang{{.*}}"-target-cpu"{{.*}}"-dependency-file" "tmp.d"
11+
12+
void main(){}

0 commit comments

Comments
 (0)