Skip to content

Commit 2216486

Browse files
committed
merge main into amd-staging
Change-Id: Ib261625373e0a21458aae0684d41797d6a0ddeee
2 parents 49c5417 + e8b70e9 commit 2216486

File tree

217 files changed

+4738
-1879
lines changed

Some content is hidden

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

217 files changed

+4738
-1879
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ jobs:
159159
'generic-no-rtti',
160160
'generic-optimized-speed',
161161
'generic-static',
162-
# TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive
163-
# or don't provide much value since the benchmark run results are too noise on the bots.
164-
'benchmarks',
165162
'bootstrapping-build'
166163
]
167164
machine: [ 'libcxx-runners-set' ]

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,44 @@ void RewriteInstance::discoverFileObjects() {
789789
BinarySection Section(*BC, *cantFail(Sym.getSection()));
790790
return Section.isAllocatable();
791791
};
792+
auto checkSymbolInSection = [this](const SymbolInfo &S) {
793+
// Sometimes, we encounter symbols with addresses outside their section. If
794+
// such symbols happen to fall into another section, they can interfere with
795+
// disassembly. Notably, this occurs with AArch64 marker symbols ($d and $t)
796+
// that belong to .eh_frame, but end up pointing into .text.
797+
// As a workaround, we ignore all symbols that lie outside their sections.
798+
auto Section = cantFail(S.Symbol.getSection());
799+
800+
// Accept all absolute symbols.
801+
if (Section == InputFile->section_end())
802+
return true;
803+
804+
uint64_t SecStart = Section->getAddress();
805+
uint64_t SecEnd = SecStart + Section->getSize();
806+
uint64_t SymEnd = S.Address + ELFSymbolRef(S.Symbol).getSize();
807+
if (S.Address >= SecStart && SymEnd <= SecEnd)
808+
return true;
809+
810+
auto SymType = cantFail(S.Symbol.getType());
811+
// Skip warnings for common benign cases.
812+
if (opts::Verbosity < 1 && SymType == SymbolRef::ST_Other)
813+
return false; // E.g. ELF::STT_TLS.
814+
815+
auto SymName = S.Symbol.getName();
816+
auto SecName = cantFail(S.Symbol.getSection())->getName();
817+
BC->errs() << "BOLT-WARNING: ignoring symbol "
818+
<< (SymName ? *SymName : "[unnamed]") << " at 0x"
819+
<< Twine::utohexstr(S.Address) << ", which lies outside "
820+
<< (SecName ? *SecName : "[unnamed]") << "\n";
821+
822+
return false;
823+
};
792824
for (const SymbolRef &Symbol : InputFile->symbols())
793-
if (isSymbolInMemory(Symbol))
794-
SortedSymbols.push_back({cantFail(Symbol.getAddress()), Symbol});
825+
if (isSymbolInMemory(Symbol)) {
826+
SymbolInfo SymInfo{cantFail(Symbol.getAddress()), Symbol};
827+
if (checkSymbolInSection(SymInfo))
828+
SortedSymbols.push_back(SymInfo);
829+
}
795830

796831
auto CompareSymbols = [this](const SymbolInfo &A, const SymbolInfo &B) {
797832
if (A.Address != B.Address)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
--- !ELF
2+
FileHeader:
3+
Class: ELFCLASS64
4+
Data: ELFDATA2LSB
5+
Type: ET_EXEC
6+
Machine: EM_AARCH64
7+
Entry: 0x2a0000
8+
ProgramHeaders:
9+
- Type: PT_PHDR
10+
Flags: [ PF_R ]
11+
VAddr: 0x40
12+
Align: 0x8
13+
FileSize: 0xa8
14+
MemSize: 0xa8
15+
Offset: 0x40
16+
- Type: PT_LOAD
17+
Flags: [ PF_R ]
18+
VAddr: 0x0
19+
Align: 0x10000
20+
FileSize: 0xf8
21+
MemSize: 0xf8
22+
Offset: 0x0
23+
- Type: PT_LOAD
24+
Flags: [ PF_X, PF_R ]
25+
VAddr: 0x2a0000
26+
Align: 0x10000
27+
FirstSec: .text
28+
LastSec: .ignored
29+
Sections:
30+
- Name: .text
31+
Type: SHT_PROGBITS
32+
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
33+
Address: 0x2a0000
34+
AddressAlign: 0x4
35+
Content: 400580d2c0035fd6
36+
- Name: .ignored
37+
Type: SHT_PROGBITS
38+
Flags: [ SHF_ALLOC ]
39+
Address: 0x2a0008
40+
AddressAlign: 0x8
41+
Size: 0x8
42+
- Name: .eh_frame
43+
Type: SHT_PROGBITS
44+
Flags: [ SHF_ALLOC ]
45+
Address: 0x2a0010
46+
AddressAlign: 0x8
47+
Content: 1000000000000000017a520004781e010b0c1f00140000001800000000002a0008000000000e01410e010000
48+
Symbols:
49+
- Name: func
50+
Section: .text
51+
Value: 0x2a0000
52+
Size: 0x8
53+
- Name: '$d.42'
54+
Section: .ignored
55+
Value: 0x2a0004
56+
...
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Check that marker symbols ($d, $x) denoting data embedded in code are ignored
2+
// if they fall outside their respective sections.
3+
4+
// RUN: yaml2obj %S/Inputs/spurious-marker-symbol.yaml -o %t.exe
5+
// RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
6+
// CHECK: 1 out of 1 functions were overwritten
7+
// RUN: llvm-objdump -j .text -d %t.bolt | FileCheck %s -check-prefix=CHECK-DISASM
8+
// CHECK-DISASM: func
9+
// CHECK-DISASM: 2a0000: d2800540 mov
10+
// CHECK-DISASM: 2a0004: d65f03c0 ret
11+
12+
// The YAML encodes the following assembly and debug information:
13+
14+
.text
15+
.globl func
16+
.type func, %function
17+
func:
18+
mov x0, #42
19+
// $d.42: (symbol in .ignored, with an address in .text)
20+
ret
21+
22+
// .eh_frame contains minimal DWARF with a CFA operation on the `ret`. BOLT
23+
// should ignore the spurious `$d.42`. If it doesn't, then it will stop
24+
// disassembling after the `mov` and will fail to process the second
25+
// DW_CFA_def_cfa_offset.
26+
//
27+
// CIE
28+
// length: 00000010
29+
// CIE_id: 00000000
30+
// version: 01
31+
// augmentation:
32+
// "zR" 7a 52 00
33+
// - read augmentation data
34+
// - read FDE pointer encoding
35+
// code_alignment_factor: 04
36+
// data_alignment_factor: 78 (-8)
37+
// return_address_register: 1e (r30 / lr)
38+
//
39+
// augmentation data:
40+
// length: 01
41+
// FDE pointers are absptr+sdata4 0b
42+
//
43+
// initial_instructions:
44+
// DW_CFA_def_cfa (31, 0): 0c 1f 00
45+
//
46+
// Encoding: 10000000'00000000'01'7a5200'04'78'1e'10'0b'0c1f00
47+
//
48+
// FDE
49+
// length: 00000014
50+
// CIE_pointer: 00000018 (backwards offset from here to CIE)
51+
// initial_location: 002a0000 (`func` as absptr+sdata4)
52+
// address_range: 00000008
53+
// augmentation data:
54+
// length: 00
55+
// instructions:
56+
// DW_CFA_def_cfa_offset (1) 0e 01
57+
// DW_CFA_advance_loc (1) 41 (`ret` at 0x2a0004)
58+
// DW_CFA_def_cfa_offset (1) 0e 01 Fails unless $d.42 is ignored.
59+
// DW_CFA_nop 00 00
60+
//
61+
// Encoding: 14000000'18000000'00002a00'08000000'000e0141'0e010000

clang/docs/ReleaseNotes.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,30 @@ C Language Changes
282282
C2y Feature Support
283283
^^^^^^^^^^^^^^^^^^^
284284

285+
- Updated conformance for `N3298 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3298.htm>`_
286+
which adds the ``i`` and ``j`` suffixes for the creation of a ``_Complex``
287+
constant value. Clang has always supported these suffixes as a GNU extension,
288+
so ``-Wgnu-imaginary-constant`` no longer has effect in C modes, as this is
289+
not a C2y extension in C. ``-Wgnu-imaginary-constant`` still applies in C++
290+
modes.
291+
292+
- Clang updated conformance for `N3370 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3370.htm>`_
293+
case range expressions. This feature was previously supported by Clang as a
294+
GNU extension, so ``-Wgnu-case-range`` no longer has effect in C modes, as
295+
this is now a C2y extension in C. ``-Wgnu-case-range`` still applies in C++
296+
modes.
297+
298+
- Clang implemented support for `N3344 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3344.pdf>`_
299+
which disallows a ``void`` parameter from having a qualifier or storage class
300+
specifier. Note that ``register void`` was previously accepted in all C
301+
language modes but is now rejected (all of the other qualifiers and storage
302+
class specifiers were previously rejected).
303+
304+
- Updated conformance for `N3364 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3364.pdf>`_
305+
on floating-point translation-time initialization with signaling NaN. This
306+
paper adopts Clang's existing practice, so there were no changes to compiler
307+
behavior.
308+
285309
C23 Feature Support
286310
^^^^^^^^^^^^^^^^^^^
287311

@@ -621,6 +645,8 @@ Bug Fixes to C++ Support
621645
an implicitly instantiated class template specialization. (#GH51051)
622646
- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208)
623647
- Name independent data members were not correctly initialized from default member initializers. (#GH114069)
648+
- Fixed an assertion failure caused by invalid default argument substitutions in non-defining
649+
friend declarations. (#GH113324).
624650

625651
Bug Fixes to AST Handling
626652
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,6 +3560,12 @@ We also define a set of safe transformations which if passed a safe value as an
35603560
- casts
35613561
- unary operators like ``&`` or ``*``
35623562
3563+
alpha.webkit.UncheckedCallArgsChecker
3564+
"""""""""""""""""""""""""""""""""""""
3565+
The goal of this rule is to make sure that lifetime of any dynamically allocated CheckedPtr capable object passed as a call argument keeps its memory region past the end of the call. This applies to call to any function, method, lambda, function pointer or functor. CheckedPtr capable objects aren't supposed to be allocated on stack so we check arguments for parameters of raw pointers and references to unchecked types.
3566+
3567+
The rules of when to use and not to use CheckedPtr / CheckedRef are same as alpha.webkit.UncountedCallArgsChecker for ref-counted objects.
3568+
35633569
alpha.webkit.UncountedLocalVarsChecker
35643570
""""""""""""""""""""""""""""""""""""""
35653571
The goal of this rule is to make sure that any uncounted local variable is backed by a ref-counted object with lifetime that is strictly larger than the scope of the uncounted local variable. To be on the safe side we require the scope of an uncounted variable to be embedded in the scope of ref-counted object that backs it.

clang/include/clang/APINotes/Types.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,19 +445,16 @@ class ParamInfo : public VariableInfo {
445445
RawRetainCountConvention() {}
446446

447447
std::optional<bool> isNoEscape() const {
448-
if (!NoEscapeSpecified)
449-
return std::nullopt;
450-
return NoEscape;
448+
return NoEscapeSpecified ? std::optional<bool>(NoEscape) : std::nullopt;
451449
}
452450
void setNoEscape(std::optional<bool> Value) {
453451
NoEscapeSpecified = Value.has_value();
454452
NoEscape = Value.value_or(false);
455453
}
456454

457455
std::optional<bool> isLifetimebound() const {
458-
if (!LifetimeboundSpecified)
459-
return std::nullopt;
460-
return Lifetimebound;
456+
return LifetimeboundSpecified ? std::optional<bool>(Lifetimebound)
457+
: std::nullopt;
461458
}
462459
void setLifetimebound(std::optional<bool> Value) {
463460
LifetimeboundSpecified = Value.has_value();
@@ -643,6 +640,8 @@ class ObjCMethodInfo : public FunctionInfo {
643640
LLVM_PREFERRED_TYPE(bool)
644641
unsigned RequiredInit : 1;
645642

643+
std::optional<ParamInfo> Self;
644+
646645
ObjCMethodInfo() : DesignatedInit(false), RequiredInit(false) {}
647646

648647
friend bool operator==(const ObjCMethodInfo &, const ObjCMethodInfo &);
@@ -664,7 +663,7 @@ class ObjCMethodInfo : public FunctionInfo {
664663
inline bool operator==(const ObjCMethodInfo &LHS, const ObjCMethodInfo &RHS) {
665664
return static_cast<const FunctionInfo &>(LHS) == RHS &&
666665
LHS.DesignatedInit == RHS.DesignatedInit &&
667-
LHS.RequiredInit == RHS.RequiredInit;
666+
LHS.RequiredInit == RHS.RequiredInit && LHS.Self == RHS.Self;
668667
}
669668

670669
inline bool operator!=(const ObjCMethodInfo &LHS, const ObjCMethodInfo &RHS) {
@@ -693,8 +692,20 @@ class FieldInfo : public VariableInfo {
693692
class CXXMethodInfo : public FunctionInfo {
694693
public:
695694
CXXMethodInfo() {}
695+
696+
std::optional<ParamInfo> This;
697+
698+
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS);
696699
};
697700

701+
inline bool operator==(const CXXMethodInfo &LHS, const CXXMethodInfo &RHS) {
702+
return static_cast<const FunctionInfo &>(LHS) == RHS && LHS.This == RHS.This;
703+
}
704+
705+
inline bool operator!=(const CXXMethodInfo &LHS, const CXXMethodInfo &RHS) {
706+
return !(LHS == RHS);
707+
}
708+
698709
/// Describes API notes data for an enumerator.
699710
class EnumConstantInfo : public CommonEntityInfo {
700711
public:

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4798,6 +4798,12 @@ def HLSLDot4AddI8Packed : LangBuiltin<"HLSL_LANG"> {
47984798
let Prototype = "int(unsigned int, unsigned int, int)";
47994799
}
48004800

4801+
def HLSLDot4AddU8Packed : LangBuiltin<"HLSL_LANG"> {
4802+
let Spellings = ["__builtin_hlsl_dot4add_u8packed"];
4803+
let Attributes = [NoThrow, Const];
4804+
let Prototype = "unsigned int(unsigned int, unsigned int, unsigned int)";
4805+
}
4806+
48014807
def HLSLFirstBitHigh : LangBuiltin<"HLSL_LANG"> {
48024808
let Spellings = ["__builtin_hlsl_elementwise_firstbithigh"];
48034809
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,13 @@ def err_expected_equal_designator : Error<"expected '=' or another designator">;
203203
def ext_gnu_old_style_field_designator : ExtWarn<
204204
"use of GNU old-style field designator extension">,
205205
InGroup<GNUDesignator>;
206-
def ext_gnu_case_range : Extension<"use of GNU case range extension">,
207-
InGroup<GNUCaseRange>;
206+
def ext_gnu_case_range : Extension<
207+
"case ranges are a GNU extension">, InGroup<GNUCaseRange>;
208+
def warn_c23_compat_case_range : Warning<
209+
"case ranges are incompatible with C standards before C2y">,
210+
DefaultIgnore, InGroup<CPre2yCompat>;
211+
def ext_c2y_case_range : Extension<
212+
"case ranges are a C2y extension">, InGroup<C2y>;
208213

209214
// Generic errors.
210215
def err_expected_expression : Error<"expected expression">;

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,10 @@ def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
17601760
HelpText<"Check uncounted call arguments.">,
17611761
Documentation<HasDocumentation>;
17621762

1763+
def UncheckedCallArgsChecker : Checker<"UncheckedCallArgsChecker">,
1764+
HelpText<"Check unchecked call arguments.">,
1765+
Documentation<HasDocumentation>;
1766+
17631767
def UncountedLocalVarsChecker : Checker<"UncountedLocalVarsChecker">,
17641768
HelpText<"Check uncounted local variables.">,
17651769
Documentation<HasDocumentation>;

clang/lib/APINotes/APINotesFormat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const uint16_t VERSION_MAJOR = 0;
2424
/// API notes file minor version number.
2525
///
2626
/// When the format changes IN ANY WAY, this number should be incremented.
27-
const uint16_t VERSION_MINOR = 31; // lifetimebound
27+
const uint16_t VERSION_MINOR =
28+
32; // implicit parameter support (at position -1)
2829

2930
const uint8_t kSwiftCopyable = 1;
3031
const uint8_t kSwiftNonCopyable = 2;

clang/lib/APINotes/APINotesReader.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//===----------------------------------------------------------------------===//
1515
#include "clang/APINotes/APINotesReader.h"
1616
#include "APINotesFormat.h"
17+
#include "clang/APINotes/Types.h"
1718
#include "llvm/ADT/Hashing.h"
1819
#include "llvm/ADT/StringExtras.h"
1920
#include "llvm/Bitstream/BitstreamReader.h"
@@ -396,12 +397,19 @@ class ObjCMethodTableInfo
396397
const uint8_t *&Data) {
397398
ObjCMethodInfo Info;
398399
uint8_t Payload = *Data++;
400+
bool HasSelf = Payload & 0x01;
401+
Payload >>= 1;
399402
Info.RequiredInit = Payload & 0x01;
400403
Payload >>= 1;
401404
Info.DesignatedInit = Payload & 0x01;
402405
Payload >>= 1;
406+
assert(Payload == 0 && "Unable to fully decode 'Payload'.");
403407

404408
ReadFunctionInfo(Data, Info);
409+
if (HasSelf) {
410+
Info.Self = ParamInfo{};
411+
ReadParamInfo(Data, *Info.Self);
412+
}
405413
return Info;
406414
}
407415
};
@@ -516,7 +524,17 @@ class CXXMethodTableInfo
516524
static CXXMethodInfo readUnversioned(internal_key_type Key,
517525
const uint8_t *&Data) {
518526
CXXMethodInfo Info;
527+
528+
uint8_t Payload = *Data++;
529+
bool HasThis = Payload & 0x01;
530+
Payload >>= 1;
531+
assert(Payload == 0 && "Unable to fully decode 'Payload'.");
532+
519533
ReadFunctionInfo(Data, Info);
534+
if (HasThis) {
535+
Info.This = ParamInfo{};
536+
ReadParamInfo(Data, *Info.This);
537+
}
520538
return Info;
521539
}
522540
};

0 commit comments

Comments
 (0)