Skip to content

Commit feeb1ff

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:c8365feed7af6d17cd2cc04cdc7fe0247f87e9c8 into amd-gfx:2c28b7a41bc2
Local branch amd-gfx 2c28b7a Merged main:aea06684992873f70c5834e2f455f913e5b8d671 into amd-gfx:617ef4684340 Remote branch main c8365fe [ctx_prof] Simple ICP criteria during module inliner (llvm#109881)
2 parents 2c28b7a + c8365fe commit feeb1ff

File tree

219 files changed

+7094
-3538
lines changed

Some content is hidden

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

219 files changed

+7094
-3538
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ bool shouldPrint(const BinaryFunction &Function) {
165165
}
166166
}
167167

168+
std::optional<StringRef> Origin = Function.getOriginSectionName();
169+
if (Origin && llvm::any_of(opts::PrintOnly, [&](const std::string &Name) {
170+
return Name == *Origin;
171+
}))
172+
return true;
173+
168174
return false;
169175
}
170176

bolt/test/X86/print-only-section.s

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Check that --print-only flag works with sections.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
6+
# RUN: ld.lld %t.o -o %t.exe
7+
# RUN: llvm-bolt %t.exe -o %t.out --print-cfg --print-only=unused_code 2>&1 \
8+
# RUN: | FileCheck %s
9+
10+
# CHECK: Binary Function "foo"
11+
# CHECK-NOT: Binary Function "_start"
12+
13+
.text
14+
.globl _start
15+
.type _start, %function
16+
_start:
17+
.cfi_startproc
18+
ret
19+
.cfi_endproc
20+
.size _start, .-_start
21+
22+
.section unused_code,"ax",@progbits
23+
.globl foo
24+
.type foo, %function
25+
foo:
26+
.cfi_startproc
27+
ret
28+
.cfi_endproc
29+
.size foo, .-foo
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Test that merge-fdata correctly handles YAML header with an uninitialized
2+
## fields. a.yaml does not have hash-func set and it used to crash merge-fdata.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: split-file %s %t
7+
# RUN: not merge-fdata %t/a.yaml %t/b.yaml 2>&1 | FileCheck %s
8+
9+
# CHECK: cannot merge profiles with different hash functions
10+
11+
#--- a.yaml
12+
---
13+
header:
14+
profile-version: 1
15+
binary-name: 'a.out'
16+
binary-build-id: '<unknown>'
17+
profile-flags: [ lbr ]
18+
profile-origin: branch profile reader
19+
profile-events: ''
20+
dfs-order: false
21+
functions:
22+
- name: 'main'
23+
fid: 1
24+
hash: 0x50BBA3441D436491
25+
exec: 1
26+
nblocks: 0
27+
...
28+
#--- b.yaml
29+
---
30+
header:
31+
profile-version: 1
32+
binary-name: 'a.out'
33+
binary-build-id: '<unknown>'
34+
profile-flags: [ lbr ]
35+
profile-origin: branch profile reader
36+
profile-events: ''
37+
dfs-order: false
38+
hash-func: xxh3
39+
functions:
40+
- name: 'main'
41+
fid: 1
42+
hash: 0x50BBA3441D436491
43+
exec: 1
44+
nblocks: 0
45+
...

bolt/tools/merge-fdata/merge-fdata.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ void mergeProfileHeaders(BinaryProfileHeader &MergedHeader,
145145
errs() << "WARNING: merging profiles with different sampling events\n";
146146
MergedHeader.EventNames += "," + Header.EventNames;
147147
}
148+
149+
if (MergedHeader.HashFunction != Header.HashFunction)
150+
report_error("merge conflict",
151+
"cannot merge profiles with different hash functions");
148152
}
149153

150154
void mergeBasicBlockProfile(BinaryBasicBlockProfile &MergedBB,
@@ -386,6 +390,7 @@ int main(int argc, char **argv) {
386390
// Merged information for all functions.
387391
StringMap<BinaryFunctionProfile> MergedBFs;
388392

393+
bool FirstHeader = true;
389394
for (std::string &InputDataFilename : Inputs) {
390395
ErrorOr<std::unique_ptr<MemoryBuffer>> MB =
391396
MemoryBuffer::getFileOrSTDIN(InputDataFilename);
@@ -409,7 +414,12 @@ int main(int argc, char **argv) {
409414
}
410415

411416
// Merge the header.
412-
mergeProfileHeaders(MergedHeader, BP.Header);
417+
if (FirstHeader) {
418+
MergedHeader = BP.Header;
419+
FirstHeader = false;
420+
} else {
421+
mergeProfileHeaders(MergedHeader, BP.Header);
422+
}
413423

414424
// Do the function merge.
415425
for (BinaryFunctionProfile &BF : BP.Functions) {

clang-tools-extra/clang-move/tool/ClangMove.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ int main(int argc, const char **argv) {
199199
for (auto I = Files.begin(), E = Files.end(); I != E; ++I) {
200200
OS << " {\n";
201201
OS << " \"FilePath\": \"" << *I << "\",\n";
202-
const auto Entry = FileMgr.getFile(*I);
202+
const auto Entry = FileMgr.getOptionalFileRef(*I);
203203
auto ID = SM.translateFile(*Entry);
204204
std::string Content;
205205
llvm::raw_string_ostream ContentStream(Content);

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,20 @@ AST_MATCHER(Type, sugaredNullptrType) {
3535
/// to null within.
3636
/// Finding sequences of explicit casts is necessary so that an entire sequence
3737
/// can be replaced instead of just the inner-most implicit cast.
38+
///
39+
/// TODO/NOTE: The second "anyOf" below discards matches on a substituted type,
40+
/// since we don't know if that would _always_ be a pointer type for all other
41+
/// specializations, unless the expression was "__null", in which case we assume
42+
/// that all specializations are expected to be for pointer types. Ideally this
43+
/// would check for the "NULL" macro instead, but that'd be harder to express.
44+
/// In practice, "NULL" is often defined as "__null", and this is a useful
45+
/// condition.
3846
StatementMatcher makeCastSequenceMatcher(llvm::ArrayRef<StringRef> NameList) {
3947
auto ImplicitCastToNull = implicitCastExpr(
4048
anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)),
41-
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType()))),
49+
anyOf(hasSourceExpression(gnuNullExpr()),
50+
unless(hasImplicitDestinationType(
51+
qualType(substTemplateTypeParmType())))),
4252
unless(hasSourceExpression(hasType(sugaredNullptrType()))),
4353
unless(hasImplicitDestinationType(
4454
qualType(matchers::matchesAnyListedTypeName(NameList)))));

clang-tools-extra/clangd/SourceCode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,8 @@ llvm::SmallVector<llvm::StringRef> ancestorNamespaces(llvm::StringRef NS) {
814814

815815
// Checks whether \p FileName is a valid spelling of main file.
816816
bool isMainFile(llvm::StringRef FileName, const SourceManager &SM) {
817-
auto FE = SM.getFileManager().getFile(FileName);
818-
return FE && *FE == SM.getFileEntryForID(SM.getMainFileID());
817+
auto FE = SM.getFileManager().getOptionalFileRef(FileName);
818+
return FE && FE == SM.getFileEntryRefForID(SM.getMainFileID());
819819
}
820820

821821
} // namespace

clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ TEST(ParsedASTTest, PatchesAdditionalIncludes) {
397397
auto &FM = SM.getFileManager();
398398
// Copy so that we can use operator[] to get the children.
399399
IncludeStructure Includes = PatchedAST->getIncludeStructure();
400-
auto MainFE = FM.getFile(testPath("foo.cpp"));
400+
auto MainFE = FM.getOptionalFileRef(testPath("foo.cpp"));
401401
ASSERT_TRUE(MainFE);
402402
auto MainID = Includes.getID(*MainFE);
403-
auto AuxFE = FM.getFile(testPath("sub/aux.h"));
403+
auto AuxFE = FM.getOptionalFileRef(testPath("sub/aux.h"));
404404
ASSERT_TRUE(AuxFE);
405405
auto AuxID = Includes.getID(*AuxFE);
406406
EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(*AuxID));

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ Changes in existing checks
130130
usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or
131131
subtracting from a pointer.
132132

133+
- Improved :doc:`bugprone-unchecked-optional-access
134+
<clang-tidy/checks/bugprone/unchecked-optional-access>` to support
135+
`bsl::optional` and `bdlb::NullableValue` from
136+
<https://github.com/bloomberg/bde>_.
137+
133138
- Improved :doc:`cert-flp30-c <clang-tidy/checks/cert/flp30-c>` check to
134139
fix false positive that floating point variable is only used in increment
135140
expression.
@@ -161,6 +166,10 @@ Changes in existing checks
161166
a false positive when only an implicit conversion happened inside an
162167
initializer list.
163168

169+
- Improved :doc:`modernize-use-nullptr
170+
<clang-tidy/checks/modernize/use-nullptr>` check to also recognize
171+
``NULL``/``__null`` (but not ``0``) when used with a templated type.
172+
164173
- Improved :doc:`modernize-use-std-print
165174
<clang-tidy/checks/modernize/use-std-print>` check to support replacing
166175
member function calls too.

clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ results. Therefore, it may be more resource intensive (RAM, CPU) than the
88
average clang-tidy check.
99

1010
This check identifies unsafe accesses to values contained in
11-
``std::optional<T>``, ``absl::optional<T>``, ``base::Optional<T>``, or
12-
``folly::Optional<T>`` objects. Below we will refer to all these types
13-
collectively as ``optional<T>``.
11+
``std::optional<T>``, ``absl::optional<T>``, ``base::Optional<T>``,
12+
``folly::Optional<T>``, ``bsl::optional``, or
13+
``BloombergLP::bdlb::NullableValue`` objects. Below we will refer to all these
14+
types collectively as ``optional<T>``.
1415

1516
An access to the value of an ``optional<T>`` occurs when one of its ``value``,
1617
``operator*``, or ``operator->`` member functions is invoked. To align with

clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class FindHeadersTest : public testing::Test {
6060
llvm::SmallVector<Hinted<Header>> findHeaders(llvm::StringRef FileName) {
6161
return include_cleaner::findHeaders(
6262
AST->sourceManager().translateFileLineCol(
63-
AST->fileManager().getFile(FileName).get(),
63+
*AST->fileManager().getOptionalFileRef(FileName),
6464
/*Line=*/1, /*Col=*/1),
6565
AST->sourceManager(), &PI);
6666
}

0 commit comments

Comments
 (0)