[AMDGPU][OpenMP] Fix clang driver crash when provided -c
authorPushpinder Singh <Pushpinder.Singh@amd.com>
Wed, 5 May 2021 12:02:25 +0000 (12:02 +0000)
committerPushpinder Singh <Pushpinder.Singh@amd.com>
Wed, 5 May 2021 14:26:58 +0000 (14:26 +0000)
commit1f5cacfcb845fd4163dec5a8c7991934c53d6cb3
tree9dfa7ec9e3730693e3e204ecdf077c1f38c65e0a
parentae2aef13618beb8cb86e8b137a8ddbc846461169
[AMDGPU][OpenMP] Fix clang driver crash when provided -c

The offload action is used in four different ways as explained
in Driver.cpp:4495. When -c is present, the final phase will be
assemble (linker when -c is not present). However, this phase
is skipped according to D96769 for amdgcn. So, offload action
arrives into following situation,

 compile (device) ---> offload ---> offload

without -c the chain looks like,
 compile (device) ---> offload ---> linker (device)
---> offload

The former situation creates an unhandled case which causes
problem. The solution presented in this patch delays the D96769
logic until job creation time. This keeps the offload action
in the 1 of the 4 specified situations.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D101901
clang/lib/Driver/Driver.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c