Skip to content

Commit ebb0695

Browse files
committed
Merge remote-tracking branch 'origin/main' into AMX-TRANSPOSE
2 parents 868a7bb + 1274bca commit ebb0695

File tree

82 files changed

+1959
-921
lines changed

Some content is hidden

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

82 files changed

+1959
-921
lines changed

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,12 @@ class BinaryContext {
13631363
if (std::optional<uint32_t> Size = MIB->getSize(Inst))
13641364
return *Size;
13651365

1366+
if (MIB->isPseudo(Inst))
1367+
return 0;
1368+
1369+
if (std::optional<uint32_t> Size = MIB->getInstructionSize(Inst))
1370+
return *Size;
1371+
13661372
if (!Emitter)
13671373
Emitter = this->MCE.get();
13681374
SmallString<256> Code;

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,11 @@ class MCPlusBuilder {
12041204
/// Get instruction size specified via annotation.
12051205
std::optional<uint32_t> getSize(const MCInst &Inst) const;
12061206

1207+
/// Get target-specific instruction size.
1208+
virtual std::optional<uint32_t> getInstructionSize(const MCInst &Inst) const {
1209+
return std::nullopt;
1210+
}
1211+
12071212
/// Set instruction size.
12081213
void setSize(MCInst &Inst, uint32_t Size) const;
12091214

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,11 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
17921792
}
17931793

17941794
uint16_t getMinFunctionAlignment() const override { return 4; }
1795+
1796+
std::optional<uint32_t>
1797+
getInstructionSize(const MCInst &Inst) const override {
1798+
return 4;
1799+
}
17951800
};
17961801

17971802
} // end anonymous namespace

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ C++23 Feature Support
316316
C++20 Feature Support
317317
^^^^^^^^^^^^^^^^^^^^^
318318

319+
- Implemented module level lookup for C++20 modules. (#GH90154)
320+
319321

320322
Resolutions to C++ Defect Reports
321323
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/DeclBase.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,10 @@ class alignas(8) Decl {
836836
return isFromASTFile() ? getImportedOwningModule() : getLocalOwningModule();
837837
}
838838

839+
/// Get the top level owning named module that owns this declaration if any.
840+
/// \returns nullptr if the declaration is not owned by a named module.
841+
Module *getTopLevelOwningNamedModule() const;
842+
839843
/// Get the module that owns this declaration for linkage purposes.
840844
/// There only ever is such a standard C++ module.
841845
Module *getOwningModuleForLinkage() const;
@@ -2722,6 +2726,9 @@ class DeclContext {
27222726
bool Deserialize = false) const;
27232727

27242728
private:
2729+
lookup_result lookupImpl(DeclarationName Name,
2730+
const DeclContext *OriginalLookupDC) const;
2731+
27252732
/// Whether this declaration context has had externally visible
27262733
/// storage added since the last lookup. In this case, \c LookupPtr's
27272734
/// invariant may not hold and needs to be fixed before we perform

clang/include/clang/AST/ExternalASTMerger.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ class ExternalASTMerger : public ExternalASTSource {
141141

142142
/// Implementation of the ExternalASTSource API.
143143
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
144-
DeclarationName Name) override;
144+
DeclarationName Name,
145+
const DeclContext *OriginalDC) override;
145146

146147
/// Implementation of the ExternalASTSource API.
147148
void

clang/include/clang/AST/ExternalASTSource.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,20 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
145145
/// Find all declarations with the given name in the given context,
146146
/// and add them to the context by calling SetExternalVisibleDeclsForName
147147
/// or SetNoExternalVisibleDeclsForName.
148+
/// \param DC The context for lookup in. \c DC should be a primary context.
149+
/// \param Name The name to look for.
150+
/// \param OriginalDC The original context for lookup. \c OriginalDC can
151+
/// provide more information than \c DC. e.g., The same namespace can appear
152+
/// in multiple module units. So we need the \c OriginalDC to tell us what
153+
/// the module the lookup come from.
154+
///
148155
/// \return \c true if any declarations might have been found, \c false if
149156
/// we definitely have no declarations with tbis name.
150157
///
151158
/// The default implementation of this method is a no-op returning \c false.
152-
virtual bool
153-
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
159+
virtual bool FindExternalVisibleDeclsByName(const DeclContext *DC,
160+
DeclarationName Name,
161+
const DeclContext *OriginalDC);
154162

155163
/// Load all the external specializations for the Decl \param D if \param
156164
/// OnlyPartial is false. Otherwise, load all the external **partial**

clang/include/clang/Sema/MultiplexExternalSemaSource.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
9595
/// Find all declarations with the given name in the
9696
/// given context.
9797
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
98-
DeclarationName Name) override;
98+
DeclarationName Name,
99+
const DeclContext *OriginalDC) override;
99100

100101
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override;
101102

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ enum ASTRecordTypes {
738738
CXX_ADDED_TEMPLATE_SPECIALIZATION = 74,
739739

740740
CXX_ADDED_TEMPLATE_PARTIAL_SPECIALIZATION = 75,
741+
742+
UPDATE_MODULE_LOCAL_VISIBLE = 76,
741743
};
742744

743745
/// Record types used within a source manager block.
@@ -1334,6 +1336,10 @@ enum DeclCode {
13341336
/// into a DeclContext via DeclContext::lookup.
13351337
DECL_CONTEXT_VISIBLE,
13361338

1339+
/// A record containing the set of declarations that are
1340+
/// only visible from DeclContext in the same module.
1341+
DECL_CONTEXT_MODULE_LOCAL_VISIBLE,
1342+
13371343
/// A LabelDecl record.
13381344
DECL_LABEL,
13391345

clang/include/clang/Serialization/ASTReader.h

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ class ASTIdentifierLookupTrait;
353353

354354
/// The on-disk hash table(s) used for DeclContext name lookup.
355355
struct DeclContextLookupTable;
356+
struct ModuleLocalLookupTable;
356357

357358
/// The on-disk hash table(s) used for specialization decls.
358359
struct LazySpecializationInfoLookupTable;
@@ -523,9 +524,14 @@ class ASTReader
523524
/// in the chain.
524525
DeclUpdateOffsetsMap DeclUpdateOffsets;
525526

527+
struct LookupBlockOffsets {
528+
uint64_t LexicalOffset;
529+
uint64_t VisibleOffset;
530+
uint64_t ModuleLocalOffset;
531+
};
532+
526533
using DelayedNamespaceOffsetMapTy =
527-
llvm::DenseMap<GlobalDeclID, std::pair</*LexicalOffset*/ uint64_t,
528-
/*VisibleOffset*/ uint64_t>>;
534+
llvm::DenseMap<GlobalDeclID, LookupBlockOffsets>;
529535

530536
/// Mapping from global declaration IDs to the lexical and visible block
531537
/// offset for delayed namespace in reduced BMI.
@@ -631,6 +637,9 @@ class ASTReader
631637
/// Map from a DeclContext to its lookup tables.
632638
llvm::DenseMap<const DeclContext *,
633639
serialization::reader::DeclContextLookupTable> Lookups;
640+
llvm::DenseMap<const DeclContext *,
641+
serialization::reader::ModuleLocalLookupTable>
642+
ModuleLocalLookups;
634643

635644
using SpecLookupTableTy =
636645
llvm::DenseMap<const Decl *,
@@ -659,6 +668,8 @@ class ASTReader
659668
/// Updates to the visible declarations of declaration contexts that
660669
/// haven't been loaded yet.
661670
llvm::DenseMap<GlobalDeclID, DeclContextVisibleUpdates> PendingVisibleUpdates;
671+
llvm::DenseMap<GlobalDeclID, DeclContextVisibleUpdates>
672+
PendingModuleLocalVisibleUpdates;
662673

663674
using SpecializationsUpdate = SmallVector<UpdateData, 1>;
664675
using SpecializationsUpdateMap =
@@ -696,7 +707,8 @@ class ASTReader
696707
/// Read the record that describes the visible contents of a DC.
697708
bool ReadVisibleDeclContextStorage(ModuleFile &M,
698709
llvm::BitstreamCursor &Cursor,
699-
uint64_t Offset, GlobalDeclID ID);
710+
uint64_t Offset, GlobalDeclID ID,
711+
bool IsModuleLocal);
700712

701713
bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor,
702714
uint64_t Offset, Decl *D, bool IsPartial);
@@ -1132,6 +1144,10 @@ class ASTReader
11321144
/// Number of visible decl contexts read/total.
11331145
unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
11341146

1147+
/// Number of module local visible decl contexts read/total.
1148+
unsigned NumModuleLocalVisibleDeclContexts = 0,
1149+
TotalModuleLocalVisibleDeclContexts = 0;
1150+
11351151
/// Total size of modules, in bits, currently loaded
11361152
uint64_t TotalModulesSizeInBits = 0;
11371153

@@ -1444,6 +1460,9 @@ class ASTReader
14441460
const serialization::reader::DeclContextLookupTable *
14451461
getLoadedLookupTables(DeclContext *Primary) const;
14461462

1463+
const serialization::reader::ModuleLocalLookupTable *
1464+
getModuleLocalLookupTables(DeclContext *Primary) const;
1465+
14471466
/// Get the loaded specializations lookup tables for \p D,
14481467
/// if any.
14491468
serialization::reader::LazySpecializationInfoLookupTable *
@@ -2119,7 +2138,8 @@ class ASTReader
21192138
/// The current implementation of this method just loads the entire
21202139
/// lookup table as unmaterialized references.
21212140
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
2122-
DeclarationName Name) override;
2141+
DeclarationName Name,
2142+
const DeclContext *OriginalDC) override;
21232143

21242144
/// Read all of the declarations lexically stored in a
21252145
/// declaration context.
@@ -2607,6 +2627,10 @@ inline bool shouldSkipCheckingODR(const Decl *D) {
26072627
(D->isFromGlobalModule() || D->isFromHeaderUnit());
26082628
}
26092629

2630+
/// Calculate a hash value for the primary module name of the given module.
2631+
/// \returns std::nullopt if M is not a C++ standard module.
2632+
std::optional<unsigned> getPrimaryModuleHash(const Module *M);
2633+
26102634
} // namespace clang
26112635

26122636
#endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H

0 commit comments

Comments
 (0)