Skip to content

Commit cc25bd3

Browse files
authored
Merge branch 'main' into nfc_adropt_ifdef_ns_emitter_subtarget_emitter
2 parents 344ed20 + 28a279c commit cc25bd3

File tree

482 files changed

+17394
-9916
lines changed

Some content is hidden

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

482 files changed

+17394
-9916
lines changed

.ci/generate_test_report_github.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import generate_test_report_lib
1010

11+
1112
def compute_platform_title() -> str:
1213
logo = ":window:" if platform.system() == "Windows" else ":penguin:"
1314
# On Linux the machine value is x86_64 on Windows it is AMD64.

.ci/generate_test_report_lib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def _format_ninja_failures(ninja_failures: list[tuple[str, str]]) -> list[str]:
100100
)
101101
return output
102102

103+
103104
def get_failures(junit_objects) -> dict[str, list[tuple[str, str]]]:
104105
failures = {}
105106
for results in junit_objects:

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -564,30 +564,30 @@ void DataAggregator::imputeFallThroughs() {
564564
// Skip fall-throughs in external code.
565565
if (Trace.From == Trace::EXTERNAL)
566566
continue;
567-
std::pair CurrentBranch(Trace.Branch, Trace.From);
567+
if (std::pair CurrentBranch(Trace.Branch, Trace.From);
568+
CurrentBranch != PrevBranch) {
569+
// New group: reset aggregates.
570+
AggregateCount = AggregateFallthroughSize = 0;
571+
PrevBranch = CurrentBranch;
572+
}
568573
// BR_ONLY must be the last trace in the group
569574
if (Trace.To == Trace::BR_ONLY) {
570575
// If the group is not empty, use aggregate values, otherwise 0-length
571576
// for unconditional jumps (call/ret/uncond branch) or 1-length for others
572577
uint64_t InferredBytes =
573-
PrevBranch == CurrentBranch
578+
AggregateFallthroughSize
574579
? AggregateFallthroughSize / AggregateCount
575580
: !checkUnconditionalControlTransfer(Trace.From);
576581
Trace.To = Trace.From + InferredBytes;
577582
LLVM_DEBUG(dbgs() << "imputed " << Trace << " (" << InferredBytes
578583
<< " bytes)\n");
579584
++InferredTraces;
580585
} else {
581-
// Trace with a valid fall-through
582-
// New group: reset aggregates.
583-
if (CurrentBranch != PrevBranch)
584-
AggregateCount = AggregateFallthroughSize = 0;
585586
// Only use valid fall-through lengths
586587
if (Trace.To != Trace::EXTERNAL)
587588
AggregateFallthroughSize += (Trace.To - Trace.From) * Info.TakenCount;
588589
AggregateCount += Info.TakenCount;
589590
}
590-
PrevBranch = CurrentBranch;
591591
}
592592
if (opts::Verbosity >= 1)
593593
outs() << "BOLT-INFO: imputed " << InferredTraces << " traces\n";

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2804,7 +2804,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
28042804
BitVector WrittenRegs(RegInfo->getNumRegs());
28052805
const BitVector &SizeRegAliases = getAliases(SizeReg);
28062806

2807-
for (auto InstIt = BB.begin(); InstIt != CallInst; ++InstIt) {
2807+
for (auto InstIt = CallInst; InstIt != BB.begin(); --InstIt) {
28082808
const MCInst &Inst = *InstIt;
28092809
WrittenRegs.reset();
28102810
getWrittenRegs(Inst, WrittenRegs);

bolt/test/X86/callcont-fallthru.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# External return to a landing pad/entry point call continuation
1616
# RUN: link_fdata %s %t %t.pa-eret PREAGG-ERET
1717
# RUN-DISABLED: link_fdata %s %t %t.pa-plt PREAGG-PLT
18+
## Fall-through imputing test cases
19+
# RUN: link_fdata %s %t %t.pa-imp PREAGG-IMP
1820

1921
# RUN: llvm-strip --strip-unneeded %t -o %t.strip
2022
# RUN: llvm-objcopy --remove-section=.eh_frame %t.strip %t.noeh
@@ -63,6 +65,11 @@
6365
# RUN-DISABLED: --check-prefix=CHECK-PLT
6466
# CHECK-PLT: traces mismatching disassembled function contents: 0
6567

68+
## Check --impute-trace-fall-throughs accepting duplicate branch-only traces
69+
# RUN: perf2bolt %t --pa -p %t.pa-imp -o %t.pa-imp.fdata --impute-trace-fall-through
70+
# RUN: FileCheck %s --check-prefix=CHECK-IMP --input-file %t.pa-imp.fdata
71+
# CHECK-IMP: 0 [unknown] 0 1 main {{.*}} 0 3
72+
6673
.globl foo
6774
.type foo, %function
6875
foo:
@@ -102,6 +109,8 @@ Ltmp1:
102109

103110
Ltmp4:
104111
cmpl $0x0, -0x14(%rbp)
112+
# PREAGG-IMP: B X:0 #Ltmp4_br# 1 0
113+
# PREAGG-IMP: B X:0 #Ltmp4_br# 2 0
105114
Ltmp4_br:
106115
je Ltmp0
107116

bolt/test/runtime/AArch64/inline-memcpy.s

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# RUN: llvm-bolt %t.exe --inline-memcpy -o %t.bolt 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
88
# RUN: llvm-objdump -d %t.bolt | FileCheck %s --check-prefix=CHECK-ASM
99

10-
# Verify BOLT reports that it inlined memcpy calls (11 successful inlines out of 16 total calls)
10+
# Verify BOLT reports that it inlined memcpy calls (11 successful inlines out of 17 total calls)
1111
# CHECK-INLINE: BOLT-INFO: inlined 11 memcpy() calls
1212

1313
# Each function should use optimal size-specific instructions and NO memcpy calls
@@ -81,11 +81,14 @@
8181
# CHECK-ASM: bl{{.*}}<memcpy
8282

8383
# Register move should NOT be inlined (size unknown at compile time)
84-
# CHECK-ASM-LABEL: <test_register_move_negative>:
84+
# CHECK-ASM-LABEL: <test_register_move_unknown>:
85+
# CHECK-ASM: bl{{.*}}<memcpy
86+
87+
# CHECK-ASM-LABEL: <test_x2_rewrite_unknown>:
8588
# CHECK-ASM: bl{{.*}}<memcpy
8689

8790
# Live-in parameter should NOT be inlined (size unknown at compile time)
88-
# CHECK-ASM-LABEL: <test_live_in_negative>:
91+
# CHECK-ASM-LABEL: <test_live_in_unknown>:
8992
# CHECK-ASM: bl{{.*}}<memcpy
9093

9194
# _memcpy8 should be inlined with end-pointer return (dest+size)
@@ -259,9 +262,9 @@ test_4_byte_add_immediate:
259262
ret
260263
.size test_4_byte_add_immediate, .-test_4_byte_add_immediate
261264

262-
.globl test_register_move_negative
263-
.type test_register_move_negative,@function
264-
test_register_move_negative:
265+
.globl test_register_move_unknown
266+
.type test_register_move_unknown,@function
267+
test_register_move_unknown:
265268
stp x29, x30, [sp, #-32]!
266269
mov x29, sp
267270
add x1, sp, #16
@@ -271,11 +274,20 @@ test_register_move_negative:
271274
bl memcpy
272275
ldp x29, x30, [sp], #32
273276
ret
274-
.size test_register_move_negative, .-test_register_move_negative
277+
.size test_register_move_unknown, .-test_register_move_unknown
278+
279+
.globl test_x2_rewrite_unknown
280+
.type test_x2_rewrite_unknown,@function
281+
test_x2_rewrite_unknown:
282+
mov x2, #8
283+
ldr x2, [sp, #24]
284+
bl memcpy
285+
ret
286+
.size test_x2_rewrite_unknown, .-test_x2_rewrite_unknown
275287

276-
.globl test_live_in_negative
277-
.type test_live_in_negative,@function
278-
test_live_in_negative:
288+
.globl test_live_in_unknown
289+
.type test_live_in_unknown,@function
290+
test_live_in_unknown:
279291
# x2 comes in as parameter, no instruction sets it (should NOT inline)
280292
stp x29, x30, [sp, #-32]!
281293
mov x29, sp
@@ -285,7 +297,7 @@ test_live_in_negative:
285297
bl memcpy
286298
ldp x29, x30, [sp], #32
287299
ret
288-
.size test_live_in_negative, .-test_live_in_negative
300+
.size test_live_in_unknown, .-test_live_in_unknown
289301

290302
.globl test_memcpy8_4_byte
291303
.type test_memcpy8_4_byte,@function

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include "SizeofExpressionCheck.h"
7474
#include "SpuriouslyWakeUpFunctionsCheck.h"
7575
#include "StandaloneEmptyCheck.h"
76+
#include "StdNamespaceModificationCheck.h"
7677
#include "StringConstructorCheck.h"
7778
#include "StringIntegerAssignmentCheck.h"
7879
#include "StringLiteralWithEmbeddedNulCheck.h"
@@ -237,6 +238,8 @@ class BugproneModule : public ClangTidyModule {
237238
"bugprone-spuriously-wake-up-functions");
238239
CheckFactories.registerCheck<StandaloneEmptyCheck>(
239240
"bugprone-standalone-empty");
241+
CheckFactories.registerCheck<StdNamespaceModificationCheck>(
242+
"bugprone-std-namespace-modification");
240243
CheckFactories.registerCheck<StringConstructorCheck>(
241244
"bugprone-string-constructor");
242245
CheckFactories.registerCheck<StringIntegerAssignmentCheck>(

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ add_clang_library(clangTidyBugproneModule STATIC
7575
SmartPtrArrayMismatchCheck.cpp
7676
SpuriouslyWakeUpFunctionsCheck.cpp
7777
StandaloneEmptyCheck.cpp
78+
StdNamespaceModificationCheck.cpp
7879
StringConstructorCheck.cpp
7980
StringIntegerAssignmentCheck.cpp
8081
StringLiteralWithEmbeddedNulCheck.cpp

clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp renamed to clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp

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

9-
#include "DontModifyStdNamespaceCheck.h"
9+
#include "StdNamespaceModificationCheck.h"
1010
#include "clang/ASTMatchers/ASTMatchFinder.h"
1111
#include "clang/ASTMatchers/ASTMatchersInternal.h"
1212

@@ -36,9 +36,9 @@ AST_POLYMORPHIC_MATCHER_P(
3636

3737
} // namespace
3838

39-
namespace clang::tidy::cert {
39+
namespace clang::tidy::bugprone {
4040

41-
void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
41+
void StdNamespaceModificationCheck::registerMatchers(MatchFinder *Finder) {
4242
auto HasStdParent =
4343
hasDeclContext(namespaceDecl(hasAnyName("std", "posix"),
4444
unless(hasParent(namespaceDecl())))
@@ -96,7 +96,7 @@ void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
9696
.bind("decl"),
9797
this);
9898
}
99-
} // namespace clang::tidy::cert
99+
} // namespace clang::tidy::bugprone
100100

101101
static const NamespaceDecl *getTopLevelLexicalNamespaceDecl(const Decl *D) {
102102
const NamespaceDecl *LastNS = nullptr;
@@ -108,7 +108,7 @@ static const NamespaceDecl *getTopLevelLexicalNamespaceDecl(const Decl *D) {
108108
return LastNS;
109109
}
110110

111-
void clang::tidy::cert::DontModifyStdNamespaceCheck::check(
111+
void clang::tidy::bugprone::StdNamespaceModificationCheck::check(
112112
const MatchFinder::MatchResult &Result) {
113113
const auto *D = Result.Nodes.getNodeAs<Decl>("decl");
114114
const auto *NS = Result.Nodes.getNodeAs<NamespaceDecl>("nmspc");

clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.h renamed to clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DONT_MODIFY_STD_NAMESPACE_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DONT_MODIFY_STD_NAMESPACE_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDNAMESPACEMODIFICATIONCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDNAMESPACEMODIFICATIONCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313

14-
namespace clang::tidy::cert {
14+
namespace clang::tidy::bugprone {
1515

1616
/// Modification of the std or posix namespace can result in undefined behavior.
1717
/// This check warns for such modifications.
1818
///
1919
/// For the user-facing documentation see:
20-
/// https://clang.llvm.org/extra/clang-tidy/checks/cert/dcl58-cpp.html
21-
class DontModifyStdNamespaceCheck : public ClangTidyCheck {
20+
/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/std-namespace-modification.html
21+
class StdNamespaceModificationCheck : public ClangTidyCheck {
2222
public:
23-
DontModifyStdNamespaceCheck(StringRef Name, ClangTidyContext *Context)
23+
StdNamespaceModificationCheck(StringRef Name, ClangTidyContext *Context)
2424
: ClangTidyCheck(Name, Context) {}
2525
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
2626
return LangOpts.CPlusPlus;
@@ -29,6 +29,6 @@ class DontModifyStdNamespaceCheck : public ClangTidyCheck {
2929
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3030
};
3131

32-
} // namespace clang::tidy::cert
32+
} // namespace clang::tidy::bugprone
3333

34-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DONT_MODIFY_STD_NAMESPACE_H
34+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDNAMESPACEMODIFICATIONCHECK_H

0 commit comments

Comments
 (0)