Skip to content

Commit 4f4e4b5

Browse files
committed
merge main into amd-staging
2 parents 6f186bd + d95f46c commit 4f4e4b5

File tree

94 files changed

+3248
-623
lines changed

Some content is hidden

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

94 files changed

+3248
-623
lines changed

clang/include/clang/Basic/BuiltinHeaders.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ HEADER(INTRIN_H, "intrin.h")
2323
HEADER(MALLOC_H, "malloc.h")
2424
HEADER(MATH_H, "math.h")
2525
HEADER(MEMORY, "memory")
26+
HEADER(MMINTRIN_H, "mmintrin.h")
2627
HEADER(OBJC_MESSAGE_H, "objc/message.h")
2728
HEADER(OBJC_OBJC_AUTO_H, "objc/objc-auto.h")
2829
HEADER(OBJC_OBJC_EXCEPTION_H, "objc/objc-exception.h")

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in
138138
}
139139
}
140140

141+
let Features = "mmx", Header = "mmintrin.h", Attributes = [NoThrow, Const] in {
142+
def _m_prefetch : X86LibBuiltin<"void(void *)">;
143+
}
144+
145+
// PRFCHW
146+
let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in {
147+
def _m_prefetchw : X86LibBuiltin<"void(void volatile const *)">;
148+
}
141149

142150
// Mechanically ported builtins from the original `.def` file.
143151
//
@@ -146,8 +154,8 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in
146154
// current formulation is based on what was easiest to recognize from the
147155
// pre-TableGen version.
148156

149-
let Features = "mmx", Attributes = [NoThrow, Const] in {
150-
def _mm_prefetch : X86NoPrefixBuiltin<"void(char const *, int)">;
157+
let Features = "sse", Header = "xmmintrin.h", Attributes = [NoThrow, Const] in {
158+
def _mm_prefetch : X86LibBuiltin<"void(char const *, int)">;
151159
}
152160

153161
let Features = "sse", Attributes = [NoThrow] in {

clang/lib/CodeGen/TargetBuiltins/X86.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,17 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
804804
Function *F = CGM.getIntrinsic(Intrinsic::prefetch, Address->getType());
805805
return Builder.CreateCall(F, {Address, RW, Locality, Data});
806806
}
807+
case X86::BI_m_prefetch:
808+
case X86::BI_m_prefetchw: {
809+
Value *Address = Ops[0];
810+
// The 'w' suffix implies write.
811+
Value *RW =
812+
ConstantInt::get(Int32Ty, BuiltinID == X86::BI_m_prefetchw ? 1 : 0);
813+
Value *Locality = ConstantInt::get(Int32Ty, 0x3);
814+
Value *Data = ConstantInt::get(Int32Ty, 1);
815+
Function *F = CGM.getIntrinsic(Intrinsic::prefetch, Address->getType());
816+
return Builder.CreateCall(F, {Address, RW, Locality, Data});
817+
}
807818
case X86::BI_mm_clflush: {
808819
return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse2_clflush),
809820
Ops[0]);

clang/lib/Format/QualifierAlignmentFixer.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,15 +635,26 @@ bool isConfiguredQualifierOrType(const FormatToken *Tok,
635635
// If a token is an identifier and it's upper case, it could
636636
// be a macro and hence we need to be able to ignore it.
637637
bool isPossibleMacro(const FormatToken *Tok) {
638-
if (!Tok)
639-
return false;
638+
assert(Tok);
640639
if (Tok->isNot(tok::identifier))
641640
return false;
642-
if (Tok->TokenText.upper() == Tok->TokenText.str()) {
643-
// T,K,U,V likely could be template arguments
644-
return Tok->TokenText.size() != 1;
645-
}
646-
return false;
641+
642+
const auto Text = Tok->TokenText;
643+
assert(Text.size() > 0);
644+
645+
// T,K,U,V likely could be template arguments
646+
if (Text.size() == 1)
647+
return false;
648+
649+
// It's unlikely that qualified names are object-like macros.
650+
const auto *Prev = Tok->getPreviousNonComment();
651+
if (Prev && Prev->is(tok::coloncolon))
652+
return false;
653+
const auto *Next = Tok->getNextNonComment();
654+
if (Next && Next->is(tok::coloncolon))
655+
return false;
656+
657+
return Text == Text.upper();
647658
}
648659

649660
} // namespace format

clang/lib/Headers/prfchwintrin.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#ifndef __PRFCHWINTRIN_H
1515
#define __PRFCHWINTRIN_H
1616

17+
#if defined(__cplusplus)
18+
extern "C" {
19+
#endif
20+
1721
/// Loads a memory sequence containing the specified memory address into
1822
/// all data cache levels.
1923
///
@@ -26,11 +30,7 @@
2630
///
2731
/// \param __P
2832
/// A pointer specifying the memory address to be prefetched.
29-
static __inline__ void __attribute__((__always_inline__, __nodebug__))
30-
_m_prefetch(void *__P)
31-
{
32-
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
33-
}
33+
void _m_prefetch(void *__P);
3434

3535
/// Loads a memory sequence containing the specified memory address into
3636
/// the L1 data cache and sets the cache-coherency state to modified.
@@ -48,13 +48,10 @@ _m_prefetch(void *__P)
4848
///
4949
/// \param __P
5050
/// A pointer specifying the memory address to be prefetched.
51-
static __inline__ void __attribute__((__always_inline__, __nodebug__))
52-
_m_prefetchw(volatile const void *__P)
53-
{
54-
#pragma clang diagnostic push
55-
#pragma clang diagnostic ignored "-Wcast-qual"
56-
__builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
57-
#pragma clang diagnostic pop
58-
}
51+
void _m_prefetchw(volatile const void *__P);
52+
53+
#if defined(__cplusplus)
54+
} // extern "C"
55+
#endif
5956

6057
#endif /* __PRFCHWINTRIN_H */

clang/lib/Headers/xmmintrin.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,8 +2198,9 @@ _mm_storer_ps(float *__p, __m128 __a)
21982198
#define _MM_HINT_NTA 0
21992199

22002200
#ifndef _MSC_VER
2201-
/* FIXME: We have to #define this because "sel" must be a constant integer, and
2202-
Sema doesn't do any form of constant propagation yet. */
2201+
// If _MSC_VER is defined, we use the builtin variant of _mm_prefetch.
2202+
// Otherwise, we provide this macro, which includes a cast, allowing the user
2203+
// to pass a pointer of any time. The _mm_prefetch accepts char to match MSVC.
22032204

22042205
/// Loads one cache line of data from the specified address to a location
22052206
/// closer to the processor.

clang/lib/Serialization/ASTWriterStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
971971
Record.push_back(E->getFPFeatures().getAsOpaqueInt());
972972

973973
if (!E->hasStoredFPFeatures() && !static_cast<bool>(E->getADLCallKind()) &&
974-
E->getStmtClass() == Stmt::CallExprClass)
974+
!E->usesMemberSyntax() && E->getStmtClass() == Stmt::CallExprClass)
975975
AbbrevToUse = Writer.getCallExprAbbrev();
976976

977977
Code = serialization::EXPR_CALL;

clang/test/Modules/pr118137.cppm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-module-interface -o %t/a.pcm
6+
// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
7+
// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-llvm -o -
8+
9+
//--- a.h
10+
typedef int nghttp2_session_callbacks;
11+
12+
//--- a.cppm
13+
module;
14+
#include "a.h"
15+
export module g;
16+
template <typename, typename T>
17+
concept Deleter = requires(T ptr) { ptr; };
18+
template <typename T, Deleter<T>> struct Handle {
19+
void GetRaw(this auto);
20+
};
21+
struct SessionCallbacksDeleter
22+
: Handle<nghttp2_session_callbacks, SessionCallbacksDeleter> {
23+
} Server_callbacks;
24+
void Server() { Server_callbacks.GetRaw(); }

clang/unittests/Format/QualifierFixerTest.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,14 +1122,17 @@ TEST_F(QualifierFixerTest, IsQualifierType) {
11221122
}
11231123

11241124
TEST_F(QualifierFixerTest, IsMacro) {
1125-
11261125
auto Tokens = annotate("INT INTPR Foo int");
11271126
ASSERT_EQ(Tokens.size(), 5u) << Tokens;
1128-
11291127
EXPECT_TRUE(isPossibleMacro(Tokens[0]));
11301128
EXPECT_TRUE(isPossibleMacro(Tokens[1]));
11311129
EXPECT_FALSE(isPossibleMacro(Tokens[2]));
11321130
EXPECT_FALSE(isPossibleMacro(Tokens[3]));
1131+
1132+
Tokens = annotate("FOO::BAR");
1133+
ASSERT_EQ(Tokens.size(), 4u) << Tokens;
1134+
EXPECT_FALSE(isPossibleMacro(Tokens[0]));
1135+
EXPECT_FALSE(isPossibleMacro(Tokens[2]));
11331136
}
11341137

11351138
TEST_F(QualifierFixerTest, OverlappingQualifier) {

compiler-rt/lib/msan/msan.cpp

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,23 +352,69 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
352352

353353
using namespace __msan;
354354

355-
#define MSAN_MAYBE_WARNING(type, size) \
356-
void __msan_maybe_warning_##size(type s, u32 o) { \
357-
GET_CALLER_PC_BP; \
358-
if (UNLIKELY(s)) { \
359-
PrintWarningWithOrigin(pc, bp, o); \
360-
if (__msan::flags()->halt_on_error) { \
361-
Printf("Exiting\n"); \
362-
Die(); \
363-
} \
364-
} \
355+
// N.B. Only [shadow, shadow+size) is defined. shadow is *not* a pointer into
356+
// an MSan shadow region.
357+
static void print_shadow_value(void *shadow, u64 size) {
358+
Printf("Shadow value (%llu byte%s):", size, size == 1 ? "" : "s");
359+
for (unsigned int i = 0; i < size; i++) {
360+
if (i % 4 == 0)
361+
Printf(" ");
362+
363+
unsigned char x = ((unsigned char *)shadow)[i];
364+
Printf("%x%x", x >> 4, x & 0xf);
365+
}
366+
Printf("\n");
367+
Printf(
368+
"Caveat: the shadow value does not necessarily directly correspond to a "
369+
"single user variable. The correspondence is stronger, but not always "
370+
"perfect, when origin tracking is enabled.\n");
371+
Printf("\n");
372+
}
373+
374+
#define MSAN_MAYBE_WARNING(type, size) \
375+
void __msan_maybe_warning_##size(type s, u32 o) { \
376+
GET_CALLER_PC_BP; \
377+
\
378+
if (UNLIKELY(s)) { \
379+
if (Verbosity() >= 1) \
380+
print_shadow_value((void *)(&s), sizeof(s)); \
381+
PrintWarningWithOrigin(pc, bp, o); \
382+
if (__msan::flags()->halt_on_error) { \
383+
Printf("Exiting\n"); \
384+
Die(); \
385+
} \
386+
} \
365387
}
366388

367389
MSAN_MAYBE_WARNING(u8, 1)
368390
MSAN_MAYBE_WARNING(u16, 2)
369391
MSAN_MAYBE_WARNING(u32, 4)
370392
MSAN_MAYBE_WARNING(u64, 8)
371393

394+
// N.B. Only [shadow, shadow+size) is defined. shadow is *not* a pointer into
395+
// an MSan shadow region.
396+
void __msan_maybe_warning_N(void *shadow, u64 size, u32 o) {
397+
GET_CALLER_PC_BP;
398+
399+
bool allZero = true;
400+
for (unsigned int i = 0; i < size; i++) {
401+
if (((char *)shadow)[i]) {
402+
allZero = false;
403+
break;
404+
}
405+
}
406+
407+
if (UNLIKELY(!allZero)) {
408+
if (Verbosity() >= 1)
409+
print_shadow_value(shadow, size);
410+
PrintWarningWithOrigin(pc, bp, o);
411+
if (__msan::flags()->halt_on_error) {
412+
Printf("Exiting\n");
413+
Die();
414+
}
415+
}
416+
}
417+
372418
#define MSAN_MAYBE_STORE_ORIGIN(type, size) \
373419
void __msan_maybe_store_origin_##size(type s, void *p, u32 o) { \
374420
if (UNLIKELY(s)) { \

0 commit comments

Comments
 (0)