Skip to content

Commit 63e627b

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:e9b33d085da0 into amd-gfx:6510fa067355
Local branch amd-gfx 6510fa0 Merged main:5b7a7ec5a210 into amd-gfx:5546a043a84f Remote branch main e9b33d0 [ConstraintElim] Add extra tests with nested loops and iv decrements.
2 parents 6510fa0 + e9b33d0 commit 63e627b

File tree

182 files changed

+4068
-3394
lines changed

Some content is hidden

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

182 files changed

+4068
-3394
lines changed

bolt/lib/Core/DebugData.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ void DebugAddrWriterDwarf5::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
495495
const endianness Endian =
496496
BC->DwCtx->isLittleEndian() ? support::little : support::big;
497497
const DWARFSection &AddrSec = BC->DwCtx->getDWARFObj().getAddrSection();
498-
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec, Endian, 0);
498+
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec,
499+
Endian == support::little, 0);
499500
DWARFDebugAddrTable AddrTable;
500501
DIDumpOptions DumpOpts;
501502
constexpr uint32_t HeaderSize = 8;

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4557,18 +4557,19 @@ foreach i = {8-15,18} in
45574557
HelpText<"Make the x"#i#" register call-saved (AArch64 only)">;
45584558

45594559
def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, Group<m_aarch64_Features_Group>,
4560+
Visibility<[ClangOption, FlangOption]>,
45604561
HelpText<"Specify the size in bits of an SVE vector register. Defaults to the"
45614562
" vector length agnostic value of \"scalable\". (AArch64 only)">;
45624563
} // let Flags = [TargetSpecific]
45634564

45644565
def mvscale_min_EQ : Joined<["-"], "mvscale-min=">,
45654566
Group<m_aarch64_Features_Group>, Flags<[NoXarchOption]>,
4566-
Visibility<[ClangOption, CC1Option]>,
4567+
Visibility<[ClangOption, CC1Option, FC1Option]>,
45674568
HelpText<"Specify the vscale minimum. Defaults to \"1\". (AArch64/RISC-V only)">,
45684569
MarshallingInfoInt<LangOpts<"VScaleMin">>;
45694570
def mvscale_max_EQ : Joined<["-"], "mvscale-max=">,
45704571
Group<m_aarch64_Features_Group>, Flags<[NoXarchOption]>,
4571-
Visibility<[ClangOption, CC1Option]>,
4572+
Visibility<[ClangOption, CC1Option, FC1Option]>,
45724573
HelpText<"Specify the vscale maximum. Defaults to the"
45734574
" vector length agnostic value of \"0\". (AArch64/RISC-V only)">,
45744575
MarshallingInfoInt<LangOpts<"VScaleMax">>;

clang/lib/AST/Interp/IntegralAP.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ template <bool Signed> class IntegralAP final {
3939
using AsUnsigned = IntegralAP<false>;
4040

4141
template <typename T>
42-
IntegralAP(T Value) : V(APInt(sizeof(T) * 8, Value, std::is_signed_v<T>)) {}
42+
IntegralAP(T Value)
43+
: V(APInt(sizeof(T) * 8, static_cast<uint64_t>(Value),
44+
std::is_signed_v<T>)) {}
4345

4446
IntegralAP(APInt V) : V(V) {}
4547
IntegralAP(APSInt V) : V(V) {}

clang/lib/AST/StmtProfile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,8 @@ void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
13351335
S->getValue().Profile(ID);
13361336

13371337
QualType T = S->getType();
1338+
if (Canonical)
1339+
T = T.getCanonicalType();
13381340
ID.AddInteger(T->getTypeClass());
13391341
if (auto BitIntT = T->getAs<BitIntType>())
13401342
BitIntT->Profile(ID);

clang/lib/CodeGen/CGDeclCXX.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,13 +666,13 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
666666
// Module initializers for imported modules are emitted first.
667667

668668
// Collect all the modules that we import
669-
SmallVector<Module *> AllImports;
669+
llvm::SmallSetVector<Module *, 8> AllImports;
670670
// Ones that we export
671671
for (auto I : Primary->Exports)
672-
AllImports.push_back(I.getPointer());
672+
AllImports.insert(I.getPointer());
673673
// Ones that we only import.
674674
for (Module *M : Primary->Imports)
675-
AllImports.push_back(M);
675+
AllImports.insert(M);
676676
// Ones that we import in the global module fragment or the private module
677677
// fragment.
678678
llvm::for_each(Primary->submodules(), [&AllImports](Module *SubM) {
@@ -683,7 +683,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
683683
"The global mdoule fragments and the private module fragments are "
684684
"not allowed to export import modules.");
685685
for (Module *M : SubM->Imports)
686-
AllImports.push_back(M);
686+
AllImports.insert(M);
687687
});
688688

689689
SmallVector<llvm::Function *, 8> ModuleInits;

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,6 +2938,9 @@ void CodeGenModule::EmitModuleInitializers(clang::Module *Primary) {
29382938
// Third any associated with the Privat eMOdule Fragment, if present.
29392939
if (auto PMF = Primary->getPrivateModuleFragment()) {
29402940
for (Decl *D : getContext().getModuleInitializers(PMF)) {
2941+
// Skip import decls, the inits for those are called explicitly.
2942+
if (isa<ImportDecl>(D))
2943+
continue;
29412944
assert(isa<VarDecl>(D) && "PMF initializer decl is not a var?");
29422945
EmitTopLevelDecl(D);
29432946
}

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -969,41 +969,29 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC,
969969
llvm::opt::ArgStringList &CmdArgs) {
970970
if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
971971
CmdArgs.push_back("Fortran_main.lib");
972-
CmdArgs.push_back("flang-rt.lib");
972+
CmdArgs.push_back("FortranRuntime.lib");
973+
CmdArgs.push_back("FortranDecimal.lib");
973974
} else {
974975
CmdArgs.push_back("-lFortran_main");
975-
CmdArgs.push_back("-lflang-rt");
976+
CmdArgs.push_back("-lFortranRuntime");
977+
CmdArgs.push_back("-lFortranDecimal");
976978
}
977979
}
978980

979981
void tools::addFortranRuntimeLibraryPath(const ToolChain &TC,
980982
const llvm::opt::ArgList &Args,
981983
ArgStringList &CmdArgs) {
982-
// Default to the <driver-path>/../lib, <driver-path>/../flang-rt/lib, and
983-
// <driver-path>/../runtimes/runtimes-bins/flang-rt/lib directories. This
984-
// works fine on the platforms that we have tested so far. We will probably
985-
// have to re-fine this in the future. In particular, on some platforms, we
986-
// may need to use lib64 instead of lib.
987-
SmallString<256> BuildLibPath =
988-
llvm::sys::path::parent_path(TC.getDriver().Dir);
989-
SmallString<256> FlangRTLibPath =
990-
llvm::sys::path::parent_path(TC.getDriver().Dir);
991-
SmallString<256> RuntimesLibPath =
984+
// Default to the <driver-path>/../lib directory. This works fine on the
985+
// platforms that we have tested so far. We will probably have to re-fine
986+
// this in the future. In particular, on some platforms, we may need to use
987+
// lib64 instead of lib.
988+
SmallString<256> DefaultLibPath =
992989
llvm::sys::path::parent_path(TC.getDriver().Dir);
993-
// Search path for Fortran_main and Flang-rt libraries.
994-
llvm::sys::path::append(BuildLibPath, "lib");
995-
llvm::sys::path::append(FlangRTLibPath, "flang-rt/lib");
996-
llvm::sys::path::append(RuntimesLibPath,
997-
"runtimes/runtimes-bins/flang-rt/lib");
998-
if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
999-
CmdArgs.push_back(Args.MakeArgString("-libpath:" + BuildLibPath));
1000-
CmdArgs.push_back(Args.MakeArgString("-libpath:" + FlangRTLibPath));
1001-
CmdArgs.push_back(Args.MakeArgString("-libpath:" + RuntimesLibPath));
1002-
} else {
1003-
CmdArgs.push_back(Args.MakeArgString("-L" + BuildLibPath));
1004-
CmdArgs.push_back(Args.MakeArgString("-L" + FlangRTLibPath));
1005-
CmdArgs.push_back(Args.MakeArgString("-L" + RuntimesLibPath));
1006-
}
990+
llvm::sys::path::append(DefaultLibPath, "lib");
991+
if (TC.getTriple().isKnownWindowsMSVCEnvironment())
992+
CmdArgs.push_back(Args.MakeArgString("-libpath:" + DefaultLibPath));
993+
else
994+
CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath));
1007995
}
1008996

1009997
static void addSanitizerRuntime(const ToolChain &TC, const ArgList &Args,

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
109
#include "Flang.h"
1110
#include "CommonArgs.h"
1211

@@ -170,6 +169,38 @@ void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
170169
}
171170
}
172171

172+
void Flang::AddAArch64TargetArgs(const ArgList &Args,
173+
ArgStringList &CmdArgs) const {
174+
// Handle -msve_vector_bits=<bits>
175+
if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
176+
StringRef Val = A->getValue();
177+
const Driver &D = getToolChain().getDriver();
178+
if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
179+
Val.equals("1024") || Val.equals("2048") || Val.equals("128+") ||
180+
Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
181+
Val.equals("2048+")) {
182+
unsigned Bits = 0;
183+
if (Val.endswith("+"))
184+
Val = Val.substr(0, Val.size() - 1);
185+
else {
186+
[[maybe_unused]] bool Invalid = Val.getAsInteger(10, Bits);
187+
assert(!Invalid && "Failed to parse value");
188+
CmdArgs.push_back(
189+
Args.MakeArgString("-mvscale-max=" + llvm::Twine(Bits / 128)));
190+
}
191+
192+
[[maybe_unused]] bool Invalid = Val.getAsInteger(10, Bits);
193+
assert(!Invalid && "Failed to parse value");
194+
CmdArgs.push_back(
195+
Args.MakeArgString("-mvscale-min=" + llvm::Twine(Bits / 128)));
196+
// Silently drop requests for vector-length agnostic code as it's implied.
197+
} else if (!Val.equals("scalable"))
198+
// Handle the unsupported values passed to msve-vector-bits.
199+
D.Diag(diag::err_drv_unsupported_option_argument)
200+
<< A->getSpelling() << Val;
201+
}
202+
}
203+
173204
void Flang::addTargetOptions(const ArgList &Args,
174205
ArgStringList &CmdArgs) const {
175206
const ToolChain &TC = getToolChain();
@@ -186,9 +217,13 @@ void Flang::addTargetOptions(const ArgList &Args,
186217
switch (TC.getArch()) {
187218
default:
188219
break;
220+
case llvm::Triple::aarch64:
221+
getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
222+
AddAArch64TargetArgs(Args, CmdArgs);
223+
break;
224+
189225
case llvm::Triple::r600:
190226
case llvm::Triple::amdgcn:
191-
case llvm::Triple::aarch64:
192227
case llvm::Triple::riscv64:
193228
case llvm::Triple::x86_64:
194229
getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);

clang/lib/Driver/ToolChains/Flang.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ class LLVM_LIBRARY_VISIBILITY Flang : public Tool {
5656
void addTargetOptions(const llvm::opt::ArgList &Args,
5757
llvm::opt::ArgStringList &CmdArgs) const;
5858

59+
/// Add specific options for AArch64 target.
60+
///
61+
/// \param [in] Args The list of input driver arguments
62+
/// \param [out] CmdArgs The list of output command arguments
63+
void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
64+
llvm::opt::ArgStringList &CmdArgs) const;
65+
5966
/// Extract offload options from the driver arguments and add them to
6067
/// the command arguments.
6168
/// \param [in] C The current compilation for the driver invocation

clang/lib/Driver/ToolChains/MinGW.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,11 @@ void toolchains::MinGW::addClangTargetOptions(
709709
}
710710
}
711711

712-
if (Arg *A = DriverArgs.getLastArgNoClaim(options::OPT_mthreads))
713-
A->ignoreTargetSpecific();
712+
for (auto Opt : {options::OPT_mthreads, options::OPT_mwindows,
713+
options::OPT_mconsole, options::OPT_mdll}) {
714+
if (Arg *A = DriverArgs.getLastArgNoClaim(Opt))
715+
A->ignoreTargetSpecific();
716+
}
714717
}
715718

716719
void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,8 +2016,7 @@ class AnnotatingParser {
20162016
Style.Language == FormatStyle::LK_Java) {
20172017
Current.setType(TT_LambdaArrow);
20182018
} else if (Current.is(tok::arrow) && AutoFound &&
2019-
(Line.MightBeFunctionDecl || Line.InPPDirective) &&
2020-
Current.NestingLevel == 0 &&
2019+
Line.MightBeFunctionDecl && Current.NestingLevel == 0 &&
20212020
!Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
20222021
// not auto operator->() -> xxx;
20232022
Current.setType(TT_TrailingReturnArrow);
@@ -3252,7 +3251,8 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
32523251
// This function heuristically determines whether 'Current' starts the name of a
32533252
// function declaration.
32543253
static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
3255-
const AnnotatedLine &Line) {
3254+
const AnnotatedLine &Line,
3255+
FormatToken *&ClosingParen) {
32563256
assert(Current.Previous);
32573257

32583258
if (Current.is(TT_FunctionDeclarationName))
@@ -3344,16 +3344,16 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
33443344
// Check whether parameter list can belong to a function declaration.
33453345
if (!Next || Next->isNot(tok::l_paren) || !Next->MatchingParen)
33463346
return false;
3347+
ClosingParen = Next->MatchingParen;
3348+
assert(ClosingParen->is(tok::r_paren));
33473349
// If the lines ends with "{", this is likely a function definition.
33483350
if (Line.Last->is(tok::l_brace))
33493351
return true;
3350-
if (Next->Next == Next->MatchingParen)
3352+
if (Next->Next == ClosingParen)
33513353
return true; // Empty parentheses.
33523354
// If there is an &/&& after the r_paren, this is likely a function.
3353-
if (Next->MatchingParen->Next &&
3354-
Next->MatchingParen->Next->is(TT_PointerOrReference)) {
3355+
if (ClosingParen->Next && ClosingParen->Next->is(TT_PointerOrReference))
33553356
return true;
3356-
}
33573357

33583358
// Check for K&R C function definitions (and C++ function definitions with
33593359
// unnamed parameters), e.g.:
@@ -3370,7 +3370,7 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
33703370
return true;
33713371
}
33723372

3373-
for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
3373+
for (const FormatToken *Tok = Next->Next; Tok && Tok != ClosingParen;
33743374
Tok = Tok->Next) {
33753375
if (Tok->is(TT_TypeDeclarationParen))
33763376
return true;
@@ -3442,11 +3442,12 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
34423442
calculateArrayInitializerColumnList(Line);
34433443

34443444
bool LineIsFunctionDeclaration = false;
3445+
FormatToken *ClosingParen = nullptr;
34453446
for (FormatToken *Tok = Current, *AfterLastAttribute = nullptr; Tok;
34463447
Tok = Tok->Next) {
34473448
if (Tok->Previous->EndsCppAttributeGroup)
34483449
AfterLastAttribute = Tok;
3449-
if (isFunctionDeclarationName(Style.isCpp(), *Tok, Line)) {
3450+
if (isFunctionDeclarationName(Style.isCpp(), *Tok, Line, ClosingParen)) {
34503451
LineIsFunctionDeclaration = true;
34513452
Tok->setFinalizedType(TT_FunctionDeclarationName);
34523453
if (AfterLastAttribute &&
@@ -3458,29 +3459,38 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
34583459
}
34593460
}
34603461

3461-
if (Style.isCpp() && !LineIsFunctionDeclaration) {
3462-
// Annotate */&/&& in `operator` function calls as binary operators.
3463-
for (const auto *Tok = Line.First; Tok; Tok = Tok->Next) {
3464-
if (Tok->isNot(tok::kw_operator))
3465-
continue;
3466-
do {
3467-
Tok = Tok->Next;
3468-
} while (Tok && Tok->isNot(TT_OverloadedOperatorLParen));
3469-
if (!Tok)
3470-
break;
3471-
const auto *LeftParen = Tok;
3472-
for (Tok = Tok->Next; Tok && Tok != LeftParen->MatchingParen;
3473-
Tok = Tok->Next) {
3474-
if (Tok->isNot(tok::identifier))
3475-
continue;
3476-
auto *Next = Tok->Next;
3477-
const bool NextIsBinaryOperator =
3478-
Next && Next->isOneOf(tok::star, tok::amp, tok::ampamp) &&
3479-
Next->Next && Next->Next->is(tok::identifier);
3480-
if (!NextIsBinaryOperator)
3462+
if (Style.isCpp()) {
3463+
if (!LineIsFunctionDeclaration) {
3464+
// Annotate */&/&& in `operator` function calls as binary operators.
3465+
for (const auto *Tok = Line.First; Tok; Tok = Tok->Next) {
3466+
if (Tok->isNot(tok::kw_operator))
34813467
continue;
3482-
Next->setType(TT_BinaryOperator);
3483-
Tok = Next;
3468+
do {
3469+
Tok = Tok->Next;
3470+
} while (Tok && Tok->isNot(TT_OverloadedOperatorLParen));
3471+
if (!Tok)
3472+
break;
3473+
const auto *LeftParen = Tok;
3474+
for (Tok = Tok->Next; Tok && Tok != LeftParen->MatchingParen;
3475+
Tok = Tok->Next) {
3476+
if (Tok->isNot(tok::identifier))
3477+
continue;
3478+
auto *Next = Tok->Next;
3479+
const bool NextIsBinaryOperator =
3480+
Next && Next->isOneOf(tok::star, tok::amp, tok::ampamp) &&
3481+
Next->Next && Next->Next->is(tok::identifier);
3482+
if (!NextIsBinaryOperator)
3483+
continue;
3484+
Next->setType(TT_BinaryOperator);
3485+
Tok = Next;
3486+
}
3487+
}
3488+
} else if (ClosingParen) {
3489+
for (auto *Tok = ClosingParen->Next; Tok; Tok = Tok->Next) {
3490+
if (Tok->is(tok::arrow)) {
3491+
Tok->setType(TT_TrailingReturnArrow);
3492+
break;
3493+
}
34843494
}
34853495
}
34863496
}

0 commit comments

Comments
 (0)