Skip to content

Commit f298a8c

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: Iee9a5c4965f1c29ba2e4d794131de3e32bbc10c4
2 parents 21f3543 + 591fc4f commit f298a8c

File tree

58 files changed

+1380
-1328
lines changed

Some content is hidden

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

58 files changed

+1380
-1328
lines changed

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,11 @@ void DIEBuilder::buildCompileUnits(const bool Init) {
266266
}
267267
void DIEBuilder::buildCompileUnits(const std::vector<DWARFUnit *> &CUs) {
268268
BuilderState.reset(new State());
269-
// Initializing to full size because there could be cross CU references with
270-
// different abbrev offsets. LLVM happens to output CUs that have cross CU
271-
// references with the same abbrev table. So destinations end up in the first
272-
// set, even if they themselves don't have src cross cu ref. We could have
273-
// cases where this is not the case. In which case this container needs to be
274-
// big enough for all.
275-
getState().CloneUnitCtxMap.resize(DwarfContext->getNumCompileUnits());
269+
// Allocating enough for current batch being processed.
270+
// In real use cases we either processing a batch of CUs with no cross
271+
// references, or if they do have them it is due to LTO. With clang they will
272+
// share the same abbrev table. In either case this vector will not grow.
273+
getState().CloneUnitCtxMap.resize(CUs.size());
276274
getState().Type = ProcessingType::CUs;
277275
for (DWARFUnit *CU : CUs)
278276
registerUnit(*CU, false);
@@ -897,6 +895,10 @@ void DIEBuilder::registerUnit(DWARFUnit &DU, bool NeedSort) {
897895
});
898896
}
899897
getState().UnitIDMap[getHash(DU)] = getState().DUList.size();
898+
// This handles the case where we do have cross cu references, but CUs do not
899+
// share the same abbrev table.
900+
if (getState().DUList.size() == getState().CloneUnitCtxMap.size())
901+
getState().CloneUnitCtxMap.emplace_back();
900902
getState().DUList.push_back(&DU);
901903
}
902904

clang/include/clang/Serialization/ASTReader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,8 @@ class BitsUnpacker {
24222422
CurrentBitsIndex = 0;
24232423
}
24242424

2425+
void advance(uint32_t BitsWidth) { CurrentBitsIndex += BitsWidth; }
2426+
24252427
bool getNextBit() {
24262428
assert(isValid());
24272429
return Value & (1 << CurrentBitsIndex++);

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,25 @@ class ASTWriter : public ASTDeserializationListener,
564564
unsigned DeclEnumAbbrev = 0;
565565
unsigned DeclObjCIvarAbbrev = 0;
566566
unsigned DeclCXXMethodAbbrev = 0;
567+
unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;
568+
unsigned DeclTemplateCXXMethodAbbrev = 0;
569+
unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;
570+
unsigned DeclTemplateSpecializedCXXMethodAbbrev = 0;
571+
unsigned DeclDependentSpecializationCXXMethodAbbrev = 0;
572+
unsigned DeclTemplateTypeParmAbbrev = 0;
573+
unsigned DeclUsingShadowAbbrev = 0;
567574

568575
unsigned DeclRefExprAbbrev = 0;
569576
unsigned CharacterLiteralAbbrev = 0;
570577
unsigned IntegerLiteralAbbrev = 0;
571578
unsigned ExprImplicitCastAbbrev = 0;
579+
unsigned BinaryOperatorAbbrev = 0;
580+
unsigned CompoundAssignOperatorAbbrev = 0;
581+
unsigned CallExprAbbrev = 0;
582+
unsigned CXXOperatorCallExprAbbrev = 0;
583+
unsigned CXXMemberCallExprAbbrev = 0;
584+
585+
unsigned CompoundStmtAbbrev = 0;
572586

573587
void WriteDeclAbbrevs();
574588
void WriteDecl(ASTContext &Context, Decl *D);
@@ -735,12 +749,41 @@ class ASTWriter : public ASTDeserializationListener,
735749
unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; }
736750
unsigned getDeclEnumAbbrev() const { return DeclEnumAbbrev; }
737751
unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; }
738-
unsigned getDeclCXXMethodAbbrev() const { return DeclCXXMethodAbbrev; }
752+
unsigned getDeclCXXMethodAbbrev(FunctionDecl::TemplatedKind Kind) const {
753+
switch (Kind) {
754+
case FunctionDecl::TK_NonTemplate:
755+
return DeclCXXMethodAbbrev;
756+
case FunctionDecl::TK_FunctionTemplate:
757+
return DeclTemplateCXXMethodAbbrev;
758+
case FunctionDecl::TK_MemberSpecialization:
759+
return DeclMemberSpecializedCXXMethodAbbrev;
760+
case FunctionDecl::TK_FunctionTemplateSpecialization:
761+
return DeclTemplateSpecializedCXXMethodAbbrev;
762+
case FunctionDecl::TK_DependentNonTemplate:
763+
return DeclDependentNonTemplateCXXMethodAbbrev;
764+
case FunctionDecl::TK_DependentFunctionTemplateSpecialization:
765+
return DeclDependentSpecializationCXXMethodAbbrev;
766+
}
767+
llvm_unreachable("Unknwon Template Kind!");
768+
}
769+
unsigned getDeclTemplateTypeParmAbbrev() const {
770+
return DeclTemplateTypeParmAbbrev;
771+
}
772+
unsigned getDeclUsingShadowAbbrev() const { return DeclUsingShadowAbbrev; }
739773

740774
unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; }
741775
unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; }
742776
unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; }
743777
unsigned getExprImplicitCastAbbrev() const { return ExprImplicitCastAbbrev; }
778+
unsigned getBinaryOperatorAbbrev() const { return BinaryOperatorAbbrev; }
779+
unsigned getCompoundAssignOperatorAbbrev() const {
780+
return CompoundAssignOperatorAbbrev;
781+
}
782+
unsigned getCallExprAbbrev() const { return CallExprAbbrev; }
783+
unsigned getCXXOperatorCallExprAbbrev() { return CXXOperatorCallExprAbbrev; }
784+
unsigned getCXXMemberCallExprAbbrev() { return CXXMemberCallExprAbbrev; }
785+
786+
unsigned getCompoundStmtAbbrev() const { return CompoundStmtAbbrev; }
744787

745788
bool hasChain() const { return Chain; }
746789
ASTReader *getChain() const { return Chain; }
@@ -841,46 +884,33 @@ class BitsPacker {
841884
BitsPacker(BitsPacker &&) = delete;
842885
BitsPacker operator=(const BitsPacker &) = delete;
843886
BitsPacker operator=(BitsPacker &&) = delete;
844-
~BitsPacker() {
845-
assert(!hasUnconsumedValues() && "There are unprocessed bits!");
887+
~BitsPacker() = default;
888+
889+
bool canWriteNextNBits(uint32_t BitsWidth) const {
890+
return CurrentBitIndex + BitsWidth < BitIndexUpbound;
891+
}
892+
893+
void reset(uint32_t Value) {
894+
UnderlyingValue = Value;
895+
CurrentBitIndex = 0;
846896
}
847897

848898
void addBit(bool Value) { addBits(Value, 1); }
849899
void addBits(uint32_t Value, uint32_t BitsWidth) {
850900
assert(BitsWidth < BitIndexUpbound);
851901
assert((Value < (1u << BitsWidth)) && "Passing narrower bit width!");
902+
assert(canWriteNextNBits(BitsWidth) &&
903+
"Inserting too much bits into a value!");
852904

853-
if (CurrentBitIndex + BitsWidth >= BitIndexUpbound) {
854-
Values.push_back(0);
855-
CurrentBitIndex = 0;
856-
}
857-
858-
assert(CurrentBitIndex < BitIndexUpbound);
859-
Values.back() |= Value << CurrentBitIndex;
905+
UnderlyingValue |= Value << CurrentBitIndex;
860906
CurrentBitIndex += BitsWidth;
861907
}
862908

863-
bool hasUnconsumedValues() const {
864-
return ConsumingValueIndex < Values.size();
865-
}
866-
uint32_t getNextValue() {
867-
assert(hasUnconsumedValues());
868-
return Values[ConsumingValueIndex++];
869-
}
870-
871-
// We can convert the packer to an uint32_t if there is only one values.
872-
operator uint32_t() {
873-
assert(Values.size() == 1);
874-
return getNextValue();
875-
}
909+
operator uint32_t() { return UnderlyingValue; }
876910

877911
private:
878-
SmallVector<uint64_t, 4> Values;
879-
uint16_t ConsumingValueIndex = 0;
880-
// Initialize CurrentBitIndex with an invalid value
881-
// to make it easier to update Values. See the implementation
882-
// of `addBits` to see the details.
883-
uint16_t CurrentBitIndex = BitIndexUpbound;
912+
uint32_t UnderlyingValue = 0;
913+
uint32_t CurrentBitIndex = 0;
884914
};
885915

886916
} // namespace clang

clang/lib/AST/ASTImporter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3418,10 +3418,16 @@ static bool isAncestorDeclContextOf(const DeclContext *DC, const Stmt *S) {
34183418
while (!ToProcess.empty()) {
34193419
const Stmt *CurrentS = ToProcess.pop_back_val();
34203420
ToProcess.append(CurrentS->child_begin(), CurrentS->child_end());
3421-
if (const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS))
3421+
if (const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
34223422
if (const Decl *D = DeclRef->getDecl())
34233423
if (isAncestorDeclContextOf(DC, D))
34243424
return true;
3425+
} else if (const auto *E =
3426+
dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3427+
if (const Decl *D = E->getAssociatedDecl())
3428+
if (isAncestorDeclContextOf(DC, D))
3429+
return true;
3430+
}
34253431
}
34263432
return false;
34273433
}

clang/lib/AST/Decl.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,7 +2943,7 @@ bool ParmVarDecl::isDestroyedInCallee() const {
29432943

29442944
// FIXME: isParamDestroyedInCallee() should probably imply
29452945
// isDestructedType()
2946-
auto *RT = getType()->getAs<RecordType>();
2946+
const auto *RT = getType()->getAs<RecordType>();
29472947
if (RT && RT->getDecl()->isParamDestroyedInCallee() &&
29482948
getType().isDestructedType())
29492949
return true;
@@ -3105,7 +3105,7 @@ FunctionDecl::getDefaultedFunctionInfo() const {
31053105
}
31063106

31073107
bool FunctionDecl::hasBody(const FunctionDecl *&Definition) const {
3108-
for (auto *I : redecls()) {
3108+
for (const auto *I : redecls()) {
31093109
if (I->doesThisDeclarationHaveABody()) {
31103110
Definition = I;
31113111
return true;
@@ -3116,7 +3116,7 @@ bool FunctionDecl::hasBody(const FunctionDecl *&Definition) const {
31163116
}
31173117

31183118
bool FunctionDecl::hasTrivialBody() const {
3119-
Stmt *S = getBody();
3119+
const Stmt *S = getBody();
31203120
if (!S) {
31213121
// Since we don't have a body for this function, we don't know if it's
31223122
// trivial or not.
@@ -3212,7 +3212,7 @@ void FunctionDecl::setPure(bool P) {
32123212

32133213
template<std::size_t Len>
32143214
static bool isNamed(const NamedDecl *ND, const char (&Str)[Len]) {
3215-
IdentifierInfo *II = ND->getIdentifier();
3215+
const IdentifierInfo *II = ND->getIdentifier();
32163216
return II && II->isStr(Str);
32173217
}
32183218

@@ -3305,9 +3305,9 @@ bool FunctionDecl::isReservedGlobalPlacementOperator() const {
33053305
if (proto->getNumParams() != 2 || proto->isVariadic())
33063306
return false;
33073307

3308-
ASTContext &Context =
3309-
cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext())
3310-
->getASTContext();
3308+
const ASTContext &Context =
3309+
cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext())
3310+
->getASTContext();
33113311

33123312
// The result type and first argument type are constant across all
33133313
// these operators. The second argument must be exactly void*.
@@ -3342,7 +3342,7 @@ bool FunctionDecl::isReplaceableGlobalAllocationFunction(
33423342

33433343
unsigned Params = 1;
33443344
QualType Ty = FPT->getParamType(Params);
3345-
ASTContext &Ctx = getASTContext();
3345+
const ASTContext &Ctx = getASTContext();
33463346

33473347
auto Consume = [&] {
33483348
++Params;
@@ -3388,7 +3388,8 @@ bool FunctionDecl::isReplaceableGlobalAllocationFunction(
33883388
QualType T = Ty;
33893389
while (const auto *TD = T->getAs<TypedefType>())
33903390
T = TD->getDecl()->getUnderlyingType();
3391-
IdentifierInfo *II = T->castAs<EnumType>()->getDecl()->getIdentifier();
3391+
const IdentifierInfo *II =
3392+
T->castAs<EnumType>()->getDecl()->getIdentifier();
33923393
if (II && II->isStr("__hot_cold_t"))
33933394
Consume();
33943395
}
@@ -3586,7 +3587,7 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const {
35863587
(!hasAttr<ArmBuiltinAliasAttr>() && !hasAttr<BuiltinAliasAttr>()))
35873588
return 0;
35883589

3589-
ASTContext &Context = getASTContext();
3590+
const ASTContext &Context = getASTContext();
35903591
if (!Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
35913592
return BuiltinID;
35923593

@@ -3745,7 +3746,7 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
37453746
assert(!doesThisDeclarationHaveABody() &&
37463747
"Must have a declaration without a body.");
37473748

3748-
ASTContext &Context = getASTContext();
3749+
const ASTContext &Context = getASTContext();
37493750

37503751
if (Context.getLangOpts().MSVCCompat) {
37513752
const FunctionDecl *Definition;

clang/lib/Headers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ set(webassembly_files
139139

140140
set(x86_files
141141
# Intrinsics
142+
adcintrin.h
142143
adxintrin.h
143144
ammintrin.h
144145
amxcomplexintrin.h

0 commit comments

Comments
 (0)