[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
This revision was automatically updated to reflect the committed changes. Closed by commit rG10c779d2065f: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S (authored by pdhaliwal). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/amdgpu-openmp-toolchain.c Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -6,7 +6,7 @@ // verify the tools invocations // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}} // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}} -// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} +// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device"{{.*}}"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} // CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4394,7 +4394,13 @@ CmdArgs.push_back("-emit-llvm"); } else if (JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice && Args.hasArg(options::OPT_S) && + Args.hasArg(options::OPT_emit_llvm)) { +CmdArgs.push_back("-emit-llvm"); + } else { +CmdArgs.push_back("-emit-llvm-bc"); + } } else if (JA.getType() == types::TY_IFS || JA.getType() == types::TY_IFS_CPP) { StringRef ArgStr = Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -6,7 +6,7 @@ // verify the tools invocations // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}} // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}} -// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} +// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device"{{.*}}"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} // CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === ---
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
pdhaliwal added a comment. Tested on gfx906. The libomptarget tests are working as expected. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
pdhaliwal updated this revision to Diff 344763. pdhaliwal added a comment. Fixed the if-else logic Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/amdgpu-openmp-toolchain.c Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -6,7 +6,7 @@ // verify the tools invocations // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}} // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}} -// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} +// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device"{{.*}}"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} // CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4394,7 +4394,13 @@ CmdArgs.push_back("-emit-llvm"); } else if (JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice && Args.hasArg(options::OPT_S) && + Args.hasArg(options::OPT_emit_llvm)) { +CmdArgs.push_back("-emit-llvm"); + } else { +CmdArgs.push_back("-emit-llvm-bc"); + } } else if (JA.getType() == types::TY_IFS || JA.getType() == types::TY_IFS_CPP) { StringRef ArgStr = Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -6,7 +6,7 @@ // verify the tools invocations // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}} // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}} -// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} +// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device"{{.*}}"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}} // CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o" @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4394,7 +4394,13 @@
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
pdhaliwal added a comment. This is not working as expected. And has resulted in broken libomptarget tests. Reverting this until I find a different fix. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG7f78e409d028: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S (authored by pdhaliwal). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/amdgpu-openmp-toolchain.c Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4394,7 +4394,13 @@ CmdArgs.push_back("-emit-llvm"); } else if (JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice) { +if (Args.hasArg(options::OPT_S) && Args.hasArg(options::OPT_emit_llvm)) + CmdArgs.push_back("-emit-llvm"); + } else { +CmdArgs.push_back("-emit-llvm-bc"); + } } else if (JA.getType() == types::TY_IFS || JA.getType() == types::TY_IFS_CPP) { StringRef ArgStr = Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4394,7 +4394,13 @@ CmdArgs.push_back("-emit-llvm"); } else if (JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice) { +if (Args.hasArg(options::OPT_S) && Args.hasArg(options::OPT_emit_llvm)) + CmdArgs.push_back("-emit-llvm"); + } else { +CmdArgs.push_back("-emit-llvm-bc"); + } } else if (JA.getType() == types::TY_IFS || JA.getType() == types::TY_IFS_CPP) { StringRef ArgStr = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
JonChesterfield accepted this revision. JonChesterfield added a comment. This revision is now accepted and ready to land. Ah, yes. Thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
pdhaliwal added inline comments. Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4397 JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice) { JonChesterfield wrote: > Does unconditionally using emit-llvm here achieve the same result? Nope, it would start producing textual IR even when there was no -emit-llvm -S. This could be problematic since we always have been producing .bc files including our libraries. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
JonChesterfield added inline comments. Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4397 JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice) { Does unconditionally using emit-llvm here achieve the same result? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102065/new/ https://reviews.llvm.org/D102065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
pdhaliwal created this revision. pdhaliwal added reviewers: jdoerfert, JonChesterfield, ronlieb, gregrodgers. Herald added subscribers: kerbowa, guansong, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl. pdhaliwal requested review of this revision. Herald added subscribers: cfe-commits, sstefan1, wdng. Herald added a project: clang. Previously clang would print a binary blob into the bundled file for amdgcn. With this patch, it will instead print textual IR as expected. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D102065 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/amdgpu-openmp-toolchain.c Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4394,7 +4394,13 @@ CmdArgs.push_back("-emit-llvm"); } else if (JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice) { +if (Args.hasArg(options::OPT_S) && Args.hasArg(options::OPT_emit_llvm)) + CmdArgs.push_back("-emit-llvm"); + } else { +CmdArgs.push_back("-emit-llvm-bc"); + } } else if (JA.getType() == types::TY_IFS || JA.getType() == types::TY_IFS_CPP) { StringRef ArgStr = Index: clang/test/Driver/amdgpu-openmp-toolchain.c === --- clang/test/Driver/amdgpu-openmp-toolchain.c +++ clang/test/Driver/amdgpu-openmp-toolchain.c @@ -71,3 +71,6 @@ // CHECK-C: "x86_64-unknown-linux-gnu" - "clang" // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as" // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler" + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR +// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4394,7 +4394,13 @@ CmdArgs.push_back("-emit-llvm"); } else if (JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC) { - CmdArgs.push_back("-emit-llvm-bc"); + // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S + if (Triple.isAMDGCN() && IsOpenMPDevice) { +if (Args.hasArg(options::OPT_S) && Args.hasArg(options::OPT_emit_llvm)) + CmdArgs.push_back("-emit-llvm"); + } else { +CmdArgs.push_back("-emit-llvm-bc"); + } } else if (JA.getType() == types::TY_IFS || JA.getType() == types::TY_IFS_CPP) { StringRef ArgStr = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits