Skip to content

Commit a6a7d0d

Browse files
author
Tyler Nowicki
authored
Merge branch 'main' into amd/dev/tnowicki/use.struct.binding
2 parents a97faf8 + b49c4af commit a6a7d0d

File tree

384 files changed

+7365
-7511
lines changed

Some content is hidden

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

384 files changed

+7365
-7511
lines changed

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -416,17 +416,6 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
416416
BF.duplicateConstantIslands();
417417
}
418418

419-
if (!FF.empty() && FF.front()->isLandingPad()) {
420-
assert(!FF.front()->isEntryPoint() &&
421-
"Landing pad cannot be entry point of function");
422-
// If the first block of the fragment is a landing pad, it's offset from the
423-
// start of the area that the corresponding LSDA describes is zero. In this
424-
// case, the call site entries in that LSDA have 0 as offset to the landing
425-
// pad, which the runtime interprets as "no handler". To prevent this,
426-
// insert some padding.
427-
Streamer.emitBytes(BC.MIB->getTrapFillValue());
428-
}
429-
430419
// Track the first emitted instruction with debug info.
431420
bool FirstInstr = true;
432421
for (BinaryBasicBlock *const BB : FF) {
@@ -926,39 +915,54 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
926915
// Emit the LSDA header.
927916

928917
// If LPStart is omitted, then the start of the FDE is used as a base for
929-
// landing pad displacements. Then if a cold fragment starts with
930-
// a landing pad, this means that the first landing pad offset will be 0.
931-
// As a result, the exception handling runtime will ignore this landing pad
932-
// because zero offset denotes the absence of a landing pad.
933-
// For this reason, when the binary has fixed starting address we emit LPStart
934-
// as 0 and output the absolute value of the landing pad in the table.
918+
// landing pad displacements. Then, if a cold fragment starts with a landing
919+
// pad, this means that the first landing pad offset will be 0. However, C++
920+
// runtime treats 0 as if there is no landing pad present, thus we *must* emit
921+
// non-zero offsets for all valid LPs.
935922
//
936-
// If the base address can change, we cannot use absolute addresses for
937-
// landing pads (at least not without runtime relocations). Hence, we fall
938-
// back to emitting landing pads relative to the FDE start.
939-
// As we are emitting label differences, we have to guarantee both labels are
940-
// defined in the same section and hence cannot place the landing pad into a
941-
// cold fragment when the corresponding call site is in the hot fragment.
942-
// Because of this issue and the previously described issue of possible
943-
// zero-offset landing pad we have to place landing pads in the same section
944-
// as the corresponding invokes for shared objects.
923+
// As a solution, for fixed-address binaries we set LPStart to 0, and for
924+
// position-independent binaries we set LP start to FDE start minus one byte
925+
// for FDEs that start with a landing pad.
926+
const bool NeedsLPAdjustment = !FF.empty() && FF.front()->isLandingPad();
945927
std::function<void(const MCSymbol *)> emitLandingPad;
946928
if (BC.HasFixedLoadAddress) {
947929
Streamer.emitIntValue(dwarf::DW_EH_PE_udata4, 1); // LPStart format
948930
Streamer.emitIntValue(0, 4); // LPStart
949931
emitLandingPad = [&](const MCSymbol *LPSymbol) {
950-
if (!LPSymbol)
951-
Streamer.emitIntValue(0, 4);
952-
else
932+
if (LPSymbol)
953933
Streamer.emitSymbolValue(LPSymbol, 4);
934+
else
935+
Streamer.emitIntValue(0, 4);
954936
};
955937
} else {
956-
Streamer.emitIntValue(dwarf::DW_EH_PE_omit, 1); // LPStart format
938+
if (NeedsLPAdjustment) {
939+
// Use relative LPStart format and emit LPStart as [SymbolStart - 1].
940+
Streamer.emitIntValue(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, 1);
941+
MCSymbol *DotSymbol = BC.Ctx->createTempSymbol("LPBase");
942+
Streamer.emitLabel(DotSymbol);
943+
944+
const MCExpr *LPStartExpr = MCBinaryExpr::createSub(
945+
MCSymbolRefExpr::create(StartSymbol, *BC.Ctx),
946+
MCSymbolRefExpr::create(DotSymbol, *BC.Ctx), *BC.Ctx);
947+
LPStartExpr = MCBinaryExpr::createSub(
948+
LPStartExpr, MCConstantExpr::create(1, *BC.Ctx), *BC.Ctx);
949+
Streamer.emitValue(LPStartExpr, 4);
950+
} else {
951+
// DW_EH_PE_omit means FDE start (StartSymbol) will be used as LPStart.
952+
Streamer.emitIntValue(dwarf::DW_EH_PE_omit, 1);
953+
}
957954
emitLandingPad = [&](const MCSymbol *LPSymbol) {
958-
if (!LPSymbol)
955+
if (LPSymbol) {
956+
const MCExpr *LPOffsetExpr = MCBinaryExpr::createSub(
957+
MCSymbolRefExpr::create(LPSymbol, *BC.Ctx),
958+
MCSymbolRefExpr::create(StartSymbol, *BC.Ctx), *BC.Ctx);
959+
if (NeedsLPAdjustment)
960+
LPOffsetExpr = MCBinaryExpr::createAdd(
961+
LPOffsetExpr, MCConstantExpr::create(1, *BC.Ctx), *BC.Ctx);
962+
Streamer.emitValue(LPOffsetExpr, 4);
963+
} else {
959964
Streamer.emitIntValue(0, 4);
960-
else
961-
Streamer.emitAbsoluteSymbolDiff(LPSymbol, StartSymbol, 4);
965+
}
962966
};
963967
}
964968

clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ getFunctionSourceCode(const FunctionDecl *FD, const DeclContext *TargetContext,
239239
return;
240240

241241
for (const NamedDecl *ND : Ref.Targets) {
242+
if (ND->getKind() == Decl::TemplateTypeParm)
243+
return;
242244
if (ND->getDeclContext() != Ref.Targets.front()->getDeclContext()) {
243245
elog("Targets from multiple contexts: {0}, {1}",
244246
printQualifiedName(*Ref.Targets.front()),

clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,29 +411,29 @@ inline typename O1<T, U...>::template O2<V, A>::E O1<T, U...>::template O2<V, A>
411411
R"cpp(
412412
struct Foo {
413413
template <typename T, bool B = true>
414-
void ^bar() {}
414+
T ^bar() { return {}; }
415415
};)cpp",
416416
R"cpp(
417417
struct Foo {
418418
template <typename T, bool B = true>
419-
void bar() ;
419+
T bar() ;
420420
};template <typename T, bool B>
421-
inline void Foo::bar() {}
421+
inline T Foo::bar() { return {}; }
422422
)cpp",
423423
""},
424424

425425
// Class template with member template
426426
{
427427
R"cpp(
428428
template <typename T> struct Foo {
429-
template <typename U> void ^bar(const T& t, const U& u) {}
429+
template <typename U> T ^bar(const T& t, const U& u) { return {}; }
430430
};)cpp",
431431
R"cpp(
432432
template <typename T> struct Foo {
433-
template <typename U> void bar(const T& t, const U& u) ;
433+
template <typename U> T bar(const T& t, const U& u) ;
434434
};template <typename T>
435435
template <typename U>
436-
inline void Foo<T>::bar(const T& t, const U& u) {}
436+
inline T Foo<T>::bar(const T& t, const U& u) { return {}; }
437437
)cpp",
438438
""},
439439
};

clang-tools-extra/test/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ set(CLANG_TOOLS_TEST_DEPS
5050
clang-resource-headers
5151

5252
clang-tidy
53-
# Clang-tidy tests need clang for building modules.
54-
clang
5553
)
5654

5755
# Add lit test dependencies.

clang/cmake/caches/CrossWinToARMLinux.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ if (NOT DEFINED CMAKE_BUILD_TYPE)
119119
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
120120
endif()
121121

122-
set(CMAKE_CROSSCOMPILING ON CACHE BOOL "")
123122
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: " CACHE STRING "")
124123
# Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
125124
set(CMAKE_C_COMPILER_TARGET "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
@@ -219,6 +218,11 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_CXX_ABI
219218
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
220219
# Merge libc++ and libc++abi libraries into the single libc++ library file.
221220
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
221+
# Forcely disable the libc++ benchmarks on Windows build hosts
222+
# (current benchmark test configuration does not support the cross builds there).
223+
if (WIN32)
224+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
225+
endif(WIN32)
222226

223227
# Avoid searching for the python3 interpreter during the runtimes configuration for the cross builds.
224228
# It starts searching the python3 package using the target's sysroot path, that usually is not compatible with the build host.

clang/docs/InternalsManual.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ wording a diagnostic.
160160
named in a diagnostic message. e.g., prefer wording like ``'this' pointer
161161
cannot be null in well-defined C++ code`` over wording like ``this pointer
162162
cannot be null in well-defined C++ code``.
163+
* Prefer diagnostic wording without contractions whenever possible. The single
164+
quote in a contraction can be visually distracting due to its use with
165+
syntactic constructs and contractions can be harder to understand for non-
166+
native English speakers.
163167

164168
The Format String
165169
^^^^^^^^^^^^^^^^^

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ Non-comprehensive list of changes in this release
357357

358358
- ``__builtin_reduce_add`` function can now be used in constant expressions.
359359
- ``__builtin_reduce_mul`` function can now be used in constant expressions.
360+
- ``__builtin_reduce_and`` function can now be used in constant expressions.
360361

361362
New Compiler Flags
362363
------------------
@@ -558,6 +559,8 @@ Improvements to Clang's diagnostics
558559

559560
- Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
560561

562+
- Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485).
563+
561564
Improvements to Clang's time-trace
562565
----------------------------------
563566

clang/include/clang/Basic/AttrDocs.td

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,17 +3921,42 @@ have their lifetimes extended.
39213921
def LifetimeCaptureByDocs : Documentation {
39223922
let Category = DocCatFunction;
39233923
let Content = [{
3924-
Similar to `lifetimebound`_, the ``lifetime_capture_by(X)`` attribute on a function
3925-
parameter or implicit object parameter indicates that that objects that are referred to
3926-
by that parameter may also be referred to by the capturing entity ``X``.
3924+
Similar to `lifetimebound`_, the ``lifetime_capture_by(X)`` attribute on a
3925+
function parameter or implicit object parameter indicates that the capturing
3926+
entity ``X`` may refer to the object referred by that parameter.
3927+
3928+
Below is a list of types of the parameters and what they're considered to refer to:
3929+
3930+
- A reference param (of non-view type) is considered to refer to its referenced object.
3931+
- A pointer param (of non-view type) is considered to refer to its pointee.
3932+
- View type param (type annotated with ``[[gsl::Pointer()]]``) is considered to refer
3933+
to its pointee (gsl owner). This holds true even if the view type appears as a reference
3934+
in the parameter. For example, both ``std::string_view`` and
3935+
``const std::string_view &`` are considered to refer to a ``std::string``.
3936+
- A ``std::initializer_list<T>`` is considered to refer to its underlying array.
3937+
- Aggregates (arrays and simple ``struct``\s) are considered to refer to all
3938+
objects that their transitive subobjects refer to.
3939+
3940+
Clang would diagnose when a temporary object is used as an argument to such an
3941+
annotated parameter.
3942+
In this case, the capturing entity ``X`` could capture a dangling reference to this
3943+
temporary object.
39273944

3928-
By default, a reference is considered to refer to its referenced object, a
3929-
pointer is considered to refer to its pointee, a ``std::initializer_list<T>``
3930-
is considered to refer to its underlying array, and aggregates (arrays and
3931-
simple ``struct``\s) are considered to refer to all objects that their
3932-
transitive subobjects refer to.
3945+
.. code-block:: c++
3946+
3947+
void addToSet(std::string_view a [[clang::lifetime_capture_by(s)]], std::set<std::string_view>& s) {
3948+
s.insert(a);
3949+
}
3950+
void use() {
3951+
std::set<std::string_view> s;
3952+
addToSet(std::string(), s); // Warning: object whose reference is captured by 's' will be destroyed at the end of the full-expression.
3953+
// ^^^^^^^^^^^^^
3954+
std::string local;
3955+
addToSet(local, s); // Ok.
3956+
}
39333957

39343958
The capturing entity ``X`` can be one of the following:
3959+
39353960
- Another (named) function parameter.
39363961

39373962
.. code-block:: c++
@@ -3951,7 +3976,7 @@ The capturing entity ``X`` can be one of the following:
39513976
std::set<std::string_view> s;
39523977
};
39533978

3954-
- 'global', 'unknown' (without quotes).
3979+
- `global`, `unknown`.
39553980

39563981
.. code-block:: c++
39573982

@@ -3983,6 +4008,22 @@ The attribute supports specifying more than one capturing entities:
39834008
s2.insert(a);
39844009
}
39854010

4011+
Limitation: The capturing entity ``X`` is not used by the analysis and is
4012+
used for documentation purposes only. This is because the analysis is
4013+
statement-local and only detects use of a temporary as an argument to the
4014+
annotated parameter.
4015+
4016+
.. code-block:: c++
4017+
4018+
void addToSet(std::string_view a [[clang::lifetime_capture_by(s)]], std::set<std::string_view>& s);
4019+
void use() {
4020+
std::set<std::string_view> s;
4021+
if (foo()) {
4022+
std::string str;
4023+
addToSet(str, s); // Not detected.
4024+
}
4025+
}
4026+
39864027
.. _`lifetimebound`: https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
39874028
}];
39884029
}

clang/include/clang/Basic/Builtins.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ def ReduceOr : Builtin {
14981498

14991499
def ReduceAnd : Builtin {
15001500
let Spellings = ["__builtin_reduce_and"];
1501-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1501+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
15021502
let Prototype = "void(...)";
15031503
}
15041504

clang/include/clang/Basic/BuiltinsLoongArchLASX.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ TARGET_BUILTIN(__builtin_lasx_xvor_v, "V32UcV32UcV32Uc", "nc", "lasx")
371371
TARGET_BUILTIN(__builtin_lasx_xvxor_v, "V32UcV32UcV32Uc", "nc", "lasx")
372372
TARGET_BUILTIN(__builtin_lasx_xvnor_v, "V32UcV32UcV32Uc", "nc", "lasx")
373373
TARGET_BUILTIN(__builtin_lasx_xvandn_v, "V32UcV32UcV32Uc", "nc", "lasx")
374-
TARGET_BUILTIN(__builtin_lasx_xvorn_v, "V32ScV32ScV32Sc", "nc", "lasx")
374+
TARGET_BUILTIN(__builtin_lasx_xvorn_v, "V32UcV32UcV32Uc", "nc", "lasx")
375375

376376
TARGET_BUILTIN(__builtin_lasx_xvandi_b, "V32UcV32UcIUi", "nc", "lasx")
377377
TARGET_BUILTIN(__builtin_lasx_xvori_b, "V32UcV32UcIUi", "nc", "lasx")

0 commit comments

Comments
 (0)