Skip to content

Commit 003c88c

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#2234)
2 parents 2f7a35f + 9d52766 commit 003c88c

File tree

170 files changed

+2417
-448
lines changed

Some content is hidden

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

170 files changed

+2417
-448
lines changed

clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ AST_MATCHER_P(QualType, hasAnyType, std::vector<StringRef>, Names) {
3131
return false;
3232

3333
std::string Name = Node.getLocalUnqualifiedType().getAsString();
34-
return llvm::any_of(Names, [&Name](StringRef Ref) { return Ref == Name; });
34+
return llvm::is_contained(Names, Name);
3535
}
3636

3737
AST_MATCHER(FieldDecl, hasIntBitwidth) {

clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ int main(int argc, char *argv[]) {
5757
llvm::sort(Entries);
5858

5959
unsigned LargestValue =
60-
std::max_element(Entries.begin(), Entries.end(),
61-
[](const auto &Entry0, const auto &Entry1) {
62-
return Entry0.second.size() < Entry1.second.size();
63-
})
64-
->second.size();
60+
llvm::max_element(Entries, [](const auto &Entry0, const auto &Entry1) {
61+
return Entry0.second.size() < Entry1.second.size();
62+
})->second.size();
6563

6664
std::error_code Ec;
6765
llvm::raw_fd_ostream Os(argv[2], Ec);

clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,10 @@ static void addPlaceholderArgs(const LambdaProperties &LP,
333333

334334
ArrayRef<BindArgument> Args = LP.BindArguments;
335335

336-
const auto *MaxPlaceholderIt =
337-
std::max_element(Args.begin(), Args.end(),
338-
[](const BindArgument &B1, const BindArgument &B2) {
339-
return B1.PlaceHolderIndex < B2.PlaceHolderIndex;
340-
});
336+
const auto *MaxPlaceholderIt = llvm::max_element(
337+
Args, [](const BindArgument &B1, const BindArgument &B2) {
338+
return B1.PlaceHolderIndex < B2.PlaceHolderIndex;
339+
});
341340

342341
// Placeholders (if present) have index 1 or greater.
343342
if (!PermissiveParameterList && (MaxPlaceholderIt == Args.end() ||

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
315315

316316
// Check whether the flag exists in the command.
317317
auto HasExact = [&](llvm::StringRef Flag) {
318-
return llvm::any_of(Cmd, [&](llvm::StringRef Arg) { return Arg == Flag; });
318+
return llvm::is_contained(Cmd, Flag);
319319
};
320320

321321
// Check whether the flag appears in the command as a prefix.

clang/include/clang/AST/ExprCXX.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5129,15 +5129,15 @@ class CXXParenListInitExpr final
51295129
return getTrailingObjects<Expr *>(NumExprs);
51305130
}
51315131

5132-
const ArrayRef<Expr *> getInitExprs() const {
5132+
ArrayRef<Expr *> getInitExprs() const {
51335133
return getTrailingObjects<Expr *>(NumExprs);
51345134
}
51355135

51365136
ArrayRef<Expr *> getUserSpecifiedInitExprs() {
51375137
return getTrailingObjects<Expr *>(NumUserSpecifiedExprs);
51385138
}
51395139

5140-
const ArrayRef<Expr *> getUserSpecifiedInitExprs() const {
5140+
ArrayRef<Expr *> getUserSpecifiedInitExprs() const {
51415141
return getTrailingObjects<Expr *>(NumUserSpecifiedExprs);
51425142
}
51435143

clang/include/clang/Serialization/ContinuousRangeMap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ class ContinuousRangeMap {
119119
~Builder() {
120120
llvm::sort(Self.Rep, Compare());
121121
Self.Rep.erase(
122-
std::unique(
123-
Self.Rep.begin(), Self.Rep.end(),
122+
llvm::unique(
123+
Self.Rep,
124124
[](const_reference A, const_reference B) {
125125
// FIXME: we should not allow any duplicate keys, but there are
126126
// a lot of duplicate 0 -> 0 mappings to remove first.

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,8 @@ mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
10441044
assert(op.getType() == op.getInput().getType() &&
10451045
"Unary operation's operand type and result type are different");
10461046
mlir::Type type = op.getType();
1047-
mlir::Type elementType = type;
1048-
bool isVector = false;
1049-
assert(!cir::MissingFeatures::vectorType());
1047+
mlir::Type elementType = elementTypeIfVector(type);
1048+
bool isVector = mlir::isa<cir::VectorType>(type);
10501049
mlir::Type llvmType = getTypeConverter()->convertType(type);
10511050
mlir::Location loc = op.getLoc();
10521051

@@ -1076,20 +1075,30 @@ mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
10761075
rewriter.replaceOp(op, adaptor.getInput());
10771076
return mlir::success();
10781077
case cir::UnaryOpKind::Minus: {
1079-
assert(!isVector &&
1080-
"Add vector handling when vector types are supported");
1081-
mlir::LLVM::ConstantOp zero = rewriter.create<mlir::LLVM::ConstantOp>(
1082-
loc, llvmType, mlir::IntegerAttr::get(llvmType, 0));
1078+
mlir::Value zero;
1079+
if (isVector)
1080+
zero = rewriter.create<mlir::LLVM::ZeroOp>(loc, llvmType);
1081+
else
1082+
zero = rewriter.create<mlir::LLVM::ConstantOp>(
1083+
loc, llvmType, mlir::IntegerAttr::get(llvmType, 0));
10831084
rewriter.replaceOpWithNewOp<mlir::LLVM::SubOp>(
10841085
op, llvmType, zero, adaptor.getInput(), maybeNSW);
10851086
return mlir::success();
10861087
}
10871088
case cir::UnaryOpKind::Not: {
10881089
// bit-wise compliment operator, implemented as an XOR with -1.
1089-
assert(!isVector &&
1090-
"Add vector handling when vector types are supported");
1091-
mlir::LLVM::ConstantOp minusOne = rewriter.create<mlir::LLVM::ConstantOp>(
1092-
loc, llvmType, mlir::IntegerAttr::get(llvmType, -1));
1090+
mlir::Value minusOne;
1091+
if (isVector) {
1092+
const uint64_t numElements =
1093+
mlir::dyn_cast<cir::VectorType>(type).getSize();
1094+
std::vector<int32_t> values(numElements, -1);
1095+
mlir::DenseIntElementsAttr denseVec = rewriter.getI32VectorAttr(values);
1096+
minusOne =
1097+
rewriter.create<mlir::LLVM::ConstantOp>(loc, llvmType, denseVec);
1098+
} else {
1099+
minusOne = rewriter.create<mlir::LLVM::ConstantOp>(
1100+
loc, llvmType, mlir::IntegerAttr::get(llvmType, -1));
1101+
}
10931102
rewriter.replaceOpWithNewOp<mlir::LLVM::XOrOp>(
10941103
op, llvmType, adaptor.getInput(), minusOne);
10951104
return mlir::success();

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10952,8 +10952,7 @@ getNDSWDS(const FunctionDecl *FD, ArrayRef<ParamAttrTy> ParamAttrs) {
1095210952
}) &&
1095310953
"Invalid size");
1095410954

10955-
return std::make_tuple(*std::min_element(std::begin(Sizes), std::end(Sizes)),
10956-
*std::max_element(std::begin(Sizes), std::end(Sizes)),
10955+
return std::make_tuple(*llvm::min_element(Sizes), *llvm::max_element(Sizes),
1095710956
OutputBecomesInput);
1095810957
}
1095910958

clang/lib/CodeGen/CodeGenPGO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ CodeGenFunction::createProfileWeights(ArrayRef<uint64_t> Weights) const {
14861486
return nullptr;
14871487

14881488
// Check for empty weights.
1489-
uint64_t MaxWeight = *std::max_element(Weights.begin(), Weights.end());
1489+
uint64_t MaxWeight = *llvm::max_element(Weights);
14901490
if (MaxWeight == 0)
14911491
return nullptr;
14921492

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,9 +1818,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
18181818
// VFTablesMap, thus a simple zero check is not sufficient.
18191819

18201820
VFTableIdTy ID(RD, VPtrOffset);
1821-
VTablesMapTy::iterator I;
1822-
bool Inserted;
1823-
std::tie(I, Inserted) = VTablesMap.insert(std::make_pair(ID, nullptr));
1821+
auto [I, Inserted] = VTablesMap.try_emplace(ID);
18241822
if (!Inserted)
18251823
return I->second;
18261824

@@ -2036,10 +2034,7 @@ const VBTableGlobals &
20362034
MicrosoftCXXABI::enumerateVBTables(const CXXRecordDecl *RD) {
20372035
// At this layer, we can key the cache off of a single class, which is much
20382036
// easier than caching each vbtable individually.
2039-
llvm::DenseMap<const CXXRecordDecl*, VBTableGlobals>::iterator Entry;
2040-
bool Added;
2041-
std::tie(Entry, Added) =
2042-
VBTablesMap.insert(std::make_pair(RD, VBTableGlobals()));
2037+
auto [Entry, Added] = VBTablesMap.try_emplace(RD);
20432038
VBTableGlobals &VBGlobals = Entry->second;
20442039
if (!Added)
20452040
return VBGlobals;

0 commit comments

Comments
 (0)