https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/146104
>From 6e4090dd5e83d28ef3655e2b11746d0a6da0b8d0 Mon Sep 17 00:00:00 2001 From: Maksim Levental <maksim.leven...@gmail.com> Date: Fri, 27 Jun 2025 12:20:07 -0400 Subject: [PATCH 1/2] Add some basic extra support for C++ unity building (Unity building here called "jumbo" because it is called that in the context of the Chromium project.) This adds an example plugin named `JumboSupport` that adds a pragma named `jumbo`, which signals that the main source file is a jumbo compilation unit that will include other source files. After each include into the main source file, the contents of all anonymous namespace declarations in the included source file are hidden, so that the anonymous namespace remains local to source files. It also undefines all macros defined in the included source file. Some (intentionally) minimal changes to clang is implemented to make it possible to implement this functionality in the plugin. --- clang/examples/CMakeLists.txt | 1 + clang/examples/JumboSupport/CMakeLists.txt | 14 ++ clang/examples/JumboSupport/JumboSupport.cpp | 165 +++++++++++++++++++ clang/include/clang/AST/Decl.h | 7 + clang/lib/AST/ItaniumMangle.cpp | 16 ++ clang/lib/Sema/SemaLookup.cpp | 6 + 6 files changed, 209 insertions(+) create mode 100644 clang/examples/JumboSupport/CMakeLists.txt create mode 100644 clang/examples/JumboSupport/JumboSupport.cpp diff --git a/clang/examples/CMakeLists.txt b/clang/examples/CMakeLists.txt index 2396ecac16b2d..f46fe762a2d71 100644 --- a/clang/examples/CMakeLists.txt +++ b/clang/examples/CMakeLists.txt @@ -11,3 +11,4 @@ if(CLANG_PLUGIN_SUPPORT) add_subdirectory(CallSuperAttribute) add_subdirectory(PluginsOrder) endif() +add_subdirectory(JumboSupport) diff --git a/clang/examples/JumboSupport/CMakeLists.txt b/clang/examples/JumboSupport/CMakeLists.txt new file mode 100644 index 0000000000000..9630ec1eeeee1 --- /dev/null +++ b/clang/examples/JumboSupport/CMakeLists.txt @@ -0,0 +1,14 @@ +add_llvm_library(JumboSupport MODULE JumboSupport.cpp PLUGIN_TOOL clang) + +if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) + set(LLVM_LINK_COMPONENTS + Support + ) + clang_target_link_libraries(JumboSupport PRIVATE + clangAST + clangBasic + clangFrontend + clangLex + LLVMSupport + ) +endif() diff --git a/clang/examples/JumboSupport/JumboSupport.cpp b/clang/examples/JumboSupport/JumboSupport.cpp new file mode 100644 index 0000000000000..b0fbbbb4c83c2 --- /dev/null +++ b/clang/examples/JumboSupport/JumboSupport.cpp @@ -0,0 +1,165 @@ +//===- ResetAnonymousNamespace.cpp ----------------------------------------===// +// +// Clang plugin that adds +// +// #pragma reset_anonymous_namespace +// +// which resets the anonymous namespace, as if a new translation unit was being +// processed. +// +//===----------------------------------------------------------------------===// + +#include <set> +#include <string> + +#include "clang/AST/AST.h" +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Frontend/FrontendPluginRegistry.h" +#include "clang/Lex/LexDiagnostic.h" +#include "clang/Lex/Preprocessor.h" + +namespace { + +bool IsLocationInFile(clang::SourceManager &SM, clang::SourceLocation Loc, + const clang::FileEntry *File) { + clang::FileID FID = SM.getFileID(SM.getSpellingLoc(Loc)); + return FID.isValid() && SM.getFileEntryForID(FID) == File; +} + +class DisableTaggedNamespaceDecls + : public clang::RecursiveASTVisitor<DisableTaggedNamespaceDecls> { +private: + clang::SourceManager &SM; + const clang::FileEntry *File; + +public: + DisableTaggedNamespaceDecls(clang::SourceManager &SM, + const clang::FileEntry *File) + : SM(SM), File(File) {} + + bool VisitNamespaceDecl(clang::NamespaceDecl *NS) { + if (NS->isAnonymousNamespace()) + if (IsLocationInFile(SM, NS->getBeginLoc(), File)) + NS->setDisabled(); + return true; + } +}; + +class ASTConsumer : public clang::ASTConsumer { + clang::ASTContext *Context; + +public: + static ASTConsumer *Instance; + + ASTConsumer() { Instance = this; } + + void Initialize(clang::ASTContext &Ctx) override { Context = &Ctx; } + + clang::ASTContext *getASTContext() { return Context; } +}; + +ASTConsumer *ASTConsumer::Instance = nullptr; + +class PPCallbacks : public clang::PPCallbacks { + clang::Preprocessor &PP; + clang::SourceManager &SM; + + const clang::FileEntry *CurrentFile; + + std::set<std::string> DefinedMacros; + +public: + PPCallbacks(clang::Preprocessor &PP) : PP(PP), SM(PP.getSourceManager()) {} + + static void Register(clang::Preprocessor &PP) { + PP.addPPCallbacks(std::make_unique<PPCallbacks>(PP)); + } + + void + InclusionDirective(clang::SourceLocation HashLoc, + const clang::Token &IncludeTok, llvm::StringRef FileName, + bool IsAngled, clang::CharSourceRange FilenameRange, + clang::OptionalFileEntryRef File, + llvm::StringRef SearchPath, llvm::StringRef RelativePath, + const clang::Module *SuggestedModule, bool ModuleImported, + clang::SrcMgr::CharacteristicKind FileType) override { + if (SM.isInMainFile(HashLoc)) + CurrentFile = &File->getFileEntry(); + } + + void FileChanged(clang::SourceLocation Loc, FileChangeReason Reason, + clang::SrcMgr::CharacteristicKind, + clang::FileID PrevFID) override { + if (SM.isInMainFile(Loc)) { + auto Context = ASTConsumer::Instance->getASTContext(); + + DisableTaggedNamespaceDecls Visitor(SM, CurrentFile); + Visitor.TraverseDecl(Context->getTranslationUnitDecl()); + + llvm::BumpPtrAllocator &Allocator = PP.getPreprocessorAllocator(); + for (auto Name : DefinedMacros) { + clang::IdentifierInfo *II = PP.getIdentifierInfo(Name); + PP.appendMacroDirective(II, new (Allocator) + clang::UndefMacroDirective(Loc)); + } + + CurrentFile = nullptr; + DefinedMacros.clear(); + } + } + + void MacroDefined(const clang::Token &Name, + const clang::MacroDirective *MD) override { + if (CurrentFile && IsLocationInFile(SM, Name.getLocation(), CurrentFile)) + DefinedMacros.emplace(Name.getIdentifierInfo()->getName().str()); + } + + void MacroUndefined(const clang::Token &Name, + const clang::MacroDefinition &MD, + const clang::MacroDirective *Undef) override { + if (CurrentFile && IsLocationInFile(SM, Name.getLocation(), CurrentFile)) + DefinedMacros.erase(Name.getIdentifierInfo()->getName().str()); + } +}; + +class JumboFrontendAction : public clang::PluginASTAction { +public: + std::unique_ptr<clang::ASTConsumer> + CreateASTConsumer(clang::CompilerInstance &CI, llvm::StringRef) override { + return std::make_unique<ASTConsumer>(); + } + + bool ParseArgs(const clang::CompilerInstance &CI, + const std::vector<std::string> &args) override { + return true; + } +}; + +class PragmaJumbo : public clang::PragmaHandler { +public: + PragmaJumbo() : clang::PragmaHandler("jumbo") {} + + void HandlePragma(clang::Preprocessor &PP, clang::PragmaIntroducer Introducer, + clang::Token &PragmaTok) override { + clang::Token Tok; + PP.LexUnexpandedToken(Tok); + if (Tok.isNot(clang::tok::eod)) + PP.Diag(Tok, clang::diag::ext_pp_extra_tokens_at_eol) << "pragma unity"; + + if (!ASTConsumer::Instance) { + // Plugin not enabled. + return; + } + + PPCallbacks::Register(PP); + } +}; + +} // namespace + +static clang::FrontendPluginRegistry::Add<JumboFrontendAction> + X("jumbo-support", "jumbo compilation support tools"); + +static clang::PragmaHandlerRegistry::Add<PragmaJumbo> + P1("jumbo", "begin treating top-level includes as jumbo includes"); diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index c4202f1f3d07e..8aed80a5d3414 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -579,6 +579,10 @@ class NamespaceDecl : public NamedDecl, /// The unnamed namespace that inhabits this namespace, if any. NamespaceDecl *AnonymousNamespace = nullptr; + /// Names in this specific namespace declaration should not be included in + /// lookups. + bool IsDisabled = false; + NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested); @@ -681,6 +685,9 @@ class NamespaceDecl : public NamedDecl, static NamespaceDecl *castFromDeclContext(const DeclContext *DC) { return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC)); } + + bool isDisabled() const { return IsDisabled; } + void setDisabled() { IsDisabled = true; } }; class VarDecl; diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 84936b72bb4fa..17552c23d2948 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -24,6 +24,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprConcepts.h" +#include "clang/Basic/SourceManager.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/Mangle.h" #include "clang/AST/TypeLoc.h" @@ -1578,8 +1579,23 @@ void CXXNameMangler::mangleUnqualifiedName( if (const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) { if (NS->isAnonymousNamespace()) { +#if 0 // This is how gcc mangles these names. Out << "12_GLOBAL__N_1"; +#endif + +#if 1 + // Add a per-file unique key for the source file containing + // the declaration. + // FIXME: This should be controlled by a flag. + SourceManager &SM = Context.getASTContext().getSourceManager(); + SourceLocation Loc = SM.getSpellingLoc(NS->getBeginLoc()); + + std::string Name("__anonymous_"); + Name.append(std::to_string(SM.getFileID(Loc).getHashValue())); + + Out << Name.size() << Name; +#endif break; } } diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index aa7191d2814fe..09647c3f4ca32 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1137,6 +1137,12 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { // Perform lookup into this declaration context. DeclContext::lookup_result DR = DC->lookup(R.getLookupName()); for (NamedDecl *D : DR) { + DeclContext *DCtx = D->getDeclContext(); + if (EnumDecl *ED = dyn_cast<EnumDecl>(DCtx)) + DCtx = ED->getDeclContext(); + if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(DCtx)) + if (NS->isDisabled()) + continue; if ((D = R.getAcceptableDecl(D))) { R.addDecl(D); Found = true; >From ece06da1f617bdf3cb831c8a3a633f9e0f6f37ae Mon Sep 17 00:00:00 2001 From: Maksim Levental <maksim.leven...@gmail.com> Date: Fri, 27 Jun 2025 14:26:00 -0400 Subject: [PATCH 2/2] unit build cmakes --- clang/examples/JumboSupport/JumboSupport.cpp | 13 +++++++++---- llvm/CMakeLists.txt | 2 ++ llvm/lib/CMakeLists.txt | 3 +++ llvm/lib/Demangle/CMakeLists.txt | 2 ++ llvm/utils/TableGen/Basic/CMakeLists.txt | 2 ++ mlir/lib/Analysis/CMakeLists.txt | 1 + mlir/lib/Conversion/LLVMCommon/CMakeLists.txt | 2 ++ mlir/lib/Conversion/SCFToGPU/CMakeLists.txt | 2 ++ mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt | 1 + mlir/lib/Debug/CMakeLists.txt | 1 + mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt | 1 + mlir/lib/Dialect/Arith/Transforms/CMakeLists.txt | 1 + .../Dialect/Bufferization/Transforms/CMakeLists.txt | 2 ++ mlir/lib/Dialect/LLVMIR/CMakeLists.txt | 1 + mlir/lib/Dialect/Linalg/IR/CMakeLists.txt | 1 + mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt | 1 + mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt | 1 + mlir/lib/Dialect/Ptr/IR/CMakeLists.txt | 2 ++ mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt | 1 + mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt | 1 + .../Dialect/SparseTensor/Transforms/CMakeLists.txt | 1 + mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt | 1 + mlir/lib/Dialect/Vector/Transforms/CMakeLists.txt | 1 + mlir/lib/IR/CMakeLists.txt | 1 + mlir/lib/Support/CMakeLists.txt | 1 + mlir/lib/TableGen/CMakeLists.txt | 2 +- mlir/lib/Tools/PDLL/CodeGen/CMakeLists.txt | 1 + mlir/lib/Transforms/CMakeLists.txt | 2 ++ mlir/lib/Transforms/Utils/CMakeLists.txt | 2 ++ mlir/test/lib/Analysis/CMakeLists.txt | 3 +++ mlir/test/lib/Conversion/FuncToLLVM/CMakeLists.txt | 1 + mlir/test/lib/Dialect/Affine/CMakeLists.txt | 1 + mlir/test/lib/Dialect/Bufferization/CMakeLists.txt | 2 ++ mlir/test/lib/Dialect/Test/CMakeLists.txt | 1 + mlir/test/lib/Dialect/Transform/CMakeLists.txt | 2 ++ mlir/test/lib/IR/CMakeLists.txt | 1 + mlir/test/lib/Pass/CMakeLists.txt | 1 + mlir/test/lib/Transforms/CMakeLists.txt | 2 ++ mlir/tools/mlir-tblgen/CMakeLists.txt | 1 + 39 files changed, 63 insertions(+), 5 deletions(-) diff --git a/clang/examples/JumboSupport/JumboSupport.cpp b/clang/examples/JumboSupport/JumboSupport.cpp index b0fbbbb4c83c2..90d7b32a67562 100644 --- a/clang/examples/JumboSupport/JumboSupport.cpp +++ b/clang/examples/JumboSupport/JumboSupport.cpp @@ -61,7 +61,7 @@ class ASTConsumer : public clang::ASTConsumer { ASTConsumer *ASTConsumer::Instance = nullptr; -class PPCallbacks : public clang::PPCallbacks { +class UnityPPCallbacks : public clang::PPCallbacks { clang::Preprocessor &PP; clang::SourceManager &SM; @@ -70,10 +70,11 @@ class PPCallbacks : public clang::PPCallbacks { std::set<std::string> DefinedMacros; public: - PPCallbacks(clang::Preprocessor &PP) : PP(PP), SM(PP.getSourceManager()) {} + UnityPPCallbacks(clang::Preprocessor &PP) + : PP(PP), SM(PP.getSourceManager()) {} static void Register(clang::Preprocessor &PP) { - PP.addPPCallbacks(std::make_unique<PPCallbacks>(PP)); + PP.addPPCallbacks(std::make_unique<UnityPPCallbacks>(PP)); } void @@ -134,6 +135,10 @@ class JumboFrontendAction : public clang::PluginASTAction { const std::vector<std::string> &args) override { return true; } + + JumboFrontendAction::ActionType getActionType() override { + return AddBeforeMainAction; + } }; class PragmaJumbo : public clang::PragmaHandler { @@ -152,7 +157,7 @@ class PragmaJumbo : public clang::PragmaHandler { return; } - PPCallbacks::Register(PP); + UnityPPCallbacks::Register(PP); } }; diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 22877bf916abf..2af15853451ea 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1320,7 +1320,9 @@ add_subdirectory(lib/Demangle) add_subdirectory(lib/Support) add_subdirectory(lib/TableGen) +set(CMAKE_UNITY_BUILD_BATCH_SIZE 1) add_subdirectory(utils/TableGen) +set(CMAKE_UNITY_BUILD_BATCH_SIZE 0) add_subdirectory(include) diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index f6465612d30c0..22e4d46bd0d0b 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -1,5 +1,6 @@ include(LLVM-Build) +set(CMAKE_UNITY_BUILD_BATCH_SIZE 1) # `Demangle', `Support' and `TableGen' libraries are added on the top-level # CMakeLists.txt @@ -69,3 +70,5 @@ endif() # Component post-processing LLVMBuildResolveComponentsLink() LLVMBuildGenerateCFragment(OUTPUT ${LLVMCONFIGLIBRARYDEPENDENCIESINC}) + +set(CMAKE_UNITY_BUILD_BATCH_SIZE 0) diff --git a/llvm/lib/Demangle/CMakeLists.txt b/llvm/lib/Demangle/CMakeLists.txt index eb7d212a02449..1c66a1f05bade 100644 --- a/llvm/lib/Demangle/CMakeLists.txt +++ b/llvm/lib/Demangle/CMakeLists.txt @@ -10,3 +10,5 @@ add_llvm_component_library(LLVMDemangle "${LLVM_MAIN_INCLUDE_DIR}/llvm/Demangle" ) + +set_target_properties(LLVMDemangle PROPERTIES UNITY_BUILD_BATCH_SIZE 1) \ No newline at end of file diff --git a/llvm/utils/TableGen/Basic/CMakeLists.txt b/llvm/utils/TableGen/Basic/CMakeLists.txt index b4a66ecce6440..5ba8b20e911d3 100644 --- a/llvm/utils/TableGen/Basic/CMakeLists.txt +++ b/llvm/utils/TableGen/Basic/CMakeLists.txt @@ -27,3 +27,5 @@ target_include_directories(LLVMTableGenBasic INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> ) + +set_target_properties(LLVMTableGenBasic PROPERTIES UNITY_BUILD_BATCH_SIZE 1) \ No newline at end of file diff --git a/mlir/lib/Analysis/CMakeLists.txt b/mlir/lib/Analysis/CMakeLists.txt index 609cb34309829..2c6595550c112 100644 --- a/mlir/lib/Analysis/CMakeLists.txt +++ b/mlir/lib/Analysis/CMakeLists.txt @@ -60,3 +60,4 @@ add_mlir_library(MLIRAnalysis MLIRViewLikeInterface ) +set_target_properties(obj.MLIRAnalysis PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Conversion/LLVMCommon/CMakeLists.txt b/mlir/lib/Conversion/LLVMCommon/CMakeLists.txt index 568d9339aaabc..07d0e68f13316 100644 --- a/mlir/lib/Conversion/LLVMCommon/CMakeLists.txt +++ b/mlir/lib/Conversion/LLVMCommon/CMakeLists.txt @@ -17,3 +17,5 @@ add_mlir_conversion_library(MLIRLLVMCommonConversion MLIRSupport MLIRTransforms ) + +set_target_properties(obj.MLIRLLVMCommonConversion PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt index b7853634bc44e..3edbb974655ea 100644 --- a/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt @@ -22,3 +22,5 @@ add_mlir_conversion_library(MLIRSCFToGPU MLIRSideEffectInterfaces MLIRTransforms ) + +set_target_properties(obj.MLIRSCFToGPU PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt b/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt index 246f10b389911..0f51a78d59c84 100644 --- a/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt @@ -25,3 +25,4 @@ add_mlir_conversion_library(MLIRShapeToStandard MLIRSCFDialect MLIRTransforms ) +set_target_properties(obj.MLIRShapeToStandard PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Debug/CMakeLists.txt b/mlir/lib/Debug/CMakeLists.txt index d270eb2e7534f..af8753ed67ebd 100644 --- a/mlir/lib/Debug/CMakeLists.txt +++ b/mlir/lib/Debug/CMakeLists.txt @@ -17,3 +17,4 @@ add_mlir_library(MLIRDebug MLIRObservers ) +set_target_properties(obj.MLIRDebug PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt index c792200f4a49a..bd93bc49156c4 100644 --- a/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt @@ -44,3 +44,4 @@ add_mlir_dialect_library(MLIRAffineTransforms MLIRVectorUtils ) +set_target_properties(obj.MLIRAffineTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/Arith/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Arith/Transforms/CMakeLists.txt index f96bda603baa6..b88eaf7bb7d14 100644 --- a/mlir/lib/Dialect/Arith/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Arith/Transforms/CMakeLists.txt @@ -36,3 +36,4 @@ add_mlir_dialect_library(MLIRArithTransforms MLIRValueBoundsOpInterface MLIRVectorDialect ) +set_target_properties(obj.MLIRArithTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt index 7c38621be1bb5..03462425fff4a 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt @@ -42,3 +42,5 @@ add_mlir_dialect_library(MLIRBufferizationTransforms MLIRViewLikeInterface MLIRSupport ) + +set_target_properties(obj.MLIRBufferizationTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt index d83fd3800eb91..e8156bfcb6520 100644 --- a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt +++ b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt @@ -66,6 +66,7 @@ add_mlir_dialect_library(MLIRNVVMDialect MLIRSideEffectInterfaces MLIRInferIntRangeInterface ) +set_target_properties(obj.MLIRNVVMDialect PROPERTIES UNITY_BUILD_BATCH_SIZE 1) add_mlir_dialect_library(MLIRROCDLDialect IR/ROCDLDialect.cpp diff --git a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt index ec433284e17ad..8923a53376643 100644 --- a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt @@ -37,3 +37,4 @@ add_mlir_dialect_library(MLIRLinalgDialect MLIRValueBoundsOpInterface MLIRViewLikeInterface ) +set_target_properties(obj.MLIRLinalgDialect PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt index 69e6fdabf9a58..72dca5b1c45c4 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -86,3 +86,4 @@ add_mlir_dialect_library(MLIRLinalgTransforms MLIRVectorUtils MLIRVectorToSCF ) +set_target_properties(obj.MLIRLinalgTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt index 637f5ec1c9f9b..ecdf0280338be 100644 --- a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt @@ -42,3 +42,4 @@ add_mlir_dialect_library(MLIRMemRefTransforms MLIRVectorDialect ) +set_target_properties(obj.MLIRMemRefTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/Ptr/IR/CMakeLists.txt b/mlir/lib/Dialect/Ptr/IR/CMakeLists.txt index 497468b9391db..46706c06b65d1 100644 --- a/mlir/lib/Dialect/Ptr/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Ptr/IR/CMakeLists.txt @@ -16,3 +16,5 @@ add_mlir_dialect_library( MLIRMemorySlotInterfaces MLIRViewLikeInterface ) + +set_target_properties(obj.MLIRPtrDialect PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt index 84dd992bec53a..c22a05aa0e5d4 100644 --- a/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt @@ -42,3 +42,4 @@ add_mlir_dialect_library(MLIRSCFTransforms MLIRTransforms MLIRTransformUtils ) +set_target_properties(obj.MLIRSCFTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt index 1a8f30dd39871..ed1dfb7d5adb3 100644 --- a/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt @@ -49,3 +49,4 @@ add_mlir_dialect_library(MLIRSPIRVDialect MLIRTransforms MLIRUBDialect ) +set_target_properties(obj.MLIRSPIRVDialect PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt index 43e5c3251c525..8aa71f934a3c3 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt @@ -53,3 +53,4 @@ add_mlir_dialect_library(MLIRSparseTensorTransforms MLIRTransforms MLIRVectorDialect ) +set_target_properties(obj.MLIRSparseTensorTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt index 99e1c4fec8467..7fad9476e1997 100644 --- a/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt @@ -40,3 +40,4 @@ add_mlir_dialect_library(MLIRTensorTransforms MLIRVectorUtils MLIRValueBoundsOpInterface ) +set_target_properties(obj.MLIRTensorTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Dialect/Vector/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Vector/Transforms/CMakeLists.txt index 8ca5cb6c6dfab..e1ea6fb1d37d9 100644 --- a/mlir/lib/Dialect/Vector/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Vector/Transforms/CMakeLists.txt @@ -52,3 +52,4 @@ add_mlir_dialect_library(MLIRVectorTransforms MLIRVectorInterfaces MLIRVectorUtils ) +set_target_properties(obj.MLIRVectorTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt index 4cabac185171c..e54bf6bba0635 100644 --- a/mlir/lib/IR/CMakeLists.txt +++ b/mlir/lib/IR/CMakeLists.txt @@ -70,3 +70,4 @@ add_mlir_library(MLIRIR MLIRSupport ) +set_target_properties(obj.MLIRIR PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Support/CMakeLists.txt b/mlir/lib/Support/CMakeLists.txt index 02b6c694a28fd..1269b1324ef74 100644 --- a/mlir/lib/Support/CMakeLists.txt +++ b/mlir/lib/Support/CMakeLists.txt @@ -22,3 +22,4 @@ add_mlir_library(MLIRSupport LINK_LIBS PUBLIC ${LLVM_PTHREAD_LIB}) +set_target_properties(obj.MLIRSupport PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/TableGen/CMakeLists.txt b/mlir/lib/TableGen/CMakeLists.txt index a90c55847718e..0eb001170767a 100644 --- a/mlir/lib/TableGen/CMakeLists.txt +++ b/mlir/lib/TableGen/CMakeLists.txt @@ -41,7 +41,7 @@ llvm_add_library(MLIRTableGen STATIC ${MLIR_MAIN_INCLUDE_DIR}/mlir/TableGen ${MLIR_MAIN_INCLUDE_DIR}/mlir/Support ) -set_target_properties(MLIRTableGen PROPERTIES FOLDER "MLIR/Tablegenning") +set_target_properties(MLIRTableGen PROPERTIES FOLDER "MLIR/Tablegenning" UNITY_BUILD_BATCH_SIZE 1) mlir_check_all_link_libraries(MLIRTableGen) diff --git a/mlir/lib/Tools/PDLL/CodeGen/CMakeLists.txt b/mlir/lib/Tools/PDLL/CodeGen/CMakeLists.txt index f378a28af2db9..bc6d0e9869066 100644 --- a/mlir/lib/Tools/PDLL/CodeGen/CMakeLists.txt +++ b/mlir/lib/Tools/PDLL/CodeGen/CMakeLists.txt @@ -8,3 +8,4 @@ add_mlir_library(MLIRPDLLCodeGen MLIRPDLDialect MLIRSupport ) +set_target_properties(obj.MLIRPDLLCodeGen PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Transforms/CMakeLists.txt b/mlir/lib/Transforms/CMakeLists.txt index 3a8088bccf299..74c2a992e092a 100644 --- a/mlir/lib/Transforms/CMakeLists.txt +++ b/mlir/lib/Transforms/CMakeLists.txt @@ -39,3 +39,5 @@ add_mlir_library(MLIRTransforms MLIRTransformUtils MLIRUBDialect ) + +set_target_properties(obj.MLIRTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/lib/Transforms/Utils/CMakeLists.txt b/mlir/lib/Transforms/Utils/CMakeLists.txt index 3ca16239ba33c..106e1f6e4b8d4 100644 --- a/mlir/lib/Transforms/Utils/CMakeLists.txt +++ b/mlir/lib/Transforms/Utils/CMakeLists.txt @@ -24,3 +24,5 @@ add_mlir_library(MLIRTransformUtils MLIRSubsetOpInterface MLIRRewrite ) + +set_target_properties(obj.MLIRTransformUtils PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/Analysis/CMakeLists.txt b/mlir/test/lib/Analysis/CMakeLists.txt index 91879981bffd2..f913ac19ec957 100644 --- a/mlir/test/lib/Analysis/CMakeLists.txt +++ b/mlir/test/lib/Analysis/CMakeLists.txt @@ -36,3 +36,6 @@ target_include_directories(MLIRTestAnalysis ${CMAKE_CURRENT_SOURCE_DIR}/../Dialect/Test ${CMAKE_CURRENT_BINARY_DIR}/../Dialect/Test ) + + +set_target_properties(MLIRTestAnalysis PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/Conversion/FuncToLLVM/CMakeLists.txt b/mlir/test/lib/Conversion/FuncToLLVM/CMakeLists.txt index f190b2da5a190..e530f1f38e127 100644 --- a/mlir/test/lib/Conversion/FuncToLLVM/CMakeLists.txt +++ b/mlir/test/lib/Conversion/FuncToLLVM/CMakeLists.txt @@ -21,3 +21,4 @@ target_include_directories(MLIRTestFuncToLLVM ${CMAKE_CURRENT_SOURCE_DIR}/../../Dialect/Test ${CMAKE_CURRENT_BINARY_DIR}/../../Dialect/Test ) +set_target_properties(MLIRTestFuncToLLVM PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/Dialect/Affine/CMakeLists.txt b/mlir/test/lib/Dialect/Affine/CMakeLists.txt index 885bc9b4c3afc..f07c0b28da70f 100644 --- a/mlir/test/lib/Dialect/Affine/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Affine/CMakeLists.txt @@ -42,3 +42,4 @@ target_include_directories(MLIRAffineTransformsTestPasses ${CMAKE_CURRENT_BINARY_DIR}/../Test ) +set_target_properties(MLIRAffineTransformsTestPasses PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/Dialect/Bufferization/CMakeLists.txt b/mlir/test/lib/Dialect/Bufferization/CMakeLists.txt index 226e0bb97732d..5f1a73729c339 100644 --- a/mlir/test/lib/Dialect/Bufferization/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Bufferization/CMakeLists.txt @@ -18,3 +18,5 @@ target_include_directories(MLIRBufferizationTestPasses ${CMAKE_CURRENT_SOURCE_DIR}/../../Dialect/Test ${CMAKE_CURRENT_BINARY_DIR}/../../Dialect/Test ) + +set_target_properties(MLIRBufferizationTestPasses PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt index f099d01abd31a..a6530f48a2d8e 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -95,6 +95,7 @@ mlir_target_link_libraries(MLIRTestDialect PUBLIC MLIRValueBoundsOpInterface MLIRBufferizationDialect ) +set_target_properties(MLIRTestDialect PROPERTIES UNITY_BUILD_BATCH_SIZE 1) add_mlir_translation_library(MLIRTestFromLLVMIRTranslation TestFromLLVMIRTranslation.cpp diff --git a/mlir/test/lib/Dialect/Transform/CMakeLists.txt b/mlir/test/lib/Dialect/Transform/CMakeLists.txt index 512a0a89bfea9..b01e34bc50ebb 100644 --- a/mlir/test/lib/Dialect/Transform/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Transform/CMakeLists.txt @@ -26,3 +26,5 @@ mlir_target_link_libraries(MLIRTestTransformDialect PUBLIC MLIRTransformLoopExtension MLIRTransformPDLExtension ) + +set_target_properties(MLIRTestTransformDialect PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/IR/CMakeLists.txt b/mlir/test/lib/IR/CMakeLists.txt index 1abcfc77d2d9b..ad4ddbfda51b9 100644 --- a/mlir/test/lib/IR/CMakeLists.txt +++ b/mlir/test/lib/IR/CMakeLists.txt @@ -44,3 +44,4 @@ target_include_directories(MLIRTestIR ${CMAKE_CURRENT_SOURCE_DIR}/../Dialect/Test ${CMAKE_CURRENT_BINARY_DIR}/../Dialect/Test ) +set_target_properties(MLIRTestIR PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/Pass/CMakeLists.txt b/mlir/test/lib/Pass/CMakeLists.txt index ab52f621c517e..ca1eac220d618 100644 --- a/mlir/test/lib/Pass/CMakeLists.txt +++ b/mlir/test/lib/Pass/CMakeLists.txt @@ -27,3 +27,4 @@ target_include_directories(MLIRTestPass ${CMAKE_CURRENT_SOURCE_DIR}/../Dialect/Test ${CMAKE_CURRENT_BINARY_DIR}/../Dialect/Test ) +set_target_properties(MLIRTestPass PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt index ddc0a779e8f69..9f1f3ab973fb5 100644 --- a/mlir/test/lib/Transforms/CMakeLists.txt +++ b/mlir/test/lib/Transforms/CMakeLists.txt @@ -59,3 +59,5 @@ target_include_directories(MLIRTestTransforms ${CMAKE_CURRENT_SOURCE_DIR}/../Dialect/Test ${CMAKE_CURRENT_BINARY_DIR}/../Dialect/Test ) + +set_target_properties(MLIRTestTransforms PROPERTIES UNITY_BUILD_BATCH_SIZE 1) diff --git a/mlir/tools/mlir-tblgen/CMakeLists.txt b/mlir/tools/mlir-tblgen/CMakeLists.txt index 2a7ef7e0576c8..04d40f1b0e425 100644 --- a/mlir/tools/mlir-tblgen/CMakeLists.txt +++ b/mlir/tools/mlir-tblgen/CMakeLists.txt @@ -39,5 +39,6 @@ add_tablegen(mlir-tblgen MLIR target_link_libraries(mlir-tblgen PRIVATE MLIRTblgenLib) +set_target_properties(mlir-tblgen PROPERTIES UNITY_BUILD_BATCH_SIZE 1) mlir_check_all_link_libraries(mlir-tblgen) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits