Skip to content

Commit 2b66b56

Browse files
authored
Merge branch 'main' into x86-cmp-bigint-nosink
2 parents bd10f49 + d4e3a23 commit 2b66b56

File tree

93 files changed

+1318
-490
lines changed

Some content is hidden

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

93 files changed

+1318
-490
lines changed

.ci/generate_test_report_github.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import generate_test_report_lib
1010

11+
1112
def compute_platform_title() -> str:
1213
logo = ":window:" if platform.system() == "Windows" else ":penguin:"
1314
# On Linux the machine value is x86_64 on Windows it is AMD64.

.ci/generate_test_report_lib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def _format_ninja_failures(ninja_failures: list[tuple[str, str]]) -> list[str]:
100100
)
101101
return output
102102

103+
103104
def get_failures(junit_objects) -> dict[str, list[tuple[str, str]]]:
104105
failures = {}
105106
for results in junit_objects:

bolt/test/runtime/AArch64/inline-memcpy.s

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@
8181
# CHECK-ASM: bl{{.*}}<memcpy
8282

8383
# Register move should NOT be inlined (size unknown at compile time)
84-
# CHECK-ASM-LABEL: <test_register_move_negative>:
84+
# CHECK-ASM-LABEL: <test_register_move_unknown>:
8585
# CHECK-ASM: bl{{.*}}<memcpy
8686

87-
# CHECK-ASM-LABEL: <test_x2_rewrite_negative>:
87+
# CHECK-ASM-LABEL: <test_x2_rewrite_unknown>:
8888
# CHECK-ASM: bl{{.*}}<memcpy
8989

9090
# Live-in parameter should NOT be inlined (size unknown at compile time)
91-
# CHECK-ASM-LABEL: <test_live_in_negative>:
91+
# CHECK-ASM-LABEL: <test_live_in_unknown>:
9292
# CHECK-ASM: bl{{.*}}<memcpy
9393

9494
# _memcpy8 should be inlined with end-pointer return (dest+size)
@@ -262,9 +262,9 @@ test_4_byte_add_immediate:
262262
ret
263263
.size test_4_byte_add_immediate, .-test_4_byte_add_immediate
264264

265-
.globl test_register_move_negative
266-
.type test_register_move_negative,@function
267-
test_register_move_negative:
265+
.globl test_register_move_unknown
266+
.type test_register_move_unknown,@function
267+
test_register_move_unknown:
268268
stp x29, x30, [sp, #-32]!
269269
mov x29, sp
270270
add x1, sp, #16
@@ -274,20 +274,20 @@ test_register_move_negative:
274274
bl memcpy
275275
ldp x29, x30, [sp], #32
276276
ret
277-
.size test_register_move_negative, .-test_register_move_negative
277+
.size test_register_move_unknown, .-test_register_move_unknown
278278

279-
.globl test_x2_rewrite_negative
280-
.type test_x2_rewrite_negative,@function
281-
test_x2_rewrite_negative:
279+
.globl test_x2_rewrite_unknown
280+
.type test_x2_rewrite_unknown,@function
281+
test_x2_rewrite_unknown:
282282
mov x2, #8
283283
ldr x2, [sp, #24]
284284
bl memcpy
285285
ret
286-
.size test_x2_rewrite_negative, .-test_x2_rewrite_negative
286+
.size test_x2_rewrite_unknown, .-test_x2_rewrite_unknown
287287

288-
.globl test_live_in_negative
289-
.type test_live_in_negative,@function
290-
test_live_in_negative:
288+
.globl test_live_in_unknown
289+
.type test_live_in_unknown,@function
290+
test_live_in_unknown:
291291
# x2 comes in as parameter, no instruction sets it (should NOT inline)
292292
stp x29, x30, [sp, #-32]!
293293
mov x29, sp
@@ -297,7 +297,7 @@ test_live_in_negative:
297297
bl memcpy
298298
ldp x29, x30, [sp], #32
299299
ret
300-
.size test_live_in_negative, .-test_live_in_negative
300+
.size test_live_in_unknown, .-test_live_in_unknown
301301

302302
.globl test_memcpy8_4_byte
303303
.type test_memcpy8_4_byte,@function

clang/include/clang/Basic/AttrDocs.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,9 +3450,9 @@ Mac, and BSD. This attribute has no effect on other targets.
34503450
def MSABIDocs : Documentation {
34513451
let Category = DocCatCallingConvs;
34523452
let Content = [{
3453-
On non-Windows x86_64 targets, this attribute changes the calling convention of
3454-
a function to match the default convention used on Windows x86_64. This
3455-
attribute has no effect on Windows targets or non-x86_64 targets.
3453+
On non-Windows x86_64 and aarch64 targets, this attribute changes the calling convention of
3454+
a function to match the default convention used on Windows. This
3455+
attribute has no effect on Windows targets or non-x86_64, non-aarch64 targets.
34563456
}];
34573457
}
34583458

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ BUILTIN(__builtin_amdgcn_raw_buffer_load_b128, "V4UiQbiiIi", "n")
180180
BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32, "iiQbiiIi", "")
181181

182182
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32, "ffQbiiIi", "", "atomic-fadd-rtn-insts")
183-
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16, "V2hV2hQbiiIi", "t", "atomic-buffer-global-pk-add-f16-insts")
183+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16, "V2hV2hQbiiIi", "", "atomic-buffer-global-pk-add-f16-insts")
184184

185185
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32, "ffQbiiIi", "", "atomic-fmin-fmax-global-f32")
186186
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32, "ffQbiiIi", "", "atomic-fmin-fmax-global-f32")

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11668,7 +11668,7 @@ class Sema final : public SemaBase {
1166811668
ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
1166911669

1167011670
DeclResult ActOnVarTemplateSpecialization(
11671-
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
11671+
Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous,
1167211672
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
1167311673
StorageClass SC, bool IsPartialSpecialization);
1167411674

clang/lib/AST/ASTContext.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,9 +3108,9 @@ TypeSourceInfo *ASTContext::CreateTypeSourceInfo(QualType T,
31083108

31093109
TypeSourceInfo *ASTContext::getTrivialTypeSourceInfo(QualType T,
31103110
SourceLocation L) const {
3111-
TypeSourceInfo *DI = CreateTypeSourceInfo(T);
3112-
DI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
3113-
return DI;
3111+
TypeSourceInfo *TSI = CreateTypeSourceInfo(T);
3112+
TSI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
3113+
return TSI;
31143114
}
31153115

31163116
const ASTRecordLayout &
@@ -5891,11 +5891,11 @@ TypeSourceInfo *ASTContext::getTemplateSpecializationTypeInfo(
58915891
QualType TST = getTemplateSpecializationType(
58925892
Keyword, Name, SpecifiedArgs.arguments(), CanonicalArgs, Underlying);
58935893

5894-
TypeSourceInfo *DI = CreateTypeSourceInfo(TST);
5895-
DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
5894+
TypeSourceInfo *TSI = CreateTypeSourceInfo(TST);
5895+
TSI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
58965896
ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
58975897
SpecifiedArgs);
5898-
return DI;
5898+
return TSI;
58995899
}
59005900

59015901
QualType ASTContext::getTemplateSpecializationType(

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ template <class Emitter> class LocOverrideScope final {
208208
} // namespace interp
209209
} // namespace clang
210210

211+
template <class Emitter>
212+
bool Compiler<Emitter>::isValidBitCast(const CastExpr *E) {
213+
QualType FromTy = E->getSubExpr()->getType()->getPointeeType();
214+
QualType ToTy = E->getType()->getPointeeType();
215+
216+
if (classify(FromTy) == classify(ToTy))
217+
return true;
218+
219+
if (FromTy->isVoidType() || ToTy->isVoidType())
220+
return true;
221+
return false;
222+
}
223+
211224
template <class Emitter>
212225
bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
213226
const Expr *SubExpr = CE->getSubExpr();
@@ -476,8 +489,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
476489
return this->delegate(SubExpr);
477490

478491
case CK_BitCast: {
492+
QualType CETy = CE->getType();
479493
// Reject bitcasts to atomic types.
480-
if (CE->getType()->isAtomicType()) {
494+
if (CETy->isAtomicType()) {
481495
if (!this->discard(SubExpr))
482496
return false;
483497
return this->emitInvalidCast(CastKind::Reinterpret, /*Fatal=*/true, CE);
@@ -492,6 +506,10 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
492506
if (!FromT || !ToT)
493507
return false;
494508

509+
if (!this->isValidBitCast(CE) &&
510+
!this->emitInvalidCast(CastKind::ReinterpretLike, /*Fatal=*/false, CE))
511+
return false;
512+
495513
assert(isPtrType(*FromT));
496514
assert(isPtrType(*ToT));
497515
if (FromT == ToT) {

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
425425

426426
bool refersToUnion(const Expr *E);
427427

428+
bool isValidBitCast(const CastExpr *E);
429+
428430
protected:
429431
/// Variable to storage mapping.
430432
llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;

clang/lib/AST/ByteCode/Interp.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,9 @@ bool Load(InterpState &S, CodePtr OpPC) {
19151915
return false;
19161916
if (!Ptr.isBlockPointer())
19171917
return false;
1918+
if (const Descriptor *D = Ptr.getFieldDesc();
1919+
!(D->isPrimitive() || D->isPrimitiveArray()) || D->getPrimType() != Name)
1920+
return false;
19181921
S.Stk.push<T>(Ptr.deref<T>());
19191922
return true;
19201923
}
@@ -1926,6 +1929,9 @@ bool LoadPop(InterpState &S, CodePtr OpPC) {
19261929
return false;
19271930
if (!Ptr.isBlockPointer())
19281931
return false;
1932+
if (const Descriptor *D = Ptr.getFieldDesc();
1933+
!(D->isPrimitive() || D->isPrimitiveArray()) || D->getPrimType() != Name)
1934+
return false;
19291935
S.Stk.push<T>(Ptr.deref<T>());
19301936
return true;
19311937
}
@@ -3288,12 +3294,18 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32883294
bool Fatal) {
32893295
const SourceLocation &Loc = S.Current->getLocation(OpPC);
32903296

3291-
if (Kind == CastKind::Reinterpret) {
3297+
switch (Kind) {
3298+
case CastKind::Reinterpret:
32923299
S.CCEDiag(Loc, diag::note_constexpr_invalid_cast)
3293-
<< static_cast<unsigned>(Kind) << S.Current->getRange(OpPC);
3300+
<< diag::ConstexprInvalidCastKind::Reinterpret
3301+
<< S.Current->getRange(OpPC);
32943302
return !Fatal;
3295-
}
3296-
if (Kind == CastKind::Volatile) {
3303+
case CastKind::ReinterpretLike:
3304+
S.CCEDiag(Loc, diag::note_constexpr_invalid_cast)
3305+
<< diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
3306+
<< S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
3307+
return !Fatal;
3308+
case CastKind::Volatile:
32973309
if (!S.checkingPotentialConstantExpression()) {
32983310
const auto *E = cast<CastExpr>(S.Current->getExpr(OpPC));
32993311
if (S.getLangOpts().CPlusPlus)
@@ -3304,14 +3316,13 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
33043316
}
33053317

33063318
return false;
3307-
}
3308-
if (Kind == CastKind::Dynamic) {
3319+
case CastKind::Dynamic:
33093320
assert(!S.getLangOpts().CPlusPlus20);
3310-
S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_cast)
3321+
S.CCEDiag(Loc, diag::note_constexpr_invalid_cast)
33113322
<< diag::ConstexprInvalidCastKind::Dynamic;
33123323
return true;
33133324
}
3314-
3325+
llvm_unreachable("Unhandled CastKind");
33153326
return false;
33163327
}
33173328

0 commit comments

Comments
 (0)