clang 19.0.0git
HIPAMD.cpp
Go to the documentation of this file.
1//===--- HIPAMD.cpp - HIP Tool and ToolChain Implementations ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "HIPAMD.h"
10#include "AMDGPU.h"
11#include "CommonArgs.h"
12#include "HIPUtility.h"
13#include "clang/Basic/Cuda.h"
16#include "clang/Driver/Driver.h"
21#include "llvm/Support/Alignment.h"
22#include "llvm/Support/FileSystem.h"
23#include "llvm/Support/Path.h"
24#include "llvm/TargetParser/TargetParser.h"
25
26using namespace clang::driver;
27using namespace clang::driver::toolchains;
28using namespace clang::driver::tools;
29using namespace clang;
30using namespace llvm::opt;
31
32#if defined(_WIN32) || defined(_WIN64)
33#define NULL_FILE "nul"
34#else
35#define NULL_FILE "/dev/null"
36#endif
37
38static bool shouldSkipSanitizeOption(const ToolChain &TC,
39 const llvm::opt::ArgList &DriverArgs,
40 StringRef TargetID,
41 const llvm::opt::Arg *A) {
42 // For actions without targetID, do nothing.
43 if (TargetID.empty())
44 return false;
45 Option O = A->getOption();
46 if (!O.matches(options::OPT_fsanitize_EQ))
47 return false;
48
49 if (!DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
50 options::OPT_fno_gpu_sanitize, true))
51 return true;
52
53 auto &Diags = TC.getDriver().getDiags();
54
55 // For simplicity, we only allow -fsanitize=address
56 SanitizerMask K = parseSanitizerValue(A->getValue(), /*AllowGroups=*/false);
57 if (K != SanitizerKind::Address)
58 return true;
59
60 llvm::StringMap<bool> FeatureMap;
61 auto OptionalGpuArch = parseTargetID(TC.getTriple(), TargetID, &FeatureMap);
62
63 assert(OptionalGpuArch && "Invalid Target ID");
64 (void)OptionalGpuArch;
65 auto Loc = FeatureMap.find("xnack");
66 if (Loc == FeatureMap.end() || !Loc->second) {
67 Diags.Report(
68 clang::diag::warn_drv_unsupported_option_for_offload_arch_req_feature)
69 << A->getAsString(DriverArgs) << TargetID << "xnack+";
70 return true;
71 }
72 return false;
73}
74
75void AMDGCN::Linker::constructLlvmLinkCommand(Compilation &C,
76 const JobAction &JA,
77 const InputInfoList &Inputs,
78 const InputInfo &Output,
79 const llvm::opt::ArgList &Args) const {
80 // Construct llvm-link command.
81 // The output from llvm-link is a bitcode file.
82 ArgStringList LlvmLinkArgs;
83
84 assert(!Inputs.empty() && "Must have at least one input.");
85
86 LlvmLinkArgs.append({"-o", Output.getFilename()});
87 for (auto Input : Inputs)
88 LlvmLinkArgs.push_back(Input.getFilename());
89
90 // Look for archive of bundled bitcode in arguments, and add temporary files
91 // for the extracted archive of bitcode to inputs.
92 auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
93 AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LlvmLinkArgs, "amdgcn",
94 TargetID, /*IsBitCodeSDL=*/true);
95
96 const char *LlvmLink =
97 Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
98 C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
99 LlvmLink, LlvmLinkArgs, Inputs,
100 Output));
101}
102
103void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
104 const InputInfoList &Inputs,
105 const InputInfo &Output,
106 const llvm::opt::ArgList &Args) const {
107 // Construct lld command.
108 // The output from ld.lld is an HSA code object file.
109 ArgStringList LldArgs{"-flavor",
110 "gnu",
111 "-m",
112 "elf64_amdgpu",
113 "--no-undefined",
114 "-shared",
115 "-plugin-opt=-amdgpu-internalize-symbols"};
116 if (Args.hasArg(options::OPT_hipstdpar))
117 LldArgs.push_back("-plugin-opt=-amdgpu-enable-hipstdpar");
118
119 auto &TC = getToolChain();
120 auto &D = TC.getDriver();
121 assert(!Inputs.empty() && "Must have at least one input.");
122 bool IsThinLTO = D.getLTOMode(/*IsOffload=*/true) == LTOK_Thin;
123 addLTOOptions(TC, Args, LldArgs, Output, Inputs[0], IsThinLTO);
124
125 // Extract all the -m options
126 std::vector<llvm::StringRef> Features;
127 amdgpu::getAMDGPUTargetFeatures(D, TC.getTriple(), Args, Features);
128
129 // Add features to mattr such as cumode
130 std::string MAttrString = "-plugin-opt=-mattr=";
131 for (auto OneFeature : unifyTargetFeatures(Features)) {
132 MAttrString.append(Args.MakeArgString(OneFeature));
133 if (OneFeature != Features.back())
134 MAttrString.append(",");
135 }
136 if (!Features.empty())
137 LldArgs.push_back(Args.MakeArgString(MAttrString));
138
139 // ToDo: Remove this option after AMDGPU backend supports ISA-level linking.
140 // Since AMDGPU backend currently does not support ISA-level linking, all
141 // called functions need to be imported.
142 if (IsThinLTO)
143 LldArgs.push_back(Args.MakeArgString("-plugin-opt=-force-import-all"));
144
145 for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
146 LldArgs.push_back(
147 Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0)));
148 }
149
150 if (C.getDriver().isSaveTempsEnabled())
151 LldArgs.push_back("-save-temps");
152
153 addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
154
155 // Given that host and device linking happen in separate processes, the device
156 // linker doesn't always have the visibility as to which device symbols are
157 // needed by a program, especially for the device symbol dependencies that are
158 // introduced through the host symbol resolution.
159 // For example: host_A() (A.obj) --> host_B(B.obj) --> device_kernel_B()
160 // (B.obj) In this case, the device linker doesn't know that A.obj actually
161 // depends on the kernel functions in B.obj. When linking to static device
162 // library, the device linker may drop some of the device global symbols if
163 // they aren't referenced. As a workaround, we are adding to the
164 // --whole-archive flag such that all global symbols would be linked in.
165 LldArgs.push_back("--whole-archive");
166
167 for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker)) {
168 StringRef ArgVal = Arg->getValue(1);
169 auto SplitArg = ArgVal.split("-mllvm=");
170 if (!SplitArg.second.empty()) {
171 LldArgs.push_back(
172 Args.MakeArgString(Twine("-plugin-opt=") + SplitArg.second));
173 } else {
174 LldArgs.push_back(Args.MakeArgString(ArgVal));
175 }
176 Arg->claim();
177 }
178
179 LldArgs.append({"-o", Output.getFilename()});
180 for (auto Input : Inputs)
181 LldArgs.push_back(Input.getFilename());
182
183 // Look for archive of bundled bitcode in arguments, and add temporary files
184 // for the extracted archive of bitcode to inputs.
185 auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
186 AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LldArgs, "amdgcn",
187 TargetID, /*IsBitCodeSDL=*/true);
188
189 LldArgs.push_back("--no-whole-archive");
190
191 const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
192 C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
193 Lld, LldArgs, Inputs, Output));
194}
195
196// For amdgcn the inputs of the linker job are device bitcode and output is
197// either an object file or bitcode (-emit-llvm). It calls llvm-link, opt,
198// llc, then lld steps.
200 const InputInfo &Output,
201 const InputInfoList &Inputs,
202 const ArgList &Args,
203 const char *LinkingOutput) const {
204 if (Inputs.size() > 0 &&
205 Inputs[0].getType() == types::TY_Image &&
206 JA.getType() == types::TY_Object)
208 Args, JA, *this);
209
210 if (JA.getType() == types::TY_HIP_FATBIN)
211 return HIP::constructHIPFatbinCommand(C, JA, Output.getFilename(), Inputs,
212 Args, *this);
213
214 if (JA.getType() == types::TY_LLVM_BC)
215 return constructLlvmLinkCommand(C, JA, Inputs, Output, Args);
216
217 return constructLldCommand(C, JA, Inputs, Output, Args);
218}
219
220HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
221 const ToolChain &HostTC, const ArgList &Args)
222 : ROCMToolChain(D, Triple, Args), HostTC(HostTC) {
223 // Lookup binaries into the driver directory, this is used to
224 // discover the clang-offload-bundler executable.
225 getProgramPaths().push_back(getDriver().Dir);
226
227 // Diagnose unsupported sanitizer options only once.
228 if (!Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize,
229 true))
230 return;
231 for (auto *A : Args.filtered(options::OPT_fsanitize_EQ)) {
232 SanitizerMask K = parseSanitizerValue(A->getValue(), /*AllowGroups=*/false);
233 if (K != SanitizerKind::Address)
234 D.getDiags().Report(clang::diag::warn_drv_unsupported_option_for_target)
235 << A->getAsString(Args) << getTriple().str();
236 }
237}
238
240 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
241 Action::OffloadKind DeviceOffloadingKind) const {
242 HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);
243
244 assert(DeviceOffloadingKind == Action::OFK_HIP &&
245 "Only HIP offloading kinds are supported for GPUs.");
246
247 CC1Args.push_back("-fcuda-is-device");
248
249 if (!DriverArgs.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
250 false))
251 CC1Args.append({"-mllvm", "-amdgpu-internalize-symbols"});
252 if (DriverArgs.hasArgNoClaim(options::OPT_hipstdpar))
253 CC1Args.append({"-mllvm", "-amdgpu-enable-hipstdpar"});
254
255 StringRef MaxThreadsPerBlock =
256 DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);
257 if (!MaxThreadsPerBlock.empty()) {
258 std::string ArgStr =
259 (Twine("--gpu-max-threads-per-block=") + MaxThreadsPerBlock).str();
260 CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
261 }
262
263 CC1Args.push_back("-fcuda-allow-variadic-functions");
264
265 // Default to "hidden" visibility, as object level linking will not be
266 // supported for the foreseeable future.
267 if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
268 options::OPT_fvisibility_ms_compat)) {
269 CC1Args.append({"-fvisibility=hidden"});
270 CC1Args.push_back("-fapply-global-visibility-to-externs");
271 }
272
273 for (auto BCFile : getDeviceLibs(DriverArgs)) {
274 CC1Args.push_back(BCFile.ShouldInternalize ? "-mlink-builtin-bitcode"
275 : "-mlink-bitcode-file");
276 CC1Args.push_back(DriverArgs.MakeArgString(BCFile.Path));
277 }
278}
279
280llvm::opt::DerivedArgList *
281HIPAMDToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
282 StringRef BoundArch,
283 Action::OffloadKind DeviceOffloadKind) const {
284 DerivedArgList *DAL =
285 HostTC.TranslateArgs(Args, BoundArch, DeviceOffloadKind);
286 if (!DAL)
287 DAL = new DerivedArgList(Args.getBaseArgs());
288
289 const OptTable &Opts = getDriver().getOpts();
290
291 for (Arg *A : Args) {
292 if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
293 DAL->append(A);
294 }
295
296 if (!BoundArch.empty()) {
297 DAL->eraseArg(options::OPT_mcpu_EQ);
298 DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_mcpu_EQ), BoundArch);
299 checkTargetID(*DAL);
300 }
301
302 return DAL;
303}
304
306 assert(getTriple().getArch() == llvm::Triple::amdgcn);
307 return new tools::AMDGCN::Linker(*this);
308}
309
310void HIPAMDToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {
313}
314
316HIPAMDToolChain::GetCXXStdlibType(const ArgList &Args) const {
317 return HostTC.GetCXXStdlibType(Args);
318}
319
320void HIPAMDToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
321 ArgStringList &CC1Args) const {
322 HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
323}
324
326 const ArgList &Args, ArgStringList &CC1Args) const {
328}
329
331 ArgStringList &CC1Args) const {
332 HostTC.AddIAMCUIncludeArgs(Args, CC1Args);
333}
334
335void HIPAMDToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
336 ArgStringList &CC1Args) const {
337 RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
338}
339
341 // The HIPAMDToolChain only supports sanitizers in the sense that it allows
342 // sanitizer arguments on the command line if they are supported by the host
343 // toolchain. The HIPAMDToolChain will actually ignore any command line
344 // arguments for any of these "supported" sanitizers. That means that no
345 // sanitization of device code is actually supported at this time.
346 //
347 // This behavior is necessary because the host and device toolchains
348 // invocations often share the command line, so the device toolchain must
349 // tolerate flags meant only for the host toolchain.
351}
352
354 const ArgList &Args) const {
355 return HostTC.computeMSVCVersion(D, Args);
356}
357
359HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
361 if (DriverArgs.hasArg(options::OPT_nogpulib))
362 return {};
363 ArgStringList LibraryPaths;
364
365 // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
366 for (StringRef Path : RocmInstallation->getRocmDeviceLibPathArg())
367 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
368
369 addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
370
371 // Maintain compatability with --hip-device-lib.
372 auto BCLibArgs = DriverArgs.getAllArgValues(options::OPT_hip_device_lib_EQ);
373 if (!BCLibArgs.empty()) {
374 llvm::for_each(BCLibArgs, [&](StringRef BCName) {
375 StringRef FullName;
376 for (StringRef LibraryPath : LibraryPaths) {
377 SmallString<128> Path(LibraryPath);
378 llvm::sys::path::append(Path, BCName);
379 FullName = Path;
380 if (llvm::sys::fs::exists(FullName)) {
381 BCLibs.push_back(FullName);
382 return;
383 }
384 }
385 getDriver().Diag(diag::err_drv_no_such_file) << BCName;
386 });
387 } else {
388 if (!RocmInstallation->hasDeviceLibrary()) {
389 getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
390 return {};
391 }
392 StringRef GpuArch = getGPUArch(DriverArgs);
393 assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
394
395 // If --hip-device-lib is not set, add the default bitcode libraries.
396 if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
397 options::OPT_fno_gpu_sanitize, true) &&
398 getSanitizerArgs(DriverArgs).needsAsanRt()) {
399 auto AsanRTL = RocmInstallation->getAsanRTLPath();
400 if (AsanRTL.empty()) {
401 unsigned DiagID = getDriver().getDiags().getCustomDiagID(
403 "AMDGPU address sanitizer runtime library (asanrtl) is not found. "
404 "Please install ROCm device library which supports address "
405 "sanitizer");
406 getDriver().Diag(DiagID);
407 return {};
408 } else
409 BCLibs.emplace_back(AsanRTL, /*ShouldInternalize=*/false);
410 }
411
412 // Add the HIP specific bitcode library.
413 BCLibs.push_back(RocmInstallation->getHIPPath());
414
415 // Add common device libraries like ocml etc.
416 for (StringRef N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
417 BCLibs.emplace_back(N);
418
419 // Add instrument lib.
420 auto InstLib =
421 DriverArgs.getLastArgValue(options::OPT_gpu_instrument_lib_EQ);
422 if (InstLib.empty())
423 return BCLibs;
424 if (llvm::sys::fs::exists(InstLib))
425 BCLibs.push_back(InstLib);
426 else
427 getDriver().Diag(diag::err_drv_no_such_file) << InstLib;
428 }
429
430 return BCLibs;
431}
432
434 const llvm::opt::ArgList &DriverArgs) const {
435 auto PTID = getParsedTargetID(DriverArgs);
436 if (PTID.OptionalTargetID && !PTID.OptionalGPUArch) {
437 getDriver().Diag(clang::diag::err_drv_bad_target_id)
438 << *PTID.OptionalTargetID;
439 }
440}
static bool shouldSkipSanitizeOption(const ToolChain &TC, const llvm::opt::ArgList &DriverArgs, StringRef TargetID, const llvm::opt::Arg *A)
Definition: HIPAMD.cpp:38
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1547
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
Definition: Diagnostic.h:873
types::ID getType() const
Definition: Action.h:148
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
DiagnosticsEngine & getDiags() const
Definition: Driver.h:401
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:144
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:399
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
const char * getFilename() const
Definition: InputInfo.h:83
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const
Add warning options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:1065
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:268
const Driver & getDriver() const
Definition: ToolChain.h:252
path_list & getProgramPaths()
Definition: ToolChain.h:297
virtual llvm::opt::DerivedArgList * TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Action::OffloadKind DeviceOffloadKind) const
TranslateArgs - Create a new derived argument list for any argument translations this ToolChain may w...
Definition: ToolChain.h:358
const llvm::Triple & getTriple() const
Definition: ToolChain.h:254
virtual void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition: ToolChain.cpp:1233
virtual VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const
On Windows, returns the MSVC compatibility version.
Definition: ToolChain.cpp:1391
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use MCU GCC toolchain includes.
Definition: ToolChain.cpp:1374
SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const
Definition: ToolChain.cpp:300
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:1137
virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const
Add options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:1058
virtual void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add the clang cc1 arguments for system include paths.
Definition: ToolChain.cpp:1053
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1338
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
const ToolChain & getToolChain() const
Definition: Tool.h:52
StringRef getGPUArch(const llvm::opt::ArgList &DriverArgs) const
Get GPU arch from -mcpu without checking.
Definition: AMDGPU.cpp:840
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override
Common warning options shared by AMDGPU HIP, OpenCL and OpenMP toolchains.
Definition: AMDGPU.cpp:833
ParsedTargetIDType getParsedTargetID(const llvm::opt::ArgList &DriverArgs) const
Get target ID, GPU arch, and target ID features if the target ID is specified and valid.
Definition: AMDGPU.cpp:846
LazyDetector< RocmInstallationDetector > RocmInstallation
Definition: Gnu.h:290
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: HIPAMD.cpp:340
Tool * buildLinker() const override
Definition: HIPAMD.cpp:305
HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const llvm::opt::ArgList &Args)
Definition: HIPAMD.cpp:220
llvm::opt::DerivedArgList * TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Action::OffloadKind DeviceOffloadKind) const override
TranslateArgs - Create a new derived argument list for any argument translations this ToolChain may w...
Definition: HIPAMD.cpp:281
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition: HIPAMD.cpp:239
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition: HIPAMD.cpp:320
void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use MCU GCC toolchain includes.
Definition: HIPAMD.cpp:330
void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1Args) const override
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition: HIPAMD.cpp:325
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition: HIPAMD.cpp:335
void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override
Check and diagnose invalid target ID specified by -mcpu.
Definition: HIPAMD.cpp:433
VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const override
On Windows, returns the MSVC compatibility version.
Definition: HIPAMD.cpp:353
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override
Common warning options shared by AMDGPU HIP, OpenCL and OpenMP toolchains.
Definition: HIPAMD.cpp:310
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override
Definition: HIPAMD.cpp:316
llvm::SmallVector< BitCodeLibraryInfo, 12 > getDeviceLibs(const llvm::opt::ArgList &Args) const override
Get paths for device libraries.
Definition: HIPAMD.cpp:359
llvm::SmallVector< std::string, 12 > getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs, const std::string &GPUArch, bool isOpenMP=false) const
Definition: AMDGPU.cpp:992
void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override
ConstructJob - Construct jobs to perform the action JA, writing to Output and with Inputs,...
Definition: HIPAMD.cpp:199
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, StringRef OutputFileName, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const Tool &T)
void constructGenerateObjFileFromHIPFatBinary(Compilation &C, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, const JobAction &JA, const Tool &T)
void getAMDGPUTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, std::vector< StringRef > &Features)
Definition: AMDGPU.cpp:643
SmallVector< StringRef > unifyTargetFeatures(ArrayRef< StringRef > Features)
If there are multiple +xxx or -xxx features, keep the last one.
Definition: CommonArgs.cpp:327
void AddStaticDeviceLibsLinking(Compilation &C, const Tool &T, const JobAction &JA, const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CmdArgs, StringRef Arch, StringRef Target, bool isBitCodeSDL)
void addDirectoryList(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const char *ArgName, const char *EnvVar)
EnvVar is split by system delimiter for environment variables.
void addLinkerCompressDebugSectionsOption(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
Definition: CommonArgs.cpp:443
void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, const InputInfo &Input, bool IsThinLTO)
The JSON file list parser is used to communicate input to InstallAPI.
std::optional< llvm::StringRef > parseTargetID(const llvm::Triple &T, llvm::StringRef OffloadArch, llvm::StringMap< bool > *FeatureMap)
Parse a target ID to get processor and feature map.
Definition: TargetID.cpp:105
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
Definition: Sanitizers.cpp:29
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
Definition: Job.h:78