Skip to content

Commit a29011f

Browse files
author
git apple-llvm automerger
committed
Merge commit '00454a17f361' from llvm.org/main into experimental/cas/main
2 parents ece3376 + 00454a1 commit a29011f

File tree

63 files changed

+2747
-1415
lines changed

Some content is hidden

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

63 files changed

+2747
-1415
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
447447
};
448448
llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
449449

450-
/// For module code-gen cases, this is the top-level (C++20) Named module
451-
/// we are building.
452-
Module *TopLevelCXXNamedModule = nullptr;
450+
/// This is the top-level (C++20) Named module we are building.
451+
Module *CurrentCXXNamedModule = nullptr;
453452

454453
/// The include tree that is being built, if any.
455454
/// See \c FrontendOptions::CASIncludeTreeID.
@@ -1060,10 +1059,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
10601059
ArrayRef<Decl*> getModuleInitializers(Module *M);
10611060

10621061
/// Set the (C++20) module we are building.
1063-
void setNamedModuleForCodeGen(Module *M) { TopLevelCXXNamedModule = M; }
1062+
void setCurrentNamedModule(Module *M);
10641063

10651064
/// Get module under construction, nullptr if this is not a C++20 module.
1066-
Module *getNamedModuleForCodeGen() const { return TopLevelCXXNamedModule; }
1065+
Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
10671066

10681067
std::optional<std::string> getCASIncludeTreeID() const {
10691068
return CASIncludeTreeID;

clang/include/clang/AST/DeclBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,9 @@ class alignas(8) Decl {
644644
return getModuleOwnershipKind() > ModuleOwnershipKind::VisibleWhenImported;
645645
}
646646

647+
/// Whether this declaration comes from another module unit.
648+
bool isInCurrentModuleUnit() const;
649+
647650
/// FIXME: Implement discarding declarations actually in global module
648651
/// fragment. See [module.global.frag]p3,4 for details.
649652
bool isDiscardedInGlobalModuleFragment() const { return false; }

clang/include/clang/Basic/BuiltinsPPC.def

Lines changed: 825 additions & 632 deletions
Large diffs are not rendered by default.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10052,12 +10052,6 @@ def err_mips_builtin_requires_dspr2 : Error<
1005210052
"this builtin requires 'dsp r2' ASE, please use -mdspr2">;
1005310053
def err_mips_builtin_requires_msa : Error<
1005410054
"this builtin requires 'msa' ASE, please use -mmsa">;
10055-
def err_ppc_builtin_only_on_arch : Error<
10056-
"this builtin is only valid on POWER%0 or later CPUs">;
10057-
def err_ppc_builtin_requires_vsx : Error<
10058-
"this builtin requires VSX to be enabled">;
10059-
def err_ppc_builtin_requires_htm : Error<
10060-
"this builtin requires HTM to be enabled">;
1006110055
def err_ppc_builtin_requires_abi : Error<
1006210056
"this builtin requires ABI -mabi=%0">;
1006310057
def err_ppc_invalid_use_mma_type : Error<

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,9 +2358,6 @@ class Sema final {
23582358
return Entity->getOwningModule();
23592359
}
23602360

2361-
// Determine whether the module M belongs to the current TU.
2362-
bool isModuleUnitOfCurrentTU(const Module *M) const;
2363-
23642361
/// Make a merged definition of an existing hidden definition \p ND
23652362
/// visible at the specified location.
23662363
void makeMergedDefinitionVisible(NamedDecl *ND);

clang/lib/AST/ASTContext.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@ ArrayRef<Decl *> ASTContext::getModuleInitializers(Module *M) {
11531153
return Inits->Initializers;
11541154
}
11551155

1156+
void ASTContext::setCurrentNamedModule(Module *M) {
1157+
assert(M->isModulePurview());
1158+
assert(!CurrentCXXNamedModule &&
1159+
"We should set named module for ASTContext for only once");
1160+
CurrentCXXNamedModule = M;
1161+
}
1162+
11561163
ExternCContextDecl *ASTContext::getExternCContextDecl() const {
11571164
if (!ExternCContext)
11581165
ExternCContext = ExternCContextDecl::Create(*this, getTranslationUnitDecl());

clang/lib/AST/DeclBase.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "clang/Basic/IdentifierTable.h"
3131
#include "clang/Basic/LLVM.h"
3232
#include "clang/Basic/LangOptions.h"
33+
#include "clang/Basic/Module.h"
3334
#include "clang/Basic/ObjCRuntime.h"
3435
#include "clang/Basic/PartialDiagnostic.h"
3536
#include "clang/Basic/SourceLocation.h"
@@ -1022,6 +1023,26 @@ bool Decl::isInExportDeclContext() const {
10221023
return DC && isa<ExportDecl>(DC);
10231024
}
10241025

1026+
bool Decl::isInCurrentModuleUnit() const {
1027+
auto *M = getOwningModule();
1028+
1029+
if (!M)
1030+
return true;
1031+
1032+
M = M->getTopLevelModule();
1033+
// FIXME: It is problematic if the header module lives in another module
1034+
// unit. Consider to fix this by techniques like
1035+
// ExternalASTSource::hasExternalDefinitions.
1036+
if (M->isHeaderLikeModule())
1037+
return true;
1038+
1039+
if (M->isGlobalModule())
1040+
return true;
1041+
1042+
assert(M->isModulePurview() && "New module kind?");
1043+
return M == getASTContext().getCurrentNamedModule();
1044+
}
1045+
10251046
static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
10261047
static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
10271048

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ using namespace clang::targets;
2121
static constexpr Builtin::Info BuiltinInfo[] = {
2222
#define BUILTIN(ID, TYPE, ATTRS) \
2323
{#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
24+
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
25+
{#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
2426
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
2527
{#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
2628
#include "clang/Basic/BuiltinsPPC.def"

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16548,7 +16548,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
1654816548
// use custom code generation to expand a builtin call with a pointer to a
1654916549
// load (if the corresponding instruction accumulates its result) followed by
1655016550
// the call to the intrinsic and a store of the result.
16551-
#define CUSTOM_BUILTIN(Name, Intr, Types, Accumulate) \
16551+
#define CUSTOM_BUILTIN(Name, Intr, Types, Accumulate, Feature) \
1655216552
case PPC::BI__builtin_##Name:
1655316553
#include "clang/Basic/BuiltinsPPC.def"
1655416554
{
@@ -16598,7 +16598,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
1659816598
}
1659916599
bool Accumulate;
1660016600
switch (BuiltinID) {
16601-
#define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \
16601+
#define CUSTOM_BUILTIN(Name, Intr, Types, Acc, Feature) \
1660216602
case PPC::BI__builtin_##Name: \
1660316603
ID = Intrinsic::ppc_##Intr; \
1660416604
Accumulate = Acc; \

clang/lib/CodeGen/CGDeclCXX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,12 +883,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
883883
// with priority emitted above. Module implementation units behave the same
884884
// way as a non-modular TU with imports.
885885
llvm::Function *Fn;
886-
if (CXX20ModuleInits && getContext().getNamedModuleForCodeGen() &&
887-
!getContext().getNamedModuleForCodeGen()->isModuleImplementation()) {
886+
if (CXX20ModuleInits && getContext().getCurrentNamedModule() &&
887+
!getContext().getCurrentNamedModule()->isModuleImplementation()) {
888888
SmallString<256> InitFnName;
889889
llvm::raw_svector_ostream Out(InitFnName);
890890
cast<ItaniumMangleContext>(getCXXABI().getMangleContext())
891-
.mangleModuleInitializer(getContext().getNamedModuleForCodeGen(), Out);
891+
.mangleModuleInitializer(getContext().getCurrentNamedModule(), Out);
892892
Fn = CreateGlobalInitOrCleanUpFunction(
893893
FTy, llvm::Twine(InitFnName), FI, SourceLocation(), false,
894894
llvm::GlobalVariable::ExternalLinkage);

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static void setVisibilityFromDLLStorageClass(const clang::LangOptions &LO,
529529
}
530530

531531
void CodeGenModule::Release() {
532-
Module *Primary = getContext().getNamedModuleForCodeGen();
532+
Module *Primary = getContext().getCurrentNamedModule();
533533
if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
534534
EmitModuleInitializers(Primary);
535535
EmitDeferred();

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
879879

880880
Module *M = HeaderInfo.lookupModule(AST->getLangOpts().CurrentModule);
881881
if (M && AST->getLangOpts().isCompilingModule() && M->isModulePurview())
882-
AST->Ctx->setNamedModuleForCodeGen(M);
882+
AST->Ctx->setCurrentNamedModule(M);
883883

884884
// Create an AST consumer, even though it isn't used.
885885
if (ToLoad >= LoadASTOnly)

0 commit comments

Comments
 (0)