Skip to content

Commit b828378

Browse files
committed
merge main into amd-staging
Change-Id: Ied5da980c6e7acd5ef81b3de15be695263afab78
2 parents e816d80 + 833a174 commit b828378

File tree

190 files changed

+29854
-24661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+29854
-24661
lines changed

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -337,33 +337,34 @@ FileOptionsBaseProvider::FileOptionsBaseProvider(
337337
void FileOptionsBaseProvider::addRawFileOptions(
338338
llvm::StringRef AbsolutePath, std::vector<OptionsSource> &CurOptions) {
339339
auto CurSize = CurOptions.size();
340-
341340
// Look for a suitable configuration file in all parent directories of the
342341
// file. Start with the immediate parent directory and move up.
343-
StringRef Path = llvm::sys::path::parent_path(AbsolutePath);
344-
for (StringRef CurrentPath = Path; !CurrentPath.empty();
345-
CurrentPath = llvm::sys::path::parent_path(CurrentPath)) {
346-
std::optional<OptionsSource> Result;
347-
348-
auto Iter = CachedOptions.find(CurrentPath);
349-
if (Iter != CachedOptions.end())
350-
Result = Iter->second;
351-
352-
if (!Result)
353-
Result = tryReadConfigFile(CurrentPath);
354-
355-
if (Result) {
356-
// Store cached value for all intermediate directories.
357-
while (Path != CurrentPath) {
342+
StringRef RootPath = llvm::sys::path::parent_path(AbsolutePath);
343+
auto MemorizedConfigFile =
344+
[this, &RootPath](StringRef CurrentPath) -> std::optional<OptionsSource> {
345+
const auto Iter = CachedOptions.Memorized.find(CurrentPath);
346+
if (Iter != CachedOptions.Memorized.end())
347+
return CachedOptions.Storage[Iter->second];
348+
std::optional<OptionsSource> OptionsSource = tryReadConfigFile(CurrentPath);
349+
if (OptionsSource) {
350+
const size_t Index = CachedOptions.Storage.size();
351+
CachedOptions.Storage.emplace_back(OptionsSource.value());
352+
while (RootPath != CurrentPath) {
358353
LLVM_DEBUG(llvm::dbgs()
359-
<< "Caching configuration for path " << Path << ".\n");
360-
if (!CachedOptions.count(Path))
361-
CachedOptions[Path] = *Result;
362-
Path = llvm::sys::path::parent_path(Path);
354+
<< "Caching configuration for path " << RootPath << ".\n");
355+
CachedOptions.Memorized[RootPath] = Index;
356+
RootPath = llvm::sys::path::parent_path(RootPath);
363357
}
364-
CachedOptions[Path] = *Result;
365-
366-
CurOptions.push_back(*Result);
358+
CachedOptions.Memorized[CurrentPath] = Index;
359+
RootPath = llvm::sys::path::parent_path(CurrentPath);
360+
}
361+
return OptionsSource;
362+
};
363+
for (StringRef CurrentPath = RootPath; !CurrentPath.empty();
364+
CurrentPath = llvm::sys::path::parent_path(CurrentPath)) {
365+
if (std::optional<OptionsSource> Result =
366+
MemorizedConfigFile(CurrentPath)) {
367+
CurOptions.emplace_back(Result.value());
367368
if (!Result->first.InheritParentConfig.value_or(false))
368369
break;
369370
}

clang-tools-extra/clang-tidy/ClangTidyOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ class FileOptionsBaseProvider : public DefaultOptionsProvider {
241241
/// \c ConfigHandlers.
242242
std::optional<OptionsSource> tryReadConfigFile(llvm::StringRef Directory);
243243

244-
llvm::StringMap<OptionsSource> CachedOptions;
244+
struct OptionsCache {
245+
llvm::StringMap<size_t> Memorized;
246+
llvm::SmallVector<OptionsSource, 4U> Storage;
247+
} CachedOptions;
245248
ClangTidyOptions OverrideOptions;
246249
ConfigFileHandlers ConfigHandlers;
247250
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,9 @@ Miscellaneous Clang Crashes Fixed
990990
- Fixed internal assertion firing when a declaration in the implicit global
991991
module is found through ADL. (GH#109879)
992992

993+
- Fixed a crash when an unscoped enumeration declared by an opaque-enum-declaration within a class template
994+
with a dependent underlying type is subject to integral promotion. (#GH117960)
995+
993996
OpenACC Specific Changes
994997
------------------------
995998

@@ -1114,6 +1117,12 @@ CUDA Support
11141117
- Clang now supports CUDA SDK up to 12.6
11151118
- Added support for sm_100
11161119
- Added support for `__grid_constant__` attribute.
1120+
- CUDA now uses the new offloading driver by default. The new driver supports
1121+
device-side LTO, interoperability with OpenMP and other languages, and native ``-fgpu-rdc``
1122+
support with static libraries. The old behavior can be returned using the
1123+
``--no-offload-new-driver`` flag. The binary format is no longer compatible
1124+
with the NVIDIA compiler's RDC-mode support. More information can be found at:
1125+
https://clang.llvm.org/docs/OffloadingDesign.html
11171126

11181127
AIX Support
11191128
^^^^^^^^^^^

clang/include/clang/Basic/Builtins.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4865,12 +4865,6 @@ def HLSLIsinf : LangBuiltin<"HLSL_LANG"> {
48654865
let Prototype = "void(...)";
48664866
}
48674867

4868-
def HLSLLength : LangBuiltin<"HLSL_LANG"> {
4869-
let Spellings = ["__builtin_hlsl_length"];
4870-
let Attributes = [NoThrow, Const];
4871-
let Prototype = "void(...)";
4872-
}
4873-
48744868
def HLSLLerp : LangBuiltin<"HLSL_LANG"> {
48754869
let Spellings = ["__builtin_hlsl_lerp"];
48764870
let Attributes = [NoThrow, Const];

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19331,20 +19331,6 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
1933119331
/*ReturnType=*/X->getType(), CGM.getHLSLRuntime().getLerpIntrinsic(),
1933219332
ArrayRef<Value *>{X, Y, S}, nullptr, "hlsl.lerp");
1933319333
}
19334-
case Builtin::BI__builtin_hlsl_length: {
19335-
Value *X = EmitScalarExpr(E->getArg(0));
19336-
19337-
assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
19338-
"length operand must have a float representation");
19339-
// if the operand is a scalar, we can use the fabs llvm intrinsic directly
19340-
if (!E->getArg(0)->getType()->isVectorType())
19341-
return EmitFAbs(*this, X);
19342-
19343-
return Builder.CreateIntrinsic(
19344-
/*ReturnType=*/X->getType()->getScalarType(),
19345-
CGM.getHLSLRuntime().getLengthIntrinsic(), ArrayRef<Value *>{X},
19346-
nullptr, "hlsl.length");
19347-
}
1934819334
case Builtin::BI__builtin_hlsl_normalize: {
1934919335
Value *X = EmitScalarExpr(E->getArg(0));
1935019336

clang/lib/CodeGen/CGHLSLRuntime.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class CGHLSLRuntime {
7777
GENERATE_HLSL_INTRINSIC_FUNCTION(Cross, cross)
7878
GENERATE_HLSL_INTRINSIC_FUNCTION(Degrees, degrees)
7979
GENERATE_HLSL_INTRINSIC_FUNCTION(Frac, frac)
80-
GENERATE_HLSL_INTRINSIC_FUNCTION(Length, length)
8180
GENERATE_HLSL_INTRINSIC_FUNCTION(Lerp, lerp)
8281
GENERATE_HLSL_INTRINSIC_FUNCTION(Normalize, normalize)
8382
GENERATE_HLSL_INTRINSIC_FUNCTION(Rsqrt, rsqrt)

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include "llvm/TargetParser/X86TargetParser.h"
7777
#include "llvm/Transforms/Utils/BuildLibCalls.h"
7878
#include <optional>
79+
#include <set>
7980

8081
using namespace clang;
8182
using namespace CodeGen;
@@ -2758,17 +2759,26 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
27582759
Attrs.addAttribute("target-features", llvm::join(Features, ","));
27592760
AddedAttr = true;
27602761
}
2762+
// Add metadata for AArch64 Function Multi Versioning.
27612763
if (getTarget().getTriple().isAArch64()) {
27622764
llvm::SmallVector<StringRef, 8> Feats;
2763-
if (TV)
2765+
bool IsDefault = false;
2766+
if (TV) {
2767+
IsDefault = TV->isDefaultVersion();
27642768
TV->getFeatures(Feats);
2765-
else if (TC)
2769+
} else if (TC) {
2770+
IsDefault = TC->isDefaultVersion(GD.getMultiVersionIndex());
27662771
TC->getFeatures(Feats, GD.getMultiVersionIndex());
2767-
if (!Feats.empty()) {
2768-
llvm::sort(Feats);
2772+
}
2773+
if (IsDefault) {
2774+
Attrs.addAttribute("fmv-features");
2775+
AddedAttr = true;
2776+
} else if (!Feats.empty()) {
2777+
// Sort features and remove duplicates.
2778+
std::set<StringRef> OrderedFeats(Feats.begin(), Feats.end());
27692779
std::string FMVFeatures;
2770-
for (StringRef F : Feats)
2771-
FMVFeatures.append(",+" + F.str());
2780+
for (StringRef F : OrderedFeats)
2781+
FMVFeatures.append("," + F.str());
27722782
Attrs.addAttribute("fmv-features", FMVFeatures.substr(1));
27732783
AddedAttr = true;
27742784
}
@@ -2810,6 +2820,7 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
28102820
llvm::AttributeMask RemoveAttrs;
28112821
RemoveAttrs.addAttribute("target-cpu");
28122822
RemoveAttrs.addAttribute("target-features");
2823+
RemoveAttrs.addAttribute("fmv-features");
28132824
RemoveAttrs.addAttribute("tune-cpu");
28142825
F->removeFnAttrs(RemoveAttrs);
28152826
F->addFnAttrs(Attrs);

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,7 +4352,8 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
43524352
Args.hasFlag(options::OPT_foffload_via_llvm,
43534353
options::OPT_fno_offload_via_llvm, false) ||
43544354
Args.hasFlag(options::OPT_offload_new_driver,
4355-
options::OPT_no_offload_new_driver, false);
4355+
options::OPT_no_offload_new_driver,
4356+
C.isOffloadingHostKind(Action::OFK_Cuda));
43564357

43574358
if (C.isOffloadingHostKind(Action::OFK_OpenMP) &&
43584359
Args.hasArg(options::OPT_offload_new_driver,
@@ -5123,7 +5124,8 @@ Action *Driver::ConstructPhaseAction(
51235124
offloadDeviceOnly() ||
51245125
(TargetDeviceOffloadKind == Action::OFK_HIP &&
51255126
!Args.hasFlag(options::OPT_offload_new_driver,
5126-
options::OPT_no_offload_new_driver, false)))
5127+
options::OPT_no_offload_new_driver,
5128+
C.isOffloadingHostKind(Action::OFK_Cuda))))
51275129
? types::TY_LLVM_IR
51285130
: types::TY_LLVM_BC;
51295131
return C.MakeAction<BackendJobAction>(Input, Output);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5148,7 +5148,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51485148
JA.isHostOffloading(Action::OFK_SYCL) ||
51495149
(JA.isHostOffloading(C.getActiveOffloadKinds()) &&
51505150
Args.hasFlag(options::OPT_offload_new_driver,
5151-
options::OPT_no_offload_new_driver, false));
5151+
options::OPT_no_offload_new_driver,
5152+
C.isOffloadingHostKind(Action::OFK_Cuda)));
51525153

51535154
bool IsRDCMode =
51545155
Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false);
@@ -5504,7 +5505,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
55045505
CmdArgs.push_back("-emit-llvm-uselists");
55055506

55065507
if (IsUsingLTO) {
5507-
if (IsDeviceOffloadAction && !JA.isDeviceOffloading(Action::OFK_OpenMP) && !Triple.isAMDGPU()) {
5508+
if (IsDeviceOffloadAction && !JA.isDeviceOffloading(Action::OFK_OpenMP) &&
5509+
!Args.hasFlag(options::OPT_offload_new_driver,
5510+
options::OPT_no_offload_new_driver,
5511+
C.isOffloadingHostKind(Action::OFK_Cuda)) &&
5512+
!Triple.isAMDGPU()) {
55085513
D.Diag(diag::err_drv_unsupported_opt_for_target)
55095514
<< Args.getLastArg(options::OPT_foffload_lto,
55105515
options::OPT_foffload_lto_EQ)
@@ -7062,7 +7067,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
70627067
options::OPT_fno_offload_via_llvm, false)) {
70637068
CmdArgs.append({"--offload-new-driver", "-foffload-via-llvm"});
70647069
} else if (Args.hasFlag(options::OPT_offload_new_driver,
7065-
options::OPT_no_offload_new_driver, false)) {
7070+
options::OPT_no_offload_new_driver,
7071+
C.isOffloadingHostKind(Action::OFK_Cuda))) {
70667072
CmdArgs.push_back("--offload-new-driver");
70677073
}
70687074

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ void NVPTX::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
510510
static bool shouldIncludePTX(const ArgList &Args, StringRef InputArch) {
511511
// The new driver does not include PTX by default to avoid overhead.
512512
bool includePTX = !Args.hasFlag(options::OPT_offload_new_driver,
513-
options::OPT_no_offload_new_driver, false);
513+
options::OPT_no_offload_new_driver, true);
514514
for (Arg *A : Args.filtered(options::OPT_cuda_include_ptx_EQ,
515515
options::OPT_no_cuda_include_ptx_EQ)) {
516516
A->claim();

0 commit comments

Comments
 (0)