[Clang] Parse toolchain-specific offloading arguments directly
authorJoseph Huber <jhuber6@vols.utk.edu>
Sun, 10 Jul 2022 02:20:04 +0000 (22:20 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Mon, 11 Jul 2022 19:37:50 +0000 (15:37 -0400)
commit359e4a8247316c2f0c21072919836fd9fd4cf0f1
tree52a7caadf08bad63f7a641297b70f7050273bdee
parent74c9030a115d1f847a0e9425749e354a4773fef5
[Clang] Parse toolchain-specific offloading arguments directly

OpenMP supports multiple offloading toolchains and architectures. In
order to support this we originally used `getArgsForToolchain` to get
the arguments only intended for each toolchain. This allowed users to
manually specify if an `--offload-arch=` argument was intended for which
toolchain using `-Xopenmp-target=` or other methods. For example,

```
clang input.c -fopenmp -fopenmp-targets=nvptx64,amdgcn -Xopenmp-target=nvptx64 --offload-arch=sm_70 -Xopenmp-target=amdgcn --offload-arch=gfx908
```

However, this was causing problems with the AMDGPU toolchain. This is
because the AMDGPU toolchain for OpenMP uses an `amdgpu` arch to determine the
architecture. If this tool is not availible the compiler will exit with an error
even when manually specifying the architecture. This patch pulls out the logic in
`getArgsForToolchain` and specializes it for extracting `--offload-arch`
arguments to avoid this.

Reviewed By: JonChesterfield, yaxunl

Differential Revision: https://reviews.llvm.org/D129435
clang/lib/Driver/Driver.cpp