Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: Ib3dfb7f526cd627eb88e9111f1989d4fb378f40f
  • Loading branch information
Jenkins committed Apr 10, 2024
2 parents 49a669a + 299b636 commit 96548f6
Show file tree
Hide file tree
Showing 87 changed files with 4,970 additions and 492 deletions.
5 changes: 4 additions & 1 deletion clang/lib/Basic/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,10 +1542,13 @@ WindowsARM64TargetInfo::getBuiltinVaListKind() const {
TargetInfo::CallingConvCheckResult
WindowsARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
switch (CC) {
case CC_X86VectorCall:
if (getTriple().isWindowsArm64EC())
return CCCR_OK;
return CCCR_Ignore;
case CC_X86StdCall:
case CC_X86ThisCall:
case CC_X86FastCall:
case CC_X86VectorCall:
return CCCR_Ignore;
case CC_C:
case CC_OpenCLKernel:
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5605,6 +5605,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
/*AttrOnCallSite=*/true,
/*IsThunk=*/false);

if (CallingConv == llvm::CallingConv::X86_VectorCall &&
getTarget().getTriple().isWindowsArm64EC()) {
CGM.Error(Loc, "__vectorcall calling convention is not currently "
"supported");
}

if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl)) {
if (FD->hasAttr<StrictFPAttr>())
// All calls within a strictfp function are marked strictfp
Expand Down
8 changes: 8 additions & 0 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,14 @@ void CodeGenModule::SetLLVMFunctionAttributes(GlobalDecl GD,
llvm::AttributeList PAL;
ConstructAttributeList(F->getName(), Info, GD, PAL, CallingConv,
/*AttrOnCallSite=*/false, IsThunk);
if (CallingConv == llvm::CallingConv::X86_VectorCall &&
getTarget().getTriple().isWindowsArm64EC()) {
SourceLocation Loc;
if (const Decl *D = GD.getDecl())
Loc = D->getLocation();

Error(Loc, "__vectorcall calling convention is not currently supported");
}
F->setAttributes(PAL);
F->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
}
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/CodeGen/Targets/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2106,8 +2106,11 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
postMerge(Size, Lo, Hi);
return;
}

bool IsInMemory =
Offset % getContext().getTypeAlign(i->getType().getCanonicalType());
// Note, skip this test for bit-fields, see below.
if (!BitField && Offset % getContext().getTypeAlign(i->getType())) {
if (!BitField && IsInMemory) {
Lo = Memory;
postMerge(Size, Lo, Hi);
return;
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,8 @@ class AnnotatingParser {
// Line.MightBeFunctionDecl can only be true after the parentheses of a
// function declaration have been found. In this case, 'Current' is a
// trailing token of this declaration and thus cannot be a name.
if (Current.is(Keywords.kw_instanceof)) {
if ((Style.isJavaScript() || Style.Language == FormatStyle::LK_Java) &&
Current.is(Keywords.kw_instanceof)) {
Current.setType(TT_BinaryOperator);
} else if (isStartOfName(Current) &&
(!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) {
Expand Down
20 changes: 10 additions & 10 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,6 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
if (Style.Language == FormatStyle::LK_Proto) {
ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
} else {
// Skip NextTok over preprocessor lines, otherwise we may not
// properly diagnose the block as a braced intializer
// if the comma separator appears after the pp directive.
while (NextTok->is(tok::hash)) {
ScopedMacroState MacroState(*Line, Tokens, NextTok);
do {
NextTok = Tokens->getNextToken();
} while (NextTok->isNot(tok::eof));
}

// Using OriginalColumn to distinguish between ObjC methods and
// binary operators is a bit hacky.
bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) &&
Expand Down Expand Up @@ -606,6 +596,16 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
NextTok = Tokens->getNextToken();
ProbablyBracedList = NextTok->isNot(tok::l_square);
}

// Cpp macro definition body that is a nonempty braced list or block:
if (IsCpp && Line->InMacroBody && PrevTok != FormatTok &&
!FormatTok->Previous && NextTok->is(tok::eof) &&
// A statement can end with only `;` (simple statement), a block
// closing brace (compound statement), or `:` (label statement).
// If PrevTok is a block opening brace, Tok ends an empty block.
!PrevTok->isOneOf(tok::semi, BK_Block, tok::colon)) {
ProbablyBracedList = true;
}
}
if (ProbablyBracedList) {
Tok->setBlockKind(BK_BracedInit);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/intrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <armintr.h>
#endif

#if defined(__aarch64__)
#if defined(__aarch64__) || defined(__arm64ec__)
#include <arm64intr.h>
#endif

Expand Down
34 changes: 22 additions & 12 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5895,7 +5895,8 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI
return false;

if (Self.RequireCompleteType(
KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
Rhs->getTypeLoc().getBeginLoc(), RhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
return false;

return BaseInterface->isSuperClassOf(DerivedInterface);
Expand All @@ -5918,8 +5919,9 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI
// If Base and Derived are class types and are different types
// (ignoring possible cv-qualifiers) then Derived shall be a
// complete type.
if (Self.RequireCompleteType(KeyLoc, RhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
if (Self.RequireCompleteType(
Rhs->getTypeLoc().getBeginLoc(), RhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
return false;

return cast<CXXRecordDecl>(rhsRecord->getDecl())
Expand Down Expand Up @@ -5971,7 +5973,8 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI
return LhsT->isVoidType();

// A function definition requires a complete, non-abstract return type.
if (!Self.isCompleteType(KeyLoc, RhsT) || Self.isAbstractType(KeyLoc, RhsT))
if (!Self.isCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT) ||
Self.isAbstractType(Rhs->getTypeLoc().getBeginLoc(), RhsT))
return false;

// Compute the result of add_rvalue_reference.
Expand Down Expand Up @@ -6021,12 +6024,14 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI
// For both, T and U shall be complete types, (possibly cv-qualified)
// void, or arrays of unknown bound.
if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() &&
Self.RequireCompleteType(KeyLoc, LhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
Self.RequireCompleteType(
Lhs->getTypeLoc().getBeginLoc(), LhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
return false;
if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() &&
Self.RequireCompleteType(KeyLoc, RhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
Self.RequireCompleteType(
Rhs->getTypeLoc().getBeginLoc(), RhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
return false;

// cv void is never assignable.
Expand Down Expand Up @@ -6081,12 +6086,17 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI
}
case BTT_IsLayoutCompatible: {
if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType())
Self.RequireCompleteType(KeyLoc, LhsT, diag::err_incomplete_type);
Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT,
diag::err_incomplete_type);
if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType())
Self.RequireCompleteType(KeyLoc, RhsT, diag::err_incomplete_type);
Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
diag::err_incomplete_type);

if (LhsT->isVariableArrayType() || RhsT->isVariableArrayType())
Self.Diag(KeyLoc, diag::err_vla_unsupported)
if (LhsT->isVariableArrayType())
Self.Diag(Lhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)
<< 1 << tok::kw___is_layout_compatible;
if (RhsT->isVariableArrayType())
Self.Diag(Rhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)
<< 1 << tok::kw___is_layout_compatible;
return Self.IsLayoutCompatible(LhsT, RhsT);
}
Expand Down
1 change: 1 addition & 0 deletions clang/test/APINotes/instancetype.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers -verify %s

@import InstancetypeModule;
Expand Down
18 changes: 18 additions & 0 deletions clang/test/CodeGen/X86/x86_64-arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,24 @@ typedef float t66 __attribute__((__vector_size__(128), __aligned__(128)));
void f66(t66 a0) {
}

typedef long long t67 __attribute__((aligned (4)));
struct s67 {
int a;
t67 b;
};
// CHECK-LABEL: define{{.*}} void @f67(ptr noundef byval(%struct.s67) align 8 %x)
void f67(struct s67 x) {
}

typedef double t68 __attribute__((aligned (4)));
struct s68 {
int a;
t68 b;
};
// CHECK-LABEL: define{{.*}} void @f68(ptr noundef byval(%struct.s68) align 8 %x)
void f68(struct s68 x) {
}

/// The synthesized __va_list_tag does not have file/line fields.
// CHECK: = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__va_list_tag",
// CHECK-NOT: file:
Expand Down
14 changes: 14 additions & 0 deletions clang/test/CodeGenCXX/arm64ec-vectorcall.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %clang_cc1 -triple arm64ec-windows-msvc -emit-llvm -o - %s -verify

// ARM64EC doesn't support generating __vectorcall calls... but __vectorcall
// function types need to be distinct from __cdecl function types to support
// compiling the STL. Make sure we only diagnose constructs that actually
// require generating code.
void __vectorcall f1();
void f2(void __vectorcall p()) {}
void f2(void p()) {}
void __vectorcall (*f3)();
void __vectorcall f4(); // expected-error {{__vectorcall}}
void __vectorcall f5() { // expected-error {{__vectorcall}}
f4(); // expected-error{{__vectorcall}}
}
1 change: 1 addition & 0 deletions clang/test/SemaCXX/type-traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,7 @@ void is_layout_compatible(int n)
// expected-error@-1 {{variable length arrays are not supported in '__is_layout_compatible'}}
static_assert(!__is_layout_compatible(int[n], int[n]));
// expected-error@-1 {{variable length arrays are not supported in '__is_layout_compatible'}}
// expected-error@-2 {{variable length arrays are not supported in '__is_layout_compatible'}}
static_assert(__is_layout_compatible(int&, int&));
static_assert(!__is_layout_compatible(int&, char&));
static_assert(__is_layout_compatible(void(int), void(int)));
Expand Down
9 changes: 8 additions & 1 deletion clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,13 @@ TEST_F(FormatTest, UnderstandsMacros) {
verifyFormat("MACRO(co_return##something)");

verifyFormat("#define A x:");

verifyFormat("#define Foo(Bar) {#Bar}", "#define Foo(Bar) \\\n"
" { \\\n"
" #Bar \\\n"
" }");
verifyFormat("#define Foo(Bar) {#Bar}", "#define Foo(Bar) \\\n"
" { #Bar }");
}

TEST_F(FormatTest, ShortBlocksInMacrosDontMergeWithCodeAfterMacro) {
Expand Down Expand Up @@ -11033,7 +11040,7 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
verifyFormat("some_templated_type<decltype([](int i) { return i; })>");

verifyFormat("#define FOO(typeName, realClass) \\\n"
" { #typeName, foo<FooType>(new foo<realClass>(#typeName)) }",
" {#typeName, foo<FooType>(new foo<realClass>(#typeName))}",
getLLVMStyleWithColumns(60));
}

Expand Down
25 changes: 21 additions & 4 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,10 @@ TEST_F(TokenAnnotatorTest, UnderstandsFunctionDeclarationNames) {
EXPECT_TOKEN(Tokens[3], tok::identifier, TT_Unknown);
EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_FunctionTypeLParen);

Tokens = annotate("void instanceof();");
ASSERT_EQ(Tokens.size(), 6u);
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);

Tokens = annotate("int iso_time(time_t);");
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
Expand Down Expand Up @@ -1933,14 +1937,20 @@ TEST_F(TokenAnnotatorTest, UnderstandHashInMacro) {
" #Bar \\\n"
" }");
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
EXPECT_BRACE_KIND(Tokens[6], BK_Block);
EXPECT_BRACE_KIND(Tokens[9], BK_Block);
EXPECT_BRACE_KIND(Tokens[6], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit);

Tokens = annotate("#define Foo(Bar) \\\n"
" { #Bar }");
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
EXPECT_BRACE_KIND(Tokens[6], BK_Block);
EXPECT_BRACE_KIND(Tokens[9], BK_Block);
EXPECT_BRACE_KIND(Tokens[6], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit);

Tokens = annotate("#define FOO(typeName, realClass) \\\n"
" {#typeName, foo<Foo>(new foo<realClass>(#typeName))}");
ASSERT_EQ(Tokens.size(), 29u) << Tokens;
EXPECT_BRACE_KIND(Tokens[8], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[27], BK_BracedInit);
}

TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacros) {
Expand Down Expand Up @@ -2822,6 +2832,13 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
EXPECT_BRACE_KIND(Tokens[0], BK_Block);
EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[21], BK_BracedInit);

Tokens =
annotate("#define SCOP_STAT(NAME, DESC) \\\n"
" {\"polly\", #NAME, \"Number of rejected regions: \" DESC}");
ASSERT_EQ(Tokens.size(), 18u) << Tokens;
EXPECT_BRACE_KIND(Tokens[8], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[16], BK_BracedInit);
}

TEST_F(TokenAnnotatorTest, StreamOperator) {
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <string>
#include <type_traits>

// Some environments, viz. glibc 2.17, allow the macro HUGE
// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/real.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <limits>
#include <string>

// Some environments, viz. glibc 2.17, allow the macro HUGE
// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

Expand Down
4 changes: 4 additions & 0 deletions flang/lib/Decimal/decimal-to-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include <cstring>
#include <utility>

// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

namespace Fortran::decimal {

template <int PREC, int LOG10RADIX>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/fold-implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <type_traits>
#include <variant>

// Some environments, viz. glibc 2.17, allow the macro HUGE
// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

Expand Down
1 change: 1 addition & 0 deletions libcxx/docs/Status/Cxx2cIssues.csv
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@
"`4054 <https://wg21.link/LWG4054>`__","Repeating a ``repeat_view`` should repeat the view","Tokyo March 2024","","","|ranges|"
"","","","","",""
"`3343 <https://wg21.link/LWG3343>`__","Ordering of calls to ``unlock()`` and ``notify_all()`` in Effects element of ``notify_all_at_thread_exit()`` should be reversed","Not Yet Adopted","|Complete|","16.0",""
"XXXX","","The sys_info range should be affected by save","Not Yet Adopted","|Complete|","19.0"
"","","","","",""
1 change: 1 addition & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ set(files
__chrono/parser_std_format_spec.h
__chrono/statically_widen.h
__chrono/steady_clock.h
__chrono/sys_info.h
__chrono/system_clock.h
__chrono/time_point.h
__chrono/time_zone.h
Expand Down
Loading

0 comments on commit 96548f6

Please sign in to comment.