Skip to content

Commit cab00da

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents 58b9ff6 + a438555 commit cab00da

File tree

31 files changed

+520
-356
lines changed

31 files changed

+520
-356
lines changed

bolt/lib/Rewrite/BuildIDRewriter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ Error BuildIDRewriter::sectionInitializer() {
7878
"out of bounds while reading note section: %s",
7979
toString(Cursor.takeError()).c_str());
8080

81-
if (Type == ELF::NT_GNU_BUILD_ID && Name.substr(0, 3) == "GNU" &&
82-
DescSz) {
81+
if (Type == ELF::NT_GNU_BUILD_ID && Name.starts_with("GNU") && DescSz) {
8382
BuildIDSection = NoteSection;
8483
BuildID = Desc;
8584
BC.setFileBuildID(getPrintableBuildID(Desc));

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,7 @@ enum DriverMode : unsigned char {
404404
DriverMode getDriverMode(const std::vector<std::string> &Args) {
405405
DriverMode Mode = DM_GCC;
406406
llvm::StringRef Argv0 = Args.front();
407-
if (Argv0.ends_with_insensitive(".exe"))
408-
Argv0 = Argv0.drop_back(strlen(".exe"));
407+
Argv0.consume_back_insensitive(".exe");
409408
if (Argv0.ends_with_insensitive("cl"))
410409
Mode = DM_CL;
411410
for (const llvm::StringRef Arg : Args) {

clang/include/clang/Driver/Compilation.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,8 @@ class Compilation {
9090
: TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
9191

9292
bool operator<(const TCArgsKey &K) const {
93-
if (TC < K.TC)
94-
return true;
95-
else if (TC == K.TC && BoundArch < K.BoundArch)
96-
return true;
97-
else if (TC == K.TC && BoundArch == K.BoundArch &&
98-
DeviceOffloadKind < K.DeviceOffloadKind)
99-
return true;
100-
return false;
93+
return std::tie(TC, BoundArch, DeviceOffloadKind) <
94+
std::tie(K.TC, K.BoundArch, K.DeviceOffloadKind);
10195
}
10296
};
10397
std::map<TCArgsKey, llvm::opt::DerivedArgList *> TCArgs;

clang/lib/Driver/Job.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ rewriteIncludes(const llvm::ArrayRef<const char *> &Args, size_t Idx,
187187
StringRef FlagRef(Args[Idx + NumArgs - 1]);
188188
assert((FlagRef.starts_with("-F") || FlagRef.starts_with("-I")) &&
189189
"Expecting -I or -F");
190-
StringRef Inc = FlagRef.slice(2, StringRef::npos);
190+
StringRef Inc = FlagRef.substr(2);
191191
if (getAbsPath(Inc, NewInc)) {
192192
SmallString<128> NewArg(FlagRef.slice(0, 2));
193193
NewArg += NewInc;

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ std::string ToolChain::detectLibcxxVersion(StringRef IncludePath) const {
14481448
StringRef VersionText = llvm::sys::path::filename(LI->path());
14491449
int Version;
14501450
if (VersionText[0] == 'v' &&
1451-
!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
1451+
!VersionText.substr(1).getAsInteger(10, Version)) {
14521452
if (Version > MaxVersion) {
14531453
MaxVersion = Version;
14541454
MaxVersionString = std::string(VersionText);

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer,
100100
unsigned Column;
101101

102102
bool operator<(const Position &other) const {
103-
if (Line < other.Line)
104-
return true;
105-
if (Line > other.Line)
106-
return false;
107-
return Column < other.Column;
103+
return std::tie(Line, Column) < std::tie(other.Line, other.Column);
108104
}
109105

110106
static Position GetBeginSpelling(const SourceManager &SM,

clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ class ZeroState {
4141
}
4242

4343
bool operator<(const ZeroState &X) const {
44-
if (BlockID != X.BlockID)
45-
return BlockID < X.BlockID;
46-
if (SFC != X.SFC)
47-
return SFC < X.SFC;
48-
return ZeroSymbol < X.ZeroSymbol;
44+
return std::tie(BlockID, SFC, ZeroSymbol) <
45+
std::tie(X.BlockID, X.SFC, X.ZeroSymbol);
4946
}
5047

5148
void Profile(llvm::FoldingSetNodeID &ID) const {

clang/utils/TableGen/ClangOptionDocEmitter.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@ std::string escapeRST(StringRef Str) {
205205
}
206206

207207
StringRef getSphinxOptionID(StringRef OptionName) {
208-
for (auto I = OptionName.begin(), E = OptionName.end(); I != E; ++I)
209-
if (!isalnum(*I) && *I != '-')
210-
return OptionName.substr(0, I - OptionName.begin());
211-
return OptionName;
208+
return OptionName.take_while([](char C) { return isalnum(C) || C == '-'; });
212209
}
213210

214211
bool canSphinxCopeWithOption(const Record *Option) {

llvm/include/llvm/Support/InstructionCost.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "llvm/Support/MathExtras.h"
2222
#include <limits>
23+
#include <tuple>
2324

2425
namespace llvm {
2526

@@ -191,9 +192,7 @@ class InstructionCost {
191192
/// the states are valid and users can test for validity of the cost
192193
/// explicitly.
193194
bool operator<(const InstructionCost &RHS) const {
194-
if (State != RHS.State)
195-
return State < RHS.State;
196-
return Value < RHS.Value;
195+
return std::tie(State, Value) < std::tie(RHS.State, RHS.Value);
197196
}
198197

199198
bool operator==(const InstructionCost &RHS) const {

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15867,49 +15867,45 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
1586715867
}
1586815868

1586915869
const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) {
15870-
auto I = Map.find(Expr);
15871-
if (I == Map.end()) {
15872-
// If we didn't find the extact ZExt expr in the map, check if there's
15873-
// an entry for a smaller ZExt we can use instead.
15874-
Type *Ty = Expr->getType();
15875-
const SCEV *Op = Expr->getOperand(0);
15876-
unsigned Bitwidth = Ty->getScalarSizeInBits() / 2;
15877-
while (Bitwidth % 8 == 0 && Bitwidth >= 8 &&
15878-
Bitwidth > Op->getType()->getScalarSizeInBits()) {
15879-
Type *NarrowTy = IntegerType::get(SE.getContext(), Bitwidth);
15880-
auto *NarrowExt = SE.getZeroExtendExpr(Op, NarrowTy);
15881-
auto I = Map.find(NarrowExt);
15882-
if (I != Map.end())
15883-
return SE.getZeroExtendExpr(I->second, Ty);
15884-
Bitwidth = Bitwidth / 2;
15885-
}
15870+
if (const SCEV *S = Map.lookup(Expr))
15871+
return S;
1588615872

15887-
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitZeroExtendExpr(
15888-
Expr);
15873+
// If we didn't find the extact ZExt expr in the map, check if there's
15874+
// an entry for a smaller ZExt we can use instead.
15875+
Type *Ty = Expr->getType();
15876+
const SCEV *Op = Expr->getOperand(0);
15877+
unsigned Bitwidth = Ty->getScalarSizeInBits() / 2;
15878+
while (Bitwidth % 8 == 0 && Bitwidth >= 8 &&
15879+
Bitwidth > Op->getType()->getScalarSizeInBits()) {
15880+
Type *NarrowTy = IntegerType::get(SE.getContext(), Bitwidth);
15881+
auto *NarrowExt = SE.getZeroExtendExpr(Op, NarrowTy);
15882+
auto I = Map.find(NarrowExt);
15883+
if (I != Map.end())
15884+
return SE.getZeroExtendExpr(I->second, Ty);
15885+
Bitwidth = Bitwidth / 2;
1588915886
}
15890-
return I->second;
15887+
15888+
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitZeroExtendExpr(
15889+
Expr);
1589115890
}
1589215891

1589315892
const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) {
15894-
auto I = Map.find(Expr);
15895-
if (I == Map.end())
15896-
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSignExtendExpr(
15897-
Expr);
15898-
return I->second;
15893+
if (const SCEV *S = Map.lookup(Expr))
15894+
return S;
15895+
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSignExtendExpr(
15896+
Expr);
1589915897
}
1590015898

1590115899
const SCEV *visitUMinExpr(const SCEVUMinExpr *Expr) {
15902-
auto I = Map.find(Expr);
15903-
if (I == Map.end())
15904-
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitUMinExpr(Expr);
15905-
return I->second;
15900+
if (const SCEV *S = Map.lookup(Expr))
15901+
return S;
15902+
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitUMinExpr(Expr);
1590615903
}
1590715904

1590815905
const SCEV *visitSMinExpr(const SCEVSMinExpr *Expr) {
15909-
auto I = Map.find(Expr);
15910-
if (I == Map.end())
15911-
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSMinExpr(Expr);
15912-
return I->second;
15906+
if (const SCEV *S = Map.lookup(Expr))
15907+
return S;
15908+
return SCEVRewriteVisitor<SCEVLoopGuardRewriter>::visitSMinExpr(Expr);
1591315909
}
1591415910

1591515911
const SCEV *visitAddExpr(const SCEVAddExpr *Expr) {

0 commit comments

Comments
 (0)