Skip to content

Commit 0698db4

Browse files
authored
Merge branch 'main' into fix-instselect-copy-scc-vcc-gfx7-followup
2 parents 8316b73 + 2837a4b commit 0698db4

File tree

540 files changed

+21902
-16136
lines changed

Some content is hidden

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

540 files changed

+21902
-16136
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
applyTo: lldb/**/*
3+
---
4+
5+
When reviewing code, focus on:
6+
7+
## Language, Libraries & Standards
8+
9+
- Target C++17 and avoid vendor-specific extensions.
10+
- For Python scripts, follow PEP 8.
11+
- Prefer standard library or LLVM support libraries instead of reinventing data structures.
12+
13+
## Comments & Documentation
14+
15+
- Each source file should include the standard LLVM file header.
16+
- Header files must have proper header guards.
17+
- Non-trivial classes and public methods should have Doxygen documentation.
18+
- Use `//` or `///` comments normally; avoid block comments unless necessary.
19+
- Non-trivial code should have comments explaining what it does and why. Avoid comments that explain how it does it at a micro level.
20+
21+
## Language & Compiler Issues
22+
23+
- Write portable code; wrap non-portable code in interfaces.
24+
- Do not use RTTI or exceptions.
25+
- Prefer C++-style casts over C-style casts.
26+
- Do not use static constructors.
27+
- Use `class` or `struct` consistently; `struct` only for all-public data.
28+
- When then same class is declared or defined multiple times, make sure it's consistently done using either `class` or `struct`.
29+
30+
## Headers & Library Layering
31+
32+
- Include order: module header → local/private headers → project headers → system headers.
33+
- Headers must compile standalone (include all dependencies).
34+
- Maintain proper library layering; avoid circular dependencies.
35+
- Include minimally; use forward declarations where possible.
36+
- Keep internal headers private to modules.
37+
- Use full namespace qualifiers for out-of-line definitions.
38+
39+
## Control Flow & Structure
40+
41+
- Prefer early exits over deep nesting.
42+
- Do not use `else` after `return`, `continue`, `break`, or `goto`.
43+
- Encapsulate loops that compute predicates into helper functions.
44+
45+
## Naming
46+
47+
- LLDB's code style differs from LLVM's coding style.
48+
- Variables are `snake_case`.
49+
- Functions and methods are `UpperCamelCase`.
50+
- Static, global and member variables have `s_`, `g_` and `m_` prefixes respectively.
51+
52+
## General Guidelines
53+
54+
- Use `assert` liberally; prefer `llvm_unreachable` for unreachable states.
55+
- Do not use `using namespace std;` in headers.
56+
- Provide a virtual method anchor for classes defined in headers.
57+
- Do not use default labels in fully covered switches over enumerations.
58+
- Use range-based for loops wherever possible.
59+
- Capture `end()` outside loops if not using range-based iteration.
60+
- Including `<iostream>` is forbidded. Use LLVM’s `raw_ostream` instead.
61+
- Don’t use `inline` when defining a function in a class definition.
62+
63+
## Microscopic Details
64+
65+
- Preserve existing style in modified code.
66+
- Prefer pre-increment (`++i`) when value is unused.
67+
- Use `private`, `protected`, or `public` keyword as appropriate to restrict class member visibility.
68+
- Omit braces for single-statement `if`, `else`, `while`, `for` unless needed.
69+
70+
## Review Style
71+
72+
- Be specific and actionable in feedback.
73+
- Explain the "why" behind recommendations.
74+
- Link back to the LLVM Coding Standards: https://llvm.org/docs/CodingStandards.html.
75+
- Ask clarifying questions when code intent is unclear.
76+
77+
Ignore formatting and assume that's handled by external tools like `clang-format` and `black`.
78+
Remember that these standards are **guidelines**.
79+
Always prioritize consistency with the style that is already being used by the surrounding code.

.github/copilot-instructions.md renamed to .github/instructions/llvm.instructions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
applyTo: llvm/**/*
3+
---
4+
15
When performing a code review, pay close attention to code modifying a function's
26
control flow. Could the change result in the corruption of performance profile
37
data? Could the change result in invalid debug information, in particular for

.github/workflows/release-binaries-all.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ jobs:
9090
runs-on:
9191
- ubuntu-22.04
9292
- ubuntu-22.04-arm
93-
- macos-13
9493
- macos-14
9594

9695
uses: ./.github/workflows/release-binaries.yml

.github/workflows/release-binaries.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ on:
2121
options:
2222
- ubuntu-22.04
2323
- ubuntu-22.04-arm
24-
- macos-13
2524
- macos-14
2625

2726
workflow_call:
@@ -130,8 +129,6 @@ jobs:
130129
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_COMPILER_RT_ENABLE_IOS=OFF"
131130
if [ "$RUNNER_ARCH" = "ARM64" ]; then
132131
arches=arm64
133-
else
134-
arches=x86_64
135132
fi
136133
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
137134
fi
@@ -147,14 +144,6 @@ jobs:
147144
build_runs_on="depot-${{ inputs.runs-on }}-16"
148145
test_runs_on=$build_runs_on
149146
;;
150-
macos-13)
151-
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
152-
build_runs_on="${{ inputs.runs-on }}"
153-
else
154-
build_runs_on="macos-13-large"
155-
fi
156-
test_runs_on="${{ inputs.runs-on }}"
157-
;;
158147
macos-14)
159148
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
160149
build_runs_on="${{ inputs.runs-on }}"

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,16 @@ class BinaryContext {
932932
std::pair<const MCSymbol *, uint64_t>
933933
handleAddressRef(uint64_t Address, BinaryFunction &BF, bool IsPCRel);
934934

935+
/// When \p Address inside function \p BF is a target of a control transfer
936+
/// instruction (branch) from another function, return a corresponding symbol
937+
/// that should be used by the branch. For example, main or secondary entry
938+
/// point.
939+
///
940+
/// If \p Address is an invalid destination, such as a constant island, return
941+
/// nullptr and mark \p BF as ignored, since we cannot properly handle a
942+
/// branch to a constant island.
943+
MCSymbol *handleExternalBranchTarget(uint64_t Address, BinaryFunction &BF);
944+
935945
/// Analyze memory contents at the given \p Address and return the type of
936946
/// memory contents (such as a possible jump table).
937947
MemoryContentsType analyzeMemoryAt(uint64_t Address, BinaryFunction &BF);

bolt/lib/Core/BinaryContext.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,23 @@ BinaryContext::handleAddressRef(uint64_t Address, BinaryFunction &BF,
518518
return std::make_pair(TargetSymbol, 0);
519519
}
520520

521+
MCSymbol *BinaryContext::handleExternalBranchTarget(uint64_t Address,
522+
BinaryFunction &BF) {
523+
if (BF.isInConstantIsland(Address)) {
524+
BF.setIgnored();
525+
this->outs() << "BOLT-WARNING: ignoring entry point at address 0x"
526+
<< Twine::utohexstr(Address)
527+
<< " in constant island of function " << BF << '\n';
528+
return nullptr;
529+
}
530+
531+
const uint64_t Offset = Address - BF.getAddress();
532+
assert(Offset < BF.getSize() &&
533+
"Address should be inside the referenced function");
534+
535+
return Offset ? BF.addEntryPointAtOffset(Offset) : BF.getSymbol();
536+
}
537+
521538
MemoryContentsType BinaryContext::analyzeMemoryAt(uint64_t Address,
522539
BinaryFunction &BF) {
523540
if (!isX86())
@@ -1399,17 +1416,10 @@ void BinaryContext::processInterproceduralReferences() {
13991416
<< Function.getPrintName() << " and "
14001417
<< TargetFunction->getPrintName() << '\n';
14011418
}
1402-
if (uint64_t Offset = Address - TargetFunction->getAddress()) {
1403-
if (!TargetFunction->isInConstantIsland(Address)) {
1404-
TargetFunction->addEntryPointAtOffset(Offset);
1405-
} else {
1406-
TargetFunction->setIgnored();
1407-
this->outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
1408-
<< Twine::utohexstr(Address)
1409-
<< " in constant island of function " << *TargetFunction
1410-
<< '\n';
1411-
}
1412-
}
1419+
1420+
// Create an extra entry point if needed. Can also render the target
1421+
// function ignored if the reference is invalid.
1422+
handleExternalBranchTarget(Address, *TargetFunction);
14131423

14141424
continue;
14151425
}

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,11 +1697,12 @@ bool BinaryFunction::scanExternalRefs() {
16971697
if (!TargetFunction || ignoreFunctionRef(*TargetFunction))
16981698
continue;
16991699

1700-
const uint64_t FunctionOffset =
1701-
TargetAddress - TargetFunction->getAddress();
1700+
// Get a reference symbol for the function when address is a valid code
1701+
// reference.
17021702
BranchTargetSymbol =
1703-
FunctionOffset ? TargetFunction->addEntryPointAtOffset(FunctionOffset)
1704-
: TargetFunction->getSymbol();
1703+
BC.handleExternalBranchTarget(TargetAddress, *TargetFunction);
1704+
if (!BranchTargetSymbol)
1705+
continue;
17051706
}
17061707

17071708
// Can't find more references. Not creating relocations since we are not

bolt/test/AArch64/constant-island-entry.s

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
// This test checks that we ignore functions which add an entry point that
2-
// is in a constant island.
1+
## This test checks that we ignore functions which add an entry point that
2+
## is in a constant island.
33

44
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
55
# RUN: %clang %cflags %t.o -pie -Wl,-q -o %t.exe
6+
7+
## Check when the caller is successfully disassembled.
68
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
79

8-
# CHECK: BOLT-WARNING: Ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
10+
## Skip caller to check the identical warning is triggered from ScanExternalRefs().
11+
# RUN: llvm-bolt %t.exe -o %t.bolt -skip-funcs=caller 2>&1 | FileCheck %s
12+
13+
# CHECK: BOLT-WARNING: ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
914

1015
.globl func
1116
.type func, %function

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

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

99
#include "RedundantParenthesesCheck.h"
10+
#include "../utils/Matchers.h"
11+
#include "../utils/OptionsUtils.h"
1012
#include "clang/AST/Expr.h"
1113
#include "clang/ASTMatchers/ASTMatchFinder.h"
1214
#include "clang/ASTMatchers/ASTMatchers.h"
@@ -32,15 +34,30 @@ AST_MATCHER(ParenExpr, isInMacro) {
3234

3335
} // namespace
3436

37+
RedundantParenthesesCheck::RedundantParenthesesCheck(StringRef Name,
38+
ClangTidyContext *Context)
39+
: ClangTidyCheck(Name, Context),
40+
AllowedDecls(utils::options::parseStringList(
41+
Options.get("AllowedDecls", "std::max;std::min"))) {}
42+
43+
void RedundantParenthesesCheck::storeOptions(
44+
ClangTidyOptions::OptionMap &Opts) {
45+
Options.store(Opts, "AllowedDecls",
46+
utils::options::serializeStringList(AllowedDecls));
47+
}
48+
3549
void RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
3650
const auto ConstantExpr =
3751
expr(anyOf(integerLiteral(), floatLiteral(), characterLiteral(),
3852
cxxBoolLiteral(), stringLiteral(), cxxNullPtrLiteralExpr()));
3953
Finder->addMatcher(
40-
parenExpr(subExpr(anyOf(parenExpr(), ConstantExpr, declRefExpr())),
41-
unless(anyOf(isInMacro(),
42-
// sizeof(...) is common used.
43-
hasParent(unaryExprOrTypeTraitExpr()))))
54+
parenExpr(
55+
subExpr(anyOf(parenExpr(), ConstantExpr,
56+
declRefExpr(to(namedDecl(unless(
57+
matchers::matchesAnyListedName(AllowedDecls))))))),
58+
unless(anyOf(isInMacro(),
59+
// sizeof(...) is common used.
60+
hasParent(unaryExprOrTypeTraitExpr()))))
4461
.bind("dup"),
4562
this);
4663
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ namespace clang::tidy::readability {
2020
/// https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-parentheses.html
2121
class RedundantParenthesesCheck : public ClangTidyCheck {
2222
public:
23-
RedundantParenthesesCheck(StringRef Name, ClangTidyContext *Context)
24-
: ClangTidyCheck(Name, Context) {}
23+
RedundantParenthesesCheck(StringRef Name, ClangTidyContext *Context);
24+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2525
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
2626
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
2727
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
2828
return LangOpts.CPlusPlus | LangOpts.C99;
2929
}
30+
31+
private:
32+
const std::vector<StringRef> AllowedDecls;
3033
};
3134

3235
} // namespace clang::tidy::readability

0 commit comments

Comments
 (0)