summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorDianQK <dianqk@dianqk.net>2024-06-04 22:46:20 +0800
committerDianQK <dianqk@dianqk.net>2024-06-26 20:18:49 +0800
commite17c16d55b20b9d2702fafa017263406d1e94042 (patch)
tree6eedc6d087162fe5b3565a634c38ac66cd8285a9 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentde0ece2f2935d005232a5062eeb8b916b1d8a41a (diff)
downloadrust-e17c16d55b20b9d2702fafa017263406d1e94042.tar.gz
rust-e17c16d55b20b9d2702fafa017263406d1e94042.zip
Format C++ files in `llvm-wrapper`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp1027
1 files changed, 497 insertions, 530 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 20167a4b45e..b6790b7df50 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -1,5 +1,6 @@
 #include "LLVMWrapper.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/DiagnosticHandler.h"
 #include "llvm/IR/DiagnosticInfo.h"
@@ -11,17 +12,16 @@
 #include "llvm/IR/LLVMRemarkStreamer.h"
 #include "llvm/IR/Mangler.h"
 #include "llvm/IR/Value.h"
-#include "llvm/Remarks/RemarkStreamer.h"
-#include "llvm/Remarks/RemarkSerializer.h"
-#include "llvm/Remarks/RemarkFormat.h"
-#include "llvm/Support/ToolOutputFile.h"
-#include "llvm/Support/ModRef.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/COFFImportFile.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Pass.h"
-#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/Remarks/RemarkFormat.h"
+#include "llvm/Remarks/RemarkSerializer.h"
+#include "llvm/Remarks/RemarkStreamer.h"
+#include "llvm/Support/ModRef.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ToolOutputFile.h"
 
 #include <iostream>
 
@@ -71,12 +71,12 @@ static LLVM_THREAD_LOCAL char *LastError;
 // Custom error handler for fatal LLVM errors.
 //
 // Notably it exits the process with code 101, unlike LLVM's default of 1.
-static void FatalErrorHandler(void *UserData,
-                              const char* Reason,
+static void FatalErrorHandler(void *UserData, const char *Reason,
                               bool GenCrashDiag) {
   // Once upon a time we emitted "LLVM ERROR:" specifically to mimic LLVM. Then,
-  // we developed crater and other tools which only expose logs, not error codes.
-  // Use a more greppable prefix that will still match the "LLVM ERROR:" prefix.
+  // we developed crater and other tools which only expose logs, not error
+  // codes. Use a more greppable prefix that will still match the "LLVM ERROR:"
+  // prefix.
   std::cerr << "rustc-LLVM ERROR: " << Reason << std::endl;
 
   // Since this error handler exits the process, we have to run any cleanup that
@@ -99,8 +99,7 @@ static void FatalErrorHandler(void *UserData,
 //
 // It aborts the process without any further allocations, similar to LLVM's
 // default except that may be configured to `throw std::bad_alloc()` instead.
-static void BadAllocErrorHandler(void *UserData,
-                                 const char* Reason,
+static void BadAllocErrorHandler(void *UserData, const char *Reason,
                                  bool GenCrashDiag) {
   const char *OOM = "rustc-LLVM ERROR: out of memory\n";
   (void)!::write(2, OOM, strlen(OOM));
@@ -190,7 +189,8 @@ static CallInst::TailCallKind fromRust(LLVMRustTailCallKind Kind) {
   }
 }
 
-extern "C" void LLVMRustSetTailCallKind(LLVMValueRef Call, LLVMRustTailCallKind TCK) {
+extern "C" void LLVMRustSetTailCallKind(LLVMValueRef Call,
+                                        LLVMRustTailCallKind TCK) {
   unwrap<CallInst>(Call)->setTailCallKind(fromRust(TCK));
 }
 
@@ -201,12 +201,13 @@ extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M,
   return wrap(unwrap(M)
                   ->getOrInsertFunction(StringRef(Name, NameLen),
                                         unwrap<FunctionType>(FunctionTy))
-                  .getCallee()
-  );
+                  .getCallee());
 }
 
-extern "C" LLVMValueRef
-LLVMRustGetOrInsertGlobal(LLVMModuleRef M, const char *Name, size_t NameLen, LLVMTypeRef Ty) {
+extern "C" LLVMValueRef LLVMRustGetOrInsertGlobal(LLVMModuleRef M,
+                                                  const char *Name,
+                                                  size_t NameLen,
+                                                  LLVMTypeRef Ty) {
   Module *Mod = unwrap(M);
   auto NameRef = StringRef(Name, NameLen);
 
@@ -221,13 +222,10 @@ LLVMRustGetOrInsertGlobal(LLVMModuleRef M, const char *Name, size_t NameLen, LLV
   return wrap(GV);
 }
 
-extern "C" LLVMValueRef
-LLVMRustInsertPrivateGlobal(LLVMModuleRef M, LLVMTypeRef Ty) {
-  return wrap(new GlobalVariable(*unwrap(M),
-                                 unwrap(Ty),
-                                 false,
-                                 GlobalValue::PrivateLinkage,
-                                 nullptr));
+extern "C" LLVMValueRef LLVMRustInsertPrivateGlobal(LLVMModuleRef M,
+                                                    LLVMTypeRef Ty) {
+  return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
+                                 GlobalValue::PrivateLinkage, nullptr));
 }
 
 static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
@@ -326,8 +324,9 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
   report_fatal_error("bad AttributeKind");
 }
 
-template<typename T> static inline void AddAttributes(T *t, unsigned Index,
-                                                      LLVMAttributeRef *Attrs, size_t AttrsLen) {
+template <typename T>
+static inline void AddAttributes(T *t, unsigned Index, LLVMAttributeRef *Attrs,
+                                 size_t AttrsLen) {
   AttributeList PAL = t->getAttributes();
   auto B = AttrBuilder(t->getContext());
   for (LLVMAttributeRef Attr : ArrayRef<LLVMAttributeRef>(Attrs, AttrsLen))
@@ -337,19 +336,22 @@ template<typename T> static inline void AddAttributes(T *t, unsigned Index,
 }
 
 extern "C" void LLVMRustAddFunctionAttributes(LLVMValueRef Fn, unsigned Index,
-                                              LLVMAttributeRef *Attrs, size_t AttrsLen) {
+                                              LLVMAttributeRef *Attrs,
+                                              size_t AttrsLen) {
   Function *F = unwrap<Function>(Fn);
   AddAttributes(F, Index, Attrs, AttrsLen);
 }
 
-extern "C" void LLVMRustAddCallSiteAttributes(LLVMValueRef Instr, unsigned Index,
-                                              LLVMAttributeRef *Attrs, size_t AttrsLen) {
+extern "C" void LLVMRustAddCallSiteAttributes(LLVMValueRef Instr,
+                                              unsigned Index,
+                                              LLVMAttributeRef *Attrs,
+                                              size_t AttrsLen) {
   CallBase *Call = unwrap<CallBase>(Instr);
   AddAttributes(Call, Index, Attrs, AttrsLen);
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateAttrNoValue(LLVMContextRef C,
-                                                      LLVMRustAttribute RustAttr) {
+extern "C" LLVMAttributeRef
+LLVMRustCreateAttrNoValue(LLVMContextRef C, LLVMRustAttribute RustAttr) {
   return wrap(Attribute::get(*unwrap(C), fromRust(RustAttr)));
 }
 
@@ -363,30 +365,36 @@ extern "C" LLVMAttributeRef LLVMRustCreateDereferenceableAttr(LLVMContextRef C,
   return wrap(Attribute::getWithDereferenceableBytes(*unwrap(C), Bytes));
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateDereferenceableOrNullAttr(LLVMContextRef C,
-                                                                    uint64_t Bytes) {
+extern "C" LLVMAttributeRef
+LLVMRustCreateDereferenceableOrNullAttr(LLVMContextRef C, uint64_t Bytes) {
   return wrap(Attribute::getWithDereferenceableOrNullBytes(*unwrap(C), Bytes));
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateByValAttr(LLVMContextRef C, LLVMTypeRef Ty) {
+extern "C" LLVMAttributeRef LLVMRustCreateByValAttr(LLVMContextRef C,
+                                                    LLVMTypeRef Ty) {
   return wrap(Attribute::getWithByValType(*unwrap(C), unwrap(Ty)));
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateStructRetAttr(LLVMContextRef C, LLVMTypeRef Ty) {
+extern "C" LLVMAttributeRef LLVMRustCreateStructRetAttr(LLVMContextRef C,
+                                                        LLVMTypeRef Ty) {
   return wrap(Attribute::getWithStructRetType(*unwrap(C), unwrap(Ty)));
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateElementTypeAttr(LLVMContextRef C, LLVMTypeRef Ty) {
+extern "C" LLVMAttributeRef LLVMRustCreateElementTypeAttr(LLVMContextRef C,
+                                                          LLVMTypeRef Ty) {
   return wrap(Attribute::get(*unwrap(C), Attribute::ElementType, unwrap(Ty)));
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Async) {
+extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C,
+                                                      bool Async) {
   return wrap(Attribute::getWithUWTableKind(
       *unwrap(C), Async ? UWTableKind::Async : UWTableKind::Sync));
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) {
-  return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg, std::nullopt));
+extern "C" LLVMAttributeRef
+LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) {
+  return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg,
+                                              std::nullopt));
 }
 
 // These values **must** match ffi::AllocKindFlags.
@@ -403,12 +411,15 @@ enum class LLVMRustAllocKindFlags : uint64_t {
   Aligned = 1 << 5,
 };
 
-static LLVMRustAllocKindFlags operator&(LLVMRustAllocKindFlags A, LLVMRustAllocKindFlags B) {
+static LLVMRustAllocKindFlags operator&(LLVMRustAllocKindFlags A,
+                                        LLVMRustAllocKindFlags B) {
   return static_cast<LLVMRustAllocKindFlags>(static_cast<uint64_t>(A) &
-                                      static_cast<uint64_t>(B));
+                                             static_cast<uint64_t>(B));
 }
 
-static bool isSet(LLVMRustAllocKindFlags F) { return F != LLVMRustAllocKindFlags::Unknown; }
+static bool isSet(LLVMRustAllocKindFlags F) {
+  return F != LLVMRustAllocKindFlags::Unknown;
+}
 
 static llvm::AllocFnKind allocKindFromRust(LLVMRustAllocKindFlags F) {
   llvm::AllocFnKind AFK = llvm::AllocFnKind::Unknown;
@@ -433,40 +444,47 @@ static llvm::AllocFnKind allocKindFromRust(LLVMRustAllocKindFlags F) {
   return AFK;
 }
 
-extern "C" LLVMAttributeRef LLVMRustCreateAllocKindAttr(LLVMContextRef C, uint64_t AllocKindArg) {
-  return wrap(Attribute::get(*unwrap(C), Attribute::AllocKind,
-      static_cast<uint64_t>(allocKindFromRust(static_cast<LLVMRustAllocKindFlags>(AllocKindArg)))));
+extern "C" LLVMAttributeRef LLVMRustCreateAllocKindAttr(LLVMContextRef C,
+                                                        uint64_t AllocKindArg) {
+  return wrap(
+      Attribute::get(*unwrap(C), Attribute::AllocKind,
+                     static_cast<uint64_t>(allocKindFromRust(
+                         static_cast<LLVMRustAllocKindFlags>(AllocKindArg)))));
 }
 
 // Simplified representation of `MemoryEffects` across the FFI boundary.
 //
-// Each variant corresponds to one of the static factory methods on `MemoryEffects`.
+// Each variant corresponds to one of the static factory methods on
+// `MemoryEffects`.
 enum class LLVMRustMemoryEffects {
   None,
   ReadOnly,
   InaccessibleMemOnly,
 };
 
-extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
-                                                            LLVMRustMemoryEffects Effects) {
+extern "C" LLVMAttributeRef
+LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
+                                LLVMRustMemoryEffects Effects) {
   switch (Effects) {
-    case LLVMRustMemoryEffects::None:
-      return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::none()));
-    case LLVMRustMemoryEffects::ReadOnly:
-      return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::readOnly()));
-    case LLVMRustMemoryEffects::InaccessibleMemOnly:
-      return wrap(Attribute::getWithMemoryEffects(*unwrap(C),
-                                                  MemoryEffects::inaccessibleMemOnly()));
-    default:
-      report_fatal_error("bad MemoryEffects.");
-  }
-}
-
-// Enable all fast-math flags, including those which will cause floating-point operations
-// to return poison for some well-defined inputs. This function can only be used to build
-// unsafe Rust intrinsics. That unsafety does permit additional optimizations, but at the
-// time of writing, their value is not well-understood relative to those enabled by
-// LLVMRustSetAlgebraicMath.
+  case LLVMRustMemoryEffects::None:
+    return wrap(
+        Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::none()));
+  case LLVMRustMemoryEffects::ReadOnly:
+    return wrap(
+        Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::readOnly()));
+  case LLVMRustMemoryEffects::InaccessibleMemOnly:
+    return wrap(Attribute::getWithMemoryEffects(
+        *unwrap(C), MemoryEffects::inaccessibleMemOnly()));
+  default:
+    report_fatal_error("bad MemoryEffects.");
+  }
+}
+
+// Enable all fast-math flags, including those which will cause floating-point
+// operations to return poison for some well-defined inputs. This function can
+// only be used to build unsafe Rust intrinsics. That unsafety does permit
+// additional optimizations, but at the time of writing, their value is not
+// well-understood relative to those enabled by LLVMRustSetAlgebraicMath.
 //
 // https://llvm.org/docs/LangRef.html#fast-math-flags
 extern "C" void LLVMRustSetFastMath(LLVMValueRef V) {
@@ -475,14 +493,12 @@ extern "C" void LLVMRustSetFastMath(LLVMValueRef V) {
   }
 }
 
-// Enable fast-math flags which permit algebraic transformations that are not allowed by
-// IEEE floating point. For example:
-// a + (b + c) = (a + b) + c
-// and
-// a / b = a * (1 / b)
-// Note that this does NOT enable any flags which can cause a floating-point operation on
-// well-defined inputs to return poison, and therefore this function can be used to build
-// safe Rust intrinsics (such as fadd_algebraic).
+// Enable fast-math flags which permit algebraic transformations that are not
+// allowed by IEEE floating point. For example: a + (b + c) = (a + b) + c and a
+// / b = a * (1 / b) Note that this does NOT enable any flags which can cause a
+// floating-point operation on well-defined inputs to return poison, and
+// therefore this function can be used to build safe Rust intrinsics (such as
+// fadd_algebraic).
 //
 // https://llvm.org/docs/LangRef.html#fast-math-flags
 extern "C" void LLVMRustSetAlgebraicMath(LLVMValueRef V) {
@@ -497,9 +513,9 @@ extern "C" void LLVMRustSetAlgebraicMath(LLVMValueRef V) {
 // Enable the reassoc fast-math flag, allowing transformations that pretend
 // floating-point addition and multiplication are associative.
 //
-// Note that this does NOT enable any flags which can cause a floating-point operation on
-// well-defined inputs to return poison, and therefore this function can be used to build
-// safe Rust intrinsics (such as fadd_algebraic).
+// Note that this does NOT enable any flags which can cause a floating-point
+// operation on well-defined inputs to return poison, and therefore this
+// function can be used to build safe Rust intrinsics (such as fadd_algebraic).
 //
 // https://llvm.org/docs/LangRef.html#fast-math-flags
 extern "C" void LLVMRustSetAllowReassoc(LLVMValueRef V) {
@@ -547,11 +563,10 @@ LLVMRustInlineAsm(LLVMTypeRef Ty, char *AsmString, size_t AsmStringLen,
                   char *Constraints, size_t ConstraintsLen,
                   LLVMBool HasSideEffects, LLVMBool IsAlignStack,
                   LLVMRustAsmDialect Dialect, LLVMBool CanThrow) {
-  return wrap(InlineAsm::get(unwrap<FunctionType>(Ty),
-                             StringRef(AsmString, AsmStringLen),
-                             StringRef(Constraints, ConstraintsLen),
-                             HasSideEffects, IsAlignStack,
-                             fromRust(Dialect), CanThrow));
+  return wrap(InlineAsm::get(
+      unwrap<FunctionType>(Ty), StringRef(AsmString, AsmStringLen),
+      StringRef(Constraints, ConstraintsLen), HasSideEffects, IsAlignStack,
+      fromRust(Dialect), CanThrow));
 }
 
 extern "C" bool LLVMRustInlineAsmVerify(LLVMTypeRef Ty, char *Constraints,
@@ -705,19 +720,22 @@ enum class LLVMRustDISPFlags : uint32_t {
 
 inline LLVMRustDISPFlags operator&(LLVMRustDISPFlags A, LLVMRustDISPFlags B) {
   return static_cast<LLVMRustDISPFlags>(static_cast<uint32_t>(A) &
-                                      static_cast<uint32_t>(B));
+                                        static_cast<uint32_t>(B));
 }
 
 inline LLVMRustDISPFlags operator|(LLVMRustDISPFlags A, LLVMRustDISPFlags B) {
   return static_cast<LLVMRustDISPFlags>(static_cast<uint32_t>(A) |
-                                      static_cast<uint32_t>(B));
+                                        static_cast<uint32_t>(B));
 }
 
-inline LLVMRustDISPFlags &operator|=(LLVMRustDISPFlags &A, LLVMRustDISPFlags B) {
+inline LLVMRustDISPFlags &operator|=(LLVMRustDISPFlags &A,
+                                     LLVMRustDISPFlags B) {
   return A = A | B;
 }
 
-inline bool isSet(LLVMRustDISPFlags F) { return F != LLVMRustDISPFlags::SPFlagZero; }
+inline bool isSet(LLVMRustDISPFlags F) {
+  return F != LLVMRustDISPFlags::SPFlagZero;
+}
 
 inline LLVMRustDISPFlags virtuality(LLVMRustDISPFlags F) {
   return static_cast<LLVMRustDISPFlags>(static_cast<uint32_t>(F) & 0x3);
@@ -761,7 +779,8 @@ enum class LLVMRustDebugEmissionKind {
   DebugDirectivesOnly,
 };
 
-static DICompileUnit::DebugEmissionKind fromRust(LLVMRustDebugEmissionKind Kind) {
+static DICompileUnit::DebugEmissionKind
+fromRust(LLVMRustDebugEmissionKind Kind) {
   switch (Kind) {
   case LLVMRustDebugEmissionKind::NoDebug:
     return DICompileUnit::DebugEmissionKind::NoDebug;
@@ -777,12 +796,13 @@ static DICompileUnit::DebugEmissionKind fromRust(LLVMRustDebugEmissionKind Kind)
 }
 
 enum class LLVMRustDebugNameTableKind {
-    Default,
-    GNU,
-    None,
+  Default,
+  GNU,
+  None,
 };
 
-static DICompileUnit::DebugNameTableKind fromRust(LLVMRustDebugNameTableKind Kind) {
+static DICompileUnit::DebugNameTableKind
+fromRust(LLVMRustDebugNameTableKind Kind) {
   switch (Kind) {
   case LLVMRustDebugNameTableKind::Default:
     return DICompileUnit::DebugNameTableKind::Default;
@@ -827,22 +847,18 @@ extern "C" uint32_t LLVMRustVersionMinor() { return LLVM_VERSION_MINOR; }
 
 extern "C" uint32_t LLVMRustVersionMajor() { return LLVM_VERSION_MAJOR; }
 
-extern "C" void LLVMRustAddModuleFlagU32(
-    LLVMModuleRef M,
-    Module::ModFlagBehavior MergeBehavior,
-    const char *Name,
-    uint32_t Value) {
+extern "C" void LLVMRustAddModuleFlagU32(LLVMModuleRef M,
+                                         Module::ModFlagBehavior MergeBehavior,
+                                         const char *Name, uint32_t Value) {
   unwrap(M)->addModuleFlag(MergeBehavior, Name, Value);
 }
 
 extern "C" void LLVMRustAddModuleFlagString(
-    LLVMModuleRef M,
-    Module::ModFlagBehavior MergeBehavior,
-    const char *Name,
-    const char *Value,
-    size_t ValueLen) {
-  unwrap(M)->addModuleFlag(MergeBehavior, Name,
-    MDString::get(unwrap(M)->getContext(), StringRef(Value, ValueLen)));
+    LLVMModuleRef M, Module::ModFlagBehavior MergeBehavior, const char *Name,
+    const char *Value, size_t ValueLen) {
+  unwrap(M)->addModuleFlag(
+      MergeBehavior, Name,
+      MDString::get(unwrap(M)->getContext(), StringRef(Value, ValueLen)));
 }
 
 extern "C" bool LLVMRustHasModuleFlag(LLVMModuleRef M, const char *Name,
@@ -850,8 +866,8 @@ extern "C" bool LLVMRustHasModuleFlag(LLVMModuleRef M, const char *Name,
   return unwrap(M)->getModuleFlag(StringRef(Name, Len)) != nullptr;
 }
 
-extern "C" void LLVMRustGlobalAddMetadata(
-    LLVMValueRef Global, unsigned Kind, LLVMMetadataRef MD) {
+extern "C" void LLVMRustGlobalAddMetadata(LLVMValueRef Global, unsigned Kind,
+                                          LLVMMetadataRef MD) {
   unwrap<GlobalObject>(Global)->addMetadata(Kind, *unwrap<MDNode>(MD));
 }
 
@@ -870,33 +886,29 @@ extern "C" void LLVMRustDIBuilderFinalize(LLVMRustDIBuilderRef Builder) {
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
     LLVMRustDIBuilderRef Builder, unsigned Lang, LLVMMetadataRef FileRef,
     const char *Producer, size_t ProducerLen, bool isOptimized,
-    const char *Flags, unsigned RuntimeVer,
-    const char *SplitName, size_t SplitNameLen,
-    LLVMRustDebugEmissionKind Kind,
-    uint64_t DWOId, bool SplitDebugInlining,
-    LLVMRustDebugNameTableKind TableKind) {
+    const char *Flags, unsigned RuntimeVer, const char *SplitName,
+    size_t SplitNameLen, LLVMRustDebugEmissionKind Kind, uint64_t DWOId,
+    bool SplitDebugInlining, LLVMRustDebugNameTableKind TableKind) {
   auto *File = unwrapDI<DIFile>(FileRef);
 
-  return wrap(Builder->createCompileUnit(Lang, File, StringRef(Producer, ProducerLen),
-                                         isOptimized, Flags, RuntimeVer,
-                                         StringRef(SplitName, SplitNameLen),
-                                         fromRust(Kind), DWOId, SplitDebugInlining,
-                                         false, fromRust(TableKind)));
+  return wrap(Builder->createCompileUnit(
+      Lang, File, StringRef(Producer, ProducerLen), isOptimized, Flags,
+      RuntimeVer, StringRef(SplitName, SplitNameLen), fromRust(Kind), DWOId,
+      SplitDebugInlining, false, fromRust(TableKind)));
 }
 
-extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(
-    LLVMRustDIBuilderRef Builder,
-    const char *Filename, size_t FilenameLen,
-    const char *Directory, size_t DirectoryLen, LLVMRustChecksumKind CSKind,
-    const char *Checksum, size_t ChecksumLen) {
+extern "C" LLVMMetadataRef
+LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
+                            size_t FilenameLen, const char *Directory,
+                            size_t DirectoryLen, LLVMRustChecksumKind CSKind,
+                            const char *Checksum, size_t ChecksumLen) {
 
   std::optional<DIFile::ChecksumKind> llvmCSKind = fromRust(CSKind);
   std::optional<DIFile::ChecksumInfo<StringRef>> CSInfo{};
   if (llvmCSKind)
     CSInfo.emplace(*llvmCSKind, StringRef{Checksum, ChecksumLen});
   return wrap(Builder->createFile(StringRef(Filename, FilenameLen),
-                                  StringRef(Directory, DirectoryLen),
-                                  CSInfo));
+                                  StringRef(Directory, DirectoryLen), CSInfo));
 }
 
 extern "C" LLVMMetadataRef
@@ -907,63 +919,59 @@ LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    const char *LinkageName, size_t LinkageNameLen,
-    LLVMMetadataRef File, unsigned LineNo,
-    LLVMMetadataRef Ty, unsigned ScopeLine, LLVMRustDIFlags Flags,
-    LLVMRustDISPFlags SPFlags, LLVMValueRef MaybeFn, LLVMMetadataRef TParam,
-    LLVMMetadataRef Decl) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
+    LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
+    unsigned ScopeLine, LLVMRustDIFlags Flags, LLVMRustDISPFlags SPFlags,
+    LLVMValueRef MaybeFn, LLVMMetadataRef TParam, LLVMMetadataRef Decl) {
   DITemplateParameterArray TParams =
       DITemplateParameterArray(unwrap<MDTuple>(TParam));
   DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags);
   DINode::DIFlags llvmFlags = fromRust(Flags);
   DISubprogram *Sub = Builder->createFunction(
-      unwrapDI<DIScope>(Scope),
-      StringRef(Name, NameLen),
-      StringRef(LinkageName, LinkageNameLen),
-      unwrapDI<DIFile>(File), LineNo,
-      unwrapDI<DISubroutineType>(Ty), ScopeLine, llvmFlags,
-      llvmSPFlags, TParams, unwrapDIPtr<DISubprogram>(Decl));
+      unwrapDI<DIScope>(Scope), StringRef(Name, NameLen),
+      StringRef(LinkageName, LinkageNameLen), unwrapDI<DIFile>(File), LineNo,
+      unwrapDI<DISubroutineType>(Ty), ScopeLine, llvmFlags, llvmSPFlags,
+      TParams, unwrapDIPtr<DISubprogram>(Decl));
   if (MaybeFn)
     unwrap<Function>(MaybeFn)->setSubprogram(Sub);
   return wrap(Sub);
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMethod(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    const char *LinkageName, size_t LinkageNameLen,
-    LLVMMetadataRef File, unsigned LineNo,
-    LLVMMetadataRef Ty, LLVMRustDIFlags Flags,
-    LLVMRustDISPFlags SPFlags, LLVMMetadataRef TParam) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
+    LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
+    LLVMRustDIFlags Flags, LLVMRustDISPFlags SPFlags, LLVMMetadataRef TParam) {
   DITemplateParameterArray TParams =
       DITemplateParameterArray(unwrap<MDTuple>(TParam));
   DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags);
   DINode::DIFlags llvmFlags = fromRust(Flags);
   DISubprogram *Sub = Builder->createMethod(
-      unwrapDI<DIScope>(Scope),
-      StringRef(Name, NameLen),
-      StringRef(LinkageName, LinkageNameLen),
-      unwrapDI<DIFile>(File), LineNo,
-      unwrapDI<DISubroutineType>(Ty),
-      0, 0, nullptr, // VTable params aren't used
+      unwrapDI<DIScope>(Scope), StringRef(Name, NameLen),
+      StringRef(LinkageName, LinkageNameLen), unwrapDI<DIFile>(File), LineNo,
+      unwrapDI<DISubroutineType>(Ty), 0, 0,
+      nullptr, // VTable params aren't used
       llvmFlags, llvmSPFlags, TParams);
   return wrap(Sub);
 }
 
-extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType(
-    LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
-    uint64_t SizeInBits, unsigned Encoding) {
-  return wrap(Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding));
+extern "C" LLVMMetadataRef
+LLVMRustDIBuilderCreateBasicType(LLVMRustDIBuilderRef Builder, const char *Name,
+                                 size_t NameLen, uint64_t SizeInBits,
+                                 unsigned Encoding) {
+  return wrap(
+      Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding));
 }
 
-extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTypedef(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Scope) {
+extern "C" LLVMMetadataRef
+LLVMRustDIBuilderCreateTypedef(LLVMRustDIBuilderRef Builder,
+                               LLVMMetadataRef Type, const char *Name,
+                               size_t NameLen, LLVMMetadataRef File,
+                               unsigned LineNo, LLVMMetadataRef Scope) {
   return wrap(Builder->createTypedef(
-    unwrap<DIType>(Type), StringRef(Name, NameLen), unwrap<DIFile>(File),
-    LineNo, unwrapDIPtr<DIScope>(Scope)));
+      unwrap<DIType>(Type), StringRef(Name, NameLen), unwrap<DIFile>(File),
+      LineNo, unwrapDIPtr<DIScope>(Scope)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreatePointerType(
@@ -971,118 +979,98 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreatePointerType(
     uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace,
     const char *Name, size_t NameLen) {
   return wrap(Builder->createPointerType(unwrapDI<DIType>(PointeeTy),
-                                         SizeInBits, AlignInBits,
-                                         AddressSpace,
+                                         SizeInBits, AlignInBits, AddressSpace,
                                          StringRef(Name, NameLen)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStructType(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
-    uint32_t AlignInBits, LLVMRustDIFlags Flags,
-    LLVMMetadataRef DerivedFrom, LLVMMetadataRef Elements,
-    unsigned RunTimeLang, LLVMMetadataRef VTableHolder,
-    const char *UniqueId, size_t UniqueIdLen) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+    uint64_t SizeInBits, uint32_t AlignInBits, LLVMRustDIFlags Flags,
+    LLVMMetadataRef DerivedFrom, LLVMMetadataRef Elements, unsigned RunTimeLang,
+    LLVMMetadataRef VTableHolder, const char *UniqueId, size_t UniqueIdLen) {
   return wrap(Builder->createStructType(
       unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
-      unwrapDI<DIFile>(File), LineNumber,
-      SizeInBits, AlignInBits, fromRust(Flags), unwrapDI<DIType>(DerivedFrom),
+      unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
+      fromRust(Flags), unwrapDI<DIType>(DerivedFrom),
       DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
       unwrapDI<DIType>(VTableHolder), StringRef(UniqueId, UniqueIdLen)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
-    uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Discriminator,
-    LLVMMetadataRef Elements, const char *UniqueId, size_t UniqueIdLen) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+    uint64_t SizeInBits, uint32_t AlignInBits, LLVMRustDIFlags Flags,
+    LLVMMetadataRef Discriminator, LLVMMetadataRef Elements,
+    const char *UniqueId, size_t UniqueIdLen) {
   return wrap(Builder->createVariantPart(
       unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
-      unwrapDI<DIFile>(File), LineNumber,
-      SizeInBits, AlignInBits, fromRust(Flags), unwrapDI<DIDerivedType>(Discriminator),
-      DINodeArray(unwrapDI<MDTuple>(Elements)), StringRef(UniqueId, UniqueIdLen)));
+      unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
+      fromRust(Flags), unwrapDI<DIDerivedType>(Discriminator),
+      DINodeArray(unwrapDI<MDTuple>(Elements)),
+      StringRef(UniqueId, UniqueIdLen)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMemberType(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
     uint32_t AlignInBits, uint64_t OffsetInBits, LLVMRustDIFlags Flags,
     LLVMMetadataRef Ty) {
-  return wrap(Builder->createMemberType(unwrapDI<DIDescriptor>(Scope),
-                                        StringRef(Name, NameLen),
-                                        unwrapDI<DIFile>(File), LineNo,
-                                        SizeInBits, AlignInBits, OffsetInBits,
-                                        fromRust(Flags), unwrapDI<DIType>(Ty)));
+  return wrap(Builder->createMemberType(
+      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
+      unwrapDI<DIFile>(File), LineNo, SizeInBits, AlignInBits, OffsetInBits,
+      fromRust(Flags), unwrapDI<DIType>(Ty)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo,
-    uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant,
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
+    uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant,
     LLVMRustDIFlags Flags, LLVMMetadataRef Ty) {
-  llvm::ConstantInt* D = nullptr;
+  llvm::ConstantInt *D = nullptr;
   if (Discriminant) {
     D = unwrap<llvm::ConstantInt>(Discriminant);
   }
-  return wrap(Builder->createVariantMemberType(unwrapDI<DIDescriptor>(Scope),
-                                               StringRef(Name, NameLen),
-                                               unwrapDI<DIFile>(File), LineNo,
-                                               SizeInBits, AlignInBits, OffsetInBits, D,
-                                               fromRust(Flags), unwrapDI<DIType>(Ty)));
+  return wrap(Builder->createVariantMemberType(
+      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
+      unwrapDI<DIFile>(File), LineNo, SizeInBits, AlignInBits, OffsetInBits, D,
+      fromRust(Flags), unwrapDI<DIType>(Ty)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticMemberType(
-    LLVMRustDIBuilderRef Builder,
-    LLVMMetadataRef Scope,
-    const char *Name,
-    size_t NameLen,
-    LLVMMetadataRef File,
-    unsigned LineNo,
-    LLVMMetadataRef Ty,
-    LLVMRustDIFlags Flags,
-    LLVMValueRef val,
-    uint32_t AlignInBits
-) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
+    LLVMRustDIFlags Flags, LLVMValueRef val, uint32_t AlignInBits) {
   return wrap(Builder->createStaticMemberType(
-    unwrapDI<DIDescriptor>(Scope),
-    StringRef(Name, NameLen),
-    unwrapDI<DIFile>(File),
-    LineNo,
-    unwrapDI<DIType>(Ty),
-    fromRust(Flags),
-    unwrap<llvm::ConstantInt>(val),
+      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
+      unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), fromRust(Flags),
+      unwrap<llvm::ConstantInt>(val),
 #if LLVM_VERSION_GE(18, 0)
-    llvm::dwarf::DW_TAG_member,
+      llvm::dwarf::DW_TAG_member,
 #endif
-    AlignInBits
-  ));
+      AlignInBits));
 }
 
-extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateLexicalBlock(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    LLVMMetadataRef File, unsigned Line, unsigned Col) {
+extern "C" LLVMMetadataRef
+LLVMRustDIBuilderCreateLexicalBlock(LLVMRustDIBuilderRef Builder,
+                                    LLVMMetadataRef Scope, LLVMMetadataRef File,
+                                    unsigned Line, unsigned Col) {
   return wrap(Builder->createLexicalBlock(unwrapDI<DIDescriptor>(Scope),
                                           unwrapDI<DIFile>(File), Line, Col));
 }
 
-extern "C" LLVMMetadataRef
-LLVMRustDIBuilderCreateLexicalBlockFile(LLVMRustDIBuilderRef Builder,
-                                        LLVMMetadataRef Scope,
-                                        LLVMMetadataRef File) {
+extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateLexicalBlockFile(
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File) {
   return wrap(Builder->createLexicalBlockFile(unwrapDI<DIDescriptor>(Scope),
                                               unwrapDI<DIFile>(File)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Context,
-    const char *Name, size_t NameLen,
-    const char *LinkageName, size_t LinkageNameLen,
-    LLVMMetadataRef File, unsigned LineNo,
-    LLVMMetadataRef Ty, bool IsLocalToUnit, LLVMValueRef V,
-    LLVMMetadataRef Decl = nullptr, uint32_t AlignInBits = 0) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Context, const char *Name,
+    size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
+    LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
+    bool IsLocalToUnit, LLVMValueRef V, LLVMMetadataRef Decl = nullptr,
+    uint32_t AlignInBits = 0) {
   llvm::GlobalVariable *InitVal = cast<llvm::GlobalVariable>(unwrap(V));
 
   llvm::DIExpression *InitExpr = nullptr;
@@ -1095,14 +1083,13 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
         FPVal->getValueAPF().bitcastToAPInt().getZExtValue());
   }
 
-  llvm::DIGlobalVariableExpression *VarExpr = Builder->createGlobalVariableExpression(
-      unwrapDI<DIDescriptor>(Context), StringRef(Name, NameLen),
-      StringRef(LinkageName, LinkageNameLen),
-      unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), IsLocalToUnit,
-      /* isDefined */ true,
-      InitExpr, unwrapDIPtr<MDNode>(Decl),
-      /* templateParams */ nullptr,
-      AlignInBits);
+  llvm::DIGlobalVariableExpression *VarExpr =
+      Builder->createGlobalVariableExpression(
+          unwrapDI<DIDescriptor>(Context), StringRef(Name, NameLen),
+          StringRef(LinkageName, LinkageNameLen), unwrapDI<DIFile>(File),
+          LineNo, unwrapDI<DIType>(Ty), IsLocalToUnit,
+          /* isDefined */ true, InitExpr, unwrapDIPtr<MDNode>(Decl),
+          /* templateParams */ nullptr, AlignInBits);
 
   InitVal->setMetadata("dbg", VarExpr);
 
@@ -1111,20 +1098,19 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticVariable(
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
     LLVMRustDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNo,
+    const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo,
     LLVMMetadataRef Ty, bool AlwaysPreserve, LLVMRustDIFlags Flags,
     unsigned ArgNo, uint32_t AlignInBits) {
   if (Tag == 0x100) { // DW_TAG_auto_variable
     return wrap(Builder->createAutoVariable(
         unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
-        unwrapDI<DIFile>(File), LineNo,
-        unwrapDI<DIType>(Ty), AlwaysPreserve, fromRust(Flags), AlignInBits));
+        unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), AlwaysPreserve,
+        fromRust(Flags), AlignInBits));
   } else {
     return wrap(Builder->createParameterVariable(
         unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ArgNo,
-        unwrapDI<DIFile>(File), LineNo,
-        unwrapDI<DIType>(Ty), AlwaysPreserve, fromRust(Flags)));
+        unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), AlwaysPreserve,
+        fromRust(Flags)));
   }
 }
 
@@ -1157,9 +1143,9 @@ extern "C" LLVMValueRef LLVMRustDIBuilderInsertDeclareAtEnd(
     LLVMBasicBlockRef InsertAtEnd) {
   auto Result = Builder->insertDeclare(
       unwrap(V), unwrap<DILocalVariable>(VarInfo),
-      Builder->createExpression(llvm::ArrayRef<uint64_t>(AddrOps, AddrOpsCount)),
-      DebugLoc(cast<MDNode>(unwrap(DL))),
-      unwrap(InsertAtEnd));
+      Builder->createExpression(
+          llvm::ArrayRef<uint64_t>(AddrOps, AddrOpsCount)),
+      DebugLoc(cast<MDNode>(unwrap(DL))), unwrap(InsertAtEnd));
 #if LLVM_VERSION_GE(19, 0)
   return wrap(Result.get<llvm::Instruction *>());
 #else
@@ -1170,21 +1156,20 @@ extern "C" LLVMValueRef LLVMRustDIBuilderInsertDeclareAtEnd(
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerator(
     LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
     const uint64_t Value[2], unsigned SizeInBits, bool IsUnsigned) {
-  return wrap(Builder->createEnumerator(StringRef(Name, NameLen),
+  return wrap(Builder->createEnumerator(
+      StringRef(Name, NameLen),
       APSInt(APInt(SizeInBits, ArrayRef<uint64_t>(Value, 2)), IsUnsigned)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
-    uint32_t AlignInBits, LLVMMetadataRef Elements,
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+    uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef Elements,
     LLVMMetadataRef ClassTy, bool IsScoped) {
   return wrap(Builder->createEnumerationType(
       unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
-      unwrapDI<DIFile>(File), LineNumber,
-      SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
-      unwrapDI<DIType>(ClassTy),
+      unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
+      DINodeArray(unwrapDI<MDTuple>(Elements)), unwrapDI<DIType>(ClassTy),
 #if LLVM_VERSION_GE(18, 0)
       /* RunTimeLang */ 0,
 #endif
@@ -1192,39 +1177,38 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
-    uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Elements,
-    unsigned RunTimeLang, const char *UniqueId, size_t UniqueIdLen) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+    uint64_t SizeInBits, uint32_t AlignInBits, LLVMRustDIFlags Flags,
+    LLVMMetadataRef Elements, unsigned RunTimeLang, const char *UniqueId,
+    size_t UniqueIdLen) {
   return wrap(Builder->createUnionType(
-      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIFile>(File),
-      LineNumber, SizeInBits, AlignInBits, fromRust(Flags),
-      DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
+      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
+      unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
+      fromRust(Flags), DINodeArray(unwrapDI<MDTuple>(Elements)), RunTimeLang,
       StringRef(UniqueId, UniqueIdLen)));
 }
 
 extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen, LLVMMetadataRef Ty) {
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef Ty) {
   bool IsDefault = false; // FIXME: should we ever set this true?
   return wrap(Builder->createTemplateTypeParameter(
-      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIType>(Ty), IsDefault));
+      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
+      unwrapDI<DIType>(Ty), IsDefault));
 }
 
-extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateNameSpace(
-    LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
-    const char *Name, size_t NameLen, bool ExportSymbols) {
+extern "C" LLVMMetadataRef
+LLVMRustDIBuilderCreateNameSpace(LLVMRustDIBuilderRef Builder,
+                                 LLVMMetadataRef Scope, const char *Name,
+                                 size_t NameLen, bool ExportSymbols) {
   return wrap(Builder->createNameSpace(
-      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ExportSymbols
-  ));
+      unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), ExportSymbols));
 }
 
-extern "C" void
-LLVMRustDICompositeTypeReplaceArrays(LLVMRustDIBuilderRef Builder,
-                                     LLVMMetadataRef CompositeTy,
-                                     LLVMMetadataRef Elements,
-                                     LLVMMetadataRef Params) {
+extern "C" void LLVMRustDICompositeTypeReplaceArrays(
+    LLVMRustDIBuilderRef Builder, LLVMMetadataRef CompositeTy,
+    LLVMMetadataRef Elements, LLVMMetadataRef Params) {
   DICompositeType *Tmp = unwrapDI<DICompositeType>(CompositeTy);
   Builder->replaceArrays(Tmp, DINodeArray(unwrap<MDTuple>(Elements)),
                          DINodeArray(unwrap<MDTuple>(Params)));
@@ -1235,9 +1219,8 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column,
                                      LLVMMetadataRef ScopeRef,
                                      LLVMMetadataRef InlinedAt) {
   MDNode *Scope = unwrapDIPtr<MDNode>(ScopeRef);
-  DILocation *Loc = DILocation::get(
-      Scope->getContext(), Line, Column, Scope,
-      unwrapDIPtr<MDNode>(InlinedAt));
+  DILocation *Loc = DILocation::get(Scope->getContext(), Line, Column, Scope,
+                                    unwrapDIPtr<MDNode>(InlinedAt));
   return wrap(Loc);
 }
 
@@ -1258,8 +1241,7 @@ extern "C" void LLVMRustWriteTypeToString(LLVMTypeRef Ty, RustStringRef Str) {
   unwrap<llvm::Type>(Ty)->print(OS);
 }
 
-extern "C" void LLVMRustWriteValueToString(LLVMValueRef V,
-                                           RustStringRef Str) {
+extern "C" void LLVMRustWriteValueToString(LLVMValueRef V, RustStringRef Str) {
   auto OS = RawRustStringOstream(Str);
   if (!V) {
     OS << "(null)";
@@ -1281,7 +1263,7 @@ extern "C" void LLVMRustWriteTwineToString(LLVMTwineRef T, RustStringRef Str) {
 
 extern "C" void LLVMRustUnpackOptimizationDiagnostic(
     LLVMDiagnosticInfoRef DI, RustStringRef PassNameOut,
-    LLVMValueRef *FunctionOut, unsigned* Line, unsigned* Column,
+    LLVMValueRef *FunctionOut, unsigned *Line, unsigned *Column,
     RustStringRef FilenameOut, RustStringRef MessageOut) {
   // Undefined to call this not on an optimization diagnostic!
   llvm::DiagnosticInfoOptimizationBase *Opt =
@@ -1304,17 +1286,15 @@ extern "C" void LLVMRustUnpackOptimizationDiagnostic(
 }
 
 enum class LLVMRustDiagnosticLevel {
-    Error,
-    Warning,
-    Note,
-    Remark,
+  Error,
+  Warning,
+  Note,
+  Remark,
 };
 
-extern "C" void
-LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI,
-                                  LLVMRustDiagnosticLevel *LevelOut,
-                                  uint64_t *CookieOut,
-                                  LLVMTwineRef *MessageOut) {
+extern "C" void LLVMRustUnpackInlineAsmDiagnostic(
+    LLVMDiagnosticInfoRef DI, LLVMRustDiagnosticLevel *LevelOut,
+    uint64_t *CookieOut, LLVMTwineRef *MessageOut) {
   // Undefined to call this not on an inline assembly diagnostic!
   llvm::DiagnosticInfoInlineAsm *IA =
       static_cast<llvm::DiagnosticInfoInlineAsm *>(unwrap(DI));
@@ -1323,20 +1303,20 @@ LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI,
   *MessageOut = wrap(&IA->getMsgStr());
 
   switch (IA->getSeverity()) {
-    case DS_Error:
-      *LevelOut = LLVMRustDiagnosticLevel::Error;
-      break;
-    case DS_Warning:
-      *LevelOut = LLVMRustDiagnosticLevel::Warning;
-      break;
-    case DS_Note:
-      *LevelOut = LLVMRustDiagnosticLevel::Note;
-      break;
-    case DS_Remark:
-      *LevelOut = LLVMRustDiagnosticLevel::Remark;
-      break;
-    default:
-      report_fatal_error("Invalid LLVMRustDiagnosticLevel value!");
+  case DS_Error:
+    *LevelOut = LLVMRustDiagnosticLevel::Error;
+    break;
+  case DS_Warning:
+    *LevelOut = LLVMRustDiagnosticLevel::Warning;
+    break;
+  case DS_Note:
+    *LevelOut = LLVMRustDiagnosticLevel::Note;
+    break;
+  case DS_Remark:
+    *LevelOut = LLVMRustDiagnosticLevel::Remark;
+    break;
+  default:
+    report_fatal_error("Invalid LLVMRustDiagnosticLevel value!");
   }
 }
 
@@ -1454,61 +1434,61 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) {
     return LLVMBFloatTypeKind;
   case Type::X86_AMXTyID:
     return LLVMX86_AMXTypeKind;
-  default:
-    {
-      std::string error;
-      auto stream = llvm::raw_string_ostream(error);
-      stream << "Rust does not support the TypeID: " << unwrap(Ty)->getTypeID()
-             << " for the type: " << *unwrap(Ty);
-      stream.flush();
-      report_fatal_error(error.c_str());
-    }
+  default: {
+    std::string error;
+    auto stream = llvm::raw_string_ostream(error);
+    stream << "Rust does not support the TypeID: " << unwrap(Ty)->getTypeID()
+           << " for the type: " << *unwrap(Ty);
+    stream.flush();
+    report_fatal_error(error.c_str());
+  }
   }
 }
 
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef)
 
-extern "C" LLVMSMDiagnosticRef LLVMRustGetSMDiagnostic(
-    LLVMDiagnosticInfoRef DI, unsigned *Cookie) {
-  llvm::DiagnosticInfoSrcMgr *SM = static_cast<llvm::DiagnosticInfoSrcMgr *>(unwrap(DI));
+extern "C" LLVMSMDiagnosticRef LLVMRustGetSMDiagnostic(LLVMDiagnosticInfoRef DI,
+                                                       unsigned *Cookie) {
+  llvm::DiagnosticInfoSrcMgr *SM =
+      static_cast<llvm::DiagnosticInfoSrcMgr *>(unwrap(DI));
   *Cookie = SM->getLocCookie();
   return wrap(&SM->getSMDiag());
 }
 
-extern "C" bool LLVMRustUnpackSMDiagnostic(LLVMSMDiagnosticRef DRef,
-                                           RustStringRef MessageOut,
-                                           RustStringRef BufferOut,
-                                           LLVMRustDiagnosticLevel* LevelOut,
-                                           unsigned* LocOut,
-                                           unsigned* RangesOut,
-                                           size_t* NumRanges) {
-  SMDiagnostic& D = *unwrap(DRef);
+extern "C" bool
+LLVMRustUnpackSMDiagnostic(LLVMSMDiagnosticRef DRef, RustStringRef MessageOut,
+                           RustStringRef BufferOut,
+                           LLVMRustDiagnosticLevel *LevelOut, unsigned *LocOut,
+                           unsigned *RangesOut, size_t *NumRanges) {
+  SMDiagnostic &D = *unwrap(DRef);
   auto MessageOS = RawRustStringOstream(MessageOut);
   MessageOS << D.getMessage();
 
   switch (D.getKind()) {
-    case SourceMgr::DK_Error:
-      *LevelOut = LLVMRustDiagnosticLevel::Error;
-      break;
-    case SourceMgr::DK_Warning:
-      *LevelOut = LLVMRustDiagnosticLevel::Warning;
-      break;
-    case SourceMgr::DK_Note:
-      *LevelOut = LLVMRustDiagnosticLevel::Note;
-      break;
-    case SourceMgr::DK_Remark:
-      *LevelOut = LLVMRustDiagnosticLevel::Remark;
-      break;
-    default:
-      report_fatal_error("Invalid LLVMRustDiagnosticLevel value!");
+  case SourceMgr::DK_Error:
+    *LevelOut = LLVMRustDiagnosticLevel::Error;
+    break;
+  case SourceMgr::DK_Warning:
+    *LevelOut = LLVMRustDiagnosticLevel::Warning;
+    break;
+  case SourceMgr::DK_Note:
+    *LevelOut = LLVMRustDiagnosticLevel::Note;
+    break;
+  case SourceMgr::DK_Remark:
+    *LevelOut = LLVMRustDiagnosticLevel::Remark;
+    break;
+  default:
+    report_fatal_error("Invalid LLVMRustDiagnosticLevel value!");
   }
 
   if (D.getLoc() == SMLoc())
     return false;
 
   const SourceMgr &LSM = *D.getSourceMgr();
-  const MemoryBuffer *LBuf = LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(D.getLoc()));
-  LLVMRustStringWriteImpl(BufferOut, LBuf->getBufferStart(), LBuf->getBufferSize());
+  const MemoryBuffer *LBuf =
+      LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(D.getLoc()));
+  LLVMRustStringWriteImpl(BufferOut, LBuf->getBufferStart(),
+                          LBuf->getBufferSize());
 
   *LocOut = D.getLoc().getPointer() - LBuf->getBufferStart();
 
@@ -1525,7 +1505,8 @@ extern "C" bool LLVMRustUnpackSMDiagnostic(LLVMSMDiagnosticRef DRef,
 extern "C" OperandBundleDef *LLVMRustBuildOperandBundleDef(const char *Name,
                                                            LLVMValueRef *Inputs,
                                                            unsigned NumInputs) {
-  return new OperandBundleDef(Name, ArrayRef<Value*>(unwrap(Inputs), NumInputs));
+  return new OperandBundleDef(Name,
+                              ArrayRef<Value *>(unwrap(Inputs), NumInputs));
 }
 
 extern "C" void LLVMRustFreeOperandBundleDef(OperandBundleDef *Bundle) {
@@ -1533,8 +1514,9 @@ extern "C" void LLVMRustFreeOperandBundleDef(OperandBundleDef *Bundle) {
 }
 
 // OpBundlesIndirect is an array of pointers (*not* a pointer to an array).
-extern "C" LLVMValueRef LLVMRustBuildCall(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
-                                          LLVMValueRef *Args, unsigned NumArgs,
+extern "C" LLVMValueRef LLVMRustBuildCall(LLVMBuilderRef B, LLVMTypeRef Ty,
+                                          LLVMValueRef Fn, LLVMValueRef *Args,
+                                          unsigned NumArgs,
                                           OperandBundleDef **OpBundlesIndirect,
                                           unsigned NumOpBundles) {
   Value *Callee = unwrap(Fn);
@@ -1547,17 +1529,19 @@ extern "C" LLVMValueRef LLVMRustBuildCall(LLVMBuilderRef B, LLVMTypeRef Ty, LLVM
     OpBundles.push_back(*OpBundlesIndirect[i]);
   }
 
-  return wrap(unwrap(B)->CreateCall(
-      FTy, Callee, ArrayRef<Value*>(unwrap(Args), NumArgs),
-      ArrayRef<OperandBundleDef>(OpBundles)));
+  return wrap(unwrap(B)->CreateCall(FTy, Callee,
+                                    ArrayRef<Value *>(unwrap(Args), NumArgs),
+                                    ArrayRef<OperandBundleDef>(OpBundles)));
 }
 
-extern "C" LLVMValueRef LLVMRustGetInstrProfIncrementIntrinsic(LLVMModuleRef M) {
+extern "C" LLVMValueRef
+LLVMRustGetInstrProfIncrementIntrinsic(LLVMModuleRef M) {
   return wrap(llvm::Intrinsic::getDeclaration(
       unwrap(M), llvm::Intrinsic::instrprof_increment));
 }
 
-extern "C" LLVMValueRef LLVMRustGetInstrProfMCDCParametersIntrinsic(LLVMModuleRef M) {
+extern "C" LLVMValueRef
+LLVMRustGetInstrProfMCDCParametersIntrinsic(LLVMModuleRef M) {
 #if LLVM_VERSION_GE(18, 0)
   return wrap(llvm::Intrinsic::getDeclaration(
       unwrap(M), llvm::Intrinsic::instrprof_mcdc_parameters));
@@ -1566,7 +1550,8 @@ extern "C" LLVMValueRef LLVMRustGetInstrProfMCDCParametersIntrinsic(LLVMModuleRe
 #endif
 }
 
-extern "C" LLVMValueRef LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(LLVMModuleRef M) {
+extern "C" LLVMValueRef
+LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(LLVMModuleRef M) {
 #if LLVM_VERSION_GE(18, 0)
   return wrap(llvm::Intrinsic::getDeclaration(
       unwrap(M), llvm::Intrinsic::instrprof_mcdc_tvbitmap_update));
@@ -1575,7 +1560,8 @@ extern "C" LLVMValueRef LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(LLVMModu
 #endif
 }
 
-extern "C" LLVMValueRef LLVMRustGetInstrProfMCDCCondBitmapIntrinsic(LLVMModuleRef M) {
+extern "C" LLVMValueRef
+LLVMRustGetInstrProfMCDCCondBitmapIntrinsic(LLVMModuleRef M) {
 #if LLVM_VERSION_GE(18, 0)
   return wrap(llvm::Intrinsic::getDeclaration(
       unwrap(M), llvm::Intrinsic::instrprof_mcdc_condbitmap_update));
@@ -1584,32 +1570,31 @@ extern "C" LLVMValueRef LLVMRustGetInstrProfMCDCCondBitmapIntrinsic(LLVMModuleRe
 #endif
 }
 
-extern "C" LLVMValueRef LLVMRustBuildMemCpy(LLVMBuilderRef B,
-                                            LLVMValueRef Dst, unsigned DstAlign,
-                                            LLVMValueRef Src, unsigned SrcAlign,
-                                            LLVMValueRef Size, bool IsVolatile) {
-  return wrap(unwrap(B)->CreateMemCpy(
-      unwrap(Dst), MaybeAlign(DstAlign),
-      unwrap(Src), MaybeAlign(SrcAlign),
-      unwrap(Size), IsVolatile));
+extern "C" LLVMValueRef LLVMRustBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst,
+                                            unsigned DstAlign, LLVMValueRef Src,
+                                            unsigned SrcAlign,
+                                            LLVMValueRef Size,
+                                            bool IsVolatile) {
+  return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
+                                      unwrap(Src), MaybeAlign(SrcAlign),
+                                      unwrap(Size), IsVolatile));
 }
 
-extern "C" LLVMValueRef LLVMRustBuildMemMove(LLVMBuilderRef B,
-                                             LLVMValueRef Dst, unsigned DstAlign,
-                                             LLVMValueRef Src, unsigned SrcAlign,
-                                             LLVMValueRef Size, bool IsVolatile) {
-  return wrap(unwrap(B)->CreateMemMove(
-      unwrap(Dst), MaybeAlign(DstAlign),
-      unwrap(Src), MaybeAlign(SrcAlign),
-      unwrap(Size), IsVolatile));
+extern "C" LLVMValueRef
+LLVMRustBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst, unsigned DstAlign,
+                     LLVMValueRef Src, unsigned SrcAlign, LLVMValueRef Size,
+                     bool IsVolatile) {
+  return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
+                                       unwrap(Src), MaybeAlign(SrcAlign),
+                                       unwrap(Size), IsVolatile));
 }
 
-extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B,
-                                            LLVMValueRef Dst, unsigned DstAlign,
-                                            LLVMValueRef Val,
-                                            LLVMValueRef Size, bool IsVolatile) {
-  return wrap(unwrap(B)->CreateMemSet(
-      unwrap(Dst), unwrap(Val), unwrap(Size), MaybeAlign(DstAlign), IsVolatile));
+extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B, LLVMValueRef Dst,
+                                            unsigned DstAlign, LLVMValueRef Val,
+                                            LLVMValueRef Size,
+                                            bool IsVolatile) {
+  return wrap(unwrap(B)->CreateMemSet(unwrap(Dst), unwrap(Val), unwrap(Size),
+                                      MaybeAlign(DstAlign), IsVolatile));
 }
 
 // OpBundlesIndirect is an array of pointers (*not* a pointer to an array).
@@ -1630,7 +1615,7 @@ LLVMRustBuildInvoke(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
   }
 
   return wrap(unwrap(B)->CreateInvoke(FTy, Callee, unwrap(Then), unwrap(Catch),
-                                      ArrayRef<Value*>(unwrap(Args), NumArgs),
+                                      ArrayRef<Value *>(unwrap(Args), NumArgs),
                                       ArrayRef<OperandBundleDef>(OpBundles),
                                       Name));
 }
@@ -1647,7 +1632,7 @@ LLVMRustBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
   FunctionType *FTy = unwrap<FunctionType>(Ty);
 
   // FIXME: Is there a way around this?
-  std::vector<BasicBlock*> IndirectDestsUnwrapped;
+  std::vector<BasicBlock *> IndirectDestsUnwrapped;
   IndirectDestsUnwrapped.reserve(NumIndirectDests);
   for (unsigned i = 0; i < NumIndirectDests; ++i) {
     IndirectDestsUnwrapped.push_back(unwrap(IndirectDests[i]));
@@ -1660,12 +1645,11 @@ LLVMRustBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
     OpBundles.push_back(*OpBundlesIndirect[i]);
   }
 
-  return wrap(unwrap(B)->CreateCallBr(
-      FTy, Callee, unwrap(DefaultDest),
-      ArrayRef<BasicBlock*>(IndirectDestsUnwrapped),
-      ArrayRef<Value*>(unwrap(Args), NumArgs),
-      ArrayRef<OperandBundleDef>(OpBundles),
-      Name));
+  return wrap(
+      unwrap(B)->CreateCallBr(FTy, Callee, unwrap(DefaultDest),
+                              ArrayRef<BasicBlock *>(IndirectDestsUnwrapped),
+                              ArrayRef<Value *>(unwrap(Args), NumArgs),
+                              ArrayRef<OperandBundleDef>(OpBundles), Name));
 }
 
 extern "C" void LLVMRustPositionBuilderAtStart(LLVMBuilderRef B,
@@ -1765,28 +1749,30 @@ extern "C" void LLVMRustSetLinkage(LLVMValueRef V,
 }
 
 extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) {
-    auto C = unwrap<llvm::ConstantInt>(CV);
-    if (C->getBitWidth() > 64)
-      return false;
-    *value = C->getZExtValue();
-    return true;
+  auto C = unwrap<llvm::ConstantInt>(CV);
+  if (C->getBitWidth() > 64)
+    return false;
+  *value = C->getZExtValue();
+  return true;
 }
 
-// Returns true if both high and low were successfully set. Fails in case constant wasn’t any of
-// the common sizes (1, 8, 16, 32, 64, 128 bits)
-extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low)
-{
-    auto C = unwrap<llvm::ConstantInt>(CV);
-    if (C->getBitWidth() > 128) { return false; }
-    APInt AP;
-    if (sext) {
-        AP = C->getValue().sext(128);
-    } else {
-        AP = C->getValue().zext(128);
-    }
-    *low = AP.getLoBits(64).getZExtValue();
-    *high = AP.getHiBits(64).getZExtValue();
-    return true;
+// Returns true if both high and low were successfully set. Fails in case
+// constant wasn’t any of the common sizes (1, 8, 16, 32, 64, 128 bits)
+extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext,
+                                       uint64_t *high, uint64_t *low) {
+  auto C = unwrap<llvm::ConstantInt>(CV);
+  if (C->getBitWidth() > 128) {
+    return false;
+  }
+  APInt AP;
+  if (sext) {
+    AP = C->getValue().sext(128);
+  } else {
+    AP = C->getValue().zext(128);
+  }
+  *low = AP.getLoBits(64).getZExtValue();
+  *high = AP.getHiBits(64).getZExtValue();
+  return true;
 }
 
 enum class LLVMRustVisibility {
@@ -1836,8 +1822,7 @@ struct LLVMRustModuleBuffer {
   std::string data;
 };
 
-extern "C" LLVMRustModuleBuffer*
-LLVMRustModuleBufferCreate(LLVMModuleRef M) {
+extern "C" LLVMRustModuleBuffer *LLVMRustModuleBufferCreate(LLVMModuleRef M) {
   auto Ret = std::make_unique<LLVMRustModuleBuffer>();
   {
     auto OS = raw_string_ostream(Ret->data);
@@ -1846,30 +1831,26 @@ LLVMRustModuleBufferCreate(LLVMModuleRef M) {
   return Ret.release();
 }
 
-extern "C" void
-LLVMRustModuleBufferFree(LLVMRustModuleBuffer *Buffer) {
+extern "C" void LLVMRustModuleBufferFree(LLVMRustModuleBuffer *Buffer) {
   delete Buffer;
 }
 
-extern "C" const void*
+extern "C" const void *
 LLVMRustModuleBufferPtr(const LLVMRustModuleBuffer *Buffer) {
   return Buffer->data.data();
 }
 
-extern "C" size_t
-LLVMRustModuleBufferLen(const LLVMRustModuleBuffer *Buffer) {
+extern "C" size_t LLVMRustModuleBufferLen(const LLVMRustModuleBuffer *Buffer) {
   return Buffer->data.length();
 }
 
-extern "C" uint64_t
-LLVMRustModuleCost(LLVMModuleRef M) {
+extern "C" uint64_t LLVMRustModuleCost(LLVMModuleRef M) {
   auto f = unwrap(M)->functions();
   return std::distance(std::begin(f), std::end(f));
 }
 
-extern "C" void
-LLVMRustModuleInstructionStats(LLVMModuleRef M, RustStringRef Str)
-{
+extern "C" void LLVMRustModuleInstructionStats(LLVMModuleRef M,
+                                               RustStringRef Str) {
   auto OS = RawRustStringOstream(Str);
   auto JOS = llvm::json::OStream(OS);
   auto Module = unwrap(M);
@@ -1881,41 +1862,45 @@ LLVMRustModuleInstructionStats(LLVMModuleRef M, RustStringRef Str)
 }
 
 // Vector reductions:
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceFAdd(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Src) {
-    return wrap(unwrap(B)->CreateFAddReduce(unwrap(Acc),unwrap(Src)));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceFMul(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Src) {
-    return wrap(unwrap(B)->CreateFMulReduce(unwrap(Acc),unwrap(Src)));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceAdd(LLVMBuilderRef B, LLVMValueRef Src) {
-    return wrap(unwrap(B)->CreateAddReduce(unwrap(Src)));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceMul(LLVMBuilderRef B, LLVMValueRef Src) {
-    return wrap(unwrap(B)->CreateMulReduce(unwrap(Src)));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceAnd(LLVMBuilderRef B, LLVMValueRef Src) {
-    return wrap(unwrap(B)->CreateAndReduce(unwrap(Src)));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceOr(LLVMBuilderRef B, LLVMValueRef Src) {
-    return wrap(unwrap(B)->CreateOrReduce(unwrap(Src)));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceXor(LLVMBuilderRef B, LLVMValueRef Src) {
-    return wrap(unwrap(B)->CreateXorReduce(unwrap(Src)));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceMin(LLVMBuilderRef B, LLVMValueRef Src, bool IsSigned) {
-    return wrap(unwrap(B)->CreateIntMinReduce(unwrap(Src), IsSigned));
-}
-extern "C" LLVMValueRef
-LLVMRustBuildVectorReduceMax(LLVMBuilderRef B, LLVMValueRef Src, bool IsSigned) {
-    return wrap(unwrap(B)->CreateIntMaxReduce(unwrap(Src), IsSigned));
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceFAdd(LLVMBuilderRef B,
+                                                      LLVMValueRef Acc,
+                                                      LLVMValueRef Src) {
+  return wrap(unwrap(B)->CreateFAddReduce(unwrap(Acc), unwrap(Src)));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceFMul(LLVMBuilderRef B,
+                                                      LLVMValueRef Acc,
+                                                      LLVMValueRef Src) {
+  return wrap(unwrap(B)->CreateFMulReduce(unwrap(Acc), unwrap(Src)));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceAdd(LLVMBuilderRef B,
+                                                     LLVMValueRef Src) {
+  return wrap(unwrap(B)->CreateAddReduce(unwrap(Src)));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceMul(LLVMBuilderRef B,
+                                                     LLVMValueRef Src) {
+  return wrap(unwrap(B)->CreateMulReduce(unwrap(Src)));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceAnd(LLVMBuilderRef B,
+                                                     LLVMValueRef Src) {
+  return wrap(unwrap(B)->CreateAndReduce(unwrap(Src)));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceOr(LLVMBuilderRef B,
+                                                    LLVMValueRef Src) {
+  return wrap(unwrap(B)->CreateOrReduce(unwrap(Src)));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceXor(LLVMBuilderRef B,
+                                                     LLVMValueRef Src) {
+  return wrap(unwrap(B)->CreateXorReduce(unwrap(Src)));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceMin(LLVMBuilderRef B,
+                                                     LLVMValueRef Src,
+                                                     bool IsSigned) {
+  return wrap(unwrap(B)->CreateIntMinReduce(unwrap(Src), IsSigned));
+}
+extern "C" LLVMValueRef LLVMRustBuildVectorReduceMax(LLVMBuilderRef B,
+                                                     LLVMValueRef Src,
+                                                     bool IsSigned) {
+  return wrap(unwrap(B)->CreateIntMaxReduce(unwrap(Src), IsSigned));
 }
 extern "C" LLVMValueRef
 LLVMRustBuildVectorReduceFMin(LLVMBuilderRef B, LLVMValueRef Src, bool NoNaN) {
@@ -1930,32 +1915,28 @@ LLVMRustBuildVectorReduceFMax(LLVMBuilderRef B, LLVMValueRef Src, bool NoNaN) {
   return wrap(I);
 }
 
-extern "C" LLVMValueRef
-LLVMRustBuildMinNum(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS) {
-    return wrap(unwrap(B)->CreateMinNum(unwrap(LHS),unwrap(RHS)));
+extern "C" LLVMValueRef LLVMRustBuildMinNum(LLVMBuilderRef B, LLVMValueRef LHS,
+                                            LLVMValueRef RHS) {
+  return wrap(unwrap(B)->CreateMinNum(unwrap(LHS), unwrap(RHS)));
 }
-extern "C" LLVMValueRef
-LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS) {
-    return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS),unwrap(RHS)));
+extern "C" LLVMValueRef LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS,
+                                            LLVMValueRef RHS) {
+  return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS), unwrap(RHS)));
 }
 
 // This struct contains all necessary info about a symbol exported from a DLL.
 struct LLVMRustCOFFShortExport {
-  const char* name;
+  const char *name;
   bool ordinal_present;
   // The value of `ordinal` is only meaningful if `ordinal_present` is true.
   uint16_t ordinal;
 };
 
 // Machine must be a COFF machine type, as defined in PE specs.
-extern "C" LLVMRustResult LLVMRustWriteImportLibrary(
-  const char* ImportName,
-  const char* Path,
-  const LLVMRustCOFFShortExport* Exports,
-  size_t NumExports,
-  uint16_t Machine,
-  bool MinGW)
-{
+extern "C" LLVMRustResult
+LLVMRustWriteImportLibrary(const char *ImportName, const char *Path,
+                           const LLVMRustCOFFShortExport *Exports,
+                           size_t NumExports, uint16_t Machine, bool MinGW) {
   std::vector<llvm::object::COFFShortExport> ConvertedExports;
   ConvertedExports.reserve(NumExports);
 
@@ -1963,27 +1944,24 @@ extern "C" LLVMRustResult LLVMRustWriteImportLibrary(
     bool ordinal_present = Exports[i].ordinal_present;
     uint16_t ordinal = ordinal_present ? Exports[i].ordinal : 0;
     ConvertedExports.push_back(llvm::object::COFFShortExport{
-      Exports[i].name,  // Name
-      std::string{},    // ExtName
-      std::string{},    // SymbolName
-      std::string{},    // AliasTarget
+        Exports[i].name, // Name
+        std::string{},   // ExtName
+        std::string{},   // SymbolName
+        std::string{},   // AliasTarget
 #if LLVM_VERSION_GE(19, 0)
-      std::string{},    // ExportAs
+        std::string{}, // ExportAs
 #endif
-      ordinal,          // Ordinal
-      ordinal_present,  // Noname
-      false,            // Data
-      false,            // Private
-      false             // Constant
+        ordinal,         // Ordinal
+        ordinal_present, // Noname
+        false,           // Data
+        false,           // Private
+        false            // Constant
     });
   }
 
   auto Error = llvm::object::writeImportLibrary(
-    ImportName,
-    Path,
-    ConvertedExports,
-    static_cast<llvm::COFF::MachineTypes>(Machine),
-    MinGW);
+      ImportName, Path, ConvertedExports,
+      static_cast<llvm::COFF::MachineTypes>(Machine), MinGW);
   if (Error) {
     std::string errorString;
     auto stream = llvm::raw_string_ostream(errorString);
@@ -2019,27 +1997,23 @@ using LLVMDiagnosticHandlerTy = DiagnosticHandler::DiagnosticHandlerTy;
 // the RemarkPasses array specifies individual passes for which remarks will be
 // enabled.
 //
-// If RemarkFilePath is not NULL, optimization remarks will be streamed directly into this file,
-// bypassing the diagnostics handler.
+// If RemarkFilePath is not NULL, optimization remarks will be streamed directly
+// into this file, bypassing the diagnostics handler.
 extern "C" void LLVMRustContextConfigureDiagnosticHandler(
     LLVMContextRef C, LLVMDiagnosticHandlerTy DiagnosticHandlerCallback,
     void *DiagnosticHandlerContext, bool RemarkAllPasses,
-    const char * const * RemarkPasses, size_t RemarkPassesLen,
-    const char * RemarkFilePath,
-    bool PGOAvailable
-) {
+    const char *const *RemarkPasses, size_t RemarkPassesLen,
+    const char *RemarkFilePath, bool PGOAvailable) {
 
   class RustDiagnosticHandler final : public DiagnosticHandler {
   public:
     RustDiagnosticHandler(
-      LLVMDiagnosticHandlerTy DiagnosticHandlerCallback,
-      void *DiagnosticHandlerContext,
-      bool RemarkAllPasses,
-      std::vector<std::string> RemarkPasses,
-      std::unique_ptr<ToolOutputFile> RemarksFile,
-      std::unique_ptr<llvm::remarks::RemarkStreamer> RemarkStreamer,
-      std::unique_ptr<LLVMRemarkStreamer> LlvmRemarkStreamer
-    )
+        LLVMDiagnosticHandlerTy DiagnosticHandlerCallback,
+        void *DiagnosticHandlerContext, bool RemarkAllPasses,
+        std::vector<std::string> RemarkPasses,
+        std::unique_ptr<ToolOutputFile> RemarksFile,
+        std::unique_ptr<llvm::remarks::RemarkStreamer> RemarkStreamer,
+        std::unique_ptr<LLVMRemarkStreamer> LlvmRemarkStreamer)
         : DiagnosticHandlerCallback(DiagnosticHandlerCallback),
           DiagnosticHandlerContext(DiagnosticHandlerContext),
           RemarkAllPasses(RemarkAllPasses),
@@ -2049,11 +2023,13 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
           LlvmRemarkStreamer(std::move(LlvmRemarkStreamer)) {}
 
     virtual bool handleDiagnostics(const DiagnosticInfo &DI) override {
-      // If this diagnostic is one of the optimization remark kinds, we can check if it's enabled
-      // before emitting it. This can avoid many short-lived allocations when unpacking the
-      // diagnostic and converting its various C++ strings into rust strings.
-      // FIXME: some diagnostic infos still allocate before we get here, and avoiding that would be
-      // good in the future. That will require changing a few call sites in LLVM.
+      // If this diagnostic is one of the optimization remark kinds, we can
+      // check if it's enabled before emitting it. This can avoid many
+      // short-lived allocations when unpacking the diagnostic and converting
+      // its various C++ strings into rust strings.
+      // FIXME: some diagnostic infos still allocate before we get here, and
+      // avoiding that would be good in the future. That will require changing a
+      // few call sites in LLVM.
       if (auto *OptDiagBase = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) {
         if (OptDiagBase->isEnabled()) {
           if (this->LlvmRemarkStreamer) {
@@ -2109,16 +2085,15 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
     bool RemarkAllPasses = false;
     std::vector<std::string> RemarkPasses;
 
-    // Since LlvmRemarkStreamer contains a pointer to RemarkStreamer, the ordering of the three
-    // members below is important.
+    // Since LlvmRemarkStreamer contains a pointer to RemarkStreamer, the
+    // ordering of the three members below is important.
     std::unique_ptr<ToolOutputFile> RemarksFile;
     std::unique_ptr<llvm::remarks::RemarkStreamer> RemarkStreamer;
     std::unique_ptr<LLVMRemarkStreamer> LlvmRemarkStreamer;
   };
 
   std::vector<std::string> Passes;
-  for (size_t I = 0; I != RemarkPassesLen; ++I)
-  {
+  for (size_t I = 0; I != RemarkPassesLen; ++I) {
     Passes.push_back(RemarkPasses[I]);
   }
 
@@ -2135,13 +2110,10 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
 
     std::error_code EC;
     RemarkFile = std::make_unique<ToolOutputFile>(
-      RemarkFilePath,
-      EC,
-      llvm::sys::fs::OF_TextWithCRLF
-    );
+        RemarkFilePath, EC, llvm::sys::fs::OF_TextWithCRLF);
     if (EC) {
       std::string Error = std::string("Cannot create remark file: ") +
-              toString(errorCodeToError(EC));
+                          toString(errorCodeToError(EC));
       report_fatal_error(Twine(Error));
     }
 
@@ -2149,28 +2121,22 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
     RemarkFile->keep();
 
     auto RemarkSerializer = remarks::createRemarkSerializer(
-      llvm::remarks::Format::YAML,
-      remarks::SerializerMode::Separate,
-      RemarkFile->os()
-    );
-    if (Error E = RemarkSerializer.takeError())
-    {
-      std::string Error = std::string("Cannot create remark serializer: ") + toString(std::move(E));
+        llvm::remarks::Format::YAML, remarks::SerializerMode::Separate,
+        RemarkFile->os());
+    if (Error E = RemarkSerializer.takeError()) {
+      std::string Error = std::string("Cannot create remark serializer: ") +
+                          toString(std::move(E));
       report_fatal_error(Twine(Error));
     }
-    RemarkStreamer = std::make_unique<llvm::remarks::RemarkStreamer>(std::move(*RemarkSerializer));
+    RemarkStreamer = std::make_unique<llvm::remarks::RemarkStreamer>(
+        std::move(*RemarkSerializer));
     LlvmRemarkStreamer = std::make_unique<LLVMRemarkStreamer>(*RemarkStreamer);
   }
 
   unwrap(C)->setDiagnosticHandler(std::make_unique<RustDiagnosticHandler>(
-    DiagnosticHandlerCallback,
-    DiagnosticHandlerContext,
-    RemarkAllPasses,
-    Passes,
-    std::move(RemarkFile),
-    std::move(RemarkStreamer),
-    std::move(LlvmRemarkStreamer)
-  ));
+      DiagnosticHandlerCallback, DiagnosticHandlerContext, RemarkAllPasses,
+      Passes, std::move(RemarkFile), std::move(RemarkStreamer),
+      std::move(LlvmRemarkStreamer)));
 }
 
 extern "C" void LLVMRustGetMangledName(LLVMValueRef V, RustStringRef Str) {
@@ -2180,14 +2146,14 @@ extern "C" void LLVMRustGetMangledName(LLVMValueRef V, RustStringRef Str) {
 }
 
 extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) {
-    auto *CB = unwrap<CallBase>(CallSite);
-    switch (CB->getIntrinsicID()) {
-        case Intrinsic::arm_ldrex:
-            return 0;
-        case Intrinsic::arm_strex:
-            return 1;
-    }
-    return -1;
+  auto *CB = unwrap<CallBase>(CallSite);
+  switch (CB->getIntrinsicID()) {
+  case Intrinsic::arm_ldrex:
+    return 0;
+  case Intrinsic::arm_strex:
+    return 1;
+  }
+  return -1;
 }
 
 extern "C" bool LLVMRustIsBitcode(char *ptr, size_t len) {
@@ -2214,10 +2180,10 @@ extern "C" bool LLVMRustLLVMHasZstdCompressionForDebugSymbols() {
 }
 
 // Operations on composite constants.
-// These are clones of LLVM api functions that will become available in future releases.
-// They can be removed once Rust's minimum supported LLVM version supports them.
-// See https://github.com/rust-lang/rust/issues/121868
-// See https://llvm.org/doxygen/group__LLVMCCoreValueConstantComposite.html
+// These are clones of LLVM api functions that will become available in future
+// releases. They can be removed once Rust's minimum supported LLVM version
+// supports them. See https://github.com/rust-lang/rust/issues/121868 See
+// https://llvm.org/doxygen/group__LLVMCCoreValueConstantComposite.html
 
 // FIXME: Remove when Rust's minimum supported LLVM version reaches 19.
 // https://github.com/llvm/llvm-project/commit/e1405e4f71c899420ebf8262d5e9745598419df8
@@ -2226,6 +2192,7 @@ extern "C" LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C,
                                                   const char *Str,
                                                   size_t Length,
                                                   bool DontNullTerminate) {
-  return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length), !DontNullTerminate));
+  return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length),
+                                           !DontNullTerminate));
 }
 #endif