Skip to content

Commit 65bc259

Browse files
authored
[NFC] Add explicit #include llvm-config.h where its macros are used, last part. (llvm#107615)
(this is the part related to bolt, lld and mlir) Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects. For example, `clangd` may report even `llvm-config.h` as "no used" in case it defines a macro, that is explicitly used with #ifdef. It is actually amplified with different build configs which use different set of macros.
1 parent f7c3309 commit 65bc259

File tree

6 files changed

+6
-1
lines changed

6 files changed

+6
-1
lines changed

bolt/include/bolt/Core/BinaryBasicBlock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "bolt/Core/MCPlus.h"
2020
#include "llvm/ADT/GraphTraits.h"
2121
#include "llvm/ADT/StringRef.h"
22+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
2223
#include "llvm/MC/MCInst.h"
2324
#include "llvm/MC/MCSymbol.h"
2425
#include "llvm/Support/ErrorOr.h"

lld/ELF/OutputSections.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "lld/Common/Arrays.h"
1717
#include "lld/Common/Memory.h"
1818
#include "llvm/BinaryFormat/Dwarf.h"
19-
#include "llvm/Config/llvm-config.h" // LLVM_ENABLE_ZLIB
19+
#include "llvm/Config/llvm-config.h" // LLVM_ENABLE_ZLIB, LLVM_ENABLE_ZSTD
2020
#include "llvm/Support/Compression.h"
2121
#include "llvm/Support/LEB128.h"
2222
#include "llvm/Support/Parallel.h"

mlir/include/mlir/Bytecode/BytecodeWriter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define MLIR_BYTECODE_BYTECODEWRITER_H
1515

1616
#include "mlir/IR/AsmState.h"
17+
#include "llvm/Config/llvm-config.h" // for LLVM_VERSION_STRING
1718

1819
namespace mlir {
1920
class DialectBytecodeWriter;

mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "mlir/Target/SPIRV/SPIRVBinaryUtils.h"
1414
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
15+
#include "llvm/Config/llvm-config.h" // for LLVM_VERSION_MAJOR
1516

1617
using namespace mlir;
1718

mlir/unittests/Target/LLVM/SerializeNVVMTarget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
1919
#include "mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"
2020

21+
#include "llvm/Config/llvm-config.h" // for LLVM_HAS_NVPTX_TARGET
2122
#include "llvm/IRReader/IRReader.h"
2223
#include "llvm/Support/MemoryBufferRef.h"
2324
#include "llvm/Support/Process.h"

polly/lib/Support/RegisterPasses.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "polly/Support/DumpFunctionPass.h"
4141
#include "polly/Support/DumpModulePass.h"
4242
#include "llvm/Analysis/CFGPrinter.h"
43+
#include "llvm/Config/llvm-config.h" // for LLVM_VERSION_STRING
4344
#include "llvm/IR/LegacyPassManager.h"
4445
#include "llvm/IR/PassManager.h"
4546
#include "llvm/IR/Verifier.h"

0 commit comments

Comments
 (0)