Skip to content

Commit 003c324

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I3d49f7a5cf6be5332e53e1c5b2eb06b961c8d71e
2 parents ec10765 + d906ac5 commit 003c324

File tree

74 files changed

+1025
-537
lines changed

Some content is hidden

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

74 files changed

+1025
-537
lines changed

clang/include/clang/ASTMatchers/ASTMatchersMacros.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHERSMACROS_H
5050
#define LLVM_CLANG_ASTMATCHERS_ASTMATCHERSMACROS_H
5151

52+
#include "clang/Support/Compiler.h"
53+
5254
/// AST_MATCHER_FUNCTION(ReturnType, DefineMatcher) { ... }
5355
/// defines a zero parameter function named DefineMatcher() that returns a
5456
/// ReturnType object.
@@ -367,7 +369,7 @@
367369
static QualType (T::*value())() const { return &T::FunctionName; } \
368370
}; \
369371
} \
370-
extern const ::clang::ast_matchers::internal:: \
372+
CLANG_ABI extern const ::clang::ast_matchers::internal:: \
371373
TypeTraversePolymorphicMatcher< \
372374
QualType, \
373375
::clang::ast_matchers::internal::TypeMatcher##MatcherName##Getter, \
@@ -407,7 +409,7 @@
407409
static TypeLoc (T::*value())() const { return &T::FunctionName##Loc; } \
408410
}; \
409411
} \
410-
extern const ::clang::ast_matchers::internal:: \
412+
CLANG_ABI extern const ::clang::ast_matchers::internal:: \
411413
TypeTraversePolymorphicMatcher< \
412414
TypeLoc, \
413415
::clang::ast_matchers::internal:: \

clang/include/clang/Basic/TargetInfo.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ enum class FloatModeKind {
8787
struct TransferrableTargetInfo {
8888
unsigned char PointerWidth, PointerAlign;
8989
unsigned char BoolWidth, BoolAlign;
90+
unsigned char ShortWidth, ShortAlign;
9091
unsigned char IntWidth, IntAlign;
9192
unsigned char HalfWidth, HalfAlign;
9293
unsigned char BFloat16Width, BFloat16Align;
@@ -497,13 +498,10 @@ class TargetInfo : public TransferrableTargetInfo,
497498
unsigned getCharWidth() const { return 8; } // FIXME
498499
unsigned getCharAlign() const { return 8; } // FIXME
499500

500-
/// Return the size of 'signed short' and 'unsigned short' for this
501-
/// target, in bits.
502-
unsigned getShortWidth() const { return 16; } // FIXME
503-
504-
/// Return the alignment of 'signed short' and 'unsigned short' for
505-
/// this target.
506-
unsigned getShortAlign() const { return 16; } // FIXME
501+
/// getShortWidth/Align - Return the size of 'signed short' and
502+
/// 'unsigned short' for this target, in bits.
503+
unsigned getShortWidth() const { return ShortWidth; }
504+
unsigned getShortAlign() const { return ShortAlign; }
507505

508506
/// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
509507
/// this target, in bits.

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5738,9 +5738,17 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
57385738
// We should already have a pointer when we get here.
57395739
return this->delegate(SubExpr);
57405740
case UO_Deref: // *x
5741-
if (DiscardResult)
5741+
if (DiscardResult) {
5742+
// assert(false);
57425743
return this->discard(SubExpr);
5743-
return this->visit(SubExpr);
5744+
}
5745+
5746+
if (!this->visit(SubExpr))
5747+
return false;
5748+
if (classifyPrim(SubExpr) == PT_Ptr)
5749+
return this->emitNarrowPtr(E);
5750+
return true;
5751+
57445752
case UO_Not: // ~x
57455753
if (!T)
57465754
return this->emitError(E);
@@ -6089,7 +6097,8 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
60896097

60906098
if (VD->evaluateValue())
60916099
return revisit(VD);
6092-
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E), E);
6100+
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6101+
/*InitializerFailed=*/true, E);
60936102
}
60946103
}
60956104
} else {
@@ -6115,7 +6124,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
61156124
}
61166125

61176126
if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
6118-
return this->emitInvalidDeclRef(DRE, E);
6127+
return this->emitInvalidDeclRef(DRE, /*InitializerFailed=*/false, E);
61196128
return false;
61206129
}
61216130

clang/lib/AST/ByteCode/Interp.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,14 +1944,14 @@ inline bool CastMemberPtrPtr(InterpState &S, CodePtr OpPC) {
19441944

19451945
template <class T, ArithOp Op>
19461946
bool OffsetHelper(InterpState &S, CodePtr OpPC, const T &Offset,
1947-
const Pointer &Ptr) {
1947+
const Pointer &Ptr, bool IsPointerArith = false) {
19481948
// A zero offset does not change the pointer.
19491949
if (Offset.isZero()) {
19501950
S.Stk.push<Pointer>(Ptr);
19511951
return true;
19521952
}
19531953

1954-
if (!CheckNull(S, OpPC, Ptr, CSK_ArrayIndex)) {
1954+
if (IsPointerArith && !CheckNull(S, OpPC, Ptr, CSK_ArrayIndex)) {
19551955
// The CheckNull will have emitted a note already, but we only
19561956
// abort in C++, since this is fine in C.
19571957
if (S.getLangOpts().CPlusPlus)
@@ -2063,14 +2063,16 @@ bool AddOffset(InterpState &S, CodePtr OpPC) {
20632063
Pointer Ptr = S.Stk.pop<Pointer>();
20642064
if (Ptr.isBlockPointer())
20652065
Ptr = Ptr.expand();
2066-
return OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr);
2066+
return OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr,
2067+
/*IsPointerArith=*/true);
20672068
}
20682069

20692070
template <PrimType Name, class T = typename PrimConv<Name>::T>
20702071
bool SubOffset(InterpState &S, CodePtr OpPC) {
20712072
const T &Offset = S.Stk.pop<T>();
20722073
const Pointer &Ptr = S.Stk.pop<Pointer>();
2073-
return OffsetHelper<T, ArithOp::Sub>(S, OpPC, Offset, Ptr);
2074+
return OffsetHelper<T, ArithOp::Sub>(S, OpPC, Offset, Ptr,
2075+
/*IsPointerArith=*/true);
20742076
}
20752077

20762078
template <ArithOp Op>
@@ -2090,7 +2092,7 @@ static inline bool IncDecPtrHelper(InterpState &S, CodePtr OpPC,
20902092

20912093
// Now the current Ptr again and a constant 1.
20922094
OneT One = OneT::from(1);
2093-
if (!OffsetHelper<OneT, Op>(S, OpPC, One, P))
2095+
if (!OffsetHelper<OneT, Op>(S, OpPC, One, P, /*IsPointerArith=*/true))
20942096
return false;
20952097

20962098
// Store the new value.
@@ -2816,9 +2818,18 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
28162818
return false;
28172819
}
28182820

2819-
inline bool InvalidDeclRef(InterpState &S, CodePtr OpPC,
2820-
const DeclRefExpr *DR) {
2821+
inline bool InvalidDeclRef(InterpState &S, CodePtr OpPC, const DeclRefExpr *DR,
2822+
bool InitializerFailed) {
28212823
assert(DR);
2824+
2825+
if (InitializerFailed) {
2826+
const SourceInfo &Loc = S.Current->getSource(OpPC);
2827+
const auto *VD = cast<VarDecl>(DR->getDecl());
2828+
S.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << VD;
2829+
S.Note(VD->getLocation(), diag::note_declared_at);
2830+
return false;
2831+
}
2832+
28222833
return CheckDeclRef(S, OpPC, DR);
28232834
}
28242835

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,10 @@ static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC,
12531253
const InterpFrame *Frame,
12541254
const Function *Func,
12551255
const CallExpr *Call) {
1256+
if (!Call->getArg(0)->getType()->isIntegerType() ||
1257+
!Call->getArg(1)->getType()->isIntegerType())
1258+
return false;
1259+
12561260
PrimType ValT = *S.Ctx.classify(Call->getArg(0));
12571261
PrimType IndexT = *S.Ctx.classify(Call->getArg(1));
12581262
APSInt Val = peekToAPSInt(S.Stk, ValT,

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ def InvalidCast : Opcode {
769769
}
770770

771771
def InvalidDeclRef : Opcode {
772-
let Args = [ArgDeclRef];
772+
let Args = [ArgDeclRef, ArgBool];
773773
}
774774

775775
def SizelessVectorElementSize : Opcode;

clang/lib/AST/ByteCode/Pointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ std::optional<APValue> Pointer::toRValue(const Context &Ctx,
635635

636636
// Return the composite type.
637637
APValue Result;
638-
if (!Composite(getType(), *this, Result))
638+
if (!Composite(ResultType, *this, Result))
639639
return std::nullopt;
640640
return Result;
641641
}

clang/lib/Basic/TargetInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
7070
HasStrictFP = false;
7171
PointerWidth = PointerAlign = 32;
7272
BoolWidth = BoolAlign = 8;
73+
ShortWidth = ShortAlign = 16;
7374
IntWidth = IntAlign = 32;
7475
LongWidth = LongAlign = 32;
7576
LongLongWidth = LongLongAlign = 64;
@@ -437,6 +438,7 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
437438
// what these normally are for the target.
438439
// We also define long long and long double here, although the
439440
// OpenCL standard only mentions these as "reserved".
441+
ShortWidth = ShortAlign = 16;
440442
IntWidth = IntAlign = 32;
441443
LongWidth = LongAlign = 64;
442444
LongLongWidth = LongLongAlign = 128;

clang/lib/Basic/Targets/AVR.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo {
2929
TLSSupported = false;
3030
PointerWidth = 16;
3131
PointerAlign = 8;
32+
ShortWidth = 16;
33+
ShortAlign = 8;
3234
IntWidth = 16;
3335
IntAlign = 8;
3436
LongWidth = 32;
@@ -65,6 +67,8 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo {
6567
return std::nullopt;
6668
}
6769

70+
bool allowsLargerPreferedTypeAlignment() const override { return false; }
71+
6872
BuiltinVaListKind getBuiltinVaListKind() const override {
6973
return TargetInfo::VoidPtrBuiltinVaList;
7074
}

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,19 +2904,18 @@ void CodeGenFunction::EmitMultiVersionResolver(
29042904
}
29052905
}
29062906

2907-
static int getPriorityFromAttrString(StringRef AttrStr) {
2907+
static unsigned getPriorityFromAttrString(StringRef AttrStr) {
29082908
SmallVector<StringRef, 8> Attrs;
29092909

29102910
AttrStr.split(Attrs, ';');
29112911

29122912
// Default Priority is zero.
2913-
int Priority = 0;
2913+
unsigned Priority = 0;
29142914
for (auto Attr : Attrs) {
29152915
if (Attr.consume_front("priority=")) {
2916-
int Result;
2917-
if (!Attr.getAsInteger(0, Result)) {
2916+
unsigned Result;
2917+
if (!Attr.getAsInteger(0, Result))
29182918
Priority = Result;
2919-
}
29202919
}
29212920
}
29222921

0 commit comments

Comments
 (0)