Skip to content

Commit f9eab42

Browse files

File tree

98 files changed

+3162
-388
lines changed

Some content is hidden

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

98 files changed

+3162
-388
lines changed

.github/workflows/release-binaries.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ jobs:
132132
arches=arm64
133133
else
134134
arches=x86_64
135-
# Disable Flang builds on macOS x86_64. The FortranLower library takes
136-
# 2-3 hours to build on macOS, much slower than on Linux.
137-
# The long build time causes the release build to time out on x86_64,
138-
# so we need to disable flang there.
139-
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS='clang;lld;lldb;clang-tools-extra;polly;mlir'"
140135
fi
141136
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
142137
fi

clang/cmake/caches/Release.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@ endfunction()
3030
#
3131
# cmake -D LLVM_RELEASE_ENABLE_PGO=ON -C Release.cmake
3232

33-
set (DEFAULT_PROJECTS "clang;lld;lldb;clang-tools-extra;polly;mlir;flang")
33+
set (DEFAULT_PROJECTS "clang;lld;lldb;clang-tools-extra;polly;mlir")
3434
# bolt only supports ELF, so only enable it for Linux.
3535
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
3636
list(APPEND DEFAULT_PROJECTS "bolt")
3737
endif()
3838

39+
# Don't build flang on Darwin due to:
40+
# https://github.com/llvm/llvm-project/issues/160546
41+
if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
42+
list(APPEND DEFAULT_PROJECTS "flang")
43+
endif()
44+
3945
set (DEFAULT_RUNTIMES "compiler-rt;libcxx")
4046
if (NOT WIN32)
4147
list(APPEND DEFAULT_RUNTIMES "libcxxabi" "libunwind")

clang/include/clang/Basic/BuiltinsARM.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ BUILTIN(__builtin_arm_cls, "UiZUi", "nc")
125125
BUILTIN(__builtin_arm_cls64, "UiWUi", "nc")
126126

127127
// Store and load exclusive
128-
BUILTIN(__builtin_arm_ldrexd, "LLUiv*", "")
129-
BUILTIN(__builtin_arm_strexd, "iLLUiv*", "")
128+
BUILTIN(__builtin_arm_ldrexd, "v.", "t")
129+
BUILTIN(__builtin_arm_strexd, "i.", "t")
130130

131131
BUILTIN(__builtin_arm_ldrex, "v.", "t")
132132
BUILTIN(__builtin_arm_ldaex, "v.", "t")

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9401,7 +9401,7 @@ def err_atomic_exclusive_builtin_pointer_size : Error<
94019401
"%select{|,| or }7%select{|8}8"
94029402
" byte type (%0 invalid)">;
94039403
def err_atomic_exclusive_builtin_pointer_size_none : Error<
9404-
"load and store exclusive builtins are not available on this architecture">;
9404+
"%select{|eight-byte }0load and store exclusive builtins are not available on this architecture">;
94059405
def err_atomic_builtin_ext_int_size : Error<
94069406
"atomic memory operand must have a power-of-two size">;
94079407
def err_atomic_builtin_bit_int_prohibit : Error<

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4491,7 +4491,7 @@ def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group<f_Group>,
44914491
HelpText<"Do not process trigraph sequences">,
44924492
Visibility<[ClangOption, CC1Option]>;
44934493
def funique_source_file_names: Flag<["-"], "funique-source-file-names">, Group<f_Group>,
4494-
HelpText<"Allow the compiler to assume that each translation unit has a unique "
4494+
HelpText<"Allow the compiler to assume that each translation unit has a unique "
44954495
"source file identifier (see -funique-source-file-identifier) at link time">;
44964496
def fno_unique_source_file_names: Flag<["-"], "fno-unique-source-file-names">;
44974497
def unique_source_file_identifier_EQ: Joined<["-"], "funique-source-file-identifier=">, Group<f_Group>,
@@ -7359,7 +7359,7 @@ defm android_pad_segment : BooleanFFlag<"android-pad-segment">, Group<f_Group>;
73597359
def shared_libflangrt : Flag<["-"], "shared-libflangrt">,
73607360
HelpText<"Link the flang-rt shared library">, Group<Link_Group>,
73617361
Visibility<[FlangOption]>, Flags<[NoArgumentUnused]>;
7362-
def static_libflangrt : Flag<["-"], "static-libflangrt">,
7362+
def static_libflangrt : Flag<["-"], "static-libflangrt">,
73637363
HelpText<"Link the flang-rt static library">, Group<Link_Group>,
73647364
Visibility<[FlangOption]>, Flags<[NoArgumentUnused]>;
73657365

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ bool CheckFinalLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
870870
return true;
871871
}
872872

873-
bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
873+
bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
874+
bool WillBeActivated) {
874875
if (!Ptr.isBlockPointer() || Ptr.isZero())
875876
return false;
876877

@@ -885,7 +886,7 @@ bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
885886
return false;
886887
if (!CheckRange(S, OpPC, Ptr, AK_Assign))
887888
return false;
888-
if (!CheckActive(S, OpPC, Ptr, AK_Assign))
889+
if (!WillBeActivated && !CheckActive(S, OpPC, Ptr, AK_Assign))
889890
return false;
890891
if (!CheckGlobal(S, OpPC, Ptr))
891892
return false;
@@ -932,14 +933,23 @@ static bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
932933
if (F->isValid() && F->hasBody() && F->isConstexpr())
933934
return true;
934935

936+
const FunctionDecl *DiagDecl = F->getDecl();
937+
const FunctionDecl *Definition = nullptr;
938+
DiagDecl->getBody(Definition);
939+
940+
if (!Definition && S.checkingPotentialConstantExpression() &&
941+
DiagDecl->isConstexpr()) {
942+
return false;
943+
}
944+
935945
// Implicitly constexpr.
936946
if (F->isLambdaStaticInvoker())
937947
return true;
938948

939949
// Bail out if the function declaration itself is invalid. We will
940950
// have produced a relevant diagnostic while parsing it, so just
941951
// note the problematic sub-expression.
942-
if (F->getDecl()->isInvalidDecl())
952+
if (DiagDecl->isInvalidDecl())
943953
return Invalid(S, OpPC);
944954

945955
// Diagnose failed assertions specially.
@@ -957,64 +967,61 @@ static bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
957967
}
958968
}
959969

960-
if (S.getLangOpts().CPlusPlus11) {
961-
const FunctionDecl *DiagDecl = F->getDecl();
962-
963-
// Invalid decls have been diagnosed before.
964-
if (DiagDecl->isInvalidDecl())
965-
return false;
970+
if (!S.getLangOpts().CPlusPlus11) {
971+
S.FFDiag(S.Current->getLocation(OpPC),
972+
diag::note_invalid_subexpr_in_const_expr);
973+
return false;
974+
}
966975

967-
// If this function is not constexpr because it is an inherited
968-
// non-constexpr constructor, diagnose that directly.
969-
const auto *CD = dyn_cast<CXXConstructorDecl>(DiagDecl);
970-
if (CD && CD->isInheritingConstructor()) {
971-
const auto *Inherited = CD->getInheritedConstructor().getConstructor();
972-
if (!Inherited->isConstexpr())
973-
DiagDecl = CD = Inherited;
974-
}
976+
// Invalid decls have been diagnosed before.
977+
if (DiagDecl->isInvalidDecl())
978+
return false;
975979

976-
// Silently reject constructors of invalid classes. The invalid class
977-
// has been rejected elsewhere before.
978-
if (CD && CD->getParent()->isInvalidDecl())
979-
return false;
980+
// If this function is not constexpr because it is an inherited
981+
// non-constexpr constructor, diagnose that directly.
982+
const auto *CD = dyn_cast<CXXConstructorDecl>(DiagDecl);
983+
if (CD && CD->isInheritingConstructor()) {
984+
const auto *Inherited = CD->getInheritedConstructor().getConstructor();
985+
if (!Inherited->isConstexpr())
986+
DiagDecl = CD = Inherited;
987+
}
980988

981-
// FIXME: If DiagDecl is an implicitly-declared special member function
982-
// or an inheriting constructor, we should be much more explicit about why
983-
// it's not constexpr.
984-
if (CD && CD->isInheritingConstructor()) {
985-
S.FFDiag(S.Current->getLocation(OpPC),
986-
diag::note_constexpr_invalid_inhctor, 1)
987-
<< CD->getInheritedConstructor().getConstructor()->getParent();
988-
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
989-
} else {
990-
// Don't emit anything if the function isn't defined and we're checking
991-
// for a constant expression. It might be defined at the point we're
992-
// actually calling it.
993-
bool IsExtern = DiagDecl->getStorageClass() == SC_Extern;
994-
bool IsDefined = F->isDefined();
995-
if (!IsDefined && !IsExtern && DiagDecl->isConstexpr() &&
996-
S.checkingPotentialConstantExpression())
997-
return false;
989+
// Silently reject constructors of invalid classes. The invalid class
990+
// has been rejected elsewhere before.
991+
if (CD && CD->getParent()->isInvalidDecl())
992+
return false;
998993

999-
// If the declaration is defined, declared 'constexpr' _and_ has a body,
1000-
// the below diagnostic doesn't add anything useful.
1001-
if (DiagDecl->isDefined() && DiagDecl->isConstexpr() &&
1002-
DiagDecl->hasBody())
1003-
return false;
994+
// FIXME: If DiagDecl is an implicitly-declared special member function
995+
// or an inheriting constructor, we should be much more explicit about why
996+
// it's not constexpr.
997+
if (CD && CD->isInheritingConstructor()) {
998+
S.FFDiag(S.Current->getLocation(OpPC), diag::note_constexpr_invalid_inhctor,
999+
1)
1000+
<< CD->getInheritedConstructor().getConstructor()->getParent();
1001+
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
1002+
} else {
1003+
// Don't emit anything if the function isn't defined and we're checking
1004+
// for a constant expression. It might be defined at the point we're
1005+
// actually calling it.
1006+
bool IsExtern = DiagDecl->getStorageClass() == SC_Extern;
1007+
bool IsDefined = F->isDefined();
1008+
if (!IsDefined && !IsExtern && DiagDecl->isConstexpr() &&
1009+
S.checkingPotentialConstantExpression())
1010+
return false;
10041011

1005-
S.FFDiag(S.Current->getLocation(OpPC),
1006-
diag::note_constexpr_invalid_function, 1)
1007-
<< DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
1012+
// If the declaration is defined, declared 'constexpr' _and_ has a body,
1013+
// the below diagnostic doesn't add anything useful.
1014+
if (DiagDecl->isDefined() && DiagDecl->isConstexpr() && DiagDecl->hasBody())
1015+
return false;
10081016

1009-
if (DiagDecl->getDefinition())
1010-
S.Note(DiagDecl->getDefinition()->getLocation(),
1011-
diag::note_declared_at);
1012-
else
1013-
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
1014-
}
1015-
} else {
10161017
S.FFDiag(S.Current->getLocation(OpPC),
1017-
diag::note_invalid_subexpr_in_const_expr);
1018+
diag::note_constexpr_invalid_function, 1)
1019+
<< DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
1020+
1021+
if (DiagDecl->getDefinition())
1022+
S.Note(DiagDecl->getDefinition()->getLocation(), diag::note_declared_at);
1023+
else
1024+
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
10181025
}
10191026

10201027
return false;

clang/lib/AST/ByteCode/Interp.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ bool CheckGlobalLoad(InterpState &S, CodePtr OpPC, const Block *B);
7575
bool CheckLocalLoad(InterpState &S, CodePtr OpPC, const Block *B);
7676

7777
/// Checks if a value can be stored in a block.
78-
bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr);
78+
bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
79+
bool WillBeActivated = false);
7980

8081
/// Checks if a value can be initialized.
8182
bool CheckInit(InterpState &S, CodePtr OpPC, const Pointer &Ptr);
@@ -1977,13 +1978,12 @@ bool StoreActivate(InterpState &S, CodePtr OpPC) {
19771978
const T &Value = S.Stk.pop<T>();
19781979
const Pointer &Ptr = S.Stk.peek<Pointer>();
19791980

1981+
if (!CheckStore(S, OpPC, Ptr, /*WilLBeActivated=*/true))
1982+
return false;
19801983
if (Ptr.canBeInitialized()) {
19811984
Ptr.initialize();
19821985
Ptr.activate();
19831986
}
1984-
1985-
if (!CheckStore(S, OpPC, Ptr))
1986-
return false;
19871987
Ptr.deref<T>() = Value;
19881988
return true;
19891989
}
@@ -1993,12 +1993,12 @@ bool StoreActivatePop(InterpState &S, CodePtr OpPC) {
19931993
const T &Value = S.Stk.pop<T>();
19941994
const Pointer &Ptr = S.Stk.pop<Pointer>();
19951995

1996+
if (!CheckStore(S, OpPC, Ptr, /*WilLBeActivated=*/true))
1997+
return false;
19961998
if (Ptr.canBeInitialized()) {
19971999
Ptr.initialize();
19982000
Ptr.activate();
19992001
}
2000-
if (!CheckStore(S, OpPC, Ptr))
2001-
return false;
20022002
Ptr.deref<T>() = Value;
20032003
return true;
20042004
}
@@ -2007,7 +2007,8 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
20072007
bool StoreBitField(InterpState &S, CodePtr OpPC) {
20082008
const T &Value = S.Stk.pop<T>();
20092009
const Pointer &Ptr = S.Stk.peek<Pointer>();
2010-
if (!CheckStore(S, OpPC, Ptr))
2010+
2011+
if (!CheckStore(S, OpPC, Ptr, /*WilLBeActivated=*/true))
20112012
return false;
20122013
if (Ptr.canBeInitialized())
20132014
Ptr.initialize();
@@ -2037,12 +2038,13 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
20372038
bool StoreBitFieldActivate(InterpState &S, CodePtr OpPC) {
20382039
const T &Value = S.Stk.pop<T>();
20392040
const Pointer &Ptr = S.Stk.peek<Pointer>();
2041+
2042+
if (!CheckStore(S, OpPC, Ptr, /*WilLBeActivated=*/true))
2043+
return false;
20402044
if (Ptr.canBeInitialized()) {
20412045
Ptr.initialize();
20422046
Ptr.activate();
20432047
}
2044-
if (!CheckStore(S, OpPC, Ptr))
2045-
return false;
20462048
if (const auto *FD = Ptr.getField())
20472049
Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue());
20482050
else
@@ -2055,12 +2057,12 @@ bool StoreBitFieldActivatePop(InterpState &S, CodePtr OpPC) {
20552057
const T &Value = S.Stk.pop<T>();
20562058
const Pointer &Ptr = S.Stk.pop<Pointer>();
20572059

2060+
if (!CheckStore(S, OpPC, Ptr, /*WillBeActivated=*/true))
2061+
return false;
20582062
if (Ptr.canBeInitialized()) {
20592063
Ptr.initialize();
20602064
Ptr.activate();
20612065
}
2062-
if (!CheckStore(S, OpPC, Ptr))
2063-
return false;
20642066
if (const auto *FD = Ptr.getField())
20652067
Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue());
20662068
else
@@ -2281,7 +2283,7 @@ std::optional<Pointer> OffsetHelper(InterpState &S, CodePtr OpPC,
22812283
}
22822284
}
22832285

2284-
if (Invalid && S.getLangOpts().CPlusPlus)
2286+
if (Invalid && (S.getLangOpts().CPlusPlus || Ptr.inArray()))
22852287
return std::nullopt;
22862288

22872289
// Offset is valid - compute it on unsigned.

clang/lib/Sema/SemaARM.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,18 +850,23 @@ bool SemaARM::CheckARMBuiltinExclusiveCall(const TargetInfo &TI,
850850
unsigned BuiltinID,
851851
CallExpr *TheCall) {
852852
assert((BuiltinID == ARM::BI__builtin_arm_ldrex ||
853+
BuiltinID == ARM::BI__builtin_arm_ldrexd ||
853854
BuiltinID == ARM::BI__builtin_arm_ldaex ||
854855
BuiltinID == ARM::BI__builtin_arm_strex ||
856+
BuiltinID == ARM::BI__builtin_arm_strexd ||
855857
BuiltinID == ARM::BI__builtin_arm_stlex ||
856858
BuiltinID == AArch64::BI__builtin_arm_ldrex ||
857859
BuiltinID == AArch64::BI__builtin_arm_ldaex ||
858860
BuiltinID == AArch64::BI__builtin_arm_strex ||
859861
BuiltinID == AArch64::BI__builtin_arm_stlex) &&
860862
"unexpected ARM builtin");
861863
bool IsLdrex = BuiltinID == ARM::BI__builtin_arm_ldrex ||
864+
BuiltinID == ARM::BI__builtin_arm_ldrexd ||
862865
BuiltinID == ARM::BI__builtin_arm_ldaex ||
863866
BuiltinID == AArch64::BI__builtin_arm_ldrex ||
864867
BuiltinID == AArch64::BI__builtin_arm_ldaex;
868+
bool IsDoubleWord = BuiltinID == ARM::BI__builtin_arm_ldrexd ||
869+
BuiltinID == ARM::BI__builtin_arm_strexd;
865870

866871
ASTContext &Context = getASTContext();
867872
DeclRefExpr *DRE =
@@ -928,6 +933,11 @@ bool SemaARM::CheckARMBuiltinExclusiveCall(const TargetInfo &TI,
928933
if (!TI.getTriple().isAArch64()) {
929934
unsigned Mask = TI.getARMLDREXMask();
930935
unsigned Bits = Context.getTypeSize(ValType);
936+
if (IsDoubleWord) {
937+
// Explicit request for ldrexd/strexd means only double word sizes
938+
// supported if the target supports them.
939+
Mask &= TargetInfo::ARM_LDREX_D;
940+
}
931941
bool Supported =
932942
(llvm::isPowerOf2_64(Bits)) && Bits >= 8 && (Mask & (Bits / 8));
933943

@@ -968,8 +978,11 @@ bool SemaARM::CheckARMBuiltinExclusiveCall(const TargetInfo &TI,
968978
}
969979
}
970980
} else {
981+
bool EmitDoubleWordDiagnostic =
982+
IsDoubleWord && !Mask && TI.getARMLDREXMask();
971983
Diag(DRE->getBeginLoc(),
972984
diag::err_atomic_exclusive_builtin_pointer_size_none)
985+
<< (EmitDoubleWordDiagnostic ? 1 : 0)
973986
<< PointerArg->getSourceRange();
974987
}
975988
}
@@ -1013,8 +1026,10 @@ bool SemaARM::CheckARMBuiltinFunctionCall(const TargetInfo &TI,
10131026
unsigned BuiltinID,
10141027
CallExpr *TheCall) {
10151028
if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
1029+
BuiltinID == ARM::BI__builtin_arm_ldrexd ||
10161030
BuiltinID == ARM::BI__builtin_arm_ldaex ||
10171031
BuiltinID == ARM::BI__builtin_arm_strex ||
1032+
BuiltinID == ARM::BI__builtin_arm_strexd ||
10181033
BuiltinID == ARM::BI__builtin_arm_stlex) {
10191034
return CheckARMBuiltinExclusiveCall(TI, BuiltinID, TheCall);
10201035
}

clang/test/AST/ByteCode/c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,9 @@ static char foo_(a) // all-warning {{definition without a prototype}}
381381
static void bar_(void) {
382382
foo_(foo_(1));
383383
}
384+
385+
void foo2(void*);
386+
void bar2(void) {
387+
int a[2][3][4][5]; // all-note {{array 'a' declared here}}
388+
foo2(&a[0][4]); // all-warning {{array index 4 is past the end of the array}}
389+
}

0 commit comments

Comments
 (0)