Skip to content

Commit 1ab2948

Browse files
authored
merge main into amd-staging (#458)
2 parents 9a51505 + 91dccab commit 1ab2948

File tree

172 files changed

+8441
-12823
lines changed

Some content is hidden

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

172 files changed

+8441
-12823
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.

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 & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,21 +1697,12 @@ bool BinaryFunction::scanExternalRefs() {
16971697
if (!TargetFunction || ignoreFunctionRef(*TargetFunction))
16981698
continue;
16991699

1700-
const uint64_t FunctionOffset =
1701-
TargetAddress - TargetFunction->getAddress();
1702-
if (!TargetFunction->isInConstantIsland(TargetAddress)) {
1703-
BranchTargetSymbol =
1704-
FunctionOffset
1705-
? TargetFunction->addEntryPointAtOffset(FunctionOffset)
1706-
: TargetFunction->getSymbol();
1707-
} else {
1708-
TargetFunction->setIgnored();
1709-
BC.outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
1710-
<< Twine::utohexstr(Address)
1711-
<< " in constant island of function " << *TargetFunction
1712-
<< '\n';
1700+
// Get a reference symbol for the function when address is a valid code
1701+
// reference.
1702+
BranchTargetSymbol =
1703+
BC.handleExternalBranchTarget(TargetAddress, *TargetFunction);
1704+
if (!BranchTargetSymbol)
17131705
continue;
1714-
}
17151706
}
17161707

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
## Skip caller to check the identical warning is triggered from ScanExternalRefs().
1111
# RUN: llvm-bolt %t.exe -o %t.bolt -skip-funcs=caller 2>&1 | FileCheck %s
1212

13-
# CHECK: BOLT-WARNING: Ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
13+
# CHECK: BOLT-WARNING: ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
1414

1515
.globl func
1616
.type func, %function

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ Bug Fixes to Attribute Support
699699
``[[gnu::error("some error")]]`` now correctly triggers an error. (#GH146520)
700700
- Fix a crash when the function name is empty in the `swift_name` attribute. (#GH157075)
701701
- Fixes crashes or missing diagnostics with the `device_kernel` attribute. (#GH161905)
702+
- Fix handling of parameter indexes when an attribute is applied to a C++23 explicit object member function.
702703

703704
Bug Fixes to C++ Support
704705
^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/Attr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "clang/AST/ASTFwd.h"
1717
#include "clang/AST/AttrIterator.h"
1818
#include "clang/AST/Decl.h"
19+
#include "clang/AST/DeclCXX.h"
1920
#include "clang/AST/Type.h"
2021
#include "clang/Basic/AttrKinds.h"
2122
#include "clang/Basic/AttributeCommonInfo.h"
@@ -327,8 +328,8 @@ class ParamIdx {
327328
ParamIdx(unsigned Idx, const Decl *D)
328329
: Idx(Idx), HasThis(false), IsValid(true) {
329330
assert(Idx >= 1 && "Idx must be one-origin");
330-
if (const auto *FD = dyn_cast<FunctionDecl>(D))
331-
HasThis = FD->isCXXInstanceMember();
331+
if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
332+
HasThis = MethodDecl->isImplicitObjectMemberFunction();
332333
}
333334

334335
/// A type into which \c ParamIdx can be serialized.

clang/include/clang/Basic/BuiltinsX86_64.td

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -239,57 +239,6 @@ let Features = "amx-complex", Attributes = [NoThrow] in {
239239
def tcmmrlfp16ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
240240
}
241241

242-
let Features = "amx-transpose", Attributes = [NoThrow] in {
243-
def t2rpntlvwz0_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
244-
}
245-
246-
let Features = "amx-movrs,amx-transpose", Attributes = [NoThrow] in {
247-
def t2rpntlvwz0rs_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
248-
}
249-
250-
let Features = "amx-transpose", Attributes = [NoThrow] in {
251-
def t2rpntlvwz0t1_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
252-
}
253-
254-
let Features = "amx-movrs,amx-transpose", Attributes = [NoThrow] in {
255-
def t2rpntlvwz0rst1_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
256-
}
257-
258-
let Features = "amx-transpose", Attributes = [NoThrow] in {
259-
def t2rpntlvwz1_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
260-
}
261-
262-
let Features = "amx-movrs,amx-transpose", Attributes = [NoThrow] in {
263-
def t2rpntlvwz1rs_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
264-
}
265-
266-
let Features = "amx-transpose", Attributes = [NoThrow] in {
267-
def t2rpntlvwz1t1_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
268-
}
269-
270-
let Features = "amx-movrs,amx-transpose", Attributes = [NoThrow] in {
271-
def t2rpntlvwz1rst1_internal : X86Builtin<"void(unsigned short, unsigned short, unsigned short, _Vector<256, int *>, _Vector<256, int *>, void const *, size_t)">;
272-
}
273-
274-
let Features = "amx-transpose", Attributes = [NoThrow] in {
275-
def ttransposed_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, _Vector<256, int>)">;
276-
}
277-
278-
let Features = "amx-bf16,amx-transpose", Attributes = [NoThrow] in {
279-
def ttdpbf16ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
280-
}
281-
282-
let Features = "amx-fp16,amx-transpose", Attributes = [NoThrow] in {
283-
def ttdpfp16ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
284-
}
285-
286-
let Features = "amx-complex,amx-transpose", Attributes = [NoThrow] in {
287-
def ttcmmimfp16ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
288-
def ttcmmrlfp16ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
289-
def tconjtcmmimfp16ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
290-
def tconjtfp16_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, _Vector<256, int>)">;
291-
}
292-
293242
let Features = "amx-avx512,avx10.2", Attributes = [NoThrow] in {
294243
def tcvtrowd2ps_internal : X86Builtin<"_Vector<16, float>(unsigned short, unsigned short, _Vector<256, int>, unsigned int)">;
295244
def tcvtrowps2bf16h_internal : X86Builtin<"_Vector<32, __bf16>(unsigned short, unsigned short, _Vector<256, int>, unsigned int)">;
@@ -303,10 +252,6 @@ let Features = "amx-tf32", Attributes = [NoThrow] in {
303252
def tmmultf32ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
304253
}
305254

306-
let Features = "amx-tf32,amx-transpose", Attributes = [NoThrow] in {
307-
def ttmmultf32ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
308-
}
309-
310255
let Features = "amx-fp8", Attributes = [NoThrow] in {
311256
def tdpbf8ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
312257
def tdpbhf8ps_internal : X86Builtin<"_Vector<256, int>(unsigned short, unsigned short, unsigned short, _Vector<256, int>, _Vector<256, int>, _Vector<256, int>)">;
@@ -321,13 +266,6 @@ let Features = "amx-tile", Attributes = [NoThrow] in {
321266
def tilezero : X86Builtin<"void(unsigned char)">;
322267
}
323268

324-
let Features = "amx-movrs,amx-transpose", Attributes = [NoThrow] in {
325-
def t2rpntlvwz0rs : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
326-
def t2rpntlvwz0rst1 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
327-
def t2rpntlvwz1rs : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
328-
def t2rpntlvwz1rst1 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
329-
}
330-
331269
let Features = "amx-movrs", Attributes = [NoThrow] in {
332270
def tileloaddrs64 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
333271
def tileloaddrst164 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
@@ -359,29 +297,6 @@ let Features = "amx-complex", Attributes = [NoThrow] in {
359297
def tcmmrlfp16ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
360298
}
361299

362-
let Features = "amx-transpose", Attributes = [NoThrow] in {
363-
def t2rpntlvwz0 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
364-
def t2rpntlvwz0t1 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
365-
def t2rpntlvwz1 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
366-
def t2rpntlvwz1t1 : X86Builtin<"void(_Constant unsigned char, void const *, size_t)">;
367-
def ttransposed : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char)">;
368-
}
369-
370-
let Features = "amx-bf16,amx-transpose", Attributes = [NoThrow] in {
371-
def ttdpbf16ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
372-
}
373-
374-
let Features = "amx-fp16,amx-transpose", Attributes = [NoThrow] in {
375-
def ttdpfp16ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
376-
}
377-
378-
let Features = "amx-complex,amx-transpose", Attributes = [NoThrow] in {
379-
def ttcmmimfp16ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
380-
def ttcmmrlfp16ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
381-
def tconjtcmmimfp16ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
382-
def tconjtfp16 : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char)">;
383-
}
384-
385300
let Features = "amx-avx512,avx10.2", Attributes = [NoThrow] in {
386301
def tcvtrowd2ps : X86Builtin<"_Vector<16, float>(_Constant unsigned char, unsigned int)">;
387302
def tcvtrowps2bf16h : X86Builtin<"_Vector<32, __bf16>(_Constant unsigned char, unsigned int)">;
@@ -406,10 +321,6 @@ let Features = "amx-tf32", Attributes = [NoThrow] in {
406321
def tmmultf32ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
407322
}
408323

409-
let Features = "amx-tf32,amx-transpose", Attributes = [NoThrow] in {
410-
def ttmmultf32ps : X86Builtin<"void(_Constant unsigned char, _Constant unsigned char, _Constant unsigned char)">;
411-
}
412-
413324
let Features = "prefetchi", Attributes = [NoThrow, Const] in {
414325
def prefetchi : X86Builtin<"void(void const *, unsigned int)">;
415326
}

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6847,8 +6847,6 @@ def mamx_tf32 : Flag<["-"], "mamx-tf32">, Group<m_x86_Features_Group>;
68476847
def mno_amx_tf32 : Flag<["-"], "mno-amx-tf32">, Group<m_x86_Features_Group>;
68486848
def mamx_tile : Flag<["-"], "mamx-tile">, Group<m_x86_Features_Group>;
68496849
def mno_amx_tile : Flag<["-"], "mno-amx-tile">, Group<m_x86_Features_Group>;
6850-
def mamx_transpose : Flag<["-"], "mamx-transpose">, Group<m_x86_Features_Group>;
6851-
def mno_amx_transpose : Flag<["-"], "mno-amx-transpose">, Group<m_x86_Features_Group>;
68526850
def mamx_movrs: Flag<["-"], "mamx-movrs">, Group<m_x86_Features_Group>;
68536851
def mno_amx_movrs: Flag<["-"], "mno-amx-movrs">, Group<m_x86_Features_Group>;
68546852
def mcmpccxadd : Flag<["-"], "mcmpccxadd">, Group<m_x86_Features_Group>;

clang/include/clang/Sema/Attr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ inline bool isInstanceMethod(const Decl *D) {
123123
return false;
124124
}
125125

126+
inline bool hasImplicitObjectParameter(const Decl *D) {
127+
if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
128+
return MethodDecl->isImplicitObjectMemberFunction();
129+
return false;
130+
}
131+
126132
/// Diagnose mutually exclusive attributes when present on a given
127133
/// declaration. Returns true if diagnosed.
128134
template <typename AttrTy>

0 commit comments

Comments
 (0)