[PATCH] D97273: OpenMP: Fix object clobbering issue when using save-temps

Pushpinder Singh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 23 08:05:26 PST 2021


pdhaliwal added a comment.

Here's a bit of background,
OffloadingPrefix was not getting properly set in the dependent actions of OffloadWrapperJobAction (which are backend [11] and assemble [12]). Since backend [11] and assemble [12] host-wrapper actions have same logic to the other host actions (3 & 4), those will overwrite the previous generated files from host-only actions.

For e.g. following were the names generated for output files previously (marked as bold). (clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -ccc-print-bindings helloworld.c -o helloworld)

1. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld.c"], output: "helloworld-host-x86_64-unknown-linux-gnu.i"
2. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld-host-x86_64-unknown-linux-gnu.i"], output: "helloworld-host-x86_64-unknown-linux-gnu.bc"
3. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld-host-x86_64-unknown-linux-gnu.bc"], output: "helloworld-host-x86_64-unknown-linux-gnu.s"
4. "x86_64-unknown-linux-gnu" - "clang::as", inputs: ["helloworld-host-x86_64-unknown-linux-gnu.s"], output: "helloworld-host-x86_64-unknown-linux-gnu.o"
5. "nvptx64-nvidia-cuda" - "clang", inputs: ["helloworld.c"], output: "helloworld-openmp-nvptx64-nvidia-cuda.i"
6. "nvptx64-nvidia-cuda" - "clang", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.i", "helloworld-host-x86_64-unknown-linux-gnu.bc"], output: "helloworld-openmp-nvptx64-nvidia-cuda.bc"
7. "nvptx64-nvidia-cuda" - "clang", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.bc"], output: "helloworld-openmp-nvptx64-nvidia-cuda.s"
8. "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.s"], output: "helloworld-openmp-nvptx64-nvidia-cuda.o"
9. "nvptx64-nvidia-cuda" - "NVPTX::OpenMPLinker", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.o"], output: "a.out-openmp-nvptx64-nvidia-cuda"
10. "x86_64-unknown-linux-gnu" - "offload wrapper", inputs: ["a.out-openmp-nvptx64-nvidia-cuda"], output: "**helloworld-host-x86_64-unknown-linux-gnu-wrapper.bc**"
11. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld-host-x86_64-unknown-linux-gnu-wrapper.bc"], output: "**helloworld-host-x86_64-unknown-linux-gnu.s**"
12. "x86_64-unknown-linux-gnu" - "clang::as", inputs: ["helloworld-host-x86_64-unknown-linux-gnu.s"], output: "**helloworld-host-x86_64-unknown-linux-gnu.o**"
13. "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["**helloworld-host-x86_64-unknown-linux-gnu.o", "helloworld-host-x86_64-unknown-linux-gnu.o**"], output: "helloworld"

And here are names generated after this patch applied,

1. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld.c"], output: "helloworld-host-x86_64-unknown-linux-gnu.i"
2. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld-host-x86_64-unknown-linux-gnu.i"], output: "helloworld-host-x86_64-unknown-linux-gnu.bc"
3. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld-host-x86_64-unknown-linux-gnu.bc"], output: "helloworld-host-x86_64-unknown-linux-gnu.s"
4. "x86_64-unknown-linux-gnu" - "clang::as", inputs: ["helloworld-host-x86_64-unknown-linux-gnu.s"], output: "helloworld-host-x86_64-unknown-linux-gnu.o"
5. "nvptx64-nvidia-cuda" - "clang", inputs: ["helloworld.c"], output: "helloworld-openmp-nvptx64-nvidia-cuda.i"
6. "nvptx64-nvidia-cuda" - "clang", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.i", "helloworld-host-x86_64-unknown-linux-gnu.bc"], output: "helloworld-openmp-nvptx64-nvidia-cuda.bc"
7. "nvptx64-nvidia-cuda" - "clang", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.bc"], output: "helloworld-openmp-nvptx64-nvidia-cuda.s"
8. "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.s"], output: "helloworld-openmp-nvptx64-nvidia-cuda.o"
9. "nvptx64-nvidia-cuda" - "NVPTX::OpenMPLinker", inputs: ["helloworld-openmp-nvptx64-nvidia-cuda.o"], output: "a.out-openmp-nvptx64-nvidia-cuda"
10. "x86_64-unknown-linux-gnu" - "offload wrapper", inputs: ["a.out-openmp-nvptx64-nvidia-cuda"], output: "**helloworld-wrapper-host-x86_64-unknown-linux-gnu.bc**"
11. "x86_64-unknown-linux-gnu" - "clang", inputs: ["helloworld-wrapper-host-x86_64-unknown-linux-gnu.bc"], output: "**helloworld-wrapper-host-x86_64-unknown-linux-gnu.s**"
12. "x86_64-unknown-linux-gnu" - "clang::as", inputs: ["helloworld-wrapper-host-x86_64-unknown-linux-gnu.s"], output: "**helloworld-wrapper-host-x86_64-unknown-linux-gnu.o**"
13. "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["**helloworld-host-x86_64-unknown-linux-gnu.o**", "**helloworld-wrapper-host-x86_64-unknown-linux-gnu.o"**], output: "helloworld"

So for having OffloadingPrefix different for 11 & 12 would require to distinguish latter from 3 & 4 which I don't think is possible. However, the changes to BaseInput in OffloadWrapperJobAction [10]  will also reflect in the dependent backend [11] and assemble [12] actions as BaseInput is present in InputInfo of the next actions (line number 4696).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97273/new/

https://reviews.llvm.org/D97273



More information about the cfe-commits mailing list