From 3909a36379afa4f50320513a70d7dea8b0037e42 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 23 May 2020 19:49:38 +0100 Subject: [PATCH] TargetLowering.h - remove unnecessary TargetMachine.h include. NFC Replace with forward declaration and move dependency down to source files that actually need it. Both TargetLowering.h and TargetMachine.h are 2 of the most expensive headers (top 10) in the ClangBuildAnalyzer report when building llc. --- include/llvm/CodeGen/TargetLowering.h | 2 +- lib/CodeGen/Analysis.cpp | 1 + lib/CodeGen/AsmPrinter/WinException.cpp | 1 + lib/CodeGen/ExpandMemCmp.cpp | 1 + lib/CodeGen/GlobalISel/CallLowering.cpp | 1 + lib/CodeGen/GlobalISel/InstructionSelect.cpp | 1 + lib/CodeGen/LiveDebugValues.cpp | 1 + lib/CodeGen/LowerEmuTLS.cpp | 1 + lib/CodeGen/SelectionDAG/InstrEmitter.cpp | 1 + lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp | 1 + lib/CodeGen/SwitchLoweringUtils.cpp | 1 + lib/CodeGen/TypePromotion.cpp | 1 + lib/LTO/UpdateCompilerUsed.cpp | 1 + lib/Target/ARM/ARMSubtarget.h | 1 + lib/Target/Sparc/SparcTargetObjectFile.cpp | 1 + lib/Target/SystemZ/SystemZFrameLowering.cpp | 1 + lib/Target/SystemZ/SystemZSubtarget.cpp | 1 + lib/Target/SystemZ/SystemZTDC.cpp | 1 + lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp | 1 + lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp | 1 + lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | 1 + lib/Target/X86/X86Subtarget.h | 2 +- lib/Target/X86/X86TargetObjectFile.cpp | 1 + 23 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/llvm/CodeGen/TargetLowering.h b/include/llvm/CodeGen/TargetLowering.h index 95dde596f8a..522621471af 100644 --- a/include/llvm/CodeGen/TargetLowering.h +++ b/include/llvm/CodeGen/TargetLowering.h @@ -50,7 +50,6 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MachineValueType.h" -#include "llvm/Target/TargetMachine.h" #include #include #include @@ -86,6 +85,7 @@ class MCExpr; class Module; class ProfileSummaryInfo; class TargetLibraryInfo; +class TargetMachine; class TargetRegisterClass; class TargetRegisterInfo; class TargetTransformInfo; diff --git a/lib/CodeGen/Analysis.cpp b/lib/CodeGen/Analysis.cpp index aa511950c25..c7aafb0bd70 100644 --- a/lib/CodeGen/Analysis.cpp +++ b/lib/CodeGen/Analysis.cpp @@ -25,6 +25,7 @@ #include "llvm/IR/Module.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/Utils/GlobalStatus.h" using namespace llvm; diff --git a/lib/CodeGen/AsmPrinter/WinException.cpp b/lib/CodeGen/AsmPrinter/WinException.cpp index dbacce7bf16..cd8077e7d54 100644 --- a/lib/CodeGen/AsmPrinter/WinException.cpp +++ b/lib/CodeGen/AsmPrinter/WinException.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" using namespace llvm; diff --git a/lib/CodeGen/ExpandMemCmp.cpp b/lib/CodeGen/ExpandMemCmp.cpp index 04433ed2f0d..9f85db9de88 100644 --- a/lib/CodeGen/ExpandMemCmp.cpp +++ b/lib/CodeGen/ExpandMemCmp.cpp @@ -25,6 +25,7 @@ #include "llvm/InitializePasses.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/SizeOpts.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; diff --git a/lib/CodeGen/GlobalISel/CallLowering.cpp b/lib/CodeGen/GlobalISel/CallLowering.cpp index 1e85d0a3a19..6ff869833b0 100644 --- a/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" +#include "llvm/Target/TargetMachine.h" #define DEBUG_TYPE "call-lowering" diff --git a/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/lib/CodeGen/GlobalISel/InstructionSelect.cpp index d6b26492a2f..fc114c6edc0 100644 --- a/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/TargetRegistry.h" +#include "llvm/Target/TargetMachine.h" #define DEBUG_TYPE "instruction-select" diff --git a/lib/CodeGen/LiveDebugValues.cpp b/lib/CodeGen/LiveDebugValues.cpp index fdea70237ef..470cb227fe7 100644 --- a/lib/CodeGen/LiveDebugValues.cpp +++ b/lib/CodeGen/LiveDebugValues.cpp @@ -64,6 +64,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetMachine.h" #include #include #include diff --git a/lib/CodeGen/LowerEmuTLS.cpp b/lib/CodeGen/LowerEmuTLS.cpp index 529d478756d..1b41f773583 100644 --- a/lib/CodeGen/LowerEmuTLS.cpp +++ b/lib/CodeGen/LowerEmuTLS.cpp @@ -21,6 +21,7 @@ #include "llvm/IR/Module.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; diff --git a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp index 9ecffa51cbe..0e4e99214aa 100644 --- a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp +++ b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; #define DEBUG_TYPE "instr-emitter" diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp index 794f0236fe4..83aaf93c9ba 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -31,6 +31,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; #define DEBUG_TYPE "pre-RA-sched" diff --git a/lib/CodeGen/SwitchLoweringUtils.cpp b/lib/CodeGen/SwitchLoweringUtils.cpp index c2cd8fa0324..078c9691f8d 100644 --- a/lib/CodeGen/SwitchLoweringUtils.cpp +++ b/lib/CodeGen/SwitchLoweringUtils.cpp @@ -13,6 +13,7 @@ #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/SwitchLoweringUtils.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; using namespace SwitchCG; diff --git a/lib/CodeGen/TypePromotion.cpp b/lib/CodeGen/TypePromotion.cpp index e8b39c03769..807babdcaf2 100644 --- a/lib/CodeGen/TypePromotion.cpp +++ b/lib/CodeGen/TypePromotion.cpp @@ -40,6 +40,7 @@ #include "llvm/Pass.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Target/TargetMachine.h" #define DEBUG_TYPE "type-promotion" #define PASS_NAME "Type Promotion" diff --git a/lib/LTO/UpdateCompilerUsed.cpp b/lib/LTO/UpdateCompilerUsed.cpp index 6434f902088..040e1106523 100644 --- a/lib/LTO/UpdateCompilerUsed.cpp +++ b/lib/LTO/UpdateCompilerUsed.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Mangler.h" #include "llvm/Transforms/Utils/ModuleUtils.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h index 536352190c1..b49b953a84b 100644 --- a/lib/Target/ARM/ARMSubtarget.h +++ b/lib/Target/ARM/ARMSubtarget.h @@ -28,6 +28,7 @@ #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/MC/MCInstrItineraries.h" #include "llvm/MC/MCSchedule.h" +#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include #include diff --git a/lib/Target/Sparc/SparcTargetObjectFile.cpp b/lib/Target/Sparc/SparcTargetObjectFile.cpp index 022ee4e9503..c03510fa090 100644 --- a/lib/Target/Sparc/SparcTargetObjectFile.cpp +++ b/lib/Target/Sparc/SparcTargetObjectFile.cpp @@ -11,6 +11,7 @@ #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/CodeGen/TargetLowering.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; diff --git a/lib/Target/SystemZ/SystemZFrameLowering.cpp b/lib/Target/SystemZ/SystemZFrameLowering.cpp index 5eadd5da7a9..330c2139826 100644 --- a/lib/Target/SystemZ/SystemZFrameLowering.cpp +++ b/lib/Target/SystemZ/SystemZFrameLowering.cpp @@ -17,6 +17,7 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/RegisterScavenging.h" #include "llvm/IR/Function.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; diff --git a/lib/Target/SystemZ/SystemZSubtarget.cpp b/lib/Target/SystemZ/SystemZSubtarget.cpp index 13194bf51c7..bebfe72a1dc 100644 --- a/lib/Target/SystemZ/SystemZSubtarget.cpp +++ b/lib/Target/SystemZ/SystemZSubtarget.cpp @@ -9,6 +9,7 @@ #include "SystemZSubtarget.h" #include "MCTargetDesc/SystemZMCTargetDesc.h" #include "llvm/IR/GlobalValue.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; diff --git a/lib/Target/SystemZ/SystemZTDC.cpp b/lib/Target/SystemZ/SystemZTDC.cpp index dd8cfbeb989..7cb7dca2ea2 100644 --- a/lib/Target/SystemZ/SystemZTDC.cpp +++ b/lib/Target/SystemZ/SystemZTDC.cpp @@ -55,6 +55,7 @@ #include "llvm/IR/IntrinsicsS390.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Module.h" +#include "llvm/Target/TargetMachine.h" #include #include diff --git a/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp index bc1c336f52b..23a5aa61daa 100644 --- a/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ b/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -31,6 +31,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; #define DEBUG_TYPE "wasm-cfg-stackify" diff --git a/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp b/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp index a2746b02d87..54115849df1 100644 --- a/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp +++ b/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp @@ -20,6 +20,7 @@ #include "llvm/CodeGen/WasmEHFuncInfo.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/Debug.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; #define DEBUG_TYPE "wasm-late-eh-prepare" diff --git a/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp b/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp index 1e1c097a0dc..e05ff6ab871 100644 --- a/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp +++ b/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp @@ -16,6 +16,7 @@ #include "WebAssemblyISelLowering.h" #include "WebAssemblySubtarget.h" #include "llvm/CodeGen/Analysis.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; WebAssemblyFunctionInfo::~WebAssemblyFunctionInfo() = default; // anchor. diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index eb2a4735320..ddcce32bfdc 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -20,6 +20,7 @@ #include "llvm/ADT/Triple.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/IR/CallingConv.h" +#include "llvm/Target/TargetMachine.h" #include #include @@ -34,7 +35,6 @@ class InstructionSelector; class LegalizerInfo; class RegisterBankInfo; class StringRef; -class TargetMachine; /// The X86 backend supports a number of different styles of PIC. /// diff --git a/lib/Target/X86/X86TargetObjectFile.cpp b/lib/Target/X86/X86TargetObjectFile.cpp index e3a8ff45f91..2b48baccc01 100644 --- a/lib/Target/X86/X86TargetObjectFile.cpp +++ b/lib/Target/X86/X86TargetObjectFile.cpp @@ -18,6 +18,7 @@ #include "llvm/MC/MCSectionCOFF.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCValue.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; using namespace dwarf;