Skip to content

Commit 3ceb816

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:0869204cff22831d0bb19a82c99bf85e4deb4ae3 into amd-gfx:d30ece0223f2
Local branch amd-gfx d30ece0 Merged main:504cf554639360525c3f746e7296a242350b2af9 into amd-gfx:bcf59b0f678d Remote branch main 0869204 [clang-format] Fix buildbot failures
2 parents d30ece0 + 0869204 commit 3ceb816

File tree

130 files changed

+1805
-1235
lines changed

Some content is hidden

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

130 files changed

+1805
-1235
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23392339
continue;
23402340
BinaryFunction *BF = BC.getBinaryFunctionAtAddress(FuncAddress);
23412341
assert(BF);
2342-
YamlBF.Name = FuncName.str();
2342+
YamlBF.Name = getLocationName(*BF);
23432343
YamlBF.Id = BF->getFunctionNumber();
23442344
YamlBF.Hash = BAT->getBFHash(FuncAddress);
23452345
YamlBF.ExecCount = BF->getKnownExecutionCount();
@@ -2403,6 +2403,17 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
24032403
return A.Offset < B.Offset;
24042404
});
24052405
}
2406+
// Set entry counts, similar to DataReader::readProfile.
2407+
for (const llvm::bolt::BranchInfo &BI : Branches.EntryData) {
2408+
if (!BlockMap.isInputBlock(BI.To.Offset)) {
2409+
if (opts::Verbosity >= 1)
2410+
errs() << "BOLT-WARNING: Unexpected EntryData in " << FuncName
2411+
<< " at 0x" << Twine::utohexstr(BI.To.Offset) << '\n';
2412+
continue;
2413+
}
2414+
const unsigned BlockIndex = BlockMap.getBBIndex(BI.To.Offset);
2415+
YamlBF.Blocks[BlockIndex].ExecCount += BI.Branches;
2416+
}
24062417
// Drop blocks without a hash, won't be useful for stale matching.
24072418
llvm::erase_if(YamlBF.Blocks,
24082419
[](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {

bolt/test/X86/bolt-address-translation-yaml.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ YAML-BAT-CHECK-NEXT: hash: 0x6AF7E61EA3966722
4848
YAML-BAT-CHECK-NEXT: exec: 25
4949
YAML-BAT-CHECK-NEXT: nblocks: 15
5050
YAML-BAT-CHECK-NEXT: blocks:
51+
YAML-BAT-CHECK-NEXT: - bid: 0
52+
YAML-BAT-CHECK-NEXT: insns: [[#]]
53+
YAML-BAT-CHECK-NEXT: hash: 0x700F19D24600000
54+
YAML-BAT-CHECK-NEXT: exec: 25
5155
YAML-BAT-CHECK: - bid: 3
5256
YAML-BAT-CHECK-NEXT: insns: [[#]]
5357
YAML-BAT-CHECK-NEXT: hash: 0xDDA1DC5F69F900AC

bolt/test/X86/register-fragments-bolt-symbols.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# PREAGG: B X:0 #chain.cold.0# 1 0
1616
# RUN: perf2bolt %t.bolt -p %t.preagg --pa -o %t.bat.fdata -w %t.bat.yaml -v=1 \
1717
# RUN: | FileCheck %s --check-prefix=CHECK-REGISTER
18+
# RUN: FileCheck --input-file %t.bat.fdata --check-prefix=CHECK-FDATA %s
19+
# RUN: FileCheck --input-file %t.bat.yaml --check-prefix=CHECK-YAML %s
1820

1921
# CHECK-SYMS: l df *ABS* [[#]] chain.s
2022
# CHECK-SYMS: l F .bolt.org.text [[#]] chain
@@ -24,6 +26,9 @@
2426

2527
# CHECK-REGISTER: BOLT-INFO: marking chain.cold.0/1(*2) as a fragment of chain/2(*2)
2628

29+
# CHECK-FDATA: 0 [unknown] 0 1 chain/chain.s/2 10 0 1
30+
# CHECK-YAML: - name: 'chain/chain.s/2'
31+
2732
.file "chain.s"
2833
.text
2934
.type chain, @function

clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp

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

99
#include "SimplifyBooleanExprCheck.h"
10+
#include "clang/AST/Expr.h"
1011
#include "clang/AST/RecursiveASTVisitor.h"
1112
#include "clang/Lex/Lexer.h"
1213
#include "llvm/Support/SaveAndRestore.h"
@@ -280,9 +281,8 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
280281
if (!S) {
281282
return true;
282283
}
283-
if (Check->IgnoreMacros && S->getBeginLoc().isMacroID()) {
284+
if (Check->canBeBypassed(S))
284285
return false;
285-
}
286286
if (!shouldIgnore(S))
287287
StmtStack.push_back(S);
288288
return true;
@@ -513,17 +513,23 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
513513
return true;
514514
}
515515

516-
static bool isUnaryLNot(const Expr *E) {
517-
return isa<UnaryOperator>(E) &&
516+
bool isExpectedUnaryLNot(const Expr *E) {
517+
return !Check->canBeBypassed(E) && isa<UnaryOperator>(E) &&
518518
cast<UnaryOperator>(E)->getOpcode() == UO_LNot;
519519
}
520520

521+
bool isExpectedBinaryOp(const Expr *E) {
522+
const auto *BinaryOp = dyn_cast<BinaryOperator>(E);
523+
return !Check->canBeBypassed(E) && BinaryOp && BinaryOp->isLogicalOp() &&
524+
BinaryOp->getType()->isBooleanType();
525+
}
526+
521527
template <typename Functor>
522528
static bool checkEitherSide(const BinaryOperator *BO, Functor Func) {
523529
return Func(BO->getLHS()) || Func(BO->getRHS());
524530
}
525531

526-
static bool nestedDemorgan(const Expr *E, unsigned NestingLevel) {
532+
bool nestedDemorgan(const Expr *E, unsigned NestingLevel) {
527533
const auto *BO = dyn_cast<BinaryOperator>(E->IgnoreUnlessSpelledInSource());
528534
if (!BO)
529535
return false;
@@ -539,15 +545,13 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
539545
return true;
540546
case BO_LAnd:
541547
case BO_LOr:
542-
if (checkEitherSide(BO, isUnaryLNot))
543-
return true;
544-
if (NestingLevel) {
545-
if (checkEitherSide(BO, [NestingLevel](const Expr *E) {
546-
return nestedDemorgan(E, NestingLevel - 1);
547-
}))
548-
return true;
549-
}
550-
return false;
548+
return checkEitherSide(
549+
BO,
550+
[this](const Expr *E) { return isExpectedUnaryLNot(E); }) ||
551+
(NestingLevel &&
552+
checkEitherSide(BO, [this, NestingLevel](const Expr *E) {
553+
return nestedDemorgan(E, NestingLevel - 1);
554+
}));
551555
default:
552556
return false;
553557
}
@@ -556,19 +560,19 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
556560
bool TraverseUnaryOperator(UnaryOperator *Op) {
557561
if (!Check->SimplifyDeMorgan || Op->getOpcode() != UO_LNot)
558562
return Base::TraverseUnaryOperator(Op);
559-
Expr *SubImp = Op->getSubExpr()->IgnoreImplicit();
560-
auto *Parens = dyn_cast<ParenExpr>(SubImp);
561-
auto *BinaryOp =
562-
Parens
563-
? dyn_cast<BinaryOperator>(Parens->getSubExpr()->IgnoreImplicit())
564-
: dyn_cast<BinaryOperator>(SubImp);
565-
if (!BinaryOp || !BinaryOp->isLogicalOp() ||
566-
!BinaryOp->getType()->isBooleanType())
563+
const Expr *SubImp = Op->getSubExpr()->IgnoreImplicit();
564+
const auto *Parens = dyn_cast<ParenExpr>(SubImp);
565+
const Expr *SubExpr =
566+
Parens ? Parens->getSubExpr()->IgnoreImplicit() : SubImp;
567+
if (!isExpectedBinaryOp(SubExpr))
567568
return Base::TraverseUnaryOperator(Op);
569+
const auto *BinaryOp = cast<BinaryOperator>(SubExpr);
568570
if (Check->SimplifyDeMorganRelaxed ||
569-
checkEitherSide(BinaryOp, isUnaryLNot) ||
570-
checkEitherSide(BinaryOp,
571-
[](const Expr *E) { return nestedDemorgan(E, 1); })) {
571+
checkEitherSide(
572+
BinaryOp,
573+
[this](const Expr *E) { return isExpectedUnaryLNot(E); }) ||
574+
checkEitherSide(
575+
BinaryOp, [this](const Expr *E) { return nestedDemorgan(E, 1); })) {
572576
if (Check->reportDeMorgan(Context, Op, BinaryOp, !IsProcessing, parent(),
573577
Parens) &&
574578
!Check->areDiagsSelfContained()) {
@@ -694,6 +698,10 @@ void SimplifyBooleanExprCheck::check(const MatchFinder::MatchResult &Result) {
694698
Visitor(this, *Result.Context).traverse();
695699
}
696700

701+
bool SimplifyBooleanExprCheck::canBeBypassed(const Stmt *S) const {
702+
return IgnoreMacros && S->getBeginLoc().isMacroID();
703+
}
704+
697705
void SimplifyBooleanExprCheck::issueDiag(const ASTContext &Context,
698706
SourceLocation Loc,
699707
StringRef Description,

clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class SimplifyBooleanExprCheck : public ClangTidyCheck {
6464
StringRef Description, SourceRange ReplacementRange,
6565
StringRef Replacement);
6666

67+
bool canBeBypassed(const Stmt *S) const;
68+
6769
const bool IgnoreMacros;
6870
const bool ChainedConditionalReturn;
6971
const bool ChainedConditionalAssignment;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ Changes in existing checks
357357
support calls to overloaded operators as base expression and provide fixes to
358358
expressions with side-effects.
359359

360+
- Improved :doc:`readability-simplify-boolean-expr
361+
<clang-tidy/checks/readability/simplify-boolean-expr>` check to avoid to emit
362+
warning for macro when IgnoreMacro option is enabled.
363+
360364
- Improved :doc:`readability-static-definition-in-anonymous-namespace
361365
<clang-tidy/checks/readability/static-definition-in-anonymous-namespace>`
362366
check by resolving fix-it overlaps in template code by disregarding implicit

clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr-macros.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,25 @@
66
// RUN: --
77

88
#define NEGATE(expr) !(expr)
9+
#define NOT_AND_NOT(a, b) (!a && !b)
910

1011
bool without_macro(bool a, bool b) {
1112
return !(!a && b);
1213
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: boolean expression can be simplified by DeMorgan's theorem
1314
// CHECK-FIXES: return a || !b;
1415
}
1516

16-
bool macro(bool a, bool b) {
17-
return NEGATE(!a && b);
18-
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:12: warning: boolean expression can be simplified by DeMorgan's theorem
19-
// CHECK-FIXES: return NEGATE(!a && b);
17+
void macro(bool a, bool b) {
18+
NEGATE(!a && b);
19+
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem
20+
// CHECK-FIXES: NEGATE(!a && b);
21+
!NOT_AND_NOT(a, b);
22+
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem
23+
// CHECK-FIXES: !NOT_AND_NOT(a, b);
24+
!(NEGATE(a) && b);
25+
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem
26+
// CHECK-FIXES: !(NEGATE(a) && b);
27+
!(a && NEGATE(b));
28+
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem
29+
// CHECK-FIXES: !(a && NEGATE(b));
2030
}

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ class IdentifierTable {
738738
II->Entry = &Entry;
739739

740740
// If this is the 'import' contextual keyword, mark it as such.
741-
if (Name.equals("import"))
741+
if (Name == "import")
742742
II->setModulesImport(true);
743743

744744
return *II;

clang/include/clang/Basic/SourceManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
15041504
if (Presumed.isInvalid())
15051505
return false;
15061506
StringRef Filename(Presumed.getFilename());
1507-
return Filename.equals("<built-in>");
1507+
return Filename == "<built-in>";
15081508
}
15091509

15101510
/// Returns whether \p Loc is located in a <command line> file.
@@ -1513,7 +1513,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
15131513
if (Presumed.isInvalid())
15141514
return false;
15151515
StringRef Filename(Presumed.getFilename());
1516-
return Filename.equals("<command line>");
1516+
return Filename == "<command line>";
15171517
}
15181518

15191519
/// Returns whether \p Loc is located in a <scratch space> file.
@@ -1522,7 +1522,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
15221522
if (Presumed.isInvalid())
15231523
return false;
15241524
StringRef Filename(Presumed.getFilename());
1525-
return Filename.equals("<scratch space>");
1525+
return Filename == "<scratch space>";
15261526
}
15271527

15281528
/// Returns if a SourceLocation is in a system header.

clang/include/clang/Driver/Driver.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,6 @@ class Driver {
424424
return ClangExecutable.c_str();
425425
}
426426

427-
/// Get the path to where the clang executable was installed.
428-
const char *getInstalledDir() const {
429-
return Dir.c_str();
430-
}
431-
432427
bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
433428
bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
434429

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,9 +6273,9 @@ def mno_gather : Flag<["-"], "mno-gather">, Group<m_Group>,
62736273
def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_Group>,
62746274
HelpText<"Disable generation of scatter instructions in auto-vectorization(x86 only)">;
62756275
def mapx_features_EQ : CommaJoined<["-"], "mapx-features=">, Group<m_x86_Features_Group>,
6276-
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
6276+
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf">;
62776277
def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, Group<m_x86_Features_Group>,
6278-
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
6278+
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf">;
62796279
// Features egpr, push2pop2, ppx and ndd are validated with llvm-test-suite && cpu2017 on Intel SDE.
62806280
// For stability, we turn on these features only for -mapxf. After a feature pass the validation,
62816281
// we will add it to -mapxf.

clang/lib/ARCMigrate/ObjCMT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
484484

485485
// Short circuit 'delegate' properties that contain the name "delegate" or
486486
// "dataSource", or have exact name "target" to have 'assign' attribute.
487-
if (PropertyName.equals("target") || PropertyName.contains("delegate") ||
487+
if (PropertyName == "target" || PropertyName.contains("delegate") ||
488488
PropertyName.contains("dataSource")) {
489489
QualType QT = Getter->getReturnType();
490490
if (!QT->isRealType())

clang/lib/AST/Interp/Pointer.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ class Pointer {
226226
return *this;
227227

228228
// If at base, point to an array of base types.
229-
if (asBlockPointer().Base == 0 ||
230-
asBlockPointer().Base == sizeof(InlineDescriptor))
229+
if (isRoot())
231230
return Pointer(asBlockPointer().Pointee, RootPtrMark, 0);
232231

233232
// Step into the containing array, if inside one.
@@ -306,10 +305,8 @@ class Pointer {
306305
const Descriptor *getFieldDesc() const {
307306
if (isIntegralPointer())
308307
return asIntPointer().Desc;
309-
if (isBlockPointer() &&
310-
(asBlockPointer().Base == 0 ||
311-
asBlockPointer().Base == sizeof(InlineDescriptor) ||
312-
asBlockPointer().Base == RootPtrMark))
308+
309+
if (isRoot())
313310
return getDeclDesc();
314311
return getInlineDesc()->Desc;
315312
}
@@ -390,8 +387,7 @@ class Pointer {
390387
// If this points inside a dummy block, return true.
391388
// FIXME: This might change in the future. If it does, we need
392389
// to set the proper Ctor/Dtor functions for dummy Descriptors.
393-
if (asBlockPointer().Base != 0 &&
394-
asBlockPointer().Base != sizeof(InlineDescriptor) && isDummy())
390+
if (!isRoot() && isDummy())
395391
return true;
396392
return getFieldDesc()->isUnknownSizeArray();
397393
}
@@ -403,9 +399,11 @@ class Pointer {
403399
}
404400
/// Pointer points directly to a block.
405401
bool isRoot() const {
406-
return (asBlockPointer().Base == 0 ||
407-
asBlockPointer().Base == RootPtrMark) &&
408-
Offset == 0;
402+
if (isZero() || isIntegralPointer())
403+
return true;
404+
return (asBlockPointer().Base ==
405+
asBlockPointer().Pointee->getDescriptor()->getMetadataSize() ||
406+
asBlockPointer().Base == 0);
409407
}
410408
/// If this pointer has an InlineDescriptor we can use to initialize.
411409
bool canBeInitialized() const {
@@ -487,9 +485,7 @@ class Pointer {
487485
bool isActive() const {
488486
if (!isBlockPointer())
489487
return true;
490-
return asBlockPointer().Base == 0 ||
491-
asBlockPointer().Base == sizeof(InlineDescriptor) ||
492-
getInlineDesc()->IsActive;
488+
return isRoot() || getInlineDesc()->IsActive;
493489
}
494490
/// Checks if a structure is a base class.
495491
bool isBaseClass() const { return isField() && getInlineDesc()->IsBase; }
@@ -508,10 +504,7 @@ class Pointer {
508504
bool isConst() const {
509505
if (isIntegralPointer())
510506
return true;
511-
return (asBlockPointer().Base == 0 ||
512-
asBlockPointer().Base == sizeof(InlineDescriptor))
513-
? getDeclDesc()->IsConst
514-
: getInlineDesc()->IsConst;
507+
return isRoot() ? getDeclDesc()->IsConst : getInlineDesc()->IsConst;
515508
}
516509

517510
/// Returns the declaration ID.
@@ -567,6 +560,9 @@ class Pointer {
567560

568561
if (!asBlockPointer().Pointee)
569562
return false;
563+
if (isDummy())
564+
return false;
565+
570566
return isElementPastEnd() || getSize() == getOffset();
571567
}
572568

clang/lib/AST/PrintfFormatString.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ static PrintfSpecifierResult ParsePrintfSpecifier(FormatStringHandler &H,
146146
if (Warn && (Size == 0 || Size > 8))
147147
H.handleInvalidMaskType(MaskType);
148148
FS.setMaskType(MaskType);
149-
} else if (MatchedStr.equals("sensitive"))
149+
} else if (MatchedStr == "sensitive")
150150
PrivacyFlags = clang::analyze_os_log::OSLogBufferItem::IsSensitive;
151151
else if (PrivacyFlags !=
152-
clang::analyze_os_log::OSLogBufferItem::IsSensitive &&
153-
MatchedStr.equals("private"))
152+
clang::analyze_os_log::OSLogBufferItem::IsSensitive &&
153+
MatchedStr == "private")
154154
PrivacyFlags = clang::analyze_os_log::OSLogBufferItem::IsPrivate;
155-
else if (PrivacyFlags == 0 && MatchedStr.equals("public"))
155+
else if (PrivacyFlags == 0 && MatchedStr == "public")
156156
PrivacyFlags = clang::analyze_os_log::OSLogBufferItem::IsPublic;
157157
} else {
158158
size_t CommaOrBracePos =

0 commit comments

Comments
 (0)