[llvm-(min-)tblgen] Avoid redundant source compilation (#114494)
All the sources of `llvm-min-tblgen` are also used for `llvm-tblgen`, with identical compilation flags. Reuse the object files of `llvm-min-tblgen` for `llvm-tblgen` by applying the usual source structure of an executable: One file per executable which named after the executable name containing the (in this case trivial) main function, which just calls the tblgen_main in TableGen.cpp. This should also clear up any confusion (including mine) of where each executable's main function is. While this slightly reduces build time, the main motivation is ccache. Using the hard_link option, building the object files for `llvm-tblgen` will result in a hard link to the same object file already used for `llvm-min-tblgen`. To signal the build system that the file is new, ccache will update the file's time stamp. Unfortunately, time stamps are shared between all hard-linked files s.t. this will indirectly also update the time stamps for the object files used for `llvm-tblgen`. At the next run, Ninja will recognize this time stamp discrepancy to the expected stamp recorded in `.ninja_log` and rebuild those object files for `llvm-min-tblgen`, which again will also update the stamp for the `llvm-tblgen`... . This is especially annoying for tablegen because it means Ninja will re-run all tablegenning in every build. I am using the hard_link option because it reduces the cost of having multiple build-trees of the LLVM sources and reduces the wear to the SSD they are stored on.
This commit is contained in:
parent
3ef78188d0
commit
27f3002974
@ -9,8 +9,15 @@ set(LLVM_LINK_COMPONENTS
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_llvm_library(LLVMTableGenBasic OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
|
add_llvm_library(LLVMTableGenBasic OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
|
||||||
|
ARMTargetDefEmitter.cpp
|
||||||
|
Attributes.cpp
|
||||||
CodeGenIntrinsics.cpp
|
CodeGenIntrinsics.cpp
|
||||||
|
DirectiveEmitter.cpp
|
||||||
|
IntrinsicEmitter.cpp
|
||||||
|
RISCVTargetDefEmitter.cpp
|
||||||
SDNodeProperties.cpp
|
SDNodeProperties.cpp
|
||||||
|
TableGen.cpp
|
||||||
|
VTEmitter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Users may include its headers as "Basic/*.h"
|
# Users may include its headers as "Basic/*.h"
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "Basic/CodeGenIntrinsics.h"
|
#include "CodeGenIntrinsics.h"
|
||||||
#include "Basic/SequenceToOffsetTable.h"
|
#include "SequenceToOffsetTable.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
@ -6,10 +6,12 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file contains the main function for LLVM's TableGen.
|
// This file contains the global defintions (mostly command line parameters)
|
||||||
|
// shared between llvm-tblgen and llvm-min-tblgen.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "TableGen.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/InitLLVM.h"
|
#include "llvm/Support/InitLLVM.h"
|
||||||
@ -74,7 +76,7 @@ static TableGen::Emitter::Opt X[] = {
|
|||||||
{"print-sets", printSets, "Print expanded sets for testing DAG exprs"},
|
{"print-sets", printSets, "Print expanded sets for testing DAG exprs"},
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int tblgen_main(int argc, char **argv) {
|
||||||
InitLLVM X(argc, argv);
|
InitLLVM X(argc, argv);
|
||||||
cl::ParseCommandLineOptions(argc, argv);
|
cl::ParseCommandLineOptions(argc, argv);
|
||||||
|
|
13
llvm/utils/TableGen/Basic/TableGen.h
Normal file
13
llvm/utils/TableGen/Basic/TableGen.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
//===- TableGen.h ---------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Shared entry point for llvm-tblgen and llvm-min-tblgen.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
int tblgen_main(int argc, char **argv);
|
@ -11,14 +11,13 @@ set(LLVM_LINK_COMPONENTS Support)
|
|||||||
# build llvm/include. It must not depend on TableGenCommon, as
|
# build llvm/include. It must not depend on TableGenCommon, as
|
||||||
# TableGenCommon depends on this already to generate things such as
|
# TableGenCommon depends on this already to generate things such as
|
||||||
# ValueType definitions.
|
# ValueType definitions.
|
||||||
|
# Sources included in both, llvm-min-tblgen and llvm-tblgen, must be included
|
||||||
|
# into LLVMTableGenBasic to avoid redundant compilation and problems with build
|
||||||
|
# caches.
|
||||||
|
# At least one source file must be included directly to avoid CMake problems.
|
||||||
|
# E.g. CMake derives which linker to use from the types of sources added.
|
||||||
add_tablegen(llvm-min-tblgen LLVM_HEADERS
|
add_tablegen(llvm-min-tblgen LLVM_HEADERS
|
||||||
TableGen.cpp
|
llvm-min-tblgen.cpp
|
||||||
ARMTargetDefEmitter.cpp
|
|
||||||
Attributes.cpp
|
|
||||||
DirectiveEmitter.cpp
|
|
||||||
IntrinsicEmitter.cpp
|
|
||||||
RISCVTargetDefEmitter.cpp
|
|
||||||
VTEmitter.cpp
|
|
||||||
$<TARGET_OBJECTS:obj.LLVMTableGenBasic>
|
$<TARGET_OBJECTS:obj.LLVMTableGenBasic>
|
||||||
|
|
||||||
PARTIAL_SOURCES_INTENDED
|
PARTIAL_SOURCES_INTENDED
|
||||||
@ -32,10 +31,8 @@ set(LLVM_LINK_COMPONENTS
|
|||||||
add_tablegen(llvm-tblgen LLVM
|
add_tablegen(llvm-tblgen LLVM
|
||||||
DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
|
DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
|
||||||
EXPORT LLVM
|
EXPORT LLVM
|
||||||
ARMTargetDefEmitter.cpp
|
|
||||||
AsmMatcherEmitter.cpp
|
AsmMatcherEmitter.cpp
|
||||||
AsmWriterEmitter.cpp
|
AsmWriterEmitter.cpp
|
||||||
Attributes.cpp
|
|
||||||
CallingConvEmitter.cpp
|
CallingConvEmitter.cpp
|
||||||
CodeEmitterGen.cpp
|
CodeEmitterGen.cpp
|
||||||
CodeGenMapTable.cpp
|
CodeGenMapTable.cpp
|
||||||
@ -48,7 +45,6 @@ add_tablegen(llvm-tblgen LLVM
|
|||||||
DecoderEmitter.cpp
|
DecoderEmitter.cpp
|
||||||
DFAEmitter.cpp
|
DFAEmitter.cpp
|
||||||
DFAPacketizerEmitter.cpp
|
DFAPacketizerEmitter.cpp
|
||||||
DirectiveEmitter.cpp
|
|
||||||
DisassemblerEmitter.cpp
|
DisassemblerEmitter.cpp
|
||||||
DXILEmitter.cpp
|
DXILEmitter.cpp
|
||||||
ExegesisEmitter.cpp
|
ExegesisEmitter.cpp
|
||||||
@ -57,18 +53,15 @@ add_tablegen(llvm-tblgen LLVM
|
|||||||
GlobalISelEmitter.cpp
|
GlobalISelEmitter.cpp
|
||||||
InstrDocsEmitter.cpp
|
InstrDocsEmitter.cpp
|
||||||
InstrInfoEmitter.cpp
|
InstrInfoEmitter.cpp
|
||||||
IntrinsicEmitter.cpp
|
llvm-tblgen.cpp
|
||||||
MacroFusionPredicatorEmitter.cpp
|
MacroFusionPredicatorEmitter.cpp
|
||||||
OptionParserEmitter.cpp
|
OptionParserEmitter.cpp
|
||||||
OptionRSTEmitter.cpp
|
OptionRSTEmitter.cpp
|
||||||
PseudoLoweringEmitter.cpp
|
PseudoLoweringEmitter.cpp
|
||||||
RegisterBankEmitter.cpp
|
RegisterBankEmitter.cpp
|
||||||
RegisterInfoEmitter.cpp
|
RegisterInfoEmitter.cpp
|
||||||
RISCVTargetDefEmitter.cpp
|
|
||||||
SearchableTableEmitter.cpp
|
SearchableTableEmitter.cpp
|
||||||
SubtargetEmitter.cpp
|
SubtargetEmitter.cpp
|
||||||
TableGen.cpp
|
|
||||||
VTEmitter.cpp
|
|
||||||
WebAssemblyDisassemblerEmitter.cpp
|
WebAssemblyDisassemblerEmitter.cpp
|
||||||
X86InstrMappingEmitter.cpp
|
X86InstrMappingEmitter.cpp
|
||||||
X86DisassemblerTables.cpp
|
X86DisassemblerTables.cpp
|
||||||
@ -79,6 +72,8 @@ add_tablegen(llvm-tblgen LLVM
|
|||||||
$<TARGET_OBJECTS:obj.LLVMTableGenBasic>
|
$<TARGET_OBJECTS:obj.LLVMTableGenBasic>
|
||||||
$<TARGET_OBJECTS:obj.LLVMTableGenCommon>
|
$<TARGET_OBJECTS:obj.LLVMTableGenCommon>
|
||||||
|
|
||||||
|
PARTIAL_SOURCES_INTENDED
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
intrinsics_gen # via llvm-min-tablegen
|
intrinsics_gen # via llvm-min-tablegen
|
||||||
)
|
)
|
||||||
|
18
llvm/utils/TableGen/llvm-min-tblgen.cpp
Normal file
18
llvm/utils/TableGen/llvm-min-tblgen.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//===- llvm-min-tblgen.cpp ------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file contains the main function for LLVM's TableGen.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "Basic/TableGen.h"
|
||||||
|
|
||||||
|
/// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
|
||||||
|
/// The indirection to tblgen_main exists to ensure that the static variables
|
||||||
|
/// for the llvm::cl:: mechanism are linked into both executables.
|
||||||
|
int main(int argc, char **argv) { return tblgen_main(argc, argv); }
|
18
llvm/utils/TableGen/llvm-tblgen.cpp
Normal file
18
llvm/utils/TableGen/llvm-tblgen.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//===- llvm-tblgen.cpp ----------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file contains the main function for LLVM's TableGen.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "Basic/TableGen.h"
|
||||||
|
|
||||||
|
/// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
|
||||||
|
/// The indirection to tblgen_main exists to ensure that the static variables
|
||||||
|
/// for the llvm::cl:: mechanism are linked into both executables.
|
||||||
|
int main(int argc, char **argv) { return tblgen_main(argc, argv); }
|
Loading…
x
Reference in New Issue
Block a user