Skip to content

Commit 80d4675

Browse files
[Flang-new][OpenMP] Add offload related flags for AMDGPU
Flang-new needs to add mlink-builtin-bitcode objects to properly support offload code generation for AMD GPU. fcuda-is-device flag is not used by Flang currently. In the future it will be needed for Flang equivalent function: AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace.
1 parent 811e505 commit 80d4675

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8016,7 +8016,7 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">,
80168016
// CUDA Options
80178017
//===----------------------------------------------------------------------===//
80188018

8019-
let Visibility = [CC1Option] in {
8019+
let Visibility = [CC1Option, FC1Option] in {
80208020

80218021
def fcuda_is_device : Flag<["-"], "fcuda-is-device">,
80228022
HelpText<"Generate code for CUDA device">,
@@ -8031,7 +8031,7 @@ def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr
80318031
HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">,
80328032
MarshallingInfoNegativeFlag<LangOpts<"CUDAHostDeviceConstexpr">>;
80338033

8034-
} // let Visibility = [CC1Option]
8034+
} // let Visibility = [CC1Option, FC1Option]
80358035

80368036
//===----------------------------------------------------------------------===//
80378037
// OpenMP Options

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args,
333333
StringRef Val = A->getValue();
334334
CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val));
335335
}
336+
337+
const ToolChain &TC = getToolChain();
338+
TC.addClangTargetOptions(Args, CmdArgs, Action::OffloadKind::OFK_OpenMP);
336339
}
337340

338341
void Flang::addTargetOptions(const ArgList &Args,

flang/test/Driver/omp-driver-offload.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,11 @@
227227
! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm"
228228
! FORCE-USM-OFFLOAD-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
229229
! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm"
230+
231+
! RUN: %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \
232+
! RUN: --offload-arch=gfx900 \
233+
! RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \
234+
! RUN: | FileCheck --check-prefix=MLINK-BUILTIN-BITCODE %s
235+
! MLINK-BUILTIN-BITCODE: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
236+
! MLINK-BUILTIN-BITCODE-SAME: "-fcuda-is-device"
237+
! MLINK-BUILTIN-BITCODE-SAME: "-mlink-builtin-bitcode" {{.*Inputs.*rocm.*amdgcn.*bitcode.*}}oclc_isa_version_900.bc

0 commit comments

Comments
 (0)