Skip to content

Commit d56c859

Browse files
committed
Merge branch 'main' into users/skatrak/spr/clause-operands-01-mlir
2 parents c9ee93f + 7789ec0 commit d56c859

File tree

644 files changed

+16686
-7254
lines changed

Some content is hidden

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

644 files changed

+16686
-7254
lines changed

.ci/monolithic-linux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -o pipefail
1818

1919
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
2020
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
21-
rm -rf ${BUILD_DIR}
21+
rm -rf "${BUILD_DIR}"
2222

2323
ccache --zero-stats
2424

@@ -37,8 +37,8 @@ projects="${1}"
3737
targets="${2}"
3838

3939
echo "--- cmake"
40-
pip install -q -r ${MONOREPO_ROOT}/mlir/python/requirements.txt
41-
cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
40+
pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt
41+
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4242
-D LLVM_ENABLE_PROJECTS="${projects}" \
4343
-G Ninja \
4444
-D CMAKE_BUILD_TYPE=Release \

.ci/monolithic-windows.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -o pipefail
1919
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
2020
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
2121

22-
rm -rf ${BUILD_DIR}
22+
rm -rf "${BUILD_DIR}"
2323

2424
if [[ -n "${CLEAR_CACHE:-}" ]]; then
2525
echo "clearing sccache"
@@ -37,14 +37,14 @@ projects="${1}"
3737
targets="${2}"
3838

3939
echo "--- cmake"
40-
pip install -q -r ${MONOREPO_ROOT}/mlir/python/requirements.txt
40+
pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt
4141

4242
# The CMAKE_*_LINKER_FLAGS to disable the manifest come from research
4343
# on fixing a build reliability issue on the build server, please
4444
# see https://github.com/llvm/llvm-project/pull/82393 and
4545
# https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840/40
4646
# for further information.
47-
cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
47+
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4848
-D LLVM_ENABLE_PROJECTS="${projects}" \
4949
-G Ninja \
5050
-D CMAKE_BUILD_TYPE=Release \

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
persist-credentials: false
3737

3838
- name: "Run analysis"
39-
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
39+
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
4040
with:
4141
results_file: results.sarif
4242
results_format: sarif

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) {
35473547
if (!isMultiEntry())
35483548
return nullptr;
35493549

3550-
uint64_t NumEntries = 0;
3550+
uint64_t NumEntries = 1;
35513551
if (hasCFG()) {
35523552
for (BinaryBasicBlock *BB : BasicBlocks) {
35533553
MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB);
@@ -3580,7 +3580,7 @@ uint64_t BinaryFunction::getEntryIDForSymbol(const MCSymbol *Symbol) const {
35803580
return 0;
35813581

35823582
// Check all secondary entries available as either basic blocks or lables.
3583-
uint64_t NumEntries = 0;
3583+
uint64_t NumEntries = 1;
35843584
for (const BinaryBasicBlock *BB : BasicBlocks) {
35853585
MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB);
35863586
if (!EntrySymbol)
@@ -3589,7 +3589,7 @@ uint64_t BinaryFunction::getEntryIDForSymbol(const MCSymbol *Symbol) const {
35893589
return NumEntries;
35903590
++NumEntries;
35913591
}
3592-
NumEntries = 0;
3592+
NumEntries = 1;
35933593
for (const std::pair<const uint32_t, MCSymbol *> &KV : Labels) {
35943594
MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(KV.second);
35953595
if (!EntrySymbol)

bolt/lib/Profile/YAMLProfileWriter.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ extern llvm::cl::opt<bool> ProfileUseDFS;
2525
namespace llvm {
2626
namespace bolt {
2727

28+
/// Set CallSiteInfo destination fields from \p Symbol and return a target
29+
/// BinaryFunction for that symbol.
30+
static const BinaryFunction *setCSIDestination(const BinaryContext &BC,
31+
yaml::bolt::CallSiteInfo &CSI,
32+
const MCSymbol *Symbol) {
33+
CSI.DestId = 0; // designated for unknown functions
34+
CSI.EntryDiscriminator = 0;
35+
if (Symbol) {
36+
uint64_t EntryID = 0;
37+
if (const BinaryFunction *const Callee =
38+
BC.getFunctionForSymbol(Symbol, &EntryID)) {
39+
CSI.DestId = Callee->getFunctionNumber();
40+
CSI.EntryDiscriminator = EntryID;
41+
return Callee;
42+
}
43+
}
44+
return nullptr;
45+
}
46+
2847
yaml::bolt::BinaryFunctionProfile
2948
YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS) {
3049
yaml::bolt::BinaryFunctionProfile YamlBF;
@@ -79,31 +98,20 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS) {
7998
continue;
8099
for (const IndirectCallProfile &CSP : ICSP.get()) {
81100
StringRef TargetName = "";
82-
CSI.DestId = 0; // designated for unknown functions
83-
CSI.EntryDiscriminator = 0;
84-
if (CSP.Symbol) {
85-
const BinaryFunction *Callee = BC.getFunctionForSymbol(CSP.Symbol);
86-
if (Callee) {
87-
CSI.DestId = Callee->getFunctionNumber();
88-
TargetName = Callee->getOneName();
89-
}
90-
}
101+
const BinaryFunction *Callee = setCSIDestination(BC, CSI, CSP.Symbol);
102+
if (Callee)
103+
TargetName = Callee->getOneName();
91104
CSI.Count = CSP.Count;
92105
CSI.Mispreds = CSP.Mispreds;
93106
CSTargets.emplace_back(TargetName, CSI);
94107
}
95108
} else { // direct call or a tail call
96-
uint64_t EntryID = 0;
97-
CSI.DestId = 0;
98109
StringRef TargetName = "";
99110
const MCSymbol *CalleeSymbol = BC.MIB->getTargetSymbol(Instr);
100111
const BinaryFunction *const Callee =
101-
BC.getFunctionForSymbol(CalleeSymbol, &EntryID);
102-
if (Callee) {
103-
CSI.DestId = Callee->getFunctionNumber();
104-
CSI.EntryDiscriminator = EntryID;
112+
setCSIDestination(BC, CSI, CalleeSymbol);
113+
if (Callee)
105114
TargetName = Callee->getOneName();
106-
}
107115

108116
auto getAnnotationWithDefault = [&](const MCInst &Inst, StringRef Ann) {
109117
return BC.MIB->getAnnotationWithDefault(Instr, Ann, 0ull);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This reproduces a bug with BOLT setting incorrect discriminator for
2+
# secondary entry points in YAML profile.
3+
4+
# REQUIRES: system-linux
5+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
6+
# RUN: link_fdata %s %t.o %t.fdata
7+
# RUN: llvm-strip --strip-unneeded %t.o
8+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
9+
# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata -w %t.yaml --print-profile \
10+
# RUN: --print-only=main | FileCheck %s --check-prefix=CHECK-CFG
11+
# RUN: FileCheck %s -input-file %t.yaml
12+
# CHECK: - name: main
13+
# CHECK-NEXT: fid: 2
14+
# CHECK-NEXT: hash: 0xADF270D550151185
15+
# CHECK-NEXT: exec: 0
16+
# CHECK-NEXT: nblocks: 4
17+
# CHECK-NEXT: blocks:
18+
# CHECK: - bid: 1
19+
# CHECK-NEXT: insns: 1
20+
# CHECK-NEXT: hash: 0x36A303CBA4360014
21+
# CHECK-NEXT: calls: [ { off: 0x0, fid: 1, disc: 1, cnt: 1 } ]
22+
# CHECK: - bid: 2
23+
# CHECK-NEXT: insns: 5
24+
# CHECK-NEXT: hash: 0x8B2F5747CD0019
25+
# CHECK-NEXT: calls: [ { off: 0x0, fid: 1, disc: 1, cnt: 1, mis: 1 } ]
26+
27+
# Make sure that the profile is attached correctly
28+
# RUN: llvm-bolt %t.exe -o %t.out --data %t.yaml --print-profile \
29+
# RUN: --print-only=main | FileCheck %s --check-prefix=CHECK-CFG
30+
31+
# CHECK-CFG: Binary Function "main" after attaching profile {
32+
# CHECK-CFG: callq secondary_entry # Offset: [[#]] # Count: 1
33+
# CHECK-CFG: callq *%rax # Offset: [[#]] # CallProfile: 1 (1 misses) :
34+
# CHECK-CFG-NEXT: { secondary_entry: 1 (1 misses) }
35+
36+
.globl func
37+
.type func, @function
38+
func:
39+
# FDATA: 0 [unknown] 0 1 func 0 1 0
40+
.cfi_startproc
41+
pushq %rbp
42+
movq %rsp, %rbp
43+
.globl secondary_entry
44+
secondary_entry:
45+
popq %rbp
46+
retq
47+
nopl (%rax)
48+
.cfi_endproc
49+
.size func, .-func
50+
51+
.globl main
52+
.type main, @function
53+
main:
54+
.cfi_startproc
55+
pushq %rbp
56+
movq %rsp, %rbp
57+
subq $16, %rsp
58+
movl $0, -4(%rbp)
59+
testq %rax, %rax
60+
jne Lindcall
61+
Lcall:
62+
call secondary_entry
63+
# FDATA: 1 main #Lcall# 1 secondary_entry 0 1 1
64+
Lindcall:
65+
callq *%rax
66+
# FDATA: 1 main #Lindcall# 1 secondary_entry 0 1 1
67+
xorl %eax, %eax
68+
addq $16, %rsp
69+
popq %rbp
70+
retq
71+
# For relocations against .text
72+
call exit
73+
.cfi_endproc
74+
.size main, .-main

clang-tools-extra/clangd/support/Trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ bool enabled();
143143
class Span {
144144
public:
145145
Span(llvm::Twine Name);
146-
/// Records span's duration in seconds to \p LatencyMetric with \p Name as the
147-
/// label.
146+
/// Records span's duration in milliseconds to \p LatencyMetric with \p Name
147+
/// as the label.
148148
Span(llvm::Twine Name, const Metric &LatencyMetric);
149149
~Span();
150150

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ Improvements to Clang's diagnostics
304304
annotated with the ``clang::always_destroy`` attribute.
305305
Fixes #GH68686, #GH86486
306306

307+
- ``-Wmicrosoft``, ``-Wgnu``, or ``-pedantic`` is now required to diagnose C99
308+
flexible array members in a union or alone in a struct. Fixes GH#84565.
309+
307310
Improvements to Clang's time-trace
308311
----------------------------------
309312

@@ -454,6 +457,8 @@ Bug Fixes to C++ Support
454457
- Fix a crash when instantiating a lambda that captures ``this`` outside of its context. Fixes (#GH85343).
455458
- Fix an issue where a namespace alias could be defined using a qualified name (all name components
456459
following the first `::` were ignored).
460+
- Fix an out-of-bounds crash when checking the validity of template partial specializations. (part of #GH86757).
461+
- Fix an issue caused by not handling invalid cases when substituting into the parameter mapping of a constraint. Fixes (#GH86757).
457462

458463
Bug Fixes to AST Handling
459464
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,89 @@ Check for performance anti-patterns when using Grand Central Dispatch.
849849
850850
.. _optin-performance-Padding:
851851
852-
optin.performance.Padding
853-
"""""""""""""""""""""""""
852+
optin.performance.Padding (C, C++, ObjC)
853+
""""""""""""""""""""""""""""""""""""""""
854854
Check for excessively padded structs.
855855
856+
This checker detects structs with excessive padding, which can lead to wasted
857+
memory thus decreased performance by reducing the effectiveness of the
858+
processor cache. Padding bytes are added by compilers to align data accesses
859+
as some processors require data to be aligned to certain boundaries. On others,
860+
unaligned data access are possible, but impose significantly larger latencies.
861+
862+
To avoid padding bytes, the fields of a struct should be ordered by decreasing
863+
by alignment. Usually, its easier to think of the ``sizeof`` of the fields, and
864+
ordering the fields by ``sizeof`` would usually also lead to the same optimal
865+
layout.
866+
867+
In rare cases, one can use the ``#pragma pack(1)`` directive to enforce a packed
868+
layout too, but it can significantly increase the access times, so reordering the
869+
fields is usually a better solution.
870+
871+
872+
.. code-block:: cpp
873+
874+
// warn: Excessive padding in 'struct NonOptimal' (35 padding bytes, where 3 is optimal)
875+
struct NonOptimal {
876+
char c1;
877+
// 7 bytes of padding
878+
std::int64_t big1; // 8 bytes
879+
char c2;
880+
// 7 bytes of padding
881+
std::int64_t big2; // 8 bytes
882+
char c3;
883+
// 7 bytes of padding
884+
std::int64_t big3; // 8 bytes
885+
char c4;
886+
// 7 bytes of padding
887+
std::int64_t big4; // 8 bytes
888+
char c5;
889+
// 7 bytes of padding
890+
};
891+
static_assert(sizeof(NonOptimal) == 4*8+5+5*7);
892+
893+
// no-warning: The fields are nicely aligned to have the minimal amount of padding bytes.
894+
struct Optimal {
895+
std::int64_t big1; // 8 bytes
896+
std::int64_t big2; // 8 bytes
897+
std::int64_t big3; // 8 bytes
898+
std::int64_t big4; // 8 bytes
899+
char c1;
900+
char c2;
901+
char c3;
902+
char c4;
903+
char c5;
904+
// 3 bytes of padding
905+
};
906+
static_assert(sizeof(Optimal) == 4*8+5+3);
907+
908+
// no-warning: Bit packing representation is also accepted by this checker, but
909+
// it can significantly increase access times, so prefer reordering the fields.
910+
#pragma pack(1)
911+
struct BitPacked {
912+
char c1;
913+
std::int64_t big1; // 8 bytes
914+
char c2;
915+
std::int64_t big2; // 8 bytes
916+
char c3;
917+
std::int64_t big3; // 8 bytes
918+
char c4;
919+
std::int64_t big4; // 8 bytes
920+
char c5;
921+
};
922+
static_assert(sizeof(BitPacked) == 4*8+5);
923+
924+
The ``AllowedPad`` option can be used to specify a threshold for the number
925+
padding bytes raising the warning. If the number of padding bytes of the struct
926+
and the optimal number of padding bytes differ by more than the threshold value,
927+
a warning will be raised.
928+
929+
By default, the ``AllowedPad`` threshold is 24 bytes.
930+
931+
To override this threshold to e.g. 4 bytes, use the
932+
``-analyzer-config optin.performance.Padding:AllowedPad=4`` option.
933+
934+
856935
.. _optin-portability-UnixAPI:
857936
858937
optin.portability.UnixAPI

clang/include/clang-c/Index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,7 @@ enum CXCallingConv {
29912991
CXCallingConv_AArch64SVEPCS = 18,
29922992
CXCallingConv_M68kRTD = 19,
29932993
CXCallingConv_PreserveNone = 20,
2994+
CXCallingConv_RISCVVectorCall = 21,
29942995

29952996
CXCallingConv_Invalid = 100,
29962997
CXCallingConv_Unexposed = 200

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ class TextNodeDumper
352352
void VisitEnumConstantDecl(const EnumConstantDecl *D);
353353
void VisitIndirectFieldDecl(const IndirectFieldDecl *D);
354354
void VisitFunctionDecl(const FunctionDecl *D);
355+
void VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl *D);
355356
void VisitFieldDecl(const FieldDecl *D);
356357
void VisitVarDecl(const VarDecl *D);
357358
void VisitBindingDecl(const BindingDecl *D);

clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,35 @@ RecordStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
744744
std::vector<const FieldDecl *>
745745
getFieldsForInitListExpr(const InitListExpr *InitList);
746746

747+
/// Helper class for initialization of a record with an `InitListExpr`.
748+
/// `InitListExpr::inits()` contains the initializers for both the base classes
749+
/// and the fields of the record; this helper class separates these out into two
750+
/// different lists. In addition, it deals with special cases associated with
751+
/// unions.
752+
class RecordInitListHelper {
753+
public:
754+
// `InitList` must have record type.
755+
RecordInitListHelper(const InitListExpr *InitList);
756+
757+
// Base classes with their associated initializer expressions.
758+
ArrayRef<std::pair<const CXXBaseSpecifier *, Expr *>> base_inits() const {
759+
return BaseInits;
760+
}
761+
762+
// Fields with their associated initializer expressions.
763+
ArrayRef<std::pair<const FieldDecl *, Expr *>> field_inits() const {
764+
return FieldInits;
765+
}
766+
767+
private:
768+
SmallVector<std::pair<const CXXBaseSpecifier *, Expr *>> BaseInits;
769+
SmallVector<std::pair<const FieldDecl *, Expr *>> FieldInits;
770+
771+
// We potentially synthesize an `ImplicitValueInitExpr` for unions. It's a
772+
// member variable because we store a pointer to it in `FieldInits`.
773+
std::optional<ImplicitValueInitExpr> ImplicitValueInitForUnion;
774+
};
775+
747776
/// Associates a new `RecordValue` with `Loc` and returns the new value.
748777
RecordValue &refreshRecordValue(RecordStorageLocation &Loc, Environment &Env);
749778

0 commit comments

Comments
 (0)