Skip to content

Commit ca389fc

Browse files
authored
Merge branch 'main' into fix/100394
2 parents db98a55 + 36a0d44 commit ca389fc

File tree

22 files changed

+216
-79
lines changed

22 files changed

+216
-79
lines changed

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv8m.main-none-eabi)
345345
set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
346346
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
347347
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
348+
set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING "")
348349
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
349350
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
350351
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
@@ -396,6 +397,7 @@ foreach(target riscv32-unknown-elf)
396397
set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
397398
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
398399
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
400+
set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING "")
399401
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
400402
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
401403
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,7 +2728,7 @@ bool Compiler<Emitter>::VisitMaterializeTemporaryExpr(
27282728

27292729
const Expr *Inner = E->getSubExpr()->skipRValueSubobjectAdjustments();
27302730
if (std::optional<unsigned> LocalIndex =
2731-
allocateLocal(Inner, E->getExtendingDecl())) {
2731+
allocateLocal(E, Inner->getType(), E->getExtendingDecl())) {
27322732
InitLinkScope<Emitter> ILS(this, InitLink::Temp(*LocalIndex));
27332733
if (!this->emitGetPtrLocal(*LocalIndex, E))
27342734
return false;
@@ -4029,15 +4029,15 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(DeclTy &&Src, PrimType Ty,
40294029

40304030
template <class Emitter>
40314031
std::optional<unsigned>
4032-
Compiler<Emitter>::allocateLocal(DeclTy &&Src, const ValueDecl *ExtendingDecl) {
4032+
Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
4033+
const ValueDecl *ExtendingDecl) {
40334034
// Make sure we don't accidentally register the same decl twice.
40344035
if ([[maybe_unused]] const auto *VD =
40354036
dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
40364037
assert(!P.getGlobal(VD));
40374038
assert(!Locals.contains(VD));
40384039
}
40394040

4040-
QualType Ty;
40414041
const ValueDecl *Key = nullptr;
40424042
const Expr *Init = nullptr;
40434043
bool IsTemporary = false;
@@ -4050,7 +4050,8 @@ Compiler<Emitter>::allocateLocal(DeclTy &&Src, const ValueDecl *ExtendingDecl) {
40504050
}
40514051
if (auto *E = Src.dyn_cast<const Expr *>()) {
40524052
IsTemporary = true;
4053-
Ty = E->getType();
4053+
if (Ty.isNull())
4054+
Ty = E->getType();
40544055
}
40554056

40564057
Descriptor *D = P.createDescriptor(

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
302302

303303
/// Allocates a space storing a local given its type.
304304
std::optional<unsigned>
305-
allocateLocal(DeclTy &&Decl, const ValueDecl *ExtendingDecl = nullptr);
305+
allocateLocal(DeclTy &&Decl, QualType Ty = QualType(),
306+
const ValueDecl *ExtendingDecl = nullptr);
306307
unsigned allocateTemporary(const Expr *E);
307308

308309
private:

clang/lib/Headers/xmmintrin.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,9 +1618,8 @@ _mm_cvtt_ps2pi(__m128 __a)
16181618
/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
16191619
/// converted value of the second operand. The upper 96 bits are copied from
16201620
/// the upper 96 bits of the first operand.
1621-
static __inline__ __m128 __DEFAULT_FN_ATTRS
1622-
_mm_cvtsi32_ss(__m128 __a, int __b)
1623-
{
1621+
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvtsi32_ss(__m128 __a,
1622+
int __b) {
16241623
__a[0] = __b;
16251624
return __a;
16261625
}
@@ -1641,9 +1640,8 @@ _mm_cvtsi32_ss(__m128 __a, int __b)
16411640
/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
16421641
/// converted value of the second operand. The upper 96 bits are copied from
16431642
/// the upper 96 bits of the first operand.
1644-
static __inline__ __m128 __DEFAULT_FN_ATTRS
1645-
_mm_cvt_si2ss(__m128 __a, int __b)
1646-
{
1643+
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvt_si2ss(__m128 __a,
1644+
int __b) {
16471645
return _mm_cvtsi32_ss(__a, __b);
16481646
}
16491647

@@ -1665,9 +1663,8 @@ _mm_cvt_si2ss(__m128 __a, int __b)
16651663
/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
16661664
/// converted value of the second operand. The upper 96 bits are copied from
16671665
/// the upper 96 bits of the first operand.
1668-
static __inline__ __m128 __DEFAULT_FN_ATTRS
1669-
_mm_cvtsi64_ss(__m128 __a, long long __b)
1670-
{
1666+
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
1667+
_mm_cvtsi64_ss(__m128 __a, long long __b) {
16711668
__a[0] = __b;
16721669
return __a;
16731670
}

clang/test/AST/ByteCode/cxx1z.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++17 -verify=expected,both %s
2+
// RUN: %clang_cc1 -std=c++17 -verify=ref,both %s
3+
4+
template<typename T, T val> struct A {};
5+
namespace Temp {
6+
struct S { int n; };
7+
constexpr S &addr(S &&s) { return s; }
8+
A<S &, addr({})> a; // both-error {{reference to temporary object}}
9+
A<S *, &addr({})> b; // both-error {{pointer to temporary object}}
10+
A<int &, addr({}).n> c; // both-error {{reference to subobject of temporary object}}
11+
A<int *, &addr({}).n> d; // both-error {{pointer to subobject of temporary object}}
12+
}

clang/test/CodeGen/X86/sse-builtins.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,15 @@ void test_constexpr() {
948948
constexpr __m128 v_mm_movelh_ps = _mm_movelh_ps(k1, k2);
949949
static_assert(v_mm_movelh_ps[0] == +1.0f && v_mm_movelh_ps[1] == +0.0f && v_mm_movelh_ps[2] == +8.0f && v_mm_movelh_ps[3] == +4.0f);
950950

951+
constexpr __m128 v_mm_cvtsi32_ss = _mm_cvtsi32_ss(k1, 42);
952+
static_assert(v_mm_cvtsi32_ss[0] == 42.0f && v_mm_cvtsi32_ss[1] == +0.0f && v_mm_cvtsi32_ss[2] == +2.0f && v_mm_cvtsi32_ss[3] == +4.0f);
953+
954+
constexpr __m128 v_mm_cvt_si2ss = _mm_cvt_si2ss(k2, -99);
955+
static_assert(v_mm_cvt_si2ss[0] == -99.0f && v_mm_cvt_si2ss[1] == +4.0f && v_mm_cvt_si2ss[2] == +2.0f && v_mm_cvt_si2ss[3] == +1.0f);
956+
957+
constexpr __m128 v_mm_cvtsi64_ss = _mm_cvtsi64_ss(k3, 555);
958+
static_assert(v_mm_cvtsi64_ss[0] == 555.0f && v_mm_cvtsi64_ss[1] == -5.0f && v_mm_cvtsi64_ss[2] == +6.0f && v_mm_cvtsi64_ss[3] == +7.0f);
959+
951960
static_assert(_mm_cvtss_f32(k2) == +8.0f);
952961
}
953962

libcxx/cmake/caches/AIX.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@ set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
1616
set(LIBUNWIND_ENABLE_SHARED ON CACHE BOOL "")
1717
set(LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
1818
set(LIBCXX_ABI_DEFINES "_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE" CACHE STRING "")
19+
20+
# On AIX, both shared and static libraries are archived. As a result, both the static and the shared targets end
21+
# up with a `.a` suffix, which conflict. To workaround that, we set a different output name for the static
22+
# libraries, which we never actually build anyway. For more information, see https://gitlab.kitware.com/cmake/cmake/-/issues/19494.
23+
set(LIBCXX_STATIC_OUTPUT_NAME "c++-static" CACHE STRING "")
24+
set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi-static" CACHE STRING "")
25+
set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind-static" CACHE STRING "")

libcxx/cmake/caches/Armv7M-picolibc.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ set(LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "")
3939
set(LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "")
4040
set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
4141
find_program(QEMU_SYSTEM_ARM qemu-system-arm REQUIRED)
42+
43+
# On embedded platforms that don't support shared library targets, CMake implicitly changes shared
44+
# library targets to be static library targets. This results in duplicate definitions of the static
45+
# library targets even though we might not ever build the shared library target, which breaks the
46+
# build. To work around this, we change the output name of the shared library target so that it
47+
# can't conflict with the static library target.
48+
#
49+
# This is tracked by https://gitlab.kitware.com/cmake/cmake/-/issues/25759.
50+
set(LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING "")
51+
set(LIBCXXABI_SHARED_OUTPUT_NAME "c++abi-shared" CACHE STRING "")
52+
set(LIBUNWIND_SHARED_OUTPUT_NAME "unwind-shared" CACHE STRING "")

libcxx/src/CMakeLists.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
143143
)
144144
endif()
145145

146-
if(NOT LIBCXX_INSTALL_LIBRARY)
147-
set(exclude_from_all EXCLUDE_FROM_ALL)
148-
endif()
149-
150146
if (APPLE AND LLVM_USE_SANITIZER)
151147
if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
152148
("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
@@ -177,13 +173,13 @@ split_list(LIBCXX_COMPILE_FLAGS)
177173
split_list(LIBCXX_LINK_FLAGS)
178174

179175
# Build the shared library.
180-
if (LIBCXX_ENABLE_SHARED)
181-
add_library(cxx_shared SHARED ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
176+
add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
182177
target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
183178
target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
184179
PRIVATE ${LIBCXX_LIBRARIES})
185180
set_target_properties(cxx_shared
186181
PROPERTIES
182+
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBCXX_ENABLE_SHARED}>,FALSE,TRUE>"
187183
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
188184
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
189185
OUTPUT_NAME "${LIBCXX_SHARED_OUTPUT_NAME}"
@@ -247,7 +243,10 @@ if (LIBCXX_ENABLE_SHARED)
247243
)
248244
endif()
249245

246+
if (LIBCXX_ENABLE_SHARED)
250247
list(APPEND LIBCXX_BUILD_TARGETS "cxx_shared")
248+
endif()
249+
251250
if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
252251
# Since we most likely do not have a mt.exe replacement, disable the
253252
# manifest bundling. This allows a normal cmake invocation to pass which
@@ -260,19 +259,18 @@ if (LIBCXX_ENABLE_SHARED)
260259
APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker /MANIFEST:NO")
261260
endif()
262261
endif()
263-
endif()
264262

265263
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
266264

267265
# Build the static library.
268-
if (LIBCXX_ENABLE_STATIC)
269-
add_library(cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
266+
add_library(cxx_static STATIC ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
270267
target_include_directories(cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
271268
target_link_libraries(cxx_static PUBLIC cxx-headers libcxx-libc-static
272269
PRIVATE ${LIBCXX_LIBRARIES}
273270
PRIVATE libcxx-abi-static)
274271
set_target_properties(cxx_static
275272
PROPERTIES
273+
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBCXX_ENABLE_STATIC}>,FALSE,TRUE>"
276274
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
277275
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
278276
OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME}"
@@ -295,16 +293,18 @@ if (LIBCXX_ENABLE_STATIC)
295293
target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=)
296294
endif()
297295

298-
list(APPEND LIBCXX_BUILD_TARGETS "cxx_static")
296+
if (LIBCXX_ENABLE_STATIC)
297+
list(APPEND LIBCXX_BUILD_TARGETS "cxx_static")
298+
endif()
299299
# Attempt to merge the libc++.a archive and the ABI library archive into one.
300300
if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
301301
target_link_libraries(cxx_static PRIVATE libcxx-abi-static-objects)
302302
endif()
303-
endif()
304303

305304
# Add a meta-target for both libraries.
306305
add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS})
307306

307+
# Build the experimental static library
308308
set(LIBCXX_EXPERIMENTAL_SOURCES
309309
experimental/keep.cpp
310310
)

libcxx/utils/ci/run-buildbot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ check-generated-output)
238238
# Reject patches that introduce non-ASCII characters or hard tabs.
239239
# Depends on LC_COLLATE set at the top of this script.
240240
set -x
241-
! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test libcxx/benchmarks \
241+
! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test \
242242
--exclude '*.dat' \
243243
--exclude '*unicode*.cpp' \
244244
--exclude '*print*.sh.cpp' \

0 commit comments

Comments
 (0)