summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-11-09 09:46:08 +0000
committerbors <bors@rust-lang.org>2024-11-09 09:46:08 +0000
commit4b198d6871e4a3826f01f7d6111b1c3484853cd8 (patch)
treea796beedb02951ec128f5c1a54c252096ce02911 /compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
parent62bb2ac03e775110d2c889f5d4a01a71e7334ff0 (diff)
parent920d2774ac92b102dedf07d04d5fd80214881699 (diff)
downloadrust-4b198d6871e4a3826f01f7d6111b1c3484853cd8.tar.gz
rust-4b198d6871e4a3826f01f7d6111b1c3484853cd8.zip
Auto merge of #132584 - Zalathar:includes, r=cuviper
Trim and tidy includes in `rustc_llvm`

These includes tend to accumulate over time, and are usually only removed when something breaks in a new LLVM version, so it's nice to clean them up manually once in a while.

General strategy used for this PR:
- Remove all includes from `LLVMWrapper.h` that aren't needed by the header itself, transplanting them to individual source files as necessary.
- For each source file, temporarily remove each include if doing so doesn't cause a compile error.
- If a “required” include looks like it shouldn't be needed, try replacing it with its sub-includes, then trim that list.
- After doing all of the above, go back and re-add any removed include if the file does actually use things defined in that header, even if the header happens to also be included by something else.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h98
1 files changed, 9 insertions, 89 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
index 76f7d054040..f6598f9faf5 100644
--- a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
+++ b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
@@ -1,31 +1,12 @@
+#ifndef INCLUDED_RUSTC_LLVM_LLVMWRAPPER_H
+#define INCLUDED_RUSTC_LLVM_LLVMWRAPPER_H
+
 #include "SuppressLLVMWarnings.h"
 
-#include "llvm-c/BitReader.h"
-#include "llvm-c/Core.h"
-#include "llvm-c/Object.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Analysis/Lint.h"
-#include "llvm/Analysis/Passes.h"
-#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/InlineAsm.h"
-#include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/Module.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/DynamicLibrary.h"
-#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/JSON.h"
-#include "llvm/Support/Memory.h"
-#include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/TargetSelect.h"
-#include "llvm/Support/Timer.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetOptions.h"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/Transforms/Scalar.h"
+#include "llvm/Config/llvm-config.h"  // LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR
+#include "llvm/Support/raw_ostream.h" // llvm::raw_ostream
+#include <cstddef>                    // size_t etc
+#include <cstdint>                    // uint64_t etc
 
 #define LLVM_VERSION_GE(major, minor)                                          \
   (LLVM_VERSION_MAJOR > (major) ||                                             \
@@ -33,73 +14,10 @@
 
 #define LLVM_VERSION_LT(major, minor) (!LLVM_VERSION_GE((major), (minor)))
 
-#if LLVM_VERSION_GE(20, 0)
-#include "llvm/Transforms/Utils/Instrumentation.h"
-#else
-#include "llvm/Transforms/Instrumentation.h"
-#endif
-
-#include "llvm/IR/LegacyPassManager.h"
-
-#include "llvm/Bitcode/BitcodeReader.h"
-#include "llvm/Bitcode/BitcodeWriter.h"
-
-#include "llvm/IR/DIBuilder.h"
-#include "llvm/IR/DebugInfo.h"
-#include "llvm/IR/IRPrintingPasses.h"
-#include "llvm/Linker/Linker.h"
-
-#include "llvm/TargetParser/Triple.h"
-
 extern "C" void LLVMRustSetLastError(const char *);
 
 enum class LLVMRustResult { Success, Failure };
 
-enum LLVMRustAttribute {
-  AlwaysInline = 0,
-  ByVal = 1,
-  Cold = 2,
-  InlineHint = 3,
-  MinSize = 4,
-  Naked = 5,
-  NoAlias = 6,
-  NoCapture = 7,
-  NoInline = 8,
-  NonNull = 9,
-  NoRedZone = 10,
-  NoReturn = 11,
-  NoUnwind = 12,
-  OptimizeForSize = 13,
-  ReadOnly = 14,
-  SExt = 15,
-  StructRet = 16,
-  UWTable = 17,
-  ZExt = 18,
-  InReg = 19,
-  SanitizeThread = 20,
-  SanitizeAddress = 21,
-  SanitizeMemory = 22,
-  NonLazyBind = 23,
-  OptimizeNone = 24,
-  ReadNone = 26,
-  SanitizeHWAddress = 28,
-  WillReturn = 29,
-  StackProtectReq = 30,
-  StackProtectStrong = 31,
-  StackProtect = 32,
-  NoUndef = 33,
-  SanitizeMemTag = 34,
-  NoCfCheck = 35,
-  ShadowCallStack = 36,
-  AllocSize = 37,
-  AllocatedPointer = 38,
-  AllocAlign = 39,
-  SanitizeSafeStack = 40,
-  FnRetThunkExtern = 41,
-  Writable = 42,
-  DeadOnUnwind = 43,
-};
-
 typedef struct OpaqueRustString *RustStringRef;
 typedef struct LLVMOpaqueTwine *LLVMTwineRef;
 typedef struct LLVMOpaqueSMDiagnostic *LLVMSMDiagnosticRef;
@@ -127,3 +45,5 @@ public:
     flush();
   }
 };
+
+#endif // INCLUDED_RUSTC_LLVM_LLVMWRAPPER_H