Skip to content

Commit

Permalink
[OpenMP][AMDGPU] Do not attach -fcuda-is-device (llvm#99002)
Browse files Browse the repository at this point in the history
-fcuda-is-device flag is not used for OpenMP offloading for AMD GPUs and
it does not need to be added as clang cc1 option for OpenMP code.

This PR has the same functionality as
llvm#96909 but it doesn't introduce
regression for virtual function support.
  • Loading branch information
DominikAdamski authored Jul 18, 2024
1 parent 0ce3ea1 commit 14c323c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CodeGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ class CodeGenModule : public CodeGenTypeCache {
bool shouldEmitRTTI(bool ForEH = false) {
return (ForEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice &&
!(getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice &&
getTriple().isNVPTX());
(getTriple().isNVPTX() || getTriple().isAMDGPU()));
}

/// Get the address of the RTTI descriptor for the given type.
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
assert(DeviceOffloadingKind == Action::OFK_OpenMP &&
"Only OpenMP offloading kinds are supported.");

CC1Args.push_back("-fcuda-is-device");

if (DriverArgs.hasArg(options::OPT_nogpulib))
return;

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/amdgpu-openmp-toolchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// verify the tools invocations
// CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-llvm-bc"{{.*}}"-x" "c"
// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}}"-fcuda-is-device"{{.*}}"-target-cpu" "gfx906"
// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" "gfx906"
// CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-obj"
// CHECK: clang-linker-wrapper{{.*}} "-o" "a.out"

Expand Down

0 comments on commit 14c323c

Please sign in to comment.