Skip to content

Commit

Permalink
Merge llvm-project release/13.x llvmorg-13.0.0-rc2-43-gf56129fe78d5
Browse files Browse the repository at this point in the history
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13.0.0-rc2-43-gf56129fe78d5.

PR:		258209

(cherry picked from commit 69ade1e)
  • Loading branch information
DimitryAndric committed Dec 6, 2021
1 parent 2e2f8ea commit c77c1b5
Show file tree
Hide file tree
Showing 63 changed files with 752 additions and 351 deletions.
8 changes: 8 additions & 0 deletions contrib/llvm-project/clang/lib/AST/ASTContext.cpp
Expand Up @@ -9653,11 +9653,19 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET,
QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
bool OfBlockPointer,
bool Unqualified, bool BlockReturnType) {
// For C++ we will not reach this code with reference types (see below),
// for OpenMP variant call overloading we might.
//
// C++ [expr]: If an expression initially has the type "reference to T", the
// type is adjusted to "T" prior to any further analysis, the expression
// designates the object or function denoted by the reference, and the
// expression is an lvalue unless the reference is an rvalue reference and
// the expression is a function call (possibly inside parentheses).
if (LangOpts.OpenMP && LHS->getAs<ReferenceType>() &&
RHS->getAs<ReferenceType>() && LHS->getTypeClass() == RHS->getTypeClass())
return mergeTypes(LHS->getAs<ReferenceType>()->getPointeeType(),
RHS->getAs<ReferenceType>()->getPointeeType(),
OfBlockPointer, Unqualified, BlockReturnType);
if (LHS->getAs<ReferenceType>() || RHS->getAs<ReferenceType>())
return {};

Expand Down
4 changes: 2 additions & 2 deletions contrib/llvm-project/clang/lib/Basic/Targets/M68k.cpp
Expand Up @@ -37,8 +37,8 @@ M68kTargetInfo::M68kTargetInfo(const llvm::Triple &Triple,
// FIXME how to wire it with the used object format?
Layout += "-m:e";

// M68k pointers are always 32 bit wide even for 16 bit cpus
Layout += "-p:32:32";
// M68k pointers are always 32 bit wide even for 16-bit CPUs
Layout += "-p:32:16:32";

// M68k integer data types
Layout += "-i8:8:8-i16:16:16-i32:16:32";
Expand Down
5 changes: 5 additions & 0 deletions contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.h
Expand Up @@ -460,6 +460,11 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("_REENTRANT");
if (this->HasFloat128)
Builder.defineMacro("__FLOAT128__");

if (Opts.C11) {
Builder.defineMacro("__STDC_NO_ATOMICS__");
Builder.defineMacro("__STDC_NO_THREADS__");
}
}

public:
Expand Down
1 change: 0 additions & 1 deletion contrib/llvm-project/clang/lib/Driver/Driver.cpp
Expand Up @@ -5568,7 +5568,6 @@ llvm::StringRef clang::driver::getDriverMode(StringRef ProgName,
if (!Arg.startswith(OptName))
continue;
Opt = Arg;
break;
}
if (Opt.empty())
Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;
Expand Down
35 changes: 35 additions & 0 deletions contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPU.cpp
Expand Up @@ -893,3 +893,38 @@ bool AMDGPUToolChain::shouldSkipArgument(const llvm::opt::Arg *A) const {
return true;
return false;
}

llvm::SmallVector<std::string, 12>
ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
const std::string &GPUArch) const {
auto Kind = llvm::AMDGPU::parseArchAMDGCN(GPUArch);
const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);

std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
if (LibDeviceFile.empty()) {
getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 1 << GPUArch;
return {};
}

// If --hip-device-lib is not set, add the default bitcode libraries.
// TODO: There are way too many flags that change this. Do we need to check
// them all?
bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
options::OPT_fno_gpu_flush_denormals_to_zero,
getDefaultDenormsAreZeroForTarget(Kind));
bool FiniteOnly = DriverArgs.hasFlag(
options::OPT_ffinite_math_only, options::OPT_fno_finite_math_only, false);
bool UnsafeMathOpt =
DriverArgs.hasFlag(options::OPT_funsafe_math_optimizations,
options::OPT_fno_unsafe_math_optimizations, false);
bool FastRelaxedMath = DriverArgs.hasFlag(options::OPT_ffast_math,
options::OPT_fno_fast_math, false);
bool CorrectSqrt = DriverArgs.hasFlag(
options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt);
bool Wave64 = isWave64(DriverArgs, Kind);

return RocmInstallation.getCommonBitcodeLibs(
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
FastRelaxedMath, CorrectSqrt);
}
5 changes: 5 additions & 0 deletions contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPU.h
Expand Up @@ -136,6 +136,11 @@ class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {
addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const override;

// Returns a list of device library names shared by different languages
llvm::SmallVector<std::string, 12>
getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
const std::string &GPUArch) const;
};

} // end namespace toolchains
Expand Down
32 changes: 27 additions & 5 deletions contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
Expand Up @@ -9,12 +9,14 @@
#include "AMDGPUOpenMP.h"
#include "AMDGPU.h"
#include "CommonArgs.h"
#include "ToolChains/ROCm.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
Expand Down Expand Up @@ -84,14 +86,34 @@ static bool checkSystemForAMDGPU(const ArgList &Args, const AMDGPUToolChain &TC,
} // namespace

const char *AMDGCN::OpenMPLinker::constructLLVMLinkCommand(
Compilation &C, const JobAction &JA, const InputInfoList &Inputs,
const ArgList &Args, StringRef SubArchName,
StringRef OutputFilePrefix) const {
const toolchains::AMDGPUOpenMPToolChain &AMDGPUOpenMPTC, Compilation &C,
const JobAction &JA, const InputInfoList &Inputs, const ArgList &Args,
StringRef SubArchName, StringRef OutputFilePrefix) const {
ArgStringList CmdArgs;

for (const auto &II : Inputs)
if (II.isFilename())
CmdArgs.push_back(II.getFilename());

if (Args.hasArg(options::OPT_l)) {
auto Lm = Args.getAllArgValues(options::OPT_l);
bool HasLibm = false;
for (auto &Lib : Lm) {
if (Lib == "m") {
HasLibm = true;
break;
}
}

if (HasLibm) {
SmallVector<std::string, 12> BCLibs =
AMDGPUOpenMPTC.getCommonDeviceLibNames(Args, SubArchName.str());
llvm::for_each(BCLibs, [&](StringRef BCFile) {
CmdArgs.push_back(Args.MakeArgString(BCFile));
});
}
}

// Add an intermediate output file.
CmdArgs.push_back("-o");
const char *OutputFileName =
Expand Down Expand Up @@ -180,8 +202,8 @@ void AMDGCN::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA,
assert(Prefix.length() && "no linker inputs are files ");

// Each command outputs different files.
const char *LLVMLinkCommand =
constructLLVMLinkCommand(C, JA, Inputs, Args, GPUArch, Prefix);
const char *LLVMLinkCommand = constructLLVMLinkCommand(
AMDGPUOpenMPTC, C, JA, Inputs, Args, GPUArch, Prefix);

// Produce readable assembly if save-temps is enabled.
if (C.getDriver().isSaveTempsEnabled())
Expand Down
14 changes: 9 additions & 5 deletions contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
Expand Up @@ -16,6 +16,10 @@
namespace clang {
namespace driver {

namespace toolchains {
class AMDGPUOpenMPToolChain;
}

namespace tools {

namespace AMDGCN {
Expand All @@ -35,11 +39,11 @@ class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool {

private:
/// \return llvm-link output file name.
const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs,
const llvm::opt::ArgList &Args,
llvm::StringRef SubArchName,
llvm::StringRef OutputFilePrefix) const;
const char *constructLLVMLinkCommand(
const toolchains::AMDGPUOpenMPToolChain &AMDGPUOpenMPTC, Compilation &C,
const JobAction &JA, const InputInfoList &Inputs,
const llvm::opt::ArgList &Args, llvm::StringRef SubArchName,
llvm::StringRef OutputFilePrefix) const;

/// \return llc output file name.
const char *constructLlcCommand(Compilation &C, const JobAction &JA,
Expand Down
3 changes: 2 additions & 1 deletion contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
Expand Up @@ -1255,7 +1255,8 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
// If we are offloading to a target via OpenMP we need to include the
// openmp_wrappers folder which contains alternative system headers.
if (JA.isDeviceOffloading(Action::OFK_OpenMP) &&
getToolChain().getTriple().isNVPTX()){
(getToolChain().getTriple().isNVPTX() ||
getToolChain().getTriple().isAMDGCN())) {
if (!Args.hasArg(options::OPT_nobuiltininc)) {
// Add openmp_wrappers/* to our system include path. This lets us wrap
// standard library headers.
Expand Down
Expand Up @@ -775,7 +775,8 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
CmdArgs.push_back("-ldl");
// Required for backtrace on some OSes
if (TC.getTriple().isOSFreeBSD() ||
TC.getTriple().isOSNetBSD())
TC.getTriple().isOSNetBSD() ||
TC.getTriple().isOSOpenBSD())
CmdArgs.push_back("-lexecinfo");
}

Expand Down
33 changes: 2 additions & 31 deletions contrib/llvm-project/clang/lib/Driver/ToolChains/HIP.cpp
Expand Up @@ -395,35 +395,8 @@ HIPToolChain::getHIPDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
}
StringRef GpuArch = getGPUArch(DriverArgs);
assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
(void)GpuArch;
auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);

std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
if (LibDeviceFile.empty()) {
getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 1 << GpuArch;
return {};
}

// If --hip-device-lib is not set, add the default bitcode libraries.
// TODO: There are way too many flags that change this. Do we need to check
// them all?
bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
options::OPT_fno_gpu_flush_denormals_to_zero,
getDefaultDenormsAreZeroForTarget(Kind));
bool FiniteOnly =
DriverArgs.hasFlag(options::OPT_ffinite_math_only,
options::OPT_fno_finite_math_only, false);
bool UnsafeMathOpt =
DriverArgs.hasFlag(options::OPT_funsafe_math_optimizations,
options::OPT_fno_unsafe_math_optimizations, false);
bool FastRelaxedMath = DriverArgs.hasFlag(
options::OPT_ffast_math, options::OPT_fno_fast_math, false);
bool CorrectSqrt = DriverArgs.hasFlag(
options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt);
bool Wave64 = isWave64(DriverArgs, Kind);

if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
options::OPT_fno_gpu_sanitize, false)) {
auto AsanRTL = RocmInstallation.getAsanRTLPath();
Expand All @@ -442,10 +415,8 @@ HIPToolChain::getHIPDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
// Add the HIP specific bitcode library.
BCLibs.push_back(RocmInstallation.getHIPPath().str());

// Add the generic set of libraries.
BCLibs.append(RocmInstallation.getCommonBitcodeLibs(
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
FastRelaxedMath, CorrectSqrt));
// Add common device libraries like ocml etc.
BCLibs.append(getCommonDeviceLibNames(DriverArgs, GpuArch.str()));

// Add instrument lib.
auto InstLib =
Expand Down
7 changes: 7 additions & 0 deletions contrib/llvm-project/clang/lib/Driver/ToolChains/OpenBSD.cpp
Expand Up @@ -174,6 +174,11 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
// Use the static OpenMP runtime with -static-openmp
bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
!Args.hasArg(options::OPT_static);
addOpenMPRuntime(CmdArgs, ToolChain, Args, StaticOpenMP);

if (D.CCCIsCXX()) {
if (ToolChain.ShouldLinkCXXStdlib(Args))
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
Expand Down Expand Up @@ -221,6 +226,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
}

ToolChain.addProfileRTLibs(Args, CmdArgs);

const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileCurCP(),
Expand Down

0 comments on commit c77c1b5

Please sign in to comment.