Critical: Use of 'unsafe' keyword bypasses Rust's safety guarantees. Requires careful auditing, clear justification (FFI, specific optimizations), and minimal scope.
unsafe extern "C" {
1//! Bindings to the LLVM-C API (`LLVM*`), and to our own `extern "C"` wrapper2//! functions around the unstable LLVM C++ API (`LLVMRust*`).3//!4//! ## Passing pointer/length strings as `*const c_uchar` (PTR_LEN_STR)5//!6//! Normally it's a good idea for Rust-side bindings to match the corresponding7//! C-side function declarations as closely as possible. But when passing `&str`8//! or `&[u8]` data as a pointer/length pair, it's more convenient to declare9//! the Rust-side pointer as `*const c_uchar` instead of `*const c_char`.10//! Both pointer types have the same ABI, and using `*const c_uchar` avoids11//! the need for an extra cast from `*const u8` on the Rust side.1213#![allow(non_camel_case_types)]1415use std::fmt::{self, Debug};16use std::marker::PhantomData;17use std::num::NonZero;18use std::ptr;1920use bitflags::bitflags;21use libc::{c_char, c_int, c_uchar, c_uint, c_ulonglong, c_void, size_t};2223use super::RustString;24use super::debuginfo::{25 DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIFile, DIFlags, DILocation, DISPFlags,26 DIScope, DISubprogram, DITemplateTypeParameter, DIType, DebugEmissionKind, DebugNameTableKind,27};28use crate::llvm::MetadataKindId;29use crate::{TryFromU32, llvm};3031/// In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`,32/// which has a different ABI from Rust or C++ `bool`.33///34/// This wrapper does not implement `PartialEq`.35/// To test the underlying boolean value, use [`Self::is_true`].36#[derive(Clone, Copy)]37#[repr(transparent)]38pub(crate) struct Bool {39 value: c_int,40}4142pub(crate) const TRUE: Bool = Bool::TRUE;43pub(crate) const FALSE: Bool = Bool::FALSE;4445impl Bool {46 pub(crate) const TRUE: Self = Self { value: 1 };47 pub(crate) const FALSE: Self = Self { value: 0 };4849 pub(crate) const fn from_bool(rust_bool: bool) -> Self {50 if rust_bool { Self::TRUE } else { Self::FALSE }51 }5253 /// Converts this LLVM-C boolean to a Rust `bool`54 pub(crate) fn is_true(self) -> bool {55 // Since we're interacting with a C API, follow the C convention of56 // treating any nonzero value as true.57 self.value != Self::FALSE.value58 }59}6061impl Debug for Bool {62 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {63 match self.value {64 0 => f.write_str("FALSE"),65 1 => f.write_str("TRUE"),66 // As with `Self::is_true`, treat any nonzero value as true.67 v => write!(f, "TRUE ({v})"),68 }69 }70}7172/// Convenience trait to convert `bool` to `llvm::Bool` with an explicit method call.73///74/// Being able to write `b.to_llvm_bool()` is less noisy than `llvm::Bool::from(b)`,75/// while being more explicit and less mistake-prone than something like `b.into()`.76pub(crate) trait ToLlvmBool: Copy {77 fn to_llvm_bool(self) -> llvm::Bool;78}7980impl ToLlvmBool for bool {81 #[inline(always)]82 fn to_llvm_bool(self) -> llvm::Bool {83 llvm::Bool::from_bool(self)84 }85}8687/// Wrapper for a raw enum value returned from LLVM's C APIs.88///89/// For C enums returned by LLVM, it's risky to use a Rust enum as the return90/// type, because it would be UB if a later version of LLVM adds a new enum91/// value and returns it. Instead, return this raw wrapper, then convert to the92/// Rust-side enum explicitly.93#[repr(transparent)]94pub(crate) struct RawEnum<T> {95 value: u32,96 /// We don't own or consume a `T`, but we can produce one.97 _rust_side_type: PhantomData<fn() -> T>,98}99100impl<T: TryFrom<u32>> RawEnum<T> {101 #[track_caller]102 pub(crate) fn to_rust(self) -> T103 where104 T::Error: Debug,105 {106 // If this fails, the Rust-side enum is out of sync with LLVM's enum.107 T::try_from(self.value).expect("enum value returned by LLVM should be known")108 }109}110111#[derive(Copy, Clone, PartialEq)]112#[repr(C)]113#[allow(dead_code)] // Variants constructed by C++.114pub(crate) enum LLVMRustResult {115 Success,116 Failure,117}118119/// Must match the layout of `LLVMRustModuleFlagMergeBehavior`.120///121/// When merging modules (e.g. during LTO), their metadata flags are combined. Conflicts are122/// resolved according to the merge behaviors specified here. Flags differing only in merge123/// behavior are still considered to be in conflict.124///125/// In order for Rust-C LTO to work, we must specify behaviors compatible with Clang. Notably,126/// 'Error' and 'Warning' cannot be mixed for a given flag.127///128/// There is a stable LLVM-C version of this enum (`LLVMModuleFlagBehavior`),129/// but as of LLVM 19 it does not support all of the enum values in the unstable130/// C++ API.131#[derive(Copy, Clone, PartialEq)]132#[repr(C)]133pub(crate) enum ModuleFlagMergeBehavior {134 Error = 1,135 Warning = 2,136 Require = 3,137 Override = 4,138 Append = 5,139 AppendUnique = 6,140 Max = 7,141 Min = 8,142}143144// Consts for the LLVM CallConv type, pre-cast to usize.145146/// Must match the layout of `LLVMTailCallKind`.147#[derive(Copy, Clone, PartialEq, Debug)]148#[repr(C)]149#[allow(dead_code)]150pub(crate) enum TailCallKind {151 None = 0,152 Tail = 1,153 MustTail = 2,154 NoTail = 3,155}156157/// LLVM CallingConv::ID. Should we wrap this?158///159/// See <https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/CallingConv.h>160#[derive(Copy, Clone, PartialEq, Debug, TryFromU32)]161#[repr(C)]162pub(crate) enum CallConv {163 CCallConv = 0,164 FastCallConv = 8,165 ColdCallConv = 9,166 PreserveMost = 14,167 PreserveAll = 15,168 SwiftCallConv = 16,169 Tail = 18,170 PreserveNone = 21,171 X86StdcallCallConv = 64,172 X86FastcallCallConv = 65,173 ArmAapcsCallConv = 67,174 Msp430Intr = 69,175 X86_ThisCall = 70,176 PtxKernel = 71,177 X86_64_SysV = 78,178 X86_64_Win64 = 79,179 X86_VectorCall = 80,180 X86_Intr = 83,181 AvrNonBlockingInterrupt = 84,182 AvrInterrupt = 85,183 AmdgpuKernel = 91,184}185186/// Must match the layout of `LLVMLinkage`.187#[derive(Copy, Clone, PartialEq, TryFromU32)]188#[repr(C)]189pub(crate) enum Linkage {190 ExternalLinkage = 0,191 AvailableExternallyLinkage = 1,192 LinkOnceAnyLinkage = 2,193 LinkOnceODRLinkage = 3,194 #[deprecated = "marked obsolete by LLVM"]195 LinkOnceODRAutoHideLinkage = 4,196 WeakAnyLinkage = 5,197 WeakODRLinkage = 6,198 AppendingLinkage = 7,199 InternalLinkage = 8,200 PrivateLinkage = 9,201 #[deprecated = "marked obsolete by LLVM"]202 DLLImportLinkage = 10,203 #[deprecated = "marked obsolete by LLVM"]204 DLLExportLinkage = 11,205 ExternalWeakLinkage = 12,206 #[deprecated = "marked obsolete by LLVM"]207 GhostLinkage = 13,208 CommonLinkage = 14,209 LinkerPrivateLinkage = 15,210 LinkerPrivateWeakLinkage = 16,211}212213/// Must match the layout of `LLVMVisibility`.214#[repr(C)]215#[derive(Copy, Clone, PartialEq, TryFromU32)]216pub(crate) enum Visibility {217 Default = 0,218 Hidden = 1,219 Protected = 2,220}221222/// LLVMUnnamedAddr223#[repr(C)]224pub(crate) enum UnnamedAddr {225 No,226 #[expect(dead_code)]227 Local,228 Global,229}230231/// LLVMDLLStorageClass232#[derive(Copy, Clone)]233#[repr(C)]234pub(crate) enum DLLStorageClass {235 #[allow(dead_code)]236 Default = 0,237 DllImport = 1, // Function to be imported from DLL.238 #[allow(dead_code)]239 DllExport = 2, // Function to be accessible from DLL.240}241242/// Must match the layout of `llvm::UWTableKind`.243#[derive(Copy, Clone)]244#[repr(C)]245pub(crate) enum UWTableKind {246 /// No unwind table requested247 None = 0,248 /// "Synchronous" unwind tables249 Sync = 1,250 /// "Asynchronous" unwind tables (instr precise)251 Async = 2,252}253254/// Must match the layout of `llvm::FramePointerKind`.255#[repr(C)]256#[derive(Copy, Clone, Debug)]257#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM")]258pub(crate) enum FramePointerKind {259 None = 0,260 NonLeaf = 1,261 All = 2,262 Reserved = 3,263 NonLeafNoReserve = 4,264}265266/// Must match the layout of `LLVMRustAttributeKind`.267/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,268/// though it is not ABI compatible (since it's a C++ enum)269#[repr(C)]270#[derive(Copy, Clone, Debug)]271#[expect(dead_code, reason = "Some variants are unused, but are kept to match the C++")]272pub(crate) enum AttributeKind {273 AlwaysInline = 0,274 ByVal = 1,275 Cold = 2,276 InlineHint = 3,277 MinSize = 4,278 Naked = 5,279 NoAlias = 6,280 CapturesAddress = 7,281 NoInline = 8,282 NonNull = 9,283 NoRedZone = 10,284 NoReturn = 11,285 NoUnwind = 12,286 OptimizeForSize = 13,287 ReadOnly = 14,288 SExt = 15,289 StructRet = 16,290 UWTable = 17,291 ZExt = 18,292 InReg = 19,293 SanitizeThread = 20,294 SanitizeAddress = 21,295 SanitizeMemory = 22,296 NonLazyBind = 23,297 OptimizeNone = 24,298 ReadNone = 26,299 SanitizeHWAddress = 28,300 WillReturn = 29,301 StackProtectReq = 30,302 StackProtectStrong = 31,303 StackProtect = 32,304 NoUndef = 33,305 SanitizeMemTag = 34,306 NoCfCheck = 35,307 ShadowCallStack = 36,308 AllocSize = 37,309 AllocatedPointer = 38,310 AllocAlign = 39,311 SanitizeSafeStack = 40,312 FnRetThunkExtern = 41,313 Writable = 42,314 DeadOnUnwind = 43,315 DeadOnReturn = 44,316 CapturesReadOnly = 45,317 CapturesNone = 46,318 SanitizeRealtimeNonblocking = 47,319 SanitizeRealtimeBlocking = 48,320 Convergent = 49,321 NoFree = 50,322}323324/// LLVMIntPredicate325#[derive(Copy, Clone)]326#[repr(C)]327pub(crate) enum IntPredicate {328 IntEQ = 32,329 IntNE = 33,330 IntUGT = 34,331 IntUGE = 35,332 IntULT = 36,333 IntULE = 37,334 IntSGT = 38,335 IntSGE = 39,336 IntSLT = 40,337 IntSLE = 41,338}339340/// LLVMRealPredicate341#[derive(Copy, Clone)]342#[repr(C)]343pub(crate) enum RealPredicate {344 RealPredicateFalse = 0,345 RealOEQ = 1,346 RealOGT = 2,347 RealOGE = 3,348 RealOLT = 4,349 RealOLE = 5,350 RealONE = 6,351 RealORD = 7,352 RealUNO = 8,353 RealUEQ = 9,354 RealUGT = 10,355 RealUGE = 11,356 RealULT = 12,357 RealULE = 13,358 RealUNE = 14,359 RealPredicateTrue = 15,360}361362/// Must match the layout of `LLVMTypeKind`.363///364/// Use [`RawEnum<TypeKind>`] for values of `LLVMTypeKind` returned from LLVM,365/// to avoid risk of UB if LLVM adds new enum values.366///367/// All of LLVM's variants should be declared here, even if no Rust-side code refers368/// to them, because unknown variants will cause [`RawEnum::to_rust`] to panic.369#[derive(Copy, Clone, PartialEq, Debug, TryFromU32)]370#[repr(C)]371pub(crate) enum TypeKind {372 Void = 0,373 Half = 1,374 Float = 2,375 Double = 3,376 X86_FP80 = 4,377 FP128 = 5,378 PPC_FP128 = 6,379 Label = 7,380 Integer = 8,381 Function = 9,382 Struct = 10,383 Array = 11,384 Pointer = 12,385 Vector = 13,386 Metadata = 14,387 Token = 16,388 ScalableVector = 17,389 BFloat = 18,390 X86_AMX = 19,391}392393/// LLVMAtomicRmwBinOp394#[derive(Copy, Clone)]395#[repr(C)]396pub(crate) enum AtomicRmwBinOp {397 AtomicXchg = 0,398 AtomicAdd = 1,399 AtomicSub = 2,400 AtomicAnd = 3,401 AtomicNand = 4,402 AtomicOr = 5,403 AtomicXor = 6,404 AtomicMax = 7,405 AtomicMin = 8,406 AtomicUMax = 9,407 AtomicUMin = 10,408}409410/// LLVMAtomicOrdering411#[derive(Copy, Clone)]412#[repr(C)]413pub(crate) enum AtomicOrdering {414 #[allow(dead_code)]415 NotAtomic = 0,416 #[allow(dead_code)]417 Unordered = 1,418 Monotonic = 2,419 // Consume = 3, // Not specified yet.420 Acquire = 4,421 Release = 5,422 AcquireRelease = 6,423 SequentiallyConsistent = 7,424}425426/// LLVMRustFileType427#[derive(Copy, Clone)]428#[repr(C)]429pub(crate) enum FileType {430 AssemblyFile,431 ObjectFile,432}433434/// Must match the layout of `LLVMInlineAsmDialect`.435#[derive(Copy, Clone, PartialEq)]436#[repr(C)]437pub(crate) enum AsmDialect {438 Att,439 Intel,440}441442/// LLVMRustCodeGenOptLevel443#[derive(Copy, Clone, PartialEq)]444#[repr(C)]445pub(crate) enum CodeGenOptLevel {446 None,447 Less,448 Default,449 Aggressive,450}451452/// LLVMRustPassBuilderOptLevel453#[repr(C)]454pub(crate) enum PassBuilderOptLevel {455 O0,456 O1,457 O2,458 O3,459 Os,460 Oz,461}462463/// LLVMRustOptStage464#[derive(PartialEq)]465#[repr(C)]466pub(crate) enum OptStage {467 PreLinkNoLTO,468 PreLinkThinLTO,469 PreLinkFatLTO,470 ThinLTO,471 FatLTO,472}473474/// LLVMRustSanitizerOptions475#[repr(C)]476pub(crate) struct SanitizerOptions {477 pub sanitize_address: bool,478 pub sanitize_address_recover: bool,479 pub sanitize_cfi: bool,480 pub sanitize_dataflow: bool,481 pub sanitize_dataflow_abilist: *const *const c_char,482 pub sanitize_dataflow_abilist_len: size_t,483 pub sanitize_kcfi: bool,484 pub sanitize_memory: bool,485 pub sanitize_memory_recover: bool,486 pub sanitize_memory_track_origins: c_int,487 pub sanitize_realtime: bool,488 pub sanitize_thread: bool,489 pub sanitize_hwaddress: bool,490 pub sanitize_hwaddress_recover: bool,491 pub sanitize_kernel_address: bool,492 pub sanitize_kernel_address_recover: bool,493 pub sanitize_kernel_hwaddress: bool,494 pub sanitize_kernel_hwaddress_recover: bool,495}496497/// LLVMRustRelocModel498#[derive(Copy, Clone, PartialEq)]499#[repr(C)]500pub(crate) enum RelocModel {501 Static,502 PIC,503 DynamicNoPic,504 ROPI,505 RWPI,506 ROPI_RWPI,507}508509/// LLVMRustFloatABI510#[derive(Copy, Clone, PartialEq)]511#[repr(C)]512pub(crate) enum FloatAbi {513 Default,514 Soft,515 Hard,516}517518/// LLVMRustCodeModel519#[derive(Copy, Clone)]520#[repr(C)]521pub(crate) enum CodeModel {522 Tiny,523 Small,524 Kernel,525 Medium,526 Large,527 None,528}529530/// LLVMRustDiagnosticKind531#[derive(Copy, Clone)]532#[repr(C)]533#[allow(dead_code)] // Variants constructed by C++.534pub(crate) enum DiagnosticKind {535 Other,536 InlineAsm,537 StackSize,538 DebugMetadataVersion,539 SampleProfile,540 OptimizationRemark,541 OptimizationRemarkMissed,542 OptimizationRemarkAnalysis,543 OptimizationRemarkAnalysisFPCommute,544 OptimizationRemarkAnalysisAliasing,545 OptimizationRemarkOther,546 OptimizationFailure,547 PGOProfile,548 Linker,549 Unsupported,550 SrcMgr,551}552553/// LLVMRustDiagnosticLevel554#[derive(Copy, Clone)]555#[repr(C)]556#[allow(dead_code)] // Variants constructed by C++.557pub(crate) enum DiagnosticLevel {558 Error,559 Warning,560 Note,561 Remark,562}563564unsafe extern "C" {565 // LLVMRustThinLTOData566 pub(crate) type ThinLTOData;567}568569/// LLVMRustThinLTOModule570#[repr(C)]571pub(crate) struct ThinLTOModule {572 pub identifier: *const c_char,573 pub data: *const u8,574 pub len: usize,575}576577/// LLVMThreadLocalMode578#[derive(Copy, Clone)]579#[repr(C)]580pub(crate) enum ThreadLocalMode {581 #[expect(dead_code)]582 NotThreadLocal,583 GeneralDynamic,584 LocalDynamic,585 InitialExec,586 LocalExec,587}588589/// LLVMRustChecksumKind590#[derive(Copy, Clone)]591#[repr(C)]592pub(crate) enum ChecksumKind {593 None,594 MD5,595 SHA1,596 SHA256,597}598599/// LLVMRustMemoryEffects600#[derive(Copy, Clone)]601#[repr(C)]602pub(crate) enum MemoryEffects {603 None,604 ReadOnly,605 InaccessibleMemOnly,606 ReadOnlyNotPure,607}608609/// LLVMOpcode610#[derive(Copy, Clone, PartialEq, Eq)]611#[repr(C)]612#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM-C")]613pub(crate) enum Opcode {614 Ret = 1,615 Br = 2,616 Switch = 3,617 IndirectBr = 4,618 Invoke = 5,619 Unreachable = 7,620 CallBr = 67,621 FNeg = 66,622 Add = 8,623 FAdd = 9,624 Sub = 10,625 FSub = 11,626 Mul = 12,627 FMul = 13,628 UDiv = 14,629 SDiv = 15,630 FDiv = 16,631 URem = 17,632 SRem = 18,633 FRem = 19,634 Shl = 20,635 LShr = 21,636 AShr = 22,637 And = 23,638 Or = 24,639 Xor = 25,640 Alloca = 26,641 Load = 27,642 Store = 28,643 GetElementPtr = 29,644 Trunc = 30,645 ZExt = 31,646 SExt = 32,647 FPToUI = 33,648 FPToSI = 34,649 UIToFP = 35,650 SIToFP = 36,651 FPTrunc = 37,652 FPExt = 38,653 PtrToInt = 39,654 IntToPtr = 40,655 BitCast = 41,656 AddrSpaceCast = 60,657 ICmp = 42,658 FCmp = 43,659 PHI = 44,660 Call = 45,661 Select = 46,662 UserOp1 = 47,663 UserOp2 = 48,664 VAArg = 49,665 ExtractElement = 50,666 InsertElement = 51,667 ShuffleVector = 52,668 ExtractValue = 53,669 InsertValue = 54,670 Freeze = 68,671 Fence = 55,672 AtomicCmpXchg = 56,673 AtomicRMW = 57,674 Resume = 58,675 LandingPad = 59,676 CleanupRet = 61,677 CatchRet = 62,678 CatchPad = 63,679 CleanupPad = 64,680 CatchSwitch = 65,681}682683/// Must match the layout of `LLVMRustCompressionKind`.684#[derive(Copy, Clone)]685#[repr(C)]686pub(crate) enum CompressionKind {687 None = 0,688 Zlib = 1,689 Zstd = 2,690}691692unsafe extern "C" {693 type Opaque;694}695#[repr(C)]696struct InvariantOpaque<'a> {697 _marker: PhantomData<&'a mut &'a ()>,698 _opaque: Opaque,699}700701// Opaque pointer types702unsafe extern "C" {703 pub(crate) type Module;704 pub(crate) type Context;705 pub(crate) type Type;706 pub(crate) type Value;707 pub(crate) type ConstantInt;708 pub(crate) type Attribute;709 pub(crate) type Metadata;710 pub(crate) type BasicBlock;711 pub(crate) type Comdat;712 /// `&'ll DbgRecord` represents `LLVMDbgRecordRef`.713 pub(crate) type DbgRecord;714}715#[repr(C)]716pub(crate) struct Builder<'a>(InvariantOpaque<'a>);717#[repr(C)]718pub(crate) struct PassManager<'a>(InvariantOpaque<'a>);719unsafe extern "C" {720 pub type TargetMachine;721}722unsafe extern "C" {723 pub(crate) type Twine;724 pub(crate) type DiagnosticInfo;725 pub(crate) type SMDiagnostic;726}727/// Opaque pointee of `LLVMOperandBundleRef`.728#[repr(C)]729pub(crate) struct OperandBundle<'a>(InvariantOpaque<'a>);730#[repr(C)]731pub(crate) struct Linker<'a>(InvariantOpaque<'a>);732733unsafe extern "C" {734 pub(crate) type DiagnosticHandler;735}736737pub(crate) type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);738739pub(crate) mod debuginfo {740 use bitflags::bitflags;741742 use super::{InvariantOpaque, Metadata};743744 /// Opaque target type for references to an LLVM debuginfo builder.745 ///746 /// `&'_ DIBuilder<'ll>` corresponds to `LLVMDIBuilderRef`, which is the747 /// LLVM-C wrapper for `DIBuilder *`.748 ///749 /// Debuginfo builders are created and destroyed during codegen, so the750 /// builder reference typically has a shorter lifetime than the LLVM751 /// session (`'ll`) that it participates in.752 #[repr(C)]753 pub(crate) struct DIBuilder<'ll>(InvariantOpaque<'ll>);754755 pub(crate) type DIDescriptor = Metadata;756 pub(crate) type DILocation = Metadata;757 pub(crate) type DIScope = DIDescriptor;758 pub(crate) type DIFile = DIScope;759 pub(crate) type DILexicalBlock = DIScope;760 pub(crate) type DISubprogram = DIScope;761 pub(crate) type DIType = DIDescriptor;762 pub(crate) type DIBasicType = DIType;763 pub(crate) type DIDerivedType = DIType;764 pub(crate) type DICompositeType = DIDerivedType;765 pub(crate) type DIVariable = DIDescriptor;766 pub(crate) type DIArray = DIDescriptor;767 pub(crate) type DITemplateTypeParameter = DIDescriptor;768769 bitflags! {770 /// Must match the layout of `LLVMDIFlags` in the LLVM-C API.771 ///772 /// Each value declared here must also be covered by the static773 /// assertions in `RustWrapper.cpp` used by `fromRust(LLVMDIFlags)`.774 #[repr(transparent)]775 #[derive(Clone, Copy, Default)]776 pub(crate) struct DIFlags: u32 {777 const FlagZero = 0;778 const FlagPrivate = 1;779 const FlagProtected = 2;780 const FlagPublic = 3;781 const FlagFwdDecl = (1 << 2);782 const FlagAppleBlock = (1 << 3);783 const FlagReservedBit4 = (1 << 4);784 const FlagVirtual = (1 << 5);785 const FlagArtificial = (1 << 6);786 const FlagExplicit = (1 << 7);787 const FlagPrototyped = (1 << 8);788 const FlagObjcClassComplete = (1 << 9);789 const FlagObjectPointer = (1 << 10);790 const FlagVector = (1 << 11);791 const FlagStaticMember = (1 << 12);792 const FlagLValueReference = (1 << 13);793 const FlagRValueReference = (1 << 14);794 const FlagReserved = (1 << 15);795 const FlagSingleInheritance = (1 << 16);796 const FlagMultipleInheritance = (2 << 16);797 const FlagVirtualInheritance = (3 << 16);798 const FlagIntroducedVirtual = (1 << 18);799 const FlagBitField = (1 << 19);800 const FlagNoReturn = (1 << 20);801 // The bit at (1 << 21) is unused, but was `LLVMDIFlagMainSubprogram`.802 const FlagTypePassByValue = (1 << 22);803 const FlagTypePassByReference = (1 << 23);804 const FlagEnumClass = (1 << 24);805 const FlagThunk = (1 << 25);806 const FlagNonTrivial = (1 << 26);807 const FlagBigEndian = (1 << 27);808 const FlagLittleEndian = (1 << 28);809 }810 }811812 // These values **must** match with LLVMRustDISPFlags!!813 bitflags! {814 #[repr(transparent)]815 #[derive(Clone, Copy, Default)]816 pub(crate) struct DISPFlags: u32 {817 const SPFlagZero = 0;818 const SPFlagVirtual = 1;819 const SPFlagPureVirtual = 2;820 const SPFlagLocalToUnit = (1 << 2);821 const SPFlagDefinition = (1 << 3);822 const SPFlagOptimized = (1 << 4);823 const SPFlagMainSubprogram = (1 << 5);824 }825 }826827 /// LLVMRustDebugEmissionKind828 #[derive(Copy, Clone)]829 #[repr(C)]830 pub(crate) enum DebugEmissionKind {831 NoDebug,832 FullDebug,833 LineTablesOnly,834 DebugDirectivesOnly,835 }836837 /// LLVMRustDebugNameTableKind838 #[derive(Clone, Copy)]839 #[repr(C)]840 pub(crate) enum DebugNameTableKind {841 Default,842 #[expect(dead_code)]843 Gnu,844 None,845 }846}847848// These values **must** match with LLVMRustAllocKindFlags849bitflags! {850 #[repr(transparent)]851 #[derive(Default)]852 pub(crate) struct AllocKindFlags : u64 {853 const Unknown = 0;854 const Alloc = 1;855 const Realloc = 1 << 1;856 const Free = 1 << 2;857 const Uninitialized = 1 << 3;858 const Zeroed = 1 << 4;859 const Aligned = 1 << 5;860 }861}862863// These values **must** match with LLVMGEPNoWrapFlags864bitflags! {865 #[repr(transparent)]866 #[derive(Default)]867 pub struct GEPNoWrapFlags : c_uint {868 const InBounds = 1 << 0;869 const NUSW = 1 << 1;870 const NUW = 1 << 2;871 }872}873874unsafe extern "C" {875 pub(crate) type Buffer;876}877878pub(crate) type SelfProfileBeforePassCallback =879 unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);880pub(crate) type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);881882pub(crate) type GetSymbolsCallback =883 unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;884pub(crate) type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;885886unsafe extern "C" {887 // Create and destroy contexts.888 pub(crate) fn LLVMContextCreate() -> &'static mut Context;889 pub(crate) fn LLVMContextDispose(C: &'static mut Context);890 pub(crate) fn LLVMContextSetDiscardValueNames(C: &Context, Discard: Bool);891 pub(crate) fn LLVMGetMDKindIDInContext(892 C: &Context,893 Name: *const c_char,894 SLen: c_uint,895 ) -> MetadataKindId;896897 pub(crate) fn LLVMDisposeTargetMachine(T: ptr::NonNull<TargetMachine>);898899 // Create modules.900 pub(crate) fn LLVMModuleCreateWithNameInContext(901 ModuleID: *const c_char,902 C: &Context,903 ) -> &Module;904 pub(crate) safe fn LLVMCloneModule(M: &Module) -> &Module;905906 /// Data layout. See Module::getDataLayout.907 pub(crate) fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;908 pub(crate) fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);909910 /// Append inline assembly to a module. See `Module::appendModuleInlineAsm`.911 pub(crate) fn LLVMAppendModuleInlineAsm(912 M: &Module,913 Asm: *const c_uchar, // See "PTR_LEN_STR".914 Len: size_t,915 );916917 /// Create the specified uniqued inline asm string. See `InlineAsm::get()`.918 pub(crate) fn LLVMGetInlineAsm<'ll>(919 Ty: &'ll Type,920 AsmString: *const c_uchar, // See "PTR_LEN_STR".921 AsmStringSize: size_t,922 Constraints: *const c_uchar, // See "PTR_LEN_STR".923 ConstraintsSize: size_t,924 HasSideEffects: llvm::Bool,925 IsAlignStack: llvm::Bool,926 Dialect: AsmDialect,927 CanThrow: llvm::Bool,928 ) -> &'ll Value;929930 pub(crate) safe fn LLVMGetTypeKind(Ty: &Type) -> RawEnum<TypeKind>;931932 // Operations on integer types933 pub(crate) fn LLVMInt1TypeInContext(C: &Context) -> &Type;934 pub(crate) fn LLVMInt8TypeInContext(C: &Context) -> &Type;935 pub(crate) fn LLVMInt16TypeInContext(C: &Context) -> &Type;936 pub(crate) fn LLVMInt32TypeInContext(C: &Context) -> &Type;937 pub(crate) fn LLVMInt64TypeInContext(C: &Context) -> &Type;938 pub(crate) safe fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;939940 pub(crate) fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;941942 // Operations on real types943 pub(crate) fn LLVMHalfTypeInContext(C: &Context) -> &Type;944 pub(crate) fn LLVMFloatTypeInContext(C: &Context) -> &Type;945 pub(crate) fn LLVMDoubleTypeInContext(C: &Context) -> &Type;946 pub(crate) fn LLVMFP128TypeInContext(C: &Context) -> &Type;947948 // Operations on non-IEEE real types949 pub(crate) fn LLVMBFloatTypeInContext(C: &Context) -> &Type;950951 // Operations on function types952 pub(crate) fn LLVMFunctionType<'a>(953 ReturnType: &'a Type,954 ParamTypes: *const &'a Type,955 ParamCount: c_uint,956 IsVarArg: Bool,957 ) -> &'a Type;958 pub(crate) fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;959 pub(crate) fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);960 pub(crate) fn LLVMGetReturnType(FunctionTy: &Type) -> &Type;961 pub(crate) fn LLVMIsFunctionVarArg(FunctionTy: &Type) -> Bool;962963 // Operations on struct types964 pub(crate) fn LLVMStructTypeInContext<'a>(965 C: &'a Context,966 ElementTypes: *const &'a Type,967 ElementCount: c_uint,968 Packed: Bool,969 ) -> &'a Type;970971 // Operations on array, pointer, and vector types (sequence types)972 pub(crate) safe fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type;973 pub(crate) fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;974 pub(crate) fn LLVMScalableVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;975976 pub(crate) fn LLVMGetElementType(Ty: &Type) -> &Type;977 pub(crate) fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;978979 // Operations on other types980 pub(crate) fn LLVMVoidTypeInContext(C: &Context) -> &Type;981982 // Operations on all values983 pub(crate) fn LLVMTypeOf(Val: &Value) -> &Type;984 pub(crate) fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;985 pub(crate) fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);986 pub(crate) fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);987 pub(crate) safe fn LLVMGetMetadata<'a>(988 Val: &'a Value,989 KindID: MetadataKindId,990 ) -> Option<&'a Value>;991 pub(crate) safe fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: MetadataKindId, Node: &'a Value);992 pub(crate) fn LLVMGlobalSetMetadata<'a>(993 Val: &'a Value,994 KindID: MetadataKindId,995 Metadata: &'a Metadata,996 );997 pub(crate) safe fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;998999 // Operations on constants of any type1000 pub(crate) fn LLVMConstNull(Ty: &Type) -> &Value;1001 pub(crate) fn LLVMGetUndef(Ty: &Type) -> &Value;1002 pub(crate) fn LLVMGetPoison(Ty: &Type) -> &Value;10031004 // Operations on metadata1005 pub(crate) fn LLVMMDStringInContext2(1006 C: &Context,1007 Str: *const c_char,1008 SLen: size_t,1009 ) -> &Metadata;1010 pub(crate) fn LLVMMDNodeInContext2<'a>(1011 C: &'a Context,1012 Vals: *const &'a Metadata,1013 Count: size_t,1014 ) -> &'a Metadata;1015 pub(crate) fn LLVMAddNamedMetadataOperand<'a>(1016 M: &'a Module,1017 Name: *const c_char,1018 Val: &'a Value,1019 );1020 pub(crate) fn LLVMReplaceMDNodeOperandWith(Val: &Value, index: u32, replacement: &Metadata);10211022 // Operations on scalar constants1023 pub(crate) fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;1024 pub(crate) fn LLVMConstIntOfArbitraryPrecision(1025 IntTy: &Type,1026 Wn: c_uint,1027 Ws: *const u64,1028 ) -> &Value;1029 pub(crate) fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;10301031 // Operations on composite constants1032 pub(crate) fn LLVMConstArray2<'a>(1033 ElementTy: &'a Type,1034 ConstantVals: *const &'a Value,1035 Length: u64,1036 ) -> &'a Value;1037 pub(crate) fn LLVMArrayType2(ElementType: &Type, ElementCount: u64) -> &Type;1038 pub(crate) fn LLVMConstStringInContext2(1039 C: &Context,1040 Str: *const c_char,1041 Length: size_t,1042 DontNullTerminate: Bool,1043 ) -> &Value;1044 pub(crate) fn LLVMConstStructInContext<'a>(1045 C: &'a Context,1046 ConstantVals: *const &'a Value,1047 Count: c_uint,1048 Packed: Bool,1049 ) -> &'a Value;1050 pub(crate) fn LLVMConstNamedStruct<'a>(1051 StructTy: &'a Type,1052 ConstantVals: *const &'a Value,1053 Count: c_uint,1054 ) -> &'a Value;1055 pub(crate) fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;10561057 // Constant expressions1058 pub(crate) fn LLVMConstInBoundsGEP2<'a>(1059 ty: &'a Type,1060 ConstantVal: &'a Value,1061 ConstantIndices: *const &'a Value,1062 NumIndices: c_uint,1063 ) -> &'a Value;1064 pub(crate) fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;1065 pub(crate) fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;1066 pub(crate) fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;1067 pub(crate) fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;1068 pub(crate) fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;1069 pub(crate) fn LLVMGetConstOpcode(ConstantVal: &Value) -> Opcode;1070 pub(crate) fn LLVMIsAConstantExpr(Val: &Value) -> Option<&Value>;10711072 // Operations on global variables, functions, and aliases (globals)1073 pub(crate) fn LLVMIsDeclaration(Global: &Value) -> Bool;1074 pub(crate) fn LLVMGetLinkage(Global: &Value) -> RawEnum<Linkage>;1075 pub(crate) fn LLVMSetLinkage(Global: &Value, RustLinkage: Linkage);1076 pub(crate) fn LLVMSetSection(Global: &Value, Section: *const c_char);1077 pub(crate) fn LLVMGetVisibility(Global: &Value) -> RawEnum<Visibility>;1078 pub(crate) fn LLVMSetVisibility(Global: &Value, Viz: Visibility);1079 pub(crate) fn LLVMGetAlignment(Global: &Value) -> c_uint;1080 pub(crate) fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);1081 pub(crate) fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);1082 pub(crate) fn LLVMGlobalGetValueType(Global: &Value) -> &Type;10831084 // Operations on global variables1085 pub(crate) safe fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;1086 pub(crate) fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;1087 pub(crate) fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;1088 pub(crate) fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;1089 pub(crate) fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;1090 pub(crate) fn LLVMDeleteGlobal(GlobalVar: &Value);1091 pub(crate) safe fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;1092 pub(crate) fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);1093 pub(crate) safe fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;1094 pub(crate) fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);1095 pub(crate) safe fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;1096 pub(crate) safe fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);1097 pub(crate) safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);1098 pub(crate) safe fn LLVMSetTailCallKind(CallInst: &Value, kind: TailCallKind);1099 pub(crate) safe fn LLVMSetExternallyInitialized(GlobalVar: &Value, IsExtInit: Bool);11001101 // Operations on attributes1102 pub(crate) fn LLVMCreateStringAttribute(1103 C: &Context,1104 Name: *const c_char,1105 NameLen: c_uint,1106 Value: *const c_char,1107 ValueLen: c_uint,1108 ) -> &Attribute;11091110 // Operations on functions1111 pub(crate) fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);1112 pub(crate) fn LLVMAddFunction<'a>(1113 Mod: &'a Module,1114 Name: *const c_char,1115 FunctionTy: &'a Type,1116 ) -> &'a Value;1117 pub(crate) fn LLVMDeleteFunction(Fn: &Value);11181119 // Operations about llvm intrinsics1120 pub(crate) fn LLVMLookupIntrinsicID(Name: *const c_char, NameLen: size_t) -> c_uint;1121 pub(crate) fn LLVMIntrinsicIsOverloaded(ID: NonZero<c_uint>) -> Bool;1122 pub(crate) fn LLVMGetIntrinsicDeclaration<'a>(1123 Mod: &'a Module,1124 ID: NonZero<c_uint>,1125 ParamTypes: *const &'a Type,1126 ParamCount: size_t,1127 ) -> &'a Value;1128 pub(crate) fn LLVMRustUpgradeIntrinsicFunction<'a>(1129 Fn: &'a Value,1130 NewFn: &mut Option<&'a Value>,1131 ) -> bool;1132 pub(crate) fn LLVMRustIsTargetIntrinsic(ID: NonZero<c_uint>) -> bool;11331134 // Operations on parameters1135 pub(crate) fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;1136 pub(crate) safe fn LLVMCountParams(Fn: &Value) -> c_uint;1137 pub(crate) fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;11381139 // Operations on basic blocks1140 pub(crate) fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;1141 pub(crate) fn LLVMAppendBasicBlockInContext<'a>(1142 C: &'a Context,1143 Fn: &'a Value,1144 Name: *const c_char,1145 ) -> &'a BasicBlock;11461147 // Operations on instructions1148 pub(crate) fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;1149 pub(crate) fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;1150 pub(crate) fn LLVMGetOperand(Val: &Value, Index: c_uint) -> Option<&Value>;11511152 // Operations on call sites1153 pub(crate) fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);11541155 // Operations on load/store instructions (only)1156 pub(crate) fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);1157 pub(crate) fn LLVMSetOrdering(MemoryAccessInst: &Value, Ordering: AtomicOrdering);11581159 // Operations on phi nodes1160 pub(crate) fn LLVMAddIncoming<'a>(1161 PhiNode: &'a Value,1162 IncomingValues: *const &'a Value,1163 IncomingBlocks: *const &'a BasicBlock,1164 Count: c_uint,1165 );11661167 // Instruction builders1168 pub(crate) fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;1169 pub(crate) fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);1170 pub(crate) fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;1171 pub(crate) fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);11721173 // Metadata1174 pub(crate) fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata);1175 pub(crate) fn LLVMGetCurrentDebugLocation2<'a>(Builder: &Builder<'a>) -> Option<&'a Metadata>;11761177 // Terminators1178 pub(crate) safe fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;1179 pub(crate) fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;1180 pub(crate) fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;1181 pub(crate) fn LLVMBuildCondBr<'a>(1182 B: &Builder<'a>,1183 If: &'a Value,1184 Then: &'a BasicBlock,1185 Else: &'a BasicBlock,1186 ) -> &'a Value;1187 pub(crate) fn LLVMBuildSwitch<'a>(1188 B: &Builder<'a>,1189 V: &'a Value,1190 Else: &'a BasicBlock,1191 NumCases: c_uint,1192 ) -> &'a Value;1193 pub(crate) fn LLVMBuildLandingPad<'a>(1194 B: &Builder<'a>,1195 Ty: &'a Type,1196 PersFn: Option<&'a Value>,1197 NumClauses: c_uint,1198 Name: *const c_char,1199 ) -> &'a Value;1200 pub(crate) fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;1201 pub(crate) fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;12021203 pub(crate) fn LLVMBuildCleanupPad<'a>(1204 B: &Builder<'a>,1205 ParentPad: Option<&'a Value>,1206 Args: *const &'a Value,1207 NumArgs: c_uint,1208 Name: *const c_char,1209 ) -> Option<&'a Value>;1210 pub(crate) fn LLVMBuildCleanupRet<'a>(1211 B: &Builder<'a>,1212 CleanupPad: &'a Value,1213 BB: Option<&'a BasicBlock>,1214 ) -> Option<&'a Value>;1215 pub(crate) fn LLVMBuildCatchPad<'a>(1216 B: &Builder<'a>,1217 ParentPad: &'a Value,1218 Args: *const &'a Value,1219 NumArgs: c_uint,1220 Name: *const c_char,1221 ) -> Option<&'a Value>;1222 pub(crate) fn LLVMBuildCatchRet<'a>(1223 B: &Builder<'a>,1224 CatchPad: &'a Value,1225 BB: &'a BasicBlock,1226 ) -> Option<&'a Value>;1227 pub(crate) fn LLVMBuildCatchSwitch<'a>(1228 Builder: &Builder<'a>,1229 ParentPad: Option<&'a Value>,1230 UnwindBB: Option<&'a BasicBlock>,1231 NumHandlers: c_uint,1232 Name: *const c_char,1233 ) -> Option<&'a Value>;1234 pub(crate) fn LLVMAddHandler<'a>(CatchSwitch: &'a Value, Dest: &'a BasicBlock);1235 pub(crate) fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);12361237 // Add a case to the switch instruction1238 pub(crate) fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);12391240 // Add a clause to the landing pad instruction1241 pub(crate) fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);12421243 // Set the cleanup on a landing pad instruction1244 pub(crate) fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);12451246 // Arithmetic1247 pub(crate) fn LLVMBuildAdd<'a>(1248 B: &Builder<'a>,1249 LHS: &'a Value,1250 RHS: &'a Value,1251 Name: *const c_char,1252 ) -> &'a Value;1253 pub(crate) fn LLVMBuildFAdd<'a>(1254 B: &Builder<'a>,1255 LHS: &'a Value,1256 RHS: &'a Value,1257 Name: *const c_char,1258 ) -> &'a Value;1259 pub(crate) fn LLVMBuildSub<'a>(1260 B: &Builder<'a>,1261 LHS: &'a Value,1262 RHS: &'a Value,1263 Name: *const c_char,1264 ) -> &'a Value;1265 pub(crate) fn LLVMBuildFSub<'a>(1266 B: &Builder<'a>,1267 LHS: &'a Value,1268 RHS: &'a Value,1269 Name: *const c_char,1270 ) -> &'a Value;1271 pub(crate) fn LLVMBuildMul<'a>(1272 B: &Builder<'a>,1273 LHS: &'a Value,1274 RHS: &'a Value,1275 Name: *const c_char,1276 ) -> &'a Value;1277 pub(crate) fn LLVMBuildFMul<'a>(1278 B: &Builder<'a>,1279 LHS: &'a Value,1280 RHS: &'a Value,1281 Name: *const c_char,1282 ) -> &'a Value;1283 pub(crate) fn LLVMBuildUDiv<'a>(1284 B: &Builder<'a>,1285 LHS: &'a Value,1286 RHS: &'a Value,1287 Name: *const c_char,1288 ) -> &'a Value;1289 pub(crate) fn LLVMBuildExactUDiv<'a>(1290 B: &Builder<'a>,1291 LHS: &'a Value,1292 RHS: &'a Value,1293 Name: *const c_char,1294 ) -> &'a Value;1295 pub(crate) fn LLVMBuildSDiv<'a>(1296 B: &Builder<'a>,1297 LHS: &'a Value,1298 RHS: &'a Value,1299 Name: *const c_char,1300 ) -> &'a Value;1301 pub(crate) fn LLVMBuildExactSDiv<'a>(1302 B: &Builder<'a>,1303 LHS: &'a Value,1304 RHS: &'a Value,1305 Name: *const c_char,1306 ) -> &'a Value;1307 pub(crate) fn LLVMBuildFDiv<'a>(1308 B: &Builder<'a>,1309 LHS: &'a Value,1310 RHS: &'a Value,1311 Name: *const c_char,1312 ) -> &'a Value;1313 pub(crate) fn LLVMBuildURem<'a>(1314 B: &Builder<'a>,1315 LHS: &'a Value,1316 RHS: &'a Value,1317 Name: *const c_char,1318 ) -> &'a Value;1319 pub(crate) fn LLVMBuildSRem<'a>(1320 B: &Builder<'a>,1321 LHS: &'a Value,1322 RHS: &'a Value,1323 Name: *const c_char,1324 ) -> &'a Value;1325 pub(crate) fn LLVMBuildFRem<'a>(1326 B: &Builder<'a>,1327 LHS: &'a Value,1328 RHS: &'a Value,1329 Name: *const c_char,1330 ) -> &'a Value;1331 pub(crate) fn LLVMBuildShl<'a>(1332 B: &Builder<'a>,1333 LHS: &'a Value,1334 RHS: &'a Value,1335 Name: *const c_char,1336 ) -> &'a Value;1337 pub(crate) fn LLVMBuildLShr<'a>(1338 B: &Builder<'a>,1339 LHS: &'a Value,1340 RHS: &'a Value,1341 Name: *const c_char,1342 ) -> &'a Value;1343 pub(crate) fn LLVMBuildAShr<'a>(1344 B: &Builder<'a>,1345 LHS: &'a Value,1346 RHS: &'a Value,1347 Name: *const c_char,1348 ) -> &'a Value;1349 pub(crate) fn LLVMBuildNSWAdd<'a>(1350 B: &Builder<'a>,1351 LHS: &'a Value,1352 RHS: &'a Value,1353 Name: *const c_char,1354 ) -> &'a Value;1355 pub(crate) fn LLVMBuildNUWAdd<'a>(1356 B: &Builder<'a>,1357 LHS: &'a Value,1358 RHS: &'a Value,1359 Name: *const c_char,1360 ) -> &'a Value;1361 pub(crate) fn LLVMBuildNSWSub<'a>(1362 B: &Builder<'a>,1363 LHS: &'a Value,1364 RHS: &'a Value,1365 Name: *const c_char,1366 ) -> &'a Value;1367 pub(crate) fn LLVMBuildNUWSub<'a>(1368 B: &Builder<'a>,1369 LHS: &'a Value,1370 RHS: &'a Value,1371 Name: *const c_char,1372 ) -> &'a Value;1373 pub(crate) fn LLVMBuildNSWMul<'a>(1374 B: &Builder<'a>,1375 LHS: &'a Value,1376 RHS: &'a Value,1377 Name: *const c_char,1378 ) -> &'a Value;1379 pub(crate) fn LLVMBuildNUWMul<'a>(1380 B: &Builder<'a>,1381 LHS: &'a Value,1382 RHS: &'a Value,1383 Name: *const c_char,1384 ) -> &'a Value;1385 pub(crate) fn LLVMBuildAnd<'a>(1386 B: &Builder<'a>,1387 LHS: &'a Value,1388 RHS: &'a Value,1389 Name: *const c_char,1390 ) -> &'a Value;1391 pub(crate) fn LLVMBuildOr<'a>(1392 B: &Builder<'a>,1393 LHS: &'a Value,1394 RHS: &'a Value,1395 Name: *const c_char,1396 ) -> &'a Value;1397 pub(crate) fn LLVMBuildXor<'a>(1398 B: &Builder<'a>,1399 LHS: &'a Value,1400 RHS: &'a Value,1401 Name: *const c_char,1402 ) -> &'a Value;1403 pub(crate) fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char)1404 -> &'a Value;1405 pub(crate) fn LLVMBuildFNeg<'a>(1406 B: &Builder<'a>,1407 V: &'a Value,1408 Name: *const c_char,1409 ) -> &'a Value;1410 pub(crate) fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char)1411 -> &'a Value;14121413 // Extra flags on arithmetic1414 pub(crate) fn LLVMSetIsDisjoint(Instr: &Value, IsDisjoint: Bool);1415 pub(crate) fn LLVMSetNUW(ArithInst: &Value, HasNUW: Bool);1416 pub(crate) fn LLVMSetNSW(ArithInst: &Value, HasNSW: Bool);14171418 // Memory1419 pub(crate) fn LLVMBuildAlloca<'a>(1420 B: &Builder<'a>,1421 Ty: &'a Type,1422 Name: *const c_char,1423 ) -> &'a Value;1424 pub(crate) fn LLVMBuildLoad2<'a>(1425 B: &Builder<'a>,1426 Ty: &'a Type,1427 PointerVal: &'a Value,1428 Name: *const c_char,1429 ) -> &'a Value;14301431 pub(crate) fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;14321433 pub(crate) fn LLVMBuildGEPWithNoWrapFlags<'a>(1434 B: &Builder<'a>,1435 Ty: &'a Type,1436 Pointer: &'a Value,1437 Indices: *const &'a Value,1438 NumIndices: c_uint,1439 Name: *const c_char,1440 Flags: GEPNoWrapFlags,1441 ) -> &'a Value;14421443 // Casts1444 pub(crate) fn LLVMBuildTrunc<'a>(1445 B: &Builder<'a>,1446 Val: &'a Value,1447 DestTy: &'a Type,1448 Name: *const c_char,1449 ) -> &'a Value;1450 pub(crate) fn LLVMBuildZExt<'a>(1451 B: &Builder<'a>,1452 Val: &'a Value,1453 DestTy: &'a Type,1454 Name: *const c_char,1455 ) -> &'a Value;1456 pub(crate) fn LLVMBuildSExt<'a>(1457 B: &Builder<'a>,1458 Val: &'a Value,1459 DestTy: &'a Type,1460 Name: *const c_char,1461 ) -> &'a Value;1462 pub(crate) fn LLVMBuildFPToUI<'a>(1463 B: &Builder<'a>,1464 Val: &'a Value,1465 DestTy: &'a Type,1466 Name: *const c_char,1467 ) -> &'a Value;1468 pub(crate) fn LLVMBuildFPToSI<'a>(1469 B: &Builder<'a>,1470 Val: &'a Value,1471 DestTy: &'a Type,1472 Name: *const c_char,1473 ) -> &'a Value;1474 pub(crate) fn LLVMBuildUIToFP<'a>(1475 B: &Builder<'a>,1476 Val: &'a Value,1477 DestTy: &'a Type,1478 Name: *const c_char,1479 ) -> &'a Value;1480 pub(crate) fn LLVMBuildSIToFP<'a>(1481 B: &Builder<'a>,1482 Val: &'a Value,1483 DestTy: &'a Type,1484 Name: *const c_char,1485 ) -> &'a Value;1486 pub(crate) fn LLVMBuildFPTrunc<'a>(1487 B: &Builder<'a>,1488 Val: &'a Value,1489 DestTy: &'a Type,1490 Name: *const c_char,1491 ) -> &'a Value;1492 pub(crate) fn LLVMBuildFPExt<'a>(1493 B: &Builder<'a>,1494 Val: &'a Value,1495 DestTy: &'a Type,1496 Name: *const c_char,1497 ) -> &'a Value;1498 pub(crate) fn LLVMBuildPtrToInt<'a>(1499 B: &Builder<'a>,1500 Val: &'a Value,1501 DestTy: &'a Type,1502 Name: *const c_char,1503 ) -> &'a Value;1504 pub(crate) fn LLVMBuildIntToPtr<'a>(1505 B: &Builder<'a>,1506 Val: &'a Value,1507 DestTy: &'a Type,1508 Name: *const c_char,1509 ) -> &'a Value;1510 pub(crate) fn LLVMBuildBitCast<'a>(1511 B: &Builder<'a>,1512 Val: &'a Value,1513 DestTy: &'a Type,1514 Name: *const c_char,1515 ) -> &'a Value;1516 pub(crate) fn LLVMBuildPointerCast<'a>(1517 B: &Builder<'a>,1518 Val: &'a Value,1519 DestTy: &'a Type,1520 Name: *const c_char,1521 ) -> &'a Value;1522 pub(crate) fn LLVMBuildIntCast2<'a>(1523 B: &Builder<'a>,1524 Val: &'a Value,1525 DestTy: &'a Type,1526 IsSigned: Bool,1527 Name: *const c_char,1528 ) -> &'a Value;15291530 // Comparisons1531 pub(crate) fn LLVMBuildICmp<'a>(1532 B: &Builder<'a>,1533 Op: c_uint,1534 LHS: &'a Value,1535 RHS: &'a Value,1536 Name: *const c_char,1537 ) -> &'a Value;1538 pub(crate) fn LLVMBuildFCmp<'a>(1539 B: &Builder<'a>,1540 Op: c_uint,1541 LHS: &'a Value,1542 RHS: &'a Value,1543 Name: *const c_char,1544 ) -> &'a Value;15451546 // Miscellaneous instructions1547 pub(crate) fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char)1548 -> &'a Value;1549 pub(crate) fn LLVMBuildSelect<'a>(1550 B: &Builder<'a>,1551 If: &'a Value,1552 Then: &'a Value,1553 Else: &'a Value,1554 Name: *const c_char,1555 ) -> &'a Value;1556 pub(crate) fn LLVMBuildVAArg<'a>(1557 B: &Builder<'a>,1558 list: &'a Value,1559 Ty: &'a Type,1560 Name: *const c_char,1561 ) -> &'a Value;1562 pub(crate) fn LLVMBuildExtractElement<'a>(1563 B: &Builder<'a>,1564 VecVal: &'a Value,1565 Index: &'a Value,1566 Name: *const c_char,1567 ) -> &'a Value;1568 pub(crate) fn LLVMBuildInsertElement<'a>(1569 B: &Builder<'a>,1570 VecVal: &'a Value,1571 EltVal: &'a Value,1572 Index: &'a Value,1573 Name: *const c_char,1574 ) -> &'a Value;1575 pub(crate) fn LLVMBuildShuffleVector<'a>(1576 B: &Builder<'a>,1577 V1: &'a Value,1578 V2: &'a Value,1579 Mask: &'a Value,1580 Name: *const c_char,1581 ) -> &'a Value;1582 pub(crate) fn LLVMBuildExtractValue<'a>(1583 B: &Builder<'a>,1584 AggVal: &'a Value,1585 Index: c_uint,1586 Name: *const c_char,1587 ) -> &'a Value;1588 pub(crate) fn LLVMBuildInsertValue<'a>(1589 B: &Builder<'a>,1590 AggVal: &'a Value,1591 EltVal: &'a Value,1592 Index: c_uint,1593 Name: *const c_char,1594 ) -> &'a Value;15951596 // Atomic Operations1597 pub(crate) fn LLVMBuildAtomicCmpXchg<'a>(1598 B: &Builder<'a>,1599 LHS: &'a Value,1600 CMP: &'a Value,1601 RHS: &'a Value,1602 Order: AtomicOrdering,1603 FailureOrder: AtomicOrdering,1604 SingleThreaded: Bool,1605 ) -> &'a Value;16061607 pub(crate) fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool);16081609 pub(crate) fn LLVMBuildAtomicRMW<'a>(1610 B: &Builder<'a>,1611 Op: AtomicRmwBinOp,1612 LHS: &'a Value,1613 RHS: &'a Value,1614 Order: AtomicOrdering,1615 SingleThreaded: Bool,1616 ) -> &'a Value;16171618 pub(crate) fn LLVMBuildFence<'a>(1619 B: &Builder<'a>,1620 Order: AtomicOrdering,1621 SingleThreaded: Bool,1622 Name: *const c_char,1623 ) -> &'a Value;16241625 /// Writes a module to the specified path. Returns 0 on success.1626 pub(crate) fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;16271628 /// Creates a legacy pass manager -- only used for final codegen.1629 pub(crate) fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;16301631 pub(crate) fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);16321633 pub(crate) fn LLVMGetHostCPUFeatures() -> *mut c_char;16341635 pub(crate) fn LLVMDisposeMessage(message: *mut c_char);16361637 pub(crate) fn LLVMIsMultithreaded() -> Bool;16381639 pub(crate) fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;16401641 pub(crate) fn LLVMStructSetBody<'a>(1642 StructTy: &'a Type,1643 ElementTypes: *const &'a Type,1644 ElementCount: c_uint,1645 Packed: Bool,1646 );16471648 pub(crate) fn LLVMCountStructElementTypes(StructTy: &Type) -> c_uint;1649 pub(crate) fn LLVMGetStructElementTypes<'a>(StructTy: &'a Type, Dest: *mut &'a Type);16501651 pub(crate) safe fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;16521653 pub(crate) safe fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);16541655 pub(crate) fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;16561657 pub(crate) fn LLVMGetOrInsertComdat(M: &Module, Name: *const c_char) -> &Comdat;1658 pub(crate) fn LLVMSetComdat(V: &Value, C: &Comdat);16591660 pub(crate) fn LLVMCreateOperandBundle(1661 Tag: *const c_char,1662 TagLen: size_t,1663 Args: *const &'_ Value,1664 NumArgs: c_uint,1665 ) -> *mut OperandBundle<'_>;1666 pub(crate) fn LLVMDisposeOperandBundle(Bundle: ptr::NonNull<OperandBundle<'_>>);16671668 pub(crate) fn LLVMBuildCallWithOperandBundles<'a>(1669 B: &Builder<'a>,1670 Ty: &'a Type,1671 Fn: &'a Value,1672 Args: *const &'a Value,1673 NumArgs: c_uint,1674 Bundles: *const &OperandBundle<'a>,1675 NumBundles: c_uint,1676 Name: *const c_char,1677 ) -> &'a Value;1678 pub(crate) fn LLVMBuildInvokeWithOperandBundles<'a>(1679 B: &Builder<'a>,1680 Ty: &'a Type,1681 Fn: &'a Value,1682 Args: *const &'a Value,1683 NumArgs: c_uint,1684 Then: &'a BasicBlock,1685 Catch: &'a BasicBlock,1686 Bundles: *const &OperandBundle<'a>,1687 NumBundles: c_uint,1688 Name: *const c_char,1689 ) -> &'a Value;1690 pub(crate) fn LLVMBuildCallBr<'a>(1691 B: &Builder<'a>,1692 Ty: &'a Type,1693 Fn: &'a Value,1694 DefaultDest: &'a BasicBlock,1695 IndirectDests: *const &'a BasicBlock,1696 NumIndirectDests: c_uint,1697 Args: *const &'a Value,1698 NumArgs: c_uint,1699 Bundles: *const &OperandBundle<'a>,1700 NumBundles: c_uint,1701 Name: *const c_char,1702 ) -> &'a Value;1703}17041705#[cfg(feature = "llvm_offload")]1706pub(crate) use self::Offload::*;17071708#[cfg(feature = "llvm_offload")]1709mod Offload {1710 use super::*;1711 unsafe extern "C" {1712 /// Processes the module and writes it in an offload compatible way into a "device.bin" file.1713 pub(crate) fn LLVMRustBundleImages<'a>(1714 M: &'a Module,1715 TM: &'a TargetMachine,1716 device_bin: *const c_char,1717 ) -> bool;1718 pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>(1719 _M: &'a Module,1720 _device_bin: *const c_char,1721 ) -> bool;1722 pub(crate) fn LLVMRustOffloadMapper<'a>(1723 OldFn: &'a Value,1724 NewFn: &'a Value,1725 RebuiltArgs: *const &Value,1726 );1727 }1728}17291730#[cfg(not(feature = "llvm_offload"))]1731pub(crate) use self::Offload_fallback::*;17321733#[cfg(not(feature = "llvm_offload"))]1734mod Offload_fallback {1735 use super::*;1736 /// Processes the module and writes it in an offload compatible way into a "device.bin" file.1737 /// Marked as unsafe to match the real offload wrapper which is unsafe due to FFI.1738 #[allow(unused_unsafe)]1739 pub(crate) unsafe fn LLVMRustBundleImages<'a>(1740 _M: &'a Module,1741 _TM: &'a TargetMachine,1742 _device_bin: *const c_char,1743 ) -> bool {1744 unimplemented!("This rustc version was not built with LLVM Offload support!");1745 }1746 pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>(1747 _M: &'a Module,1748 _device_bin: *const c_char,1749 ) -> bool {1750 unimplemented!("This rustc version was not built with LLVM Offload support!");1751 }1752 #[allow(unused_unsafe)]1753 pub(crate) unsafe fn LLVMRustOffloadMapper<'a>(1754 _OldFn: &'a Value,1755 _NewFn: &'a Value,1756 _RebuiltArgs: *const &Value,1757 ) {1758 unimplemented!("This rustc version was not built with LLVM Offload support!");1759 }1760}17611762// FFI bindings for `DIBuilder` functions in the LLVM-C API.1763// Try to keep these in the same order as in `llvm/include/llvm-c/DebugInfo.h`.1764//1765// FIXME(#134001): Audit all `Option` parameters, especially in lists, to check1766// that they really are nullable on the C/C++ side. LLVM doesn't appear to1767// actually document which ones are nullable.1768unsafe extern "C" {1769 pub(crate) fn LLVMCreateDIBuilder<'ll>(M: &'ll Module) -> *mut DIBuilder<'ll>;1770 pub(crate) fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull<DIBuilder<'ll>>);17711772 pub(crate) fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>);17731774 pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>(1775 Builder: &DIBuilder<'ll>,1776 ParentScope: Option<&'ll Metadata>,1777 Name: *const c_uchar, // See "PTR_LEN_STR".1778 NameLen: size_t,1779 ExportSymbols: llvm::Bool,1780 ) -> &'ll Metadata;17811782 pub(crate) fn LLVMDIBuilderCreateLexicalBlock<'ll>(1783 Builder: &DIBuilder<'ll>,1784 Scope: &'ll Metadata,1785 File: &'ll Metadata,1786 Line: c_uint,1787 Column: c_uint,1788 ) -> &'ll Metadata;17891790 pub(crate) fn LLVMDIBuilderCreateLexicalBlockFile<'ll>(1791 Builder: &DIBuilder<'ll>,1792 Scope: &'ll Metadata,1793 File: &'ll Metadata,1794 Discriminator: c_uint, // (optional "DWARF path discriminator"; default is 0)1795 ) -> &'ll Metadata;17961797 pub(crate) fn LLVMDIBuilderCreateDebugLocation<'ll>(1798 Ctx: &'ll Context,1799 Line: c_uint,1800 Column: c_uint,1801 Scope: &'ll Metadata,1802 InlinedAt: Option<&'ll Metadata>,1803 ) -> &'ll Metadata;18041805 pub(crate) fn LLVMDIBuilderCreateSubroutineType<'ll>(1806 Builder: &DIBuilder<'ll>,1807 File: Option<&'ll Metadata>, // (ignored and has no effect)1808 ParameterTypes: *const Option<&'ll Metadata>,1809 NumParameterTypes: c_uint,1810 Flags: DIFlags, // (default is `DIFlags::DIFlagZero`)1811 ) -> &'ll Metadata;18121813 pub(crate) fn LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision<'ll>(1814 Builder: &DIBuilder<'ll>,1815 Name: *const c_uchar, // See "PTR_LEN_STR".1816 NameLen: size_t,1817 SizeInBits: u64,1818 Words: *const u64, // LLVM computes `NumWords = (SizeInBits + 63) / 64`.1819 IsUnsigned: llvm::Bool,1820 ) -> &'ll Metadata;18211822 pub(crate) fn LLVMDIBuilderCreateUnionType<'ll>(1823 Builder: &DIBuilder<'ll>,1824 Scope: Option<&'ll Metadata>,1825 Name: *const c_uchar, // See "PTR_LEN_STR".1826 NameLen: size_t,1827 File: &'ll Metadata,1828 LineNumber: c_uint,1829 SizeInBits: u64,1830 AlignInBits: u32,1831 Flags: DIFlags,1832 Elements: *const Option<&'ll Metadata>,1833 NumElements: c_uint,1834 RunTimeLang: c_uint, // (optional Objective-C runtime version; default is 0)1835 UniqueId: *const c_uchar, // See "PTR_LEN_STR".1836 UniqueIdLen: size_t,1837 ) -> &'ll Metadata;18381839 pub(crate) fn LLVMDIBuilderCreateArrayType<'ll>(1840 Builder: &DIBuilder<'ll>,1841 Size: u64,1842 Align: u32,1843 Ty: &'ll Metadata,1844 Subscripts: *const &'ll Metadata,1845 NumSubscripts: c_uint,1846 ) -> &'ll Metadata;18471848 pub(crate) fn LLVMDIBuilderCreateBasicType<'ll>(1849 Builder: &DIBuilder<'ll>,1850 Name: *const c_uchar, // See "PTR_LEN_STR".1851 NameLen: size_t,1852 SizeInBits: u64,1853 Encoding: c_uint, // (`LLVMDWARFTypeEncoding`)1854 Flags: DIFlags, // (default is `DIFlags::DIFlagZero`)1855 ) -> &'ll Metadata;18561857 pub(crate) fn LLVMDIBuilderCreatePointerType<'ll>(1858 Builder: &DIBuilder<'ll>,1859 PointeeTy: &'ll Metadata,1860 SizeInBits: u64,1861 AlignInBits: u32,1862 AddressSpace: c_uint, // (optional DWARF address space; default is 0)1863 Name: *const c_uchar, // See "PTR_LEN_STR".1864 NameLen: size_t,1865 ) -> &'ll Metadata;18661867 pub(crate) fn LLVMDIBuilderCreateStructType<'ll>(1868 Builder: &DIBuilder<'ll>,1869 Scope: Option<&'ll Metadata>,1870 Name: *const c_uchar, // See "PTR_LEN_STR".1871 NameLen: size_t,1872 File: &'ll Metadata,1873 LineNumber: c_uint,1874 SizeInBits: u64,1875 AlignInBits: u32,1876 Flags: DIFlags,1877 DerivedFrom: Option<&'ll Metadata>,1878 Elements: *const Option<&'ll Metadata>,1879 NumElements: c_uint,1880 RunTimeLang: c_uint, // (optional Objective-C runtime version; default is 0)1881 VTableHolder: Option<&'ll Metadata>,1882 UniqueId: *const c_uchar, // See "PTR_LEN_STR".1883 UniqueIdLen: size_t,1884 ) -> &'ll Metadata;18851886 pub(crate) fn LLVMDIBuilderCreateMemberType<'ll>(1887 Builder: &DIBuilder<'ll>,1888 Scope: &'ll Metadata,1889 Name: *const c_uchar, // See "PTR_LEN_STR".1890 NameLen: size_t,1891 File: &'ll Metadata,1892 LineNo: c_uint,1893 SizeInBits: u64,1894 AlignInBits: u32,1895 OffsetInBits: u64,1896 Flags: DIFlags,1897 Ty: &'ll Metadata,1898 ) -> &'ll Metadata;18991900 pub(crate) fn LLVMDIBuilderCreateStaticMemberType<'ll>(1901 Builder: &DIBuilder<'ll>,1902 Scope: &'ll Metadata,1903 Name: *const c_uchar, // See "PTR_LEN_STR".1904 NameLen: size_t,1905 File: &'ll Metadata,1906 LineNumber: c_uint,1907 Type: &'ll Metadata,1908 Flags: DIFlags,1909 ConstantVal: Option<&'ll Value>,1910 AlignInBits: u32,1911 ) -> &'ll Metadata;19121913 /// Creates a "qualified type" in the C/C++ sense, by adding modifiers1914 /// like `const` or `volatile`.1915 pub(crate) fn LLVMDIBuilderCreateQualifiedType<'ll>(1916 Builder: &DIBuilder<'ll>,1917 Tag: c_uint, // (DWARF tag, e.g. `DW_TAG_const_type`)1918 Type: &'ll Metadata,1919 ) -> &'ll Metadata;19201921 pub(crate) fn LLVMDIBuilderCreateTypedef<'ll>(1922 Builder: &DIBuilder<'ll>,1923 Type: &'ll Metadata,1924 Name: *const c_uchar, // See "PTR_LEN_STR".1925 NameLen: size_t,1926 File: &'ll Metadata,1927 LineNo: c_uint,1928 Scope: Option<&'ll Metadata>,1929 AlignInBits: u32, // (optional; default is 0)1930 ) -> &'ll Metadata;19311932 pub(crate) fn LLVMDIBuilderGetOrCreateSubrange<'ll>(1933 Builder: &DIBuilder<'ll>,1934 LowerBound: i64,1935 Count: i64,1936 ) -> &'ll Metadata;19371938 pub(crate) fn LLVMDIBuilderGetOrCreateArray<'ll>(1939 Builder: &DIBuilder<'ll>,1940 Data: *const Option<&'ll Metadata>,1941 NumElements: size_t,1942 ) -> &'ll Metadata;19431944 pub(crate) fn LLVMDIBuilderCreateExpression<'ll>(1945 Builder: &DIBuilder<'ll>,1946 Addr: *const u64,1947 Length: size_t,1948 ) -> &'ll Metadata;19491950 pub(crate) fn LLVMDIBuilderCreateGlobalVariableExpression<'ll>(1951 Builder: &DIBuilder<'ll>,1952 Scope: Option<&'ll Metadata>,1953 Name: *const c_uchar, // See "PTR_LEN_STR".1954 NameLen: size_t,1955 Linkage: *const c_uchar, // See "PTR_LEN_STR".1956 LinkLen: size_t,1957 File: &'ll Metadata,1958 LineNo: c_uint,1959 Ty: &'ll Metadata,1960 LocalToUnit: llvm::Bool,1961 Expr: &'ll Metadata,1962 Decl: Option<&'ll Metadata>,1963 AlignInBits: u32,1964 ) -> &'ll Metadata;19651966 pub(crate) fn LLVMDIBuilderInsertDeclareRecordAtEnd<'ll>(1967 Builder: &DIBuilder<'ll>,1968 Storage: &'ll Value,1969 VarInfo: &'ll Metadata,1970 Expr: &'ll Metadata,1971 DebugLoc: &'ll Metadata,1972 Block: &'ll BasicBlock,1973 ) -> &'ll DbgRecord;19741975 pub(crate) fn LLVMDIBuilderInsertDbgValueRecordAtEnd<'ll>(1976 Builder: &DIBuilder<'ll>,1977 Val: &'ll Value,1978 VarInfo: &'ll Metadata,1979 Expr: &'ll Metadata,1980 DebugLoc: &'ll Metadata,1981 Block: &'ll BasicBlock,1982 ) -> &'ll DbgRecord;19831984 pub(crate) fn LLVMDIBuilderCreateAutoVariable<'ll>(1985 Builder: &DIBuilder<'ll>,1986 Scope: &'ll Metadata,1987 Name: *const c_uchar, // See "PTR_LEN_STR".1988 NameLen: size_t,1989 File: &'ll Metadata,1990 LineNo: c_uint,1991 Ty: &'ll Metadata,1992 AlwaysPreserve: llvm::Bool, // "If true, this descriptor will survive optimizations."1993 Flags: DIFlags,1994 AlignInBits: u32,1995 ) -> &'ll Metadata;19961997 pub(crate) fn LLVMDIBuilderCreateParameterVariable<'ll>(1998 Builder: &DIBuilder<'ll>,1999 Scope: &'ll Metadata,2000 Name: *const c_uchar, // See "PTR_LEN_STR".
Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.