This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGbde13a8102ba: [HIP] Fix job action offloading kind for mixed HIP/C++ compilation (authored by yaxunl). Herald added a project: clang.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120910/new/ https://reviews.llvm.org/D120910 Files: clang/lib/Driver/Driver.cpp clang/test/Driver/Inputs/empty.cpp clang/test/Driver/Inputs/empty.hip clang/test/Driver/hip-phases.hip Index: clang/test/Driver/hip-phases.hip =================================================================== --- clang/test/Driver/hip-phases.hip +++ clang/test/Driver/hip-phases.hip @@ -338,7 +338,7 @@ // RL2-NB-NOT: linker // RL2-NB-NOT: offload -// NL2-DAG: [[P4:[0-9]+]]: linker, {[[P0]], [[P2]]}, image, (host-[[T:hip]]) +// NL2-DAG: [[P4:[0-9]+]]: linker, {[[P0]], [[P2]]}, image // RL2-EM-DAG: [[P4:[0-9]+]]: linker, {[[P1]], [[P3]], [[P9]]}, image, (host-[[T]]) // RL2-DEV-NOT: linker @@ -455,3 +455,21 @@ // PPELLVM2-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH2]])" {[[P8]]}, ir // PPELLVM2-DAG: [[P10:[0-9]+]]: clang-offload-bundler, {[[P4]], [[P9]]}, ir, (device-hip, ) // PPELLVM2-NOT: host + +// Test mixed HIP and C++ compilation. HIP program should have HIP offload kind. +// C++ program should have no offload kind. + +// RUN: %clang -target x86_64-unknown-linux-gnu \ +// RUN: -ccc-print-phases --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \ +// RUN: -c %S/Inputs/empty.hip %S/Inputs/empty.cpp 2>&1 | FileCheck -check-prefixes=MIXED %s + +// RUN: %clang -target x86_64-unknown-linux-gnu \ +// RUN: -ccc-print-phases --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \ +// RUN: -c %S/Inputs/empty.hip %S/Inputs/empty.cpp 2>&1 | FileCheck -check-prefixes=MIXED-NEG %s + +// MIXED-DAG: input, "{{.*}}empty.hip", hip, (host-hip) +// MIXED-DAG: input, "{{.*}}empty.hip", hip, (device-hip, gfx803) +// MIXED-DAG: input, "{{.*}}empty.hip", hip, (device-hip, gfx900) +// MIXED-DAG: input, "{{.*}}empty.cpp", c++ +// MIXED-NEG-NOT: input, "{{.*}}empty.cpp", c++, (host-hip) +// MIXED-NEG-NOT: input, "{{.*}}empty.cpp", c++, (device-hip Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -2692,6 +2692,7 @@ UA->registerDependentActionInfo(ToolChains[0], Arch, AssociatedOffloadKind); } + IsActive = true; return ABRT_Success; } @@ -3038,6 +3039,9 @@ getDeviceDependences(OffloadAction::DeviceDependences &DA, phases::ID CurPhase, phases::ID FinalPhase, PhasesTy &Phases) override { + if (!IsActive) + return ABRT_Inactive; + // amdgcn does not support linking of object files, therefore we skip // backend and assemble phases to output LLVM IR. Except for generating // non-relocatable device coee, where we generate fat binary for device
Index: clang/test/Driver/hip-phases.hip =================================================================== --- clang/test/Driver/hip-phases.hip +++ clang/test/Driver/hip-phases.hip @@ -338,7 +338,7 @@ // RL2-NB-NOT: linker // RL2-NB-NOT: offload -// NL2-DAG: [[P4:[0-9]+]]: linker, {[[P0]], [[P2]]}, image, (host-[[T:hip]]) +// NL2-DAG: [[P4:[0-9]+]]: linker, {[[P0]], [[P2]]}, image // RL2-EM-DAG: [[P4:[0-9]+]]: linker, {[[P1]], [[P3]], [[P9]]}, image, (host-[[T]]) // RL2-DEV-NOT: linker @@ -455,3 +455,21 @@ // PPELLVM2-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH2]])" {[[P8]]}, ir // PPELLVM2-DAG: [[P10:[0-9]+]]: clang-offload-bundler, {[[P4]], [[P9]]}, ir, (device-hip, ) // PPELLVM2-NOT: host + +// Test mixed HIP and C++ compilation. HIP program should have HIP offload kind. +// C++ program should have no offload kind. + +// RUN: %clang -target x86_64-unknown-linux-gnu \ +// RUN: -ccc-print-phases --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \ +// RUN: -c %S/Inputs/empty.hip %S/Inputs/empty.cpp 2>&1 | FileCheck -check-prefixes=MIXED %s + +// RUN: %clang -target x86_64-unknown-linux-gnu \ +// RUN: -ccc-print-phases --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \ +// RUN: -c %S/Inputs/empty.hip %S/Inputs/empty.cpp 2>&1 | FileCheck -check-prefixes=MIXED-NEG %s + +// MIXED-DAG: input, "{{.*}}empty.hip", hip, (host-hip) +// MIXED-DAG: input, "{{.*}}empty.hip", hip, (device-hip, gfx803) +// MIXED-DAG: input, "{{.*}}empty.hip", hip, (device-hip, gfx900) +// MIXED-DAG: input, "{{.*}}empty.cpp", c++ +// MIXED-NEG-NOT: input, "{{.*}}empty.cpp", c++, (host-hip) +// MIXED-NEG-NOT: input, "{{.*}}empty.cpp", c++, (device-hip Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -2692,6 +2692,7 @@ UA->registerDependentActionInfo(ToolChains[0], Arch, AssociatedOffloadKind); } + IsActive = true; return ABRT_Success; } @@ -3038,6 +3039,9 @@ getDeviceDependences(OffloadAction::DeviceDependences &DA, phases::ID CurPhase, phases::ID FinalPhase, PhasesTy &Phases) override { + if (!IsActive) + return ABRT_Inactive; + // amdgcn does not support linking of object files, therefore we skip // backend and assemble phases to output LLVM IR. Except for generating // non-relocatable device coee, where we generate fat binary for device
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits