Skip to content

Commit 70925fa

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:e35b60628093 into amd-gfx:b59526a8f0aa
Local branch amd-gfx b59526a Merged main:410f130bb99b into amd-gfx:c44543097cba Remote branch main e35b606 [mlir][sparsifier] fix `isAdmissibleBSR` (llvm#72195)
2 parents b59526a + e35b606 commit 70925fa

File tree

87 files changed

+2076
-661
lines changed

Some content is hidden

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

87 files changed

+2076
-661
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ class BinaryFunction {
12961296
/// Return true if the function body is non-contiguous.
12971297
bool isSplit() const { return isSimple() && getLayout().isSplit(); }
12981298

1299-
bool shouldPreserveNops() const;
1299+
bool shouldPreserveNops() const { return PreserveNops; }
13001300

13011301
/// Return true if the function has exception handling tables.
13021302
bool hasEHRanges() const { return HasEHRanges; }

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4367,10 +4367,6 @@ MCInst *BinaryFunction::getInstructionAtOffset(uint64_t Offset) {
43674367
}
43684368
}
43694369

4370-
bool BinaryFunction::shouldPreserveNops() const {
4371-
return PreserveNops || opts::KeepNops;
4372-
}
4373-
43744370
void BinaryFunction::printLoopInfo(raw_ostream &OS) const {
43754371
if (!opts::shouldPrint(*this))
43764372
return;

bolt/lib/Rewrite/BinaryPassManager.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ static cl::opt<bool> JTFootprintReductionFlag(
7272
"instructions at jump sites"),
7373
cl::cat(BoltOptCategory));
7474

75+
static cl::opt<bool>
76+
KeepNops("keep-nops",
77+
cl::desc("keep no-op instructions. By default they are removed."),
78+
cl::Hidden, cl::cat(BoltOptCategory));
79+
7580
cl::opt<bool> NeverPrint("never-print", cl::desc("never print"),
7681
cl::ReallyHidden, cl::cat(BoltOptCategory));
7782

@@ -359,7 +364,8 @@ void BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
359364

360365
Manager.registerPass(std::make_unique<ShortenInstructions>(NeverPrint));
361366

362-
Manager.registerPass(std::make_unique<RemoveNops>(NeverPrint));
367+
Manager.registerPass(std::make_unique<RemoveNops>(NeverPrint),
368+
!opts::KeepNops);
363369

364370
Manager.registerPass(std::make_unique<NormalizeCFG>(PrintNormalized));
365371

bolt/lib/Utils/CommandLineOpts.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ cl::opt<bool>
129129
cl::desc("instrument code to generate accurate profile data"),
130130
cl::cat(BoltOptCategory));
131131

132-
cl::opt<bool>
133-
KeepNops("keep-nops",
134-
cl::desc("keep no-op instructions. By default they are removed."),
135-
cl::Hidden, cl::cat(BoltOptCategory));
136-
137132
cl::opt<std::string>
138133
OutputFilename("o",
139134
cl::desc("<output file>"),

clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ using namespace clang::ast_matchers;
1919

2020
namespace clang::tidy::abseil {
2121

22+
const auto DefaultStringLikeClasses =
23+
"::std::basic_string;::std::basic_string_view";
24+
2225
StringFindStartswithCheck::StringFindStartswithCheck(StringRef Name,
2326
ClangTidyContext *Context)
2427
: ClangTidyCheck(Name, Context),
2528
StringLikeClasses(utils::options::parseStringList(
26-
Options.get("StringLikeClasses", "::std::basic_string"))),
29+
Options.get("StringLikeClasses", DefaultStringLikeClasses))),
2730
IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
2831
utils::IncludeSorter::IS_LLVM),
2932
areDiagsSelfContained()),

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression,
152152
return "false";
153153
}
154154

155-
if (const auto *IntLit = dyn_cast<IntegerLiteral>(Expression)) {
155+
if (const auto *IntLit =
156+
dyn_cast<IntegerLiteral>(Expression->IgnoreParens())) {
156157
return (IntLit->getValue() == 0) ? "false" : "true";
157158
}
158159

@@ -385,7 +386,7 @@ void ImplicitBoolConversionCheck::handleCastFromBool(
385386
<< DestType;
386387

387388
if (const auto *BoolLiteral =
388-
dyn_cast<CXXBoolLiteralExpr>(Cast->getSubExpr())) {
389+
dyn_cast<CXXBoolLiteralExpr>(Cast->getSubExpr()->IgnoreParens())) {
389390
Diag << tooling::fixit::createReplacement(
390391
*Cast, getEquivalentForBoolLiteral(BoolLiteral, DestType, Context));
391392
} else {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ New check aliases
208208
Changes in existing checks
209209
^^^^^^^^^^^^^^^^^^^^^^^^^^
210210

211+
- Improved :doc:`abseil-string-find-startswith
212+
<clang-tidy/checks/abseil/string-find-startswith>` check to also consider
213+
``std::basic_string_view`` in addition to ``std::basic_string`` by default.
214+
211215
- Improved :doc:`bugprone-dangling-handle
212216
<clang-tidy/checks/bugprone/dangling-handle>` check to support functional
213217
casting during type conversions at variable initialization, now with improved
@@ -315,7 +319,9 @@ Changes in existing checks
315319

316320
- Improved :doc:`misc-const-correctness
317321
<clang-tidy/checks/misc/const-correctness>` check to avoid false positive when
318-
using pointer to member function.
322+
using pointer to member function. Additionally, the check no longer emits
323+
a diagnostic when a variable that is not type-dependent is an operand of a
324+
type-dependent binary operator.
319325

320326
- Improved :doc:`misc-include-cleaner
321327
<clang-tidy/checks/misc/include-cleaner>` check by adding option
@@ -410,7 +416,8 @@ Changes in existing checks
410416
- Improved :doc:`readability-implicit-bool-conversion
411417
<clang-tidy/checks/readability/implicit-bool-conversion>` check to take
412418
do-while loops into account for the `AllowIntegerConditions` and
413-
`AllowPointerConditions` options.
419+
`AllowPointerConditions` options. It also now provides more consistent
420+
suggestions when parentheses are added to the return value.
414421

415422
- Improved :doc:`readability-non-const-parameter
416423
<clang-tidy/checks/readability/non-const-parameter>` check to ignore

clang-tools-extra/docs/clang-tidy/checks/abseil/string-find-startswith.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
abseil-string-find-startswith
44
=============================
55

6-
Checks whether a ``std::string::find()`` or ``std::string::rfind()`` result is
7-
compared with 0, and suggests replacing with ``absl::StartsWith()``. This is
8-
both a readability and performance issue.
6+
Checks whether a ``std::string::find()`` or ``std::string::rfind()`` (and
7+
corresponding ``std::string_view`` methods) result is compared with 0, and
8+
suggests replacing with ``absl::StartsWith()``. This is both a readability and
9+
performance issue.
910

1011
.. code-block:: c++
1112

@@ -28,9 +29,9 @@ Options
2829

2930
.. option:: StringLikeClasses
3031

31-
Semicolon-separated list of names of string-like classes. By default only
32-
``std::basic_string`` is considered. The list of methods to considered is
33-
fixed.
32+
Semicolon-separated list of names of string-like classes. By default both
33+
``std::basic_string`` and ``std::basic_string_view`` are considered. The list
34+
of methods to be considered is fixed.
3435

3536
.. option:: IncludeStyle
3637

clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ struct basic_string {
4343
size_type find(const C* s, size_type pos = 0) const;
4444
size_type find(const C* s, size_type pos, size_type n) const;
4545

46+
size_type rfind(const _Type& str, size_type pos = npos) const;
47+
size_type rfind(const C* s, size_type pos, size_type count) const;
48+
size_type rfind(const C* s, size_type pos = npos) const;
49+
size_type rfind(C ch, size_type pos = npos) const;
50+
4651
_Type& insert(size_type pos, const _Type& str);
4752
_Type& insert(size_type pos, const C* s);
4853
_Type& insert(size_type pos, const C* s, size_type n);
@@ -54,6 +59,8 @@ struct basic_string {
5459
_Type& operator+=(const C* s);
5560
_Type& operator=(const _Type& str);
5661
_Type& operator=(const C* s);
62+
63+
static constexpr size_t npos = -1;
5764
};
5865

5966
typedef basic_string<char> string;
@@ -63,8 +70,23 @@ typedef basic_string<char32> u32string;
6370

6471
template <typename C, typename T = char_traits<C>>
6572
struct basic_string_view {
73+
typedef size_t size_type;
74+
typedef basic_string_view<C, T> _Type;
75+
6676
const C *str;
6777
constexpr basic_string_view(const C* s) : str(s) {}
78+
79+
size_type find(_Type v, size_type pos = 0) const;
80+
size_type find(C ch, size_type pos = 0) const;
81+
size_type find(const C* s, size_type pos, size_type count) const;
82+
size_type find(const C* s, size_type pos = 0) const;
83+
84+
size_type rfind(_Type v, size_type pos = npos) const;
85+
size_type rfind(C ch, size_type pos = npos) const;
86+
size_type rfind(const C* s, size_type pos, size_type count) const;
87+
size_type rfind(const C* s, size_type pos = npos) const;
88+
89+
static constexpr size_t npos = -1;
6890
};
6991
typedef basic_string_view<char> string_view;
7092
typedef basic_string_view<wchar_t> wstring_view;

clang-tools-extra/test/clang-tidy/checkers/abseil/string-find-startswith.cpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
// RUN: %check_clang_tidy %s abseil-string-find-startswith %t -- \
2-
// RUN: -config="{CheckOptions: {abseil-string-find-startswith.StringLikeClasses: '::std::basic_string;::basic_string'}}"
2+
// RUN: -config="{CheckOptions: \
3+
// RUN: {abseil-string-find-startswith.StringLikeClasses: \
4+
// RUN: '::std::basic_string;::std::basic_string_view;::basic_string'}}" \
5+
// RUN: -- -isystem %clang_tidy_headers
6+
7+
#include <string>
38

49
using size_t = decltype(sizeof(int));
510

611
namespace std {
7-
template <typename T> class allocator {};
8-
template <typename T> class char_traits {};
9-
template <typename C, typename T = std::char_traits<C>,
10-
typename A = std::allocator<C>>
11-
struct basic_string {
12-
basic_string();
13-
basic_string(const basic_string &);
14-
basic_string(const C *, const A &a = A());
15-
~basic_string();
16-
int find(basic_string<C> s, int pos = 0);
17-
int find(const char *s, int pos = 0);
18-
int rfind(basic_string<C> s, int pos = npos);
19-
int rfind(const char *s, int pos = npos);
20-
static constexpr size_t npos = -1;
21-
};
22-
typedef basic_string<char> string;
23-
typedef basic_string<wchar_t> wstring;
24-
2512
struct cxx_string {
2613
int find(const char *s, int pos = 0);
2714
int rfind(const char *s, int pos = npos);
@@ -39,7 +26,7 @@ std::string bar();
3926

4027
#define A_MACRO(x, y) ((x) == (y))
4128

42-
void tests(std::string s, global_string s2) {
29+
void tests(std::string s, global_string s2, std::string_view sv) {
4330
s.find("a") == 0;
4431
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith instead of find() == 0 [abseil-string-find-startswith]
4532
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, "a");{{$}}
@@ -96,6 +83,14 @@ void tests(std::string s, global_string s2) {
9683
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
9784
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s2, "a");{{$}}
9885

86+
sv.find("a") == 0;
87+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
88+
// CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(sv, "a");{{$}}
89+
90+
sv.rfind("a", 0) != 0;
91+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
92+
// CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(sv, "a");{{$}}
93+
9994
// expressions that don't trigger the check are here.
10095
A_MACRO(s.find("a"), 0);
10196
A_MACRO(s.rfind("a", 0), 0);

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ void instantiate_template_cases() {
2020
type_dependent_variables<int>();
2121
type_dependent_variables<float>();
2222
}
23+
24+
namespace gh57297{
25+
// The expression to check may not be the dependent operand in a dependent
26+
// operator.
27+
28+
// Explicitly not declaring a (templated) stream operator
29+
// so the `<<` is a `binaryOperator` with a dependent type.
30+
struct Stream { };
31+
template <typename T> void f() { T t; Stream x; x << t; }
32+
} // namespace gh57297

clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,36 @@ bool f(S& s) {
472472

473473
} // namespace ignore_1bit_bitfields
474474

475+
int implicitConversionReturnInt()
476+
{
477+
return true;
478+
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion bool -> 'int'
479+
// CHECK-FIXES: return 1
480+
}
481+
482+
int implicitConversionReturnIntWithParens()
483+
{
484+
return (true);
485+
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion bool -> 'int'
486+
// CHECK-FIXES: return 1
487+
}
488+
489+
490+
bool implicitConversionReturnBool()
491+
{
492+
return 1;
493+
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> bool
494+
// CHECK-FIXES: return true
495+
}
496+
497+
bool implicitConversionReturnBoolWithParens()
498+
{
499+
return (1);
500+
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> bool
501+
// CHECK-FIXES: return true
502+
}
503+
504+
475505
namespace PR47000 {
476506
int to_int(bool x) { return int{x}; }
477507

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,7 @@ defm fixed_point : BoolFOption<"fixed-point",
21172117
LangOpts<"FixedPoint">, DefaultFalse,
21182118
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable">,
21192119
NegFlag<SetFalse, [], [ClangOption], "Disable">,
2120-
BothFlags<[], [ClangOption], " fixed point types">>, ShouldParseIf<!strconcat("!", cplusplus.KeyPath)>;
2120+
BothFlags<[], [ClangOption], " fixed point types">>;
21212121
defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
21222122
LangOpts<"RegisterStaticDestructors">, DefaultTrue,
21232123
NegFlag<SetFalse, [], [ClangOption, CC1Option],

0 commit comments

Comments
 (0)