Skip to content

Commit 01347f9

Browse files
committed
Trim and tidy includes in rustc_llvm
1 parent 44a056a commit 01347f9

File tree

6 files changed

+47
-73
lines changed

6 files changed

+47
-73
lines changed

compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#include "LLVMWrapper.h"
2+
23
#include "llvm/ADT/ArrayRef.h"
4+
#include "llvm/ADT/StringRef.h"
5+
#include "llvm/IR/Module.h"
36
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
47
#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h"
58
#include "llvm/ProfileData/InstrProf.h"
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,19 @@
1+
#ifndef INCLUDED_RUSTC_LLVM_LLVMWRAPPER_H
2+
#define INCLUDED_RUSTC_LLVM_LLVMWRAPPER_H
3+
14
#include "SuppressLLVMWarnings.h"
25

3-
#include "llvm-c/BitReader.h"
4-
#include "llvm-c/Core.h"
5-
#include "llvm-c/Object.h"
6-
#include "llvm/ADT/ArrayRef.h"
7-
#include "llvm/ADT/DenseSet.h"
8-
#include "llvm/ADT/SmallVector.h"
9-
#include "llvm/Analysis/Lint.h"
10-
#include "llvm/Analysis/Passes.h"
11-
#include "llvm/IR/IRBuilder.h"
12-
#include "llvm/IR/InlineAsm.h"
13-
#include "llvm/IR/LLVMContext.h"
14-
#include "llvm/IR/Module.h"
15-
#include "llvm/Support/CommandLine.h"
16-
#include "llvm/Support/Debug.h"
17-
#include "llvm/Support/DynamicLibrary.h"
18-
#include "llvm/Support/FormattedStream.h"
19-
#include "llvm/Support/JSON.h"
20-
#include "llvm/Support/Memory.h"
21-
#include "llvm/Support/SourceMgr.h"
22-
#include "llvm/Support/TargetSelect.h"
23-
#include "llvm/Support/Timer.h"
24-
#include "llvm/Support/raw_ostream.h"
25-
#include "llvm/Target/TargetMachine.h"
26-
#include "llvm/Target/TargetOptions.h"
27-
#include "llvm/Transforms/IPO.h"
28-
#include "llvm/Transforms/Scalar.h"
6+
#include "llvm/Config/llvm-config.h" // LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR
7+
#include "llvm/Support/raw_ostream.h" // llvm::raw_ostream
8+
#include <cstddef> // size_t etc
9+
#include <cstdint> // uint64_t etc
2910

3011
#define LLVM_VERSION_GE(major, minor) \
3112
(LLVM_VERSION_MAJOR > (major) || \
3213
LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR >= (minor))
3314

3415
#define LLVM_VERSION_LT(major, minor) (!LLVM_VERSION_GE((major), (minor)))
3516

36-
#if LLVM_VERSION_GE(20, 0)
37-
#include "llvm/Transforms/Utils/Instrumentation.h"
38-
#else
39-
#include "llvm/Transforms/Instrumentation.h"
40-
#endif
41-
42-
#include "llvm/IR/LegacyPassManager.h"
43-
44-
#include "llvm/Bitcode/BitcodeReader.h"
45-
#include "llvm/Bitcode/BitcodeWriter.h"
46-
47-
#include "llvm/IR/DIBuilder.h"
48-
#include "llvm/IR/DebugInfo.h"
49-
#include "llvm/IR/IRPrintingPasses.h"
50-
#include "llvm/Linker/Linker.h"
51-
52-
#include "llvm/TargetParser/Triple.h"
53-
5417
extern "C" void LLVMRustSetLastError(const char *);
5518

5619
enum class LLVMRustResult { Success, Failure };
@@ -81,3 +44,5 @@ class RawRustStringOstream : public llvm::raw_ostream {
8144
flush();
8245
}
8346
};
47+
48+
#endif // INCLUDED_RUSTC_LLVM_LLVMWRAPPER_H

compiler/rustc_llvm/llvm-wrapper/Linker.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#include "llvm/Linker/Linker.h"
2-
#include "SuppressLLVMWarnings.h"
3-
41
#include "LLVMWrapper.h"
52

3+
#include "llvm/Bitcode/BitcodeReader.h"
4+
#include "llvm/IR/Module.h"
5+
#include "llvm/Linker/Linker.h"
6+
#include "llvm/Support/MemoryBuffer.h"
7+
68
using namespace llvm;
79

810
struct RustLinker {

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
#include <stdio.h>
2-
3-
#include <cstddef>
4-
#include <iomanip>
5-
#include <set>
6-
#include <vector>
7-
81
#include "LLVMWrapper.h"
92

10-
#include "llvm/Analysis/AliasAnalysis.h"
3+
#include "llvm-c/Core.h"
4+
#include "llvm/Analysis/Lint.h"
115
#include "llvm/Analysis/TargetLibraryInfo.h"
12-
#include "llvm/Analysis/TargetTransformInfo.h"
136
#include "llvm/Bitcode/BitcodeWriter.h"
147
#include "llvm/CodeGen/CommandFlags.h"
15-
#include "llvm/CodeGen/TargetSubtargetInfo.h"
168
#include "llvm/IR/AssemblyAnnotationWriter.h"
179
#include "llvm/IR/AutoUpgrade.h"
18-
#include "llvm/IR/IntrinsicInst.h"
10+
#include "llvm/IR/LegacyPassManager.h"
11+
#include "llvm/IR/PassManager.h"
1912
#include "llvm/IR/Verifier.h"
2013
#include "llvm/LTO/LTO.h"
14+
#include "llvm/MC/MCSubtargetInfo.h"
2115
#include "llvm/MC/TargetRegistry.h"
22-
#include "llvm/Object/IRObjectFile.h"
2316
#include "llvm/Object/ObjectFile.h"
2417
#include "llvm/Passes/PassBuilder.h"
2518
#include "llvm/Passes/PassPlugin.h"
@@ -30,25 +23,28 @@
3023
#include "llvm/Support/VirtualFileSystem.h"
3124
#include "llvm/Target/TargetMachine.h"
3225
#include "llvm/TargetParser/Host.h"
33-
#include "llvm/Transforms/IPO/AlwaysInliner.h"
3426
#include "llvm/Transforms/IPO/FunctionImport.h"
3527
#include "llvm/Transforms/IPO/Internalize.h"
3628
#include "llvm/Transforms/IPO/LowerTypeTests.h"
3729
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
3830
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
3931
#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
40-
#include "llvm/Transforms/Utils/AddDiscriminators.h"
41-
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
42-
#if LLVM_VERSION_GE(19, 0)
43-
#include "llvm/Support/PGOOptions.h"
44-
#endif
4532
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
4633
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
4734
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
4835
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
49-
#include "llvm/Transforms/Utils.h"
5036
#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
37+
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
5138
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
39+
#include <set>
40+
#include <string>
41+
#include <vector>
42+
43+
// Conditional includes prevent clang-format from fully sorting the list,
44+
// so keep them separate.
45+
#if LLVM_VERSION_GE(19, 0)
46+
#include "llvm/Support/PGOOptions.h"
47+
#endif
5248

5349
using namespace llvm;
5450

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
#include "LLVMWrapper.h"
2+
3+
#include "llvm-c/Core.h"
24
#include "llvm/ADT/Statistic.h"
5+
#include "llvm/ADT/StringRef.h"
6+
#include "llvm/BinaryFormat/Magic.h"
37
#include "llvm/Bitcode/BitcodeWriter.h"
8+
#include "llvm/IR/DIBuilder.h"
49
#include "llvm/IR/DebugInfoMetadata.h"
510
#include "llvm/IR/DiagnosticHandler.h"
611
#include "llvm/IR/DiagnosticInfo.h"
712
#include "llvm/IR/DiagnosticPrinter.h"
813
#include "llvm/IR/GlobalVariable.h"
14+
#include "llvm/IR/IRBuilder.h"
15+
#include "llvm/IR/InlineAsm.h"
916
#include "llvm/IR/Instructions.h"
10-
#include "llvm/IR/Intrinsics.h"
1117
#include "llvm/IR/IntrinsicsARM.h"
18+
#include "llvm/IR/LLVMContext.h"
1219
#include "llvm/IR/LLVMRemarkStreamer.h"
1320
#include "llvm/IR/Mangler.h"
21+
#include "llvm/IR/Module.h"
1422
#include "llvm/IR/Value.h"
15-
#include "llvm/Object/Archive.h"
1623
#include "llvm/Object/COFFImportFile.h"
17-
#include "llvm/Object/ObjectFile.h"
18-
#include "llvm/Pass.h"
1924
#include "llvm/Remarks/RemarkFormat.h"
2025
#include "llvm/Remarks/RemarkSerializer.h"
2126
#include "llvm/Remarks/RemarkStreamer.h"
27+
#include "llvm/Support/Compression.h"
28+
#include "llvm/Support/FileSystem.h"
29+
#include "llvm/Support/JSON.h"
2230
#include "llvm/Support/ModRef.h"
2331
#include "llvm/Support/Signals.h"
32+
#include "llvm/Support/Timer.h"
2433
#include "llvm/Support/ToolOutputFile.h"
25-
2634
#include <iostream>
2735

2836
// for raw `write` in the bad-alloc handler

compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
// * https://github.com/llvm/llvm-project/blob/ef6d1ec07c693352c4a60dd58db08d2d8558f6ea/llvm/lib/Object/ArchiveWriter.cpp
99

1010
#include "LLVMWrapper.h"
11-
#include "SuppressLLVMWarnings.h"
11+
1212
#include "llvm/ADT/SmallString.h"
1313
#include "llvm/IR/LLVMContext.h"
1414
#include "llvm/Object/COFF.h"
1515
#include "llvm/Object/COFFImportFile.h"
1616
#include "llvm/Object/IRObjectFile.h"
1717
#include "llvm/Object/ObjectFile.h"
18-
#include <llvm/Support/raw_ostream.h>
18+
#include "llvm/Support/raw_ostream.h"
1919

2020
using namespace llvm;
2121
using namespace llvm::sys;

0 commit comments

Comments
 (0)