From 34bec34a6afc20887c1d2b93328b5eec72a0e074 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Thu, 19 Sep 2024 14:14:18 -0700 Subject: [PATCH 1/2] Add missing deps edge: CodeGenAction.cpp.o -> GenVT.inc (#109306) CodeGenAction.cpp.o depends on generating GenVT.inc before trying to compile it through the following header chain: ``` GenVT.inc MachineValueType.h LowLevelType.h MachineMemOperand.h MachineInstr.h MachineBasicBlock.h MachineFunctionPass.h MachineOptimizationRemarkEmitter.h CodeGenAction.cpp ``` There is a dependency edge through LLVMCodeGenTypes, but that edge is applied to the clangCodeGen link step, not the compile step of the files that make up clangCodeGen. Usually the compile and link are close enough in the build that GenVT.inc is scheduled early enough that it exists by the time we're compiling CodeGenAction.cpp.o, but on machines with high core counts, it seems to be more prevalent that the scheduling works out just right to expose the missing edge. I've only been able to reproduce this on machines with at least 64 cores (but even then it was not reliable). Additionally, llvm-tblgen depends on GenVT.inc, so to see the missing dependency edge, one must be using a pre-built tablegen binary. Adding the missing dependency edge to ensure that GenVT.inc is generated before trying to compile CodeGenAction.cpp.o. Found by inspecting the dependency graph generated from Ninja with: ```sh cmake -G 'Ninja' \ ... -DLLVM_TABLEGEN= \ -DCLANG_TABLEGEN= \ -DLLVM_ENABLE_PROJECTS=clang \ ... ninja -t graph \ tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenAction.cpp.o | dot -Tpdf > CodeGenAction.pdf ``` (cherry picked from commit c3fe727181818d3efdd2ce96598bfe6a2d3ffb83) --- clang/lib/CodeGen/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt index 2a179deddcc31..084c8409c69b3 100644 --- a/clang/lib/CodeGen/CMakeLists.txt +++ b/clang/lib/CodeGen/CMakeLists.txt @@ -143,6 +143,7 @@ add_clang_library(clangCodeGen VarBypassDetector.cpp DEPENDS + vt_gen intrinsics_gen ClangDriverOptions # These generated headers are included transitively. From a5bdaafb5b8d93db6a285ea6206be3f62923aeb7 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Tue, 24 Sep 2024 14:11:42 -0700 Subject: [PATCH 2/2] Export empty vt_gen target (for standalone builds) (#109817) Fixing the standalone builds by exporting the vt_gen target so that the sources of the clangCodeGen target can form an explicit dependency edge on it. (cherry picked from commit cace9869775a185793122f845d81a5ff46f15728) --- llvm/cmake/modules/CMakeLists.txt | 3 +++ llvm/cmake/modules/LLVMConfig.cmake.in | 3 +++ 2 files changed, 6 insertions(+) diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt index d99af79aa38e0..ef4cfa3acdb59 100644 --- a/llvm/cmake/modules/CMakeLists.txt +++ b/llvm/cmake/modules/CMakeLists.txt @@ -36,6 +36,9 @@ endif() if(omp_gen IN_LIST LLVM_COMMON_DEPENDS) list(REMOVE_ITEM LLVM_COMMON_DEPENDS omp_gen) endif() +if(vt_gen IN_LIST LLVM_COMMON_DEPENDS) + list(REMOVE_ITEM LLVM_COMMON_DEPENDS vt_gen) +endif() # # Generate LLVMConfig.cmake for the build tree. diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in index 7e1501a89354c..c49f10b9343ff 100644 --- a/llvm/cmake/modules/LLVMConfig.cmake.in +++ b/llvm/cmake/modules/LLVMConfig.cmake.in @@ -151,6 +151,9 @@ endif() if(NOT TARGET intrinsics_gen) add_custom_target(intrinsics_gen) endif() +if(NOT TARGET vt_gen) + add_custom_target(vt_gen) +endif() if(NOT TARGET omp_gen) add_custom_target(omp_gen) endif()