]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Rollup merge of #85770 - Bobo1239:set_locale_for_sort, r=jyn514
[rust.git] / compiler / rustc_codegen_llvm / src / llvm / ffi.rs
1 #![allow(non_camel_case_types)]
2 #![allow(non_upper_case_globals)]
3
4 use rustc_codegen_ssa::coverageinfo::map as coverage_map;
5
6 use super::debuginfo::{
7     DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
8     DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
9     DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
10     DebugEmissionKind,
11 };
12
13 use libc::{c_char, c_int, c_uint, size_t};
14 use libc::{c_ulonglong, c_void};
15
16 use std::marker::PhantomData;
17
18 use super::RustString;
19
20 pub type Bool = c_uint;
21
22 pub const True: Bool = 1 as Bool;
23 pub const False: Bool = 0 as Bool;
24
25 #[derive(Copy, Clone, PartialEq)]
26 #[repr(C)]
27 #[allow(dead_code)] // Variants constructed by C++.
28 pub enum LLVMRustResult {
29     Success,
30     Failure,
31 }
32 // Consts for the LLVM CallConv type, pre-cast to usize.
33
34 /// LLVM CallingConv::ID. Should we wrap this?
35 #[derive(Copy, Clone, PartialEq, Debug)]
36 #[repr(C)]
37 pub enum CallConv {
38     CCallConv = 0,
39     FastCallConv = 8,
40     ColdCallConv = 9,
41     X86StdcallCallConv = 64,
42     X86FastcallCallConv = 65,
43     ArmAapcsCallConv = 67,
44     Msp430Intr = 69,
45     X86_ThisCall = 70,
46     PtxKernel = 71,
47     X86_64_SysV = 78,
48     X86_64_Win64 = 79,
49     X86_VectorCall = 80,
50     X86_Intr = 83,
51     AvrNonBlockingInterrupt = 84,
52     AvrInterrupt = 85,
53     AmdGpuKernel = 91,
54 }
55
56 /// LLVMRustLinkage
57 #[derive(Copy, Clone, PartialEq)]
58 #[repr(C)]
59 pub enum Linkage {
60     ExternalLinkage = 0,
61     AvailableExternallyLinkage = 1,
62     LinkOnceAnyLinkage = 2,
63     LinkOnceODRLinkage = 3,
64     WeakAnyLinkage = 4,
65     WeakODRLinkage = 5,
66     AppendingLinkage = 6,
67     InternalLinkage = 7,
68     PrivateLinkage = 8,
69     ExternalWeakLinkage = 9,
70     CommonLinkage = 10,
71 }
72
73 // LLVMRustVisibility
74 #[repr(C)]
75 #[derive(Copy, Clone, PartialEq)]
76 pub enum Visibility {
77     Default = 0,
78     Hidden = 1,
79     Protected = 2,
80 }
81
82 /// LLVMUnnamedAddr
83 #[repr(C)]
84 pub enum UnnamedAddr {
85     No,
86     Local,
87     Global,
88 }
89
90 /// LLVMDLLStorageClass
91 #[derive(Copy, Clone)]
92 #[repr(C)]
93 pub enum DLLStorageClass {
94     #[allow(dead_code)]
95     Default = 0,
96     DllImport = 1, // Function to be imported from DLL.
97     #[allow(dead_code)]
98     DllExport = 2, // Function to be accessible from DLL.
99 }
100
101 /// Matches LLVMRustAttribute in LLVMWrapper.h
102 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
103 /// though it is not ABI compatible (since it's a C++ enum)
104 #[repr(C)]
105 #[derive(Copy, Clone, Debug)]
106 pub enum Attribute {
107     AlwaysInline = 0,
108     ByVal = 1,
109     Cold = 2,
110     InlineHint = 3,
111     MinSize = 4,
112     Naked = 5,
113     NoAlias = 6,
114     NoCapture = 7,
115     NoInline = 8,
116     NonNull = 9,
117     NoRedZone = 10,
118     NoReturn = 11,
119     NoUnwind = 12,
120     OptimizeForSize = 13,
121     ReadOnly = 14,
122     SExt = 15,
123     StructRet = 16,
124     UWTable = 17,
125     ZExt = 18,
126     InReg = 19,
127     SanitizeThread = 20,
128     SanitizeAddress = 21,
129     SanitizeMemory = 22,
130     NonLazyBind = 23,
131     OptimizeNone = 24,
132     ReturnsTwice = 25,
133     ReadNone = 26,
134     InaccessibleMemOnly = 27,
135     SanitizeHWAddress = 28,
136     WillReturn = 29,
137 }
138
139 /// LLVMIntPredicate
140 #[derive(Copy, Clone)]
141 #[repr(C)]
142 pub enum IntPredicate {
143     IntEQ = 32,
144     IntNE = 33,
145     IntUGT = 34,
146     IntUGE = 35,
147     IntULT = 36,
148     IntULE = 37,
149     IntSGT = 38,
150     IntSGE = 39,
151     IntSLT = 40,
152     IntSLE = 41,
153 }
154
155 impl IntPredicate {
156     pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
157         match intpre {
158             rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
159             rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
160             rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
161             rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
162             rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
163             rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
164             rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
165             rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
166             rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
167             rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
168         }
169     }
170 }
171
172 /// LLVMRealPredicate
173 #[derive(Copy, Clone)]
174 #[repr(C)]
175 pub enum RealPredicate {
176     RealPredicateFalse = 0,
177     RealOEQ = 1,
178     RealOGT = 2,
179     RealOGE = 3,
180     RealOLT = 4,
181     RealOLE = 5,
182     RealONE = 6,
183     RealORD = 7,
184     RealUNO = 8,
185     RealUEQ = 9,
186     RealUGT = 10,
187     RealUGE = 11,
188     RealULT = 12,
189     RealULE = 13,
190     RealUNE = 14,
191     RealPredicateTrue = 15,
192 }
193
194 /// LLVMTypeKind
195 #[derive(Copy, Clone, PartialEq, Debug)]
196 #[repr(C)]
197 pub enum TypeKind {
198     Void = 0,
199     Half = 1,
200     Float = 2,
201     Double = 3,
202     X86_FP80 = 4,
203     FP128 = 5,
204     PPC_FP128 = 6,
205     Label = 7,
206     Integer = 8,
207     Function = 9,
208     Struct = 10,
209     Array = 11,
210     Pointer = 12,
211     Vector = 13,
212     Metadata = 14,
213     X86_MMX = 15,
214     Token = 16,
215     ScalableVector = 17,
216     BFloat = 18,
217     X86_AMX = 19,
218 }
219
220 impl TypeKind {
221     pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
222         match self {
223             TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
224             TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
225             TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
226             TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
227             TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
228             TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
229             TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
230             TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
231             TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
232             TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
233             TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
234             TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
235             TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
236             TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
237             TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
238             TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
239             TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
240             TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
241             TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
242             TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
243         }
244     }
245 }
246
247 /// LLVMAtomicRmwBinOp
248 #[derive(Copy, Clone)]
249 #[repr(C)]
250 pub enum AtomicRmwBinOp {
251     AtomicXchg = 0,
252     AtomicAdd = 1,
253     AtomicSub = 2,
254     AtomicAnd = 3,
255     AtomicNand = 4,
256     AtomicOr = 5,
257     AtomicXor = 6,
258     AtomicMax = 7,
259     AtomicMin = 8,
260     AtomicUMax = 9,
261     AtomicUMin = 10,
262 }
263
264 impl AtomicRmwBinOp {
265     pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
266         match op {
267             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
268             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
269             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
270             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
271             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
272             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
273             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
274             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
275             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
276             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
277             rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
278         }
279     }
280 }
281
282 /// LLVMAtomicOrdering
283 #[derive(Copy, Clone)]
284 #[repr(C)]
285 pub enum AtomicOrdering {
286     #[allow(dead_code)]
287     NotAtomic = 0,
288     Unordered = 1,
289     Monotonic = 2,
290     // Consume = 3,  // Not specified yet.
291     Acquire = 4,
292     Release = 5,
293     AcquireRelease = 6,
294     SequentiallyConsistent = 7,
295 }
296
297 impl AtomicOrdering {
298     pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
299         match ao {
300             rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
301             rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
302             rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
303             rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
304             rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
305             rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
306                 AtomicOrdering::AcquireRelease
307             }
308             rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
309                 AtomicOrdering::SequentiallyConsistent
310             }
311         }
312     }
313 }
314
315 /// LLVMRustSynchronizationScope
316 #[derive(Copy, Clone)]
317 #[repr(C)]
318 pub enum SynchronizationScope {
319     SingleThread,
320     CrossThread,
321 }
322
323 impl SynchronizationScope {
324     pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
325         match sc {
326             rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
327                 SynchronizationScope::SingleThread
328             }
329             rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
330                 SynchronizationScope::CrossThread
331             }
332         }
333     }
334 }
335
336 /// LLVMRustFileType
337 #[derive(Copy, Clone)]
338 #[repr(C)]
339 pub enum FileType {
340     AssemblyFile,
341     ObjectFile,
342 }
343
344 /// LLVMMetadataType
345 #[derive(Copy, Clone)]
346 #[repr(C)]
347 pub enum MetadataType {
348     MD_dbg = 0,
349     MD_tbaa = 1,
350     MD_prof = 2,
351     MD_fpmath = 3,
352     MD_range = 4,
353     MD_tbaa_struct = 5,
354     MD_invariant_load = 6,
355     MD_alias_scope = 7,
356     MD_noalias = 8,
357     MD_nontemporal = 9,
358     MD_mem_parallel_loop_access = 10,
359     MD_nonnull = 11,
360 }
361
362 /// LLVMRustAsmDialect
363 #[derive(Copy, Clone)]
364 #[repr(C)]
365 pub enum AsmDialect {
366     Att,
367     Intel,
368 }
369
370 impl AsmDialect {
371     pub fn from_generic(asm: rustc_ast::LlvmAsmDialect) -> Self {
372         match asm {
373             rustc_ast::LlvmAsmDialect::Att => AsmDialect::Att,
374             rustc_ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
375         }
376     }
377 }
378
379 /// LLVMRustCodeGenOptLevel
380 #[derive(Copy, Clone, PartialEq)]
381 #[repr(C)]
382 pub enum CodeGenOptLevel {
383     None,
384     Less,
385     Default,
386     Aggressive,
387 }
388
389 /// LLVMRustPassBuilderOptLevel
390 #[repr(C)]
391 pub enum PassBuilderOptLevel {
392     O0,
393     O1,
394     O2,
395     O3,
396     Os,
397     Oz,
398 }
399
400 /// LLVMRustOptStage
401 #[derive(PartialEq)]
402 #[repr(C)]
403 pub enum OptStage {
404     PreLinkNoLTO,
405     PreLinkThinLTO,
406     PreLinkFatLTO,
407     ThinLTO,
408     FatLTO,
409 }
410
411 /// LLVMRustSanitizerOptions
412 #[repr(C)]
413 pub struct SanitizerOptions {
414     pub sanitize_address: bool,
415     pub sanitize_address_recover: bool,
416     pub sanitize_memory: bool,
417     pub sanitize_memory_recover: bool,
418     pub sanitize_memory_track_origins: c_int,
419     pub sanitize_thread: bool,
420     pub sanitize_hwaddress: bool,
421     pub sanitize_hwaddress_recover: bool,
422 }
423
424 /// LLVMRelocMode
425 #[derive(Copy, Clone, PartialEq)]
426 #[repr(C)]
427 pub enum RelocModel {
428     Static,
429     PIC,
430     DynamicNoPic,
431     ROPI,
432     RWPI,
433     ROPI_RWPI,
434 }
435
436 /// LLVMRustCodeModel
437 #[derive(Copy, Clone)]
438 #[repr(C)]
439 pub enum CodeModel {
440     Tiny,
441     Small,
442     Kernel,
443     Medium,
444     Large,
445     None,
446 }
447
448 /// LLVMRustDiagnosticKind
449 #[derive(Copy, Clone)]
450 #[repr(C)]
451 #[allow(dead_code)] // Variants constructed by C++.
452 pub enum DiagnosticKind {
453     Other,
454     InlineAsm,
455     StackSize,
456     DebugMetadataVersion,
457     SampleProfile,
458     OptimizationRemark,
459     OptimizationRemarkMissed,
460     OptimizationRemarkAnalysis,
461     OptimizationRemarkAnalysisFPCommute,
462     OptimizationRemarkAnalysisAliasing,
463     OptimizationRemarkOther,
464     OptimizationFailure,
465     PGOProfile,
466     Linker,
467     Unsupported,
468 }
469
470 /// LLVMRustDiagnosticLevel
471 #[derive(Copy, Clone)]
472 #[repr(C)]
473 #[allow(dead_code)] // Variants constructed by C++.
474 pub enum DiagnosticLevel {
475     Error,
476     Warning,
477     Note,
478     Remark,
479 }
480
481 /// LLVMRustArchiveKind
482 #[derive(Copy, Clone)]
483 #[repr(C)]
484 pub enum ArchiveKind {
485     K_GNU,
486     K_BSD,
487     K_DARWIN,
488     K_COFF,
489 }
490
491 /// LLVMRustPassKind
492 #[derive(Copy, Clone, PartialEq, Debug)]
493 #[repr(C)]
494 #[allow(dead_code)] // Variants constructed by C++.
495 pub enum PassKind {
496     Other,
497     Function,
498     Module,
499 }
500
501 /// LLVMRustThinLTOData
502 extern "C" {
503     pub type ThinLTOData;
504 }
505
506 /// LLVMRustThinLTOBuffer
507 extern "C" {
508     pub type ThinLTOBuffer;
509 }
510
511 // LLVMRustModuleNameCallback
512 pub type ThinLTOModuleNameCallback =
513     unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
514
515 /// LLVMRustThinLTOModule
516 #[repr(C)]
517 pub struct ThinLTOModule {
518     pub identifier: *const c_char,
519     pub data: *const u8,
520     pub len: usize,
521 }
522
523 /// LLVMThreadLocalMode
524 #[derive(Copy, Clone)]
525 #[repr(C)]
526 pub enum ThreadLocalMode {
527     NotThreadLocal,
528     GeneralDynamic,
529     LocalDynamic,
530     InitialExec,
531     LocalExec,
532 }
533
534 /// LLVMRustChecksumKind
535 #[derive(Copy, Clone)]
536 #[repr(C)]
537 pub enum ChecksumKind {
538     None,
539     MD5,
540     SHA1,
541     SHA256,
542 }
543
544 extern "C" {
545     type Opaque;
546 }
547 #[repr(C)]
548 struct InvariantOpaque<'a> {
549     _marker: PhantomData<&'a mut &'a ()>,
550     _opaque: Opaque,
551 }
552
553 // Opaque pointer types
554 extern "C" {
555     pub type Module;
556 }
557 extern "C" {
558     pub type Context;
559 }
560 extern "C" {
561     pub type Type;
562 }
563 extern "C" {
564     pub type Value;
565 }
566 extern "C" {
567     pub type ConstantInt;
568 }
569 extern "C" {
570     pub type Metadata;
571 }
572 extern "C" {
573     pub type BasicBlock;
574 }
575 #[repr(C)]
576 pub struct Builder<'a>(InvariantOpaque<'a>);
577 extern "C" {
578     pub type MemoryBuffer;
579 }
580 #[repr(C)]
581 pub struct PassManager<'a>(InvariantOpaque<'a>);
582 extern "C" {
583     pub type PassManagerBuilder;
584 }
585 extern "C" {
586     pub type ObjectFile;
587 }
588 #[repr(C)]
589 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
590 extern "C" {
591     pub type Pass;
592 }
593 extern "C" {
594     pub type TargetMachine;
595 }
596 extern "C" {
597     pub type Archive;
598 }
599 #[repr(C)]
600 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
601 #[repr(C)]
602 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
603 extern "C" {
604     pub type Twine;
605 }
606 extern "C" {
607     pub type DiagnosticInfo;
608 }
609 extern "C" {
610     pub type SMDiagnostic;
611 }
612 #[repr(C)]
613 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
614 #[repr(C)]
615 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
616 #[repr(C)]
617 pub struct Linker<'a>(InvariantOpaque<'a>);
618
619 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
620 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
621
622 pub mod coverageinfo {
623     use super::coverage_map;
624
625     /// Aligns with [llvm::coverage::CounterMappingRegion::RegionKind](https://github.com/rust-lang/llvm-project/blob/rustc/11.0-2020-10-12/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L206-L222)
626     #[derive(Copy, Clone, Debug)]
627     #[repr(C)]
628     pub enum RegionKind {
629         /// A CodeRegion associates some code with a counter
630         CodeRegion = 0,
631
632         /// An ExpansionRegion represents a file expansion region that associates
633         /// a source range with the expansion of a virtual source file, such as
634         /// for a macro instantiation or #include file.
635         ExpansionRegion = 1,
636
637         /// A SkippedRegion represents a source range with code that was skipped
638         /// by a preprocessor or similar means.
639         SkippedRegion = 2,
640
641         /// A GapRegion is like a CodeRegion, but its count is only set as the
642         /// line execution count when its the only region in the line.
643         GapRegion = 3,
644     }
645
646     /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the
647     /// coverage map, in accordance with the
648     /// [LLVM Code Coverage Mapping Format](https://github.com/rust-lang/llvm-project/blob/rustc/11.0-2020-10-12/llvm/docs/CoverageMappingFormat.rst#llvm-code-coverage-mapping-format).
649     /// The struct composes fields representing the `Counter` type and value(s) (injected counter
650     /// ID, or expression type and operands), the source file (an indirect index into a "filenames
651     /// array", encoded separately), and source location (start and end positions of the represented
652     /// code region).
653     ///
654     /// Matches LLVMRustCounterMappingRegion.
655     #[derive(Copy, Clone, Debug)]
656     #[repr(C)]
657     pub struct CounterMappingRegion {
658         /// The counter type and type-dependent counter data, if any.
659         counter: coverage_map::Counter,
660
661         /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the
662         /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes
663         /// that, in turn, are used to look up the filename for this region.
664         file_id: u32,
665
666         /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find
667         /// the mapping regions created as a result of macro expansion, by checking if their file id
668         /// matches the expanded file id.
669         expanded_file_id: u32,
670
671         /// 1-based starting line of the mapping region.
672         start_line: u32,
673
674         /// 1-based starting column of the mapping region.
675         start_col: u32,
676
677         /// 1-based ending line of the mapping region.
678         end_line: u32,
679
680         /// 1-based ending column of the mapping region. If the high bit is set, the current
681         /// mapping region is a gap area.
682         end_col: u32,
683
684         kind: RegionKind,
685     }
686
687     impl CounterMappingRegion {
688         crate fn code_region(
689             counter: coverage_map::Counter,
690             file_id: u32,
691             start_line: u32,
692             start_col: u32,
693             end_line: u32,
694             end_col: u32,
695         ) -> Self {
696             Self {
697                 counter,
698                 file_id,
699                 expanded_file_id: 0,
700                 start_line,
701                 start_col,
702                 end_line,
703                 end_col,
704                 kind: RegionKind::CodeRegion,
705             }
706         }
707
708         // This function might be used in the future; the LLVM API is still evolving, as is coverage
709         // support.
710         #[allow(dead_code)]
711         crate fn expansion_region(
712             file_id: u32,
713             expanded_file_id: u32,
714             start_line: u32,
715             start_col: u32,
716             end_line: u32,
717             end_col: u32,
718         ) -> Self {
719             Self {
720                 counter: coverage_map::Counter::zero(),
721                 file_id,
722                 expanded_file_id,
723                 start_line,
724                 start_col,
725                 end_line,
726                 end_col,
727                 kind: RegionKind::ExpansionRegion,
728             }
729         }
730
731         // This function might be used in the future; the LLVM API is still evolving, as is coverage
732         // support.
733         #[allow(dead_code)]
734         crate fn skipped_region(
735             file_id: u32,
736             start_line: u32,
737             start_col: u32,
738             end_line: u32,
739             end_col: u32,
740         ) -> Self {
741             Self {
742                 counter: coverage_map::Counter::zero(),
743                 file_id,
744                 expanded_file_id: 0,
745                 start_line,
746                 start_col,
747                 end_line,
748                 end_col,
749                 kind: RegionKind::SkippedRegion,
750             }
751         }
752
753         // This function might be used in the future; the LLVM API is still evolving, as is coverage
754         // support.
755         #[allow(dead_code)]
756         crate fn gap_region(
757             counter: coverage_map::Counter,
758             file_id: u32,
759             start_line: u32,
760             start_col: u32,
761             end_line: u32,
762             end_col: u32,
763         ) -> Self {
764             Self {
765                 counter,
766                 file_id,
767                 expanded_file_id: 0,
768                 start_line,
769                 start_col,
770                 end_line,
771                 end_col: ((1 as u32) << 31) | end_col,
772                 kind: RegionKind::GapRegion,
773             }
774         }
775     }
776 }
777
778 pub mod debuginfo {
779     use super::{InvariantOpaque, Metadata};
780     use bitflags::bitflags;
781
782     #[repr(C)]
783     pub struct DIBuilder<'a>(InvariantOpaque<'a>);
784
785     pub type DIDescriptor = Metadata;
786     pub type DILocation = Metadata;
787     pub type DIScope = DIDescriptor;
788     pub type DIFile = DIScope;
789     pub type DILexicalBlock = DIScope;
790     pub type DISubprogram = DIScope;
791     pub type DINameSpace = DIScope;
792     pub type DIType = DIDescriptor;
793     pub type DIBasicType = DIType;
794     pub type DIDerivedType = DIType;
795     pub type DICompositeType = DIDerivedType;
796     pub type DIVariable = DIDescriptor;
797     pub type DIGlobalVariableExpression = DIDescriptor;
798     pub type DIArray = DIDescriptor;
799     pub type DISubrange = DIDescriptor;
800     pub type DIEnumerator = DIDescriptor;
801     pub type DITemplateTypeParameter = DIDescriptor;
802
803     // These values **must** match with LLVMRustDIFlags!!
804     bitflags! {
805         #[repr(transparent)]
806         #[derive(Default)]
807         pub struct DIFlags: u32 {
808             const FlagZero                = 0;
809             const FlagPrivate             = 1;
810             const FlagProtected           = 2;
811             const FlagPublic              = 3;
812             const FlagFwdDecl             = (1 << 2);
813             const FlagAppleBlock          = (1 << 3);
814             const FlagBlockByrefStruct    = (1 << 4);
815             const FlagVirtual             = (1 << 5);
816             const FlagArtificial          = (1 << 6);
817             const FlagExplicit            = (1 << 7);
818             const FlagPrototyped          = (1 << 8);
819             const FlagObjcClassComplete   = (1 << 9);
820             const FlagObjectPointer       = (1 << 10);
821             const FlagVector              = (1 << 11);
822             const FlagStaticMember        = (1 << 12);
823             const FlagLValueReference     = (1 << 13);
824             const FlagRValueReference     = (1 << 14);
825             const FlagExternalTypeRef     = (1 << 15);
826             const FlagIntroducedVirtual   = (1 << 18);
827             const FlagBitField            = (1 << 19);
828             const FlagNoReturn            = (1 << 20);
829         }
830     }
831
832     // These values **must** match with LLVMRustDISPFlags!!
833     bitflags! {
834         #[repr(transparent)]
835         #[derive(Default)]
836         pub struct DISPFlags: u32 {
837             const SPFlagZero              = 0;
838             const SPFlagVirtual           = 1;
839             const SPFlagPureVirtual       = 2;
840             const SPFlagLocalToUnit       = (1 << 2);
841             const SPFlagDefinition        = (1 << 3);
842             const SPFlagOptimized         = (1 << 4);
843             const SPFlagMainSubprogram    = (1 << 5);
844         }
845     }
846
847     /// LLVMRustDebugEmissionKind
848     #[derive(Copy, Clone)]
849     #[repr(C)]
850     pub enum DebugEmissionKind {
851         NoDebug,
852         FullDebug,
853         LineTablesOnly,
854     }
855
856     impl DebugEmissionKind {
857         pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
858             use rustc_session::config::DebugInfo;
859             match kind {
860                 DebugInfo::None => DebugEmissionKind::NoDebug,
861                 DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
862                 DebugInfo::Full => DebugEmissionKind::FullDebug,
863             }
864         }
865     }
866 }
867
868 extern "C" {
869     pub type ModuleBuffer;
870 }
871
872 pub type SelfProfileBeforePassCallback =
873     unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
874 pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
875
876 extern "C" {
877     pub fn LLVMRustInstallFatalErrorHandler();
878
879     // Create and destroy contexts.
880     pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
881     pub fn LLVMContextDispose(C: &'static mut Context);
882     pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
883
884     // Create modules.
885     pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
886     pub fn LLVMGetModuleContext(M: &Module) -> &Context;
887     pub fn LLVMCloneModule(M: &Module) -> &Module;
888
889     /// Data layout. See Module::getDataLayout.
890     pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
891     pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
892
893     /// See Module::setModuleInlineAsm.
894     pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
895     pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
896
897     /// See llvm::LLVMTypeKind::getTypeID.
898     pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
899
900     // Operations on integer types
901     pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
902     pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
903     pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
904     pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
905     pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
906     pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
907
908     pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
909
910     // Operations on real types
911     pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
912     pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
913
914     // Operations on function types
915     pub fn LLVMFunctionType(
916         ReturnType: &'a Type,
917         ParamTypes: *const &'a Type,
918         ParamCount: c_uint,
919         IsVarArg: Bool,
920     ) -> &'a Type;
921     pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
922     pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
923
924     // Operations on struct types
925     pub fn LLVMStructTypeInContext(
926         C: &'a Context,
927         ElementTypes: *const &'a Type,
928         ElementCount: c_uint,
929         Packed: Bool,
930     ) -> &'a Type;
931
932     // Operations on array, pointer, and vector types (sequence types)
933     pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
934     pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
935     pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
936
937     pub fn LLVMGetElementType(Ty: &Type) -> &Type;
938     pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
939
940     // Operations on other types
941     pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
942     pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
943
944     // Operations on all values
945     pub fn LLVMTypeOf(Val: &Value) -> &Type;
946     pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
947     pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
948     pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
949     pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
950
951     // Operations on constants of any type
952     pub fn LLVMConstNull(Ty: &Type) -> &Value;
953     pub fn LLVMGetUndef(Ty: &Type) -> &Value;
954
955     // Operations on metadata
956     pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
957     pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
958     pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
959
960     // Operations on scalar constants
961     pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
962     pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
963     pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
964     pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
965     pub fn LLVMRustConstInt128Get(
966         ConstantVal: &ConstantInt,
967         SExt: bool,
968         high: &mut u64,
969         low: &mut u64,
970     ) -> bool;
971
972     // Operations on composite constants
973     pub fn LLVMConstStringInContext(
974         C: &Context,
975         Str: *const c_char,
976         Length: c_uint,
977         DontNullTerminate: Bool,
978     ) -> &Value;
979     pub fn LLVMConstStructInContext(
980         C: &'a Context,
981         ConstantVals: *const &'a Value,
982         Count: c_uint,
983         Packed: Bool,
984     ) -> &'a Value;
985
986     pub fn LLVMConstArray(
987         ElementTy: &'a Type,
988         ConstantVals: *const &'a Value,
989         Length: c_uint,
990     ) -> &'a Value;
991     pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
992
993     // Constant expressions
994     pub fn LLVMConstInBoundsGEP(
995         ConstantVal: &'a Value,
996         ConstantIndices: *const &'a Value,
997         NumIndices: c_uint,
998     ) -> &'a Value;
999     pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1000     pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1001     pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1002     pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1003     pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1004     pub fn LLVMConstExtractValue(
1005         AggConstant: &Value,
1006         IdxList: *const c_uint,
1007         NumIdx: c_uint,
1008     ) -> &Value;
1009
1010     // Operations on global variables, functions, and aliases (globals)
1011     pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
1012     pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
1013     pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
1014     pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
1015     pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
1016     pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
1017     pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
1018     pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
1019     pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1020     pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1021
1022     // Operations on global variables
1023     pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1024     pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1025     pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1026     pub fn LLVMRustGetOrInsertGlobal(
1027         M: &'a Module,
1028         Name: *const c_char,
1029         NameLen: size_t,
1030         T: &'a Type,
1031     ) -> &'a Value;
1032     pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
1033     pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1034     pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1035     pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1036     pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1037     pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
1038     pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1039     pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
1040     pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1041     pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1042     pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1043     pub fn LLVMRustGetNamedValue(
1044         M: &Module,
1045         Name: *const c_char,
1046         NameLen: size_t,
1047     ) -> Option<&Value>;
1048     pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1049
1050     // Operations on functions
1051     pub fn LLVMRustGetOrInsertFunction(
1052         M: &'a Module,
1053         Name: *const c_char,
1054         NameLen: size_t,
1055         FunctionTy: &'a Type,
1056     ) -> &'a Value;
1057     pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1058     pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
1059     pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
1060     pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
1061     pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
1062     pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type);
1063     pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
1064     pub fn LLVMRustAddFunctionAttrStringValue(
1065         Fn: &Value,
1066         index: c_uint,
1067         Name: *const c_char,
1068         Value: *const c_char,
1069     );
1070     pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
1071
1072     // Operations on parameters
1073     pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1074     pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1075     pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1076
1077     // Operations on basic blocks
1078     pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1079     pub fn LLVMAppendBasicBlockInContext(
1080         C: &'a Context,
1081         Fn: &'a Value,
1082         Name: *const c_char,
1083     ) -> &'a BasicBlock;
1084
1085     // Operations on instructions
1086     pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1087     pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1088
1089     // Operations on call sites
1090     pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1091     pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
1092     pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char);
1093     pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
1094     pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1095     pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1096     pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1097     pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1098
1099     // Operations on load/store instructions (only)
1100     pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1101
1102     // Operations on phi nodes
1103     pub fn LLVMAddIncoming(
1104         PhiNode: &'a Value,
1105         IncomingValues: *const &'a Value,
1106         IncomingBlocks: *const &'a BasicBlock,
1107         Count: c_uint,
1108     );
1109
1110     // Instruction builders
1111     pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
1112     pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
1113     pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
1114     pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
1115
1116     // Metadata
1117     pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
1118
1119     // Terminators
1120     pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
1121     pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1122     pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1123     pub fn LLVMBuildCondBr(
1124         B: &Builder<'a>,
1125         If: &'a Value,
1126         Then: &'a BasicBlock,
1127         Else: &'a BasicBlock,
1128     ) -> &'a Value;
1129     pub fn LLVMBuildSwitch(
1130         B: &Builder<'a>,
1131         V: &'a Value,
1132         Else: &'a BasicBlock,
1133         NumCases: c_uint,
1134     ) -> &'a Value;
1135     pub fn LLVMRustBuildInvoke(
1136         B: &Builder<'a>,
1137         Fn: &'a Value,
1138         Args: *const &'a Value,
1139         NumArgs: c_uint,
1140         Then: &'a BasicBlock,
1141         Catch: &'a BasicBlock,
1142         Bundle: Option<&OperandBundleDef<'a>>,
1143         Name: *const c_char,
1144     ) -> &'a Value;
1145     pub fn LLVMBuildLandingPad(
1146         B: &Builder<'a>,
1147         Ty: &'a Type,
1148         PersFn: &'a Value,
1149         NumClauses: c_uint,
1150         Name: *const c_char,
1151     ) -> &'a Value;
1152     pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1153     pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1154
1155     pub fn LLVMRustBuildCleanupPad(
1156         B: &Builder<'a>,
1157         ParentPad: Option<&'a Value>,
1158         ArgCnt: c_uint,
1159         Args: *const &'a Value,
1160         Name: *const c_char,
1161     ) -> Option<&'a Value>;
1162     pub fn LLVMRustBuildCleanupRet(
1163         B: &Builder<'a>,
1164         CleanupPad: &'a Value,
1165         UnwindBB: Option<&'a BasicBlock>,
1166     ) -> Option<&'a Value>;
1167     pub fn LLVMRustBuildCatchPad(
1168         B: &Builder<'a>,
1169         ParentPad: &'a Value,
1170         ArgCnt: c_uint,
1171         Args: *const &'a Value,
1172         Name: *const c_char,
1173     ) -> Option<&'a Value>;
1174     pub fn LLVMRustBuildCatchRet(
1175         B: &Builder<'a>,
1176         Pad: &'a Value,
1177         BB: &'a BasicBlock,
1178     ) -> Option<&'a Value>;
1179     pub fn LLVMRustBuildCatchSwitch(
1180         Builder: &Builder<'a>,
1181         ParentPad: Option<&'a Value>,
1182         BB: Option<&'a BasicBlock>,
1183         NumHandlers: c_uint,
1184         Name: *const c_char,
1185     ) -> Option<&'a Value>;
1186     pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1187     pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1188
1189     // Add a case to the switch instruction
1190     pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1191
1192     // Add a clause to the landing pad instruction
1193     pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1194
1195     // Set the cleanup on a landing pad instruction
1196     pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1197
1198     // Arithmetic
1199     pub fn LLVMBuildAdd(
1200         B: &Builder<'a>,
1201         LHS: &'a Value,
1202         RHS: &'a Value,
1203         Name: *const c_char,
1204     ) -> &'a Value;
1205     pub fn LLVMBuildFAdd(
1206         B: &Builder<'a>,
1207         LHS: &'a Value,
1208         RHS: &'a Value,
1209         Name: *const c_char,
1210     ) -> &'a Value;
1211     pub fn LLVMBuildSub(
1212         B: &Builder<'a>,
1213         LHS: &'a Value,
1214         RHS: &'a Value,
1215         Name: *const c_char,
1216     ) -> &'a Value;
1217     pub fn LLVMBuildFSub(
1218         B: &Builder<'a>,
1219         LHS: &'a Value,
1220         RHS: &'a Value,
1221         Name: *const c_char,
1222     ) -> &'a Value;
1223     pub fn LLVMBuildMul(
1224         B: &Builder<'a>,
1225         LHS: &'a Value,
1226         RHS: &'a Value,
1227         Name: *const c_char,
1228     ) -> &'a Value;
1229     pub fn LLVMBuildFMul(
1230         B: &Builder<'a>,
1231         LHS: &'a Value,
1232         RHS: &'a Value,
1233         Name: *const c_char,
1234     ) -> &'a Value;
1235     pub fn LLVMBuildUDiv(
1236         B: &Builder<'a>,
1237         LHS: &'a Value,
1238         RHS: &'a Value,
1239         Name: *const c_char,
1240     ) -> &'a Value;
1241     pub fn LLVMBuildExactUDiv(
1242         B: &Builder<'a>,
1243         LHS: &'a Value,
1244         RHS: &'a Value,
1245         Name: *const c_char,
1246     ) -> &'a Value;
1247     pub fn LLVMBuildSDiv(
1248         B: &Builder<'a>,
1249         LHS: &'a Value,
1250         RHS: &'a Value,
1251         Name: *const c_char,
1252     ) -> &'a Value;
1253     pub fn LLVMBuildExactSDiv(
1254         B: &Builder<'a>,
1255         LHS: &'a Value,
1256         RHS: &'a Value,
1257         Name: *const c_char,
1258     ) -> &'a Value;
1259     pub fn LLVMBuildFDiv(
1260         B: &Builder<'a>,
1261         LHS: &'a Value,
1262         RHS: &'a Value,
1263         Name: *const c_char,
1264     ) -> &'a Value;
1265     pub fn LLVMBuildURem(
1266         B: &Builder<'a>,
1267         LHS: &'a Value,
1268         RHS: &'a Value,
1269         Name: *const c_char,
1270     ) -> &'a Value;
1271     pub fn LLVMBuildSRem(
1272         B: &Builder<'a>,
1273         LHS: &'a Value,
1274         RHS: &'a Value,
1275         Name: *const c_char,
1276     ) -> &'a Value;
1277     pub fn LLVMBuildFRem(
1278         B: &Builder<'a>,
1279         LHS: &'a Value,
1280         RHS: &'a Value,
1281         Name: *const c_char,
1282     ) -> &'a Value;
1283     pub fn LLVMBuildShl(
1284         B: &Builder<'a>,
1285         LHS: &'a Value,
1286         RHS: &'a Value,
1287         Name: *const c_char,
1288     ) -> &'a Value;
1289     pub fn LLVMBuildLShr(
1290         B: &Builder<'a>,
1291         LHS: &'a Value,
1292         RHS: &'a Value,
1293         Name: *const c_char,
1294     ) -> &'a Value;
1295     pub fn LLVMBuildAShr(
1296         B: &Builder<'a>,
1297         LHS: &'a Value,
1298         RHS: &'a Value,
1299         Name: *const c_char,
1300     ) -> &'a Value;
1301     pub fn LLVMBuildNSWAdd(
1302         B: &Builder<'a>,
1303         LHS: &'a Value,
1304         RHS: &'a Value,
1305         Name: *const c_char,
1306     ) -> &'a Value;
1307     pub fn LLVMBuildNUWAdd(
1308         B: &Builder<'a>,
1309         LHS: &'a Value,
1310         RHS: &'a Value,
1311         Name: *const c_char,
1312     ) -> &'a Value;
1313     pub fn LLVMBuildNSWSub(
1314         B: &Builder<'a>,
1315         LHS: &'a Value,
1316         RHS: &'a Value,
1317         Name: *const c_char,
1318     ) -> &'a Value;
1319     pub fn LLVMBuildNUWSub(
1320         B: &Builder<'a>,
1321         LHS: &'a Value,
1322         RHS: &'a Value,
1323         Name: *const c_char,
1324     ) -> &'a Value;
1325     pub fn LLVMBuildNSWMul(
1326         B: &Builder<'a>,
1327         LHS: &'a Value,
1328         RHS: &'a Value,
1329         Name: *const c_char,
1330     ) -> &'a Value;
1331     pub fn LLVMBuildNUWMul(
1332         B: &Builder<'a>,
1333         LHS: &'a Value,
1334         RHS: &'a Value,
1335         Name: *const c_char,
1336     ) -> &'a Value;
1337     pub fn LLVMBuildAnd(
1338         B: &Builder<'a>,
1339         LHS: &'a Value,
1340         RHS: &'a Value,
1341         Name: *const c_char,
1342     ) -> &'a Value;
1343     pub fn LLVMBuildOr(
1344         B: &Builder<'a>,
1345         LHS: &'a Value,
1346         RHS: &'a Value,
1347         Name: *const c_char,
1348     ) -> &'a Value;
1349     pub fn LLVMBuildXor(
1350         B: &Builder<'a>,
1351         LHS: &'a Value,
1352         RHS: &'a Value,
1353         Name: *const c_char,
1354     ) -> &'a Value;
1355     pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1356     pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1357     pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1358     pub fn LLVMRustSetFastMath(Instr: &Value);
1359
1360     // Memory
1361     pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1362     pub fn LLVMBuildArrayAlloca(
1363         B: &Builder<'a>,
1364         Ty: &'a Type,
1365         Val: &'a Value,
1366         Name: *const c_char,
1367     ) -> &'a Value;
1368     pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1369
1370     pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1371
1372     pub fn LLVMBuildGEP(
1373         B: &Builder<'a>,
1374         Pointer: &'a Value,
1375         Indices: *const &'a Value,
1376         NumIndices: c_uint,
1377         Name: *const c_char,
1378     ) -> &'a Value;
1379     pub fn LLVMBuildInBoundsGEP(
1380         B: &Builder<'a>,
1381         Pointer: &'a Value,
1382         Indices: *const &'a Value,
1383         NumIndices: c_uint,
1384         Name: *const c_char,
1385     ) -> &'a Value;
1386     pub fn LLVMBuildStructGEP(
1387         B: &Builder<'a>,
1388         Pointer: &'a Value,
1389         Idx: c_uint,
1390         Name: *const c_char,
1391     ) -> &'a Value;
1392
1393     // Casts
1394     pub fn LLVMBuildTrunc(
1395         B: &Builder<'a>,
1396         Val: &'a Value,
1397         DestTy: &'a Type,
1398         Name: *const c_char,
1399     ) -> &'a Value;
1400     pub fn LLVMBuildZExt(
1401         B: &Builder<'a>,
1402         Val: &'a Value,
1403         DestTy: &'a Type,
1404         Name: *const c_char,
1405     ) -> &'a Value;
1406     pub fn LLVMBuildSExt(
1407         B: &Builder<'a>,
1408         Val: &'a Value,
1409         DestTy: &'a Type,
1410         Name: *const c_char,
1411     ) -> &'a Value;
1412     pub fn LLVMBuildFPToUI(
1413         B: &Builder<'a>,
1414         Val: &'a Value,
1415         DestTy: &'a Type,
1416         Name: *const c_char,
1417     ) -> &'a Value;
1418     pub fn LLVMBuildFPToSI(
1419         B: &Builder<'a>,
1420         Val: &'a Value,
1421         DestTy: &'a Type,
1422         Name: *const c_char,
1423     ) -> &'a Value;
1424     pub fn LLVMBuildUIToFP(
1425         B: &Builder<'a>,
1426         Val: &'a Value,
1427         DestTy: &'a Type,
1428         Name: *const c_char,
1429     ) -> &'a Value;
1430     pub fn LLVMBuildSIToFP(
1431         B: &Builder<'a>,
1432         Val: &'a Value,
1433         DestTy: &'a Type,
1434         Name: *const c_char,
1435     ) -> &'a Value;
1436     pub fn LLVMBuildFPTrunc(
1437         B: &Builder<'a>,
1438         Val: &'a Value,
1439         DestTy: &'a Type,
1440         Name: *const c_char,
1441     ) -> &'a Value;
1442     pub fn LLVMBuildFPExt(
1443         B: &Builder<'a>,
1444         Val: &'a Value,
1445         DestTy: &'a Type,
1446         Name: *const c_char,
1447     ) -> &'a Value;
1448     pub fn LLVMBuildPtrToInt(
1449         B: &Builder<'a>,
1450         Val: &'a Value,
1451         DestTy: &'a Type,
1452         Name: *const c_char,
1453     ) -> &'a Value;
1454     pub fn LLVMBuildIntToPtr(
1455         B: &Builder<'a>,
1456         Val: &'a Value,
1457         DestTy: &'a Type,
1458         Name: *const c_char,
1459     ) -> &'a Value;
1460     pub fn LLVMBuildBitCast(
1461         B: &Builder<'a>,
1462         Val: &'a Value,
1463         DestTy: &'a Type,
1464         Name: *const c_char,
1465     ) -> &'a Value;
1466     pub fn LLVMBuildPointerCast(
1467         B: &Builder<'a>,
1468         Val: &'a Value,
1469         DestTy: &'a Type,
1470         Name: *const c_char,
1471     ) -> &'a Value;
1472     pub fn LLVMRustBuildIntCast(
1473         B: &Builder<'a>,
1474         Val: &'a Value,
1475         DestTy: &'a Type,
1476         IsSized: bool,
1477     ) -> &'a Value;
1478
1479     // Comparisons
1480     pub fn LLVMBuildICmp(
1481         B: &Builder<'a>,
1482         Op: c_uint,
1483         LHS: &'a Value,
1484         RHS: &'a Value,
1485         Name: *const c_char,
1486     ) -> &'a Value;
1487     pub fn LLVMBuildFCmp(
1488         B: &Builder<'a>,
1489         Op: c_uint,
1490         LHS: &'a Value,
1491         RHS: &'a Value,
1492         Name: *const c_char,
1493     ) -> &'a Value;
1494
1495     // Miscellaneous instructions
1496     pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1497     pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
1498     pub fn LLVMRustBuildCall(
1499         B: &Builder<'a>,
1500         Fn: &'a Value,
1501         Args: *const &'a Value,
1502         NumArgs: c_uint,
1503         Bundle: Option<&OperandBundleDef<'a>>,
1504     ) -> &'a Value;
1505     pub fn LLVMRustBuildMemCpy(
1506         B: &Builder<'a>,
1507         Dst: &'a Value,
1508         DstAlign: c_uint,
1509         Src: &'a Value,
1510         SrcAlign: c_uint,
1511         Size: &'a Value,
1512         IsVolatile: bool,
1513     ) -> &'a Value;
1514     pub fn LLVMRustBuildMemMove(
1515         B: &Builder<'a>,
1516         Dst: &'a Value,
1517         DstAlign: c_uint,
1518         Src: &'a Value,
1519         SrcAlign: c_uint,
1520         Size: &'a Value,
1521         IsVolatile: bool,
1522     ) -> &'a Value;
1523     pub fn LLVMRustBuildMemSet(
1524         B: &Builder<'a>,
1525         Dst: &'a Value,
1526         DstAlign: c_uint,
1527         Val: &'a Value,
1528         Size: &'a Value,
1529         IsVolatile: bool,
1530     ) -> &'a Value;
1531     pub fn LLVMBuildSelect(
1532         B: &Builder<'a>,
1533         If: &'a Value,
1534         Then: &'a Value,
1535         Else: &'a Value,
1536         Name: *const c_char,
1537     ) -> &'a Value;
1538     pub fn LLVMBuildVAArg(
1539         B: &Builder<'a>,
1540         list: &'a Value,
1541         Ty: &'a Type,
1542         Name: *const c_char,
1543     ) -> &'a Value;
1544     pub fn LLVMBuildExtractElement(
1545         B: &Builder<'a>,
1546         VecVal: &'a Value,
1547         Index: &'a Value,
1548         Name: *const c_char,
1549     ) -> &'a Value;
1550     pub fn LLVMBuildInsertElement(
1551         B: &Builder<'a>,
1552         VecVal: &'a Value,
1553         EltVal: &'a Value,
1554         Index: &'a Value,
1555         Name: *const c_char,
1556     ) -> &'a Value;
1557     pub fn LLVMBuildShuffleVector(
1558         B: &Builder<'a>,
1559         V1: &'a Value,
1560         V2: &'a Value,
1561         Mask: &'a Value,
1562         Name: *const c_char,
1563     ) -> &'a Value;
1564     pub fn LLVMBuildExtractValue(
1565         B: &Builder<'a>,
1566         AggVal: &'a Value,
1567         Index: c_uint,
1568         Name: *const c_char,
1569     ) -> &'a Value;
1570     pub fn LLVMBuildInsertValue(
1571         B: &Builder<'a>,
1572         AggVal: &'a Value,
1573         EltVal: &'a Value,
1574         Index: c_uint,
1575         Name: *const c_char,
1576     ) -> &'a Value;
1577
1578     pub fn LLVMRustBuildVectorReduceFAdd(
1579         B: &Builder<'a>,
1580         Acc: &'a Value,
1581         Src: &'a Value,
1582     ) -> &'a Value;
1583     pub fn LLVMRustBuildVectorReduceFMul(
1584         B: &Builder<'a>,
1585         Acc: &'a Value,
1586         Src: &'a Value,
1587     ) -> &'a Value;
1588     pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1589     pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1590     pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1591     pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1592     pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1593     pub fn LLVMRustBuildVectorReduceMin(
1594         B: &Builder<'a>,
1595         Src: &'a Value,
1596         IsSigned: bool,
1597     ) -> &'a Value;
1598     pub fn LLVMRustBuildVectorReduceMax(
1599         B: &Builder<'a>,
1600         Src: &'a Value,
1601         IsSigned: bool,
1602     ) -> &'a Value;
1603     pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1604     -> &'a Value;
1605     pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1606     -> &'a Value;
1607
1608     pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1609     pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1610
1611     // Atomic Operations
1612     pub fn LLVMRustBuildAtomicLoad(
1613         B: &Builder<'a>,
1614         PointerVal: &'a Value,
1615         Name: *const c_char,
1616         Order: AtomicOrdering,
1617     ) -> &'a Value;
1618
1619     pub fn LLVMRustBuildAtomicStore(
1620         B: &Builder<'a>,
1621         Val: &'a Value,
1622         Ptr: &'a Value,
1623         Order: AtomicOrdering,
1624     ) -> &'a Value;
1625
1626     pub fn LLVMRustBuildAtomicCmpXchg(
1627         B: &Builder<'a>,
1628         LHS: &'a Value,
1629         CMP: &'a Value,
1630         RHS: &'a Value,
1631         Order: AtomicOrdering,
1632         FailureOrder: AtomicOrdering,
1633         Weak: Bool,
1634     ) -> &'a Value;
1635
1636     pub fn LLVMBuildAtomicRMW(
1637         B: &Builder<'a>,
1638         Op: AtomicRmwBinOp,
1639         LHS: &'a Value,
1640         RHS: &'a Value,
1641         Order: AtomicOrdering,
1642         SingleThreaded: Bool,
1643     ) -> &'a Value;
1644
1645     pub fn LLVMRustBuildAtomicFence(
1646         B: &Builder<'_>,
1647         Order: AtomicOrdering,
1648         Scope: SynchronizationScope,
1649     );
1650
1651     /// Writes a module to the specified path. Returns 0 on success.
1652     pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1653
1654     /// Creates a pass manager.
1655     pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1656
1657     /// Creates a function-by-function pass manager
1658     pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1659
1660     /// Disposes a pass manager.
1661     pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1662
1663     /// Runs a pass manager on a module.
1664     pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1665
1666     pub fn LLVMInitializePasses();
1667
1668     pub fn LLVMTimeTraceProfilerInitialize();
1669
1670     pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1671
1672     pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1673
1674     pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1675     pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1676     pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1677     pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1678     pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1679         PMB: &PassManagerBuilder,
1680         threshold: c_uint,
1681     );
1682     pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1683         PMB: &PassManagerBuilder,
1684         PM: &PassManager<'_>,
1685     );
1686
1687     pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1688         PMB: &PassManagerBuilder,
1689         PM: &PassManager<'_>,
1690     );
1691     pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1692         PMB: &PassManagerBuilder,
1693         PM: &PassManager<'_>,
1694         Internalize: Bool,
1695         RunInliner: Bool,
1696     );
1697     pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1698         PMB: &PassManagerBuilder,
1699         PM: &PassManager<'_>,
1700     );
1701
1702     pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1703
1704     pub fn LLVMDisposeMessage(message: *mut c_char);
1705
1706     // Stuff that's in llvm-wrapper/ because it's not upstream yet.
1707
1708     /// Opens an object file.
1709     pub fn LLVMCreateObjectFile(
1710         MemBuf: &'static mut MemoryBuffer,
1711     ) -> Option<&'static mut ObjectFile>;
1712     /// Closes an object file.
1713     pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1714
1715     /// Enumerates the sections in an object file.
1716     pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1717     /// Destroys a section iterator.
1718     pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1719     /// Returns `true` if the section iterator is at the end of the section
1720     /// list:
1721     pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1722     /// Moves the section iterator to point to the next section.
1723     pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
1724     /// Returns the current section size.
1725     pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
1726     /// Returns the current section contents as a string buffer.
1727     pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
1728
1729     /// Reads the given file and returns it as a memory buffer. Use
1730     /// LLVMDisposeMemoryBuffer() to get rid of it.
1731     pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1732         Path: *const c_char,
1733     ) -> Option<&'static mut MemoryBuffer>;
1734
1735     pub fn LLVMStartMultithreaded() -> Bool;
1736
1737     /// Returns a string describing the last error caused by an LLVMRust* call.
1738     pub fn LLVMRustGetLastError() -> *const c_char;
1739
1740     /// Print the pass timings since static dtors aren't picking them up.
1741     pub fn LLVMRustPrintPassTimings();
1742
1743     pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1744
1745     pub fn LLVMStructSetBody(
1746         StructTy: &'a Type,
1747         ElementTypes: *const &'a Type,
1748         ElementCount: c_uint,
1749         Packed: Bool,
1750     );
1751
1752     /// Prepares inline assembly.
1753     pub fn LLVMRustInlineAsm(
1754         Ty: &Type,
1755         AsmString: *const c_char,
1756         AsmStringLen: size_t,
1757         Constraints: *const c_char,
1758         ConstraintsLen: size_t,
1759         SideEffects: Bool,
1760         AlignStack: Bool,
1761         Dialect: AsmDialect,
1762     ) -> &Value;
1763     pub fn LLVMRustInlineAsmVerify(
1764         Ty: &Type,
1765         Constraints: *const c_char,
1766         ConstraintsLen: size_t,
1767     ) -> bool;
1768
1769     #[allow(improper_ctypes)]
1770     pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1771         Filenames: *const *const c_char,
1772         FilenamesLen: size_t,
1773         BufferOut: &RustString,
1774     );
1775
1776     #[allow(improper_ctypes)]
1777     pub fn LLVMRustCoverageWriteMappingToBuffer(
1778         VirtualFileMappingIDs: *const c_uint,
1779         NumVirtualFileMappingIDs: c_uint,
1780         Expressions: *const coverage_map::CounterExpression,
1781         NumExpressions: c_uint,
1782         MappingRegions: *const coverageinfo::CounterMappingRegion,
1783         NumMappingRegions: c_uint,
1784         BufferOut: &RustString,
1785     );
1786
1787     pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char)
1788     -> &'a Value;
1789     pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1790     pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1791
1792     #[allow(improper_ctypes)]
1793     pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1794
1795     #[allow(improper_ctypes)]
1796     pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1797
1798     #[allow(improper_ctypes)]
1799     pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1800
1801     pub fn LLVMRustCoverageMappingVersion() -> u32;
1802     pub fn LLVMRustDebugMetadataVersion() -> u32;
1803     pub fn LLVMRustVersionMajor() -> u32;
1804     pub fn LLVMRustVersionMinor() -> u32;
1805     pub fn LLVMRustVersionPatch() -> u32;
1806
1807     pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1808
1809     pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1810
1811     pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1812
1813     pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1814
1815     pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1816
1817     pub fn LLVMRustDIBuilderCreateCompileUnit(
1818         Builder: &DIBuilder<'a>,
1819         Lang: c_uint,
1820         File: &'a DIFile,
1821         Producer: *const c_char,
1822         ProducerLen: size_t,
1823         isOptimized: bool,
1824         Flags: *const c_char,
1825         RuntimeVer: c_uint,
1826         SplitName: *const c_char,
1827         SplitNameLen: size_t,
1828         kind: DebugEmissionKind,
1829         DWOId: u64,
1830         SplitDebugInlining: bool,
1831     ) -> &'a DIDescriptor;
1832
1833     pub fn LLVMRustDIBuilderCreateFile(
1834         Builder: &DIBuilder<'a>,
1835         Filename: *const c_char,
1836         FilenameLen: size_t,
1837         Directory: *const c_char,
1838         DirectoryLen: size_t,
1839         CSKind: ChecksumKind,
1840         Checksum: *const c_char,
1841         ChecksumLen: size_t,
1842     ) -> &'a DIFile;
1843
1844     pub fn LLVMRustDIBuilderCreateSubroutineType(
1845         Builder: &DIBuilder<'a>,
1846         ParameterTypes: &'a DIArray,
1847     ) -> &'a DICompositeType;
1848
1849     pub fn LLVMRustDIBuilderCreateFunction(
1850         Builder: &DIBuilder<'a>,
1851         Scope: &'a DIDescriptor,
1852         Name: *const c_char,
1853         NameLen: size_t,
1854         LinkageName: *const c_char,
1855         LinkageNameLen: size_t,
1856         File: &'a DIFile,
1857         LineNo: c_uint,
1858         Ty: &'a DIType,
1859         ScopeLine: c_uint,
1860         Flags: DIFlags,
1861         SPFlags: DISPFlags,
1862         MaybeFn: Option<&'a Value>,
1863         TParam: &'a DIArray,
1864         Decl: Option<&'a DIDescriptor>,
1865     ) -> &'a DISubprogram;
1866
1867     pub fn LLVMRustDIBuilderCreateBasicType(
1868         Builder: &DIBuilder<'a>,
1869         Name: *const c_char,
1870         NameLen: size_t,
1871         SizeInBits: u64,
1872         Encoding: c_uint,
1873     ) -> &'a DIBasicType;
1874
1875     pub fn LLVMRustDIBuilderCreateTypedef(
1876         Builder: &DIBuilder<'a>,
1877         Type: &'a DIBasicType,
1878         Name: *const c_char,
1879         NameLen: size_t,
1880         File: &'a DIFile,
1881         LineNo: c_uint,
1882         Scope: Option<&'a DIScope>,
1883     ) -> &'a DIDerivedType;
1884
1885     pub fn LLVMRustDIBuilderCreatePointerType(
1886         Builder: &DIBuilder<'a>,
1887         PointeeTy: &'a DIType,
1888         SizeInBits: u64,
1889         AlignInBits: u32,
1890         AddressSpace: c_uint,
1891         Name: *const c_char,
1892         NameLen: size_t,
1893     ) -> &'a DIDerivedType;
1894
1895     pub fn LLVMRustDIBuilderCreateStructType(
1896         Builder: &DIBuilder<'a>,
1897         Scope: Option<&'a DIDescriptor>,
1898         Name: *const c_char,
1899         NameLen: size_t,
1900         File: &'a DIFile,
1901         LineNumber: c_uint,
1902         SizeInBits: u64,
1903         AlignInBits: u32,
1904         Flags: DIFlags,
1905         DerivedFrom: Option<&'a DIType>,
1906         Elements: &'a DIArray,
1907         RunTimeLang: c_uint,
1908         VTableHolder: Option<&'a DIType>,
1909         UniqueId: *const c_char,
1910         UniqueIdLen: size_t,
1911     ) -> &'a DICompositeType;
1912
1913     pub fn LLVMRustDIBuilderCreateMemberType(
1914         Builder: &DIBuilder<'a>,
1915         Scope: &'a DIDescriptor,
1916         Name: *const c_char,
1917         NameLen: size_t,
1918         File: &'a DIFile,
1919         LineNo: c_uint,
1920         SizeInBits: u64,
1921         AlignInBits: u32,
1922         OffsetInBits: u64,
1923         Flags: DIFlags,
1924         Ty: &'a DIType,
1925     ) -> &'a DIDerivedType;
1926
1927     pub fn LLVMRustDIBuilderCreateVariantMemberType(
1928         Builder: &DIBuilder<'a>,
1929         Scope: &'a DIScope,
1930         Name: *const c_char,
1931         NameLen: size_t,
1932         File: &'a DIFile,
1933         LineNumber: c_uint,
1934         SizeInBits: u64,
1935         AlignInBits: u32,
1936         OffsetInBits: u64,
1937         Discriminant: Option<&'a Value>,
1938         Flags: DIFlags,
1939         Ty: &'a DIType,
1940     ) -> &'a DIType;
1941
1942     pub fn LLVMRustDIBuilderCreateLexicalBlock(
1943         Builder: &DIBuilder<'a>,
1944         Scope: &'a DIScope,
1945         File: &'a DIFile,
1946         Line: c_uint,
1947         Col: c_uint,
1948     ) -> &'a DILexicalBlock;
1949
1950     pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1951         Builder: &DIBuilder<'a>,
1952         Scope: &'a DIScope,
1953         File: &'a DIFile,
1954     ) -> &'a DILexicalBlock;
1955
1956     pub fn LLVMRustDIBuilderCreateStaticVariable(
1957         Builder: &DIBuilder<'a>,
1958         Context: Option<&'a DIScope>,
1959         Name: *const c_char,
1960         NameLen: size_t,
1961         LinkageName: *const c_char,
1962         LinkageNameLen: size_t,
1963         File: &'a DIFile,
1964         LineNo: c_uint,
1965         Ty: &'a DIType,
1966         isLocalToUnit: bool,
1967         Val: &'a Value,
1968         Decl: Option<&'a DIDescriptor>,
1969         AlignInBits: u32,
1970     ) -> &'a DIGlobalVariableExpression;
1971
1972     pub fn LLVMRustDIBuilderCreateVariable(
1973         Builder: &DIBuilder<'a>,
1974         Tag: c_uint,
1975         Scope: &'a DIDescriptor,
1976         Name: *const c_char,
1977         NameLen: size_t,
1978         File: &'a DIFile,
1979         LineNo: c_uint,
1980         Ty: &'a DIType,
1981         AlwaysPreserve: bool,
1982         Flags: DIFlags,
1983         ArgNo: c_uint,
1984         AlignInBits: u32,
1985     ) -> &'a DIVariable;
1986
1987     pub fn LLVMRustDIBuilderCreateArrayType(
1988         Builder: &DIBuilder<'a>,
1989         Size: u64,
1990         AlignInBits: u32,
1991         Ty: &'a DIType,
1992         Subscripts: &'a DIArray,
1993     ) -> &'a DIType;
1994
1995     pub fn LLVMRustDIBuilderGetOrCreateSubrange(
1996         Builder: &DIBuilder<'a>,
1997         Lo: i64,
1998         Count: i64,
1999     ) -> &'a DISubrange;
2000
2001     pub fn LLVMRustDIBuilderGetOrCreateArray(
2002         Builder: &DIBuilder<'a>,
2003         Ptr: *const Option<&'a DIDescriptor>,
2004         Count: c_uint,
2005     ) -> &'a DIArray;
2006
2007     pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
2008         Builder: &DIBuilder<'a>,
2009         Val: &'a Value,
2010         VarInfo: &'a DIVariable,
2011         AddrOps: *const i64,
2012         AddrOpsCount: c_uint,
2013         DL: &'a DILocation,
2014         InsertAtEnd: &'a BasicBlock,
2015     ) -> &'a Value;
2016
2017     pub fn LLVMRustDIBuilderCreateEnumerator(
2018         Builder: &DIBuilder<'a>,
2019         Name: *const c_char,
2020         NameLen: size_t,
2021         Value: i64,
2022         IsUnsigned: bool,
2023     ) -> &'a DIEnumerator;
2024
2025     pub fn LLVMRustDIBuilderCreateEnumerationType(
2026         Builder: &DIBuilder<'a>,
2027         Scope: &'a DIScope,
2028         Name: *const c_char,
2029         NameLen: size_t,
2030         File: &'a DIFile,
2031         LineNumber: c_uint,
2032         SizeInBits: u64,
2033         AlignInBits: u32,
2034         Elements: &'a DIArray,
2035         ClassType: &'a DIType,
2036         IsScoped: bool,
2037     ) -> &'a DIType;
2038
2039     pub fn LLVMRustDIBuilderCreateUnionType(
2040         Builder: &DIBuilder<'a>,
2041         Scope: &'a DIScope,
2042         Name: *const c_char,
2043         NameLen: size_t,
2044         File: &'a DIFile,
2045         LineNumber: c_uint,
2046         SizeInBits: u64,
2047         AlignInBits: u32,
2048         Flags: DIFlags,
2049         Elements: Option<&'a DIArray>,
2050         RunTimeLang: c_uint,
2051         UniqueId: *const c_char,
2052         UniqueIdLen: size_t,
2053     ) -> &'a DIType;
2054
2055     pub fn LLVMRustDIBuilderCreateVariantPart(
2056         Builder: &DIBuilder<'a>,
2057         Scope: &'a DIScope,
2058         Name: *const c_char,
2059         NameLen: size_t,
2060         File: &'a DIFile,
2061         LineNo: c_uint,
2062         SizeInBits: u64,
2063         AlignInBits: u32,
2064         Flags: DIFlags,
2065         Discriminator: Option<&'a DIDerivedType>,
2066         Elements: &'a DIArray,
2067         UniqueId: *const c_char,
2068         UniqueIdLen: size_t,
2069     ) -> &'a DIDerivedType;
2070
2071     pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2072
2073     pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
2074         Builder: &DIBuilder<'a>,
2075         Scope: Option<&'a DIScope>,
2076         Name: *const c_char,
2077         NameLen: size_t,
2078         Ty: &'a DIType,
2079     ) -> &'a DITemplateTypeParameter;
2080
2081     pub fn LLVMRustDIBuilderCreateNameSpace(
2082         Builder: &DIBuilder<'a>,
2083         Scope: Option<&'a DIScope>,
2084         Name: *const c_char,
2085         NameLen: size_t,
2086         ExportSymbols: bool,
2087     ) -> &'a DINameSpace;
2088
2089     pub fn LLVMRustDICompositeTypeReplaceArrays(
2090         Builder: &DIBuilder<'a>,
2091         CompositeType: &'a DIType,
2092         Elements: Option<&'a DIArray>,
2093         Params: Option<&'a DIArray>,
2094     );
2095
2096     pub fn LLVMRustDIBuilderCreateDebugLocation(
2097         Line: c_uint,
2098         Column: c_uint,
2099         Scope: &'a DIScope,
2100         InlinedAt: Option<&'a DILocation>,
2101     ) -> &'a DILocation;
2102     pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
2103     pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
2104
2105     #[allow(improper_ctypes)]
2106     pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2107     #[allow(improper_ctypes)]
2108     pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2109
2110     pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2111
2112     pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
2113     pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2114     pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2115     pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2116     pub fn LLVMRustCreateMemorySanitizerPass(
2117         TrackOrigins: c_int,
2118         Recover: bool,
2119     ) -> &'static mut Pass;
2120     pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
2121     pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2122     pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2123     pub fn LLVMRustAddLastExtensionPasses(
2124         PMB: &PassManagerBuilder,
2125         Passes: *const &'static mut Pass,
2126         NumPasses: size_t,
2127     );
2128
2129     pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2130
2131     pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2132     pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
2133     pub fn LLVMRustGetTargetFeature(
2134         T: &TargetMachine,
2135         Index: size_t,
2136         Feature: &mut *const c_char,
2137         Desc: &mut *const c_char,
2138     );
2139
2140     pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2141     pub fn LLVMRustCreateTargetMachine(
2142         Triple: *const c_char,
2143         CPU: *const c_char,
2144         Features: *const c_char,
2145         Abi: *const c_char,
2146         Model: CodeModel,
2147         Reloc: RelocModel,
2148         Level: CodeGenOptLevel,
2149         UseSoftFP: bool,
2150         FunctionSections: bool,
2151         DataSections: bool,
2152         TrapUnreachable: bool,
2153         Singlethread: bool,
2154         AsmComments: bool,
2155         EmitStackSizeSection: bool,
2156         RelaxELFRelocations: bool,
2157         UseInitArray: bool,
2158         SplitDwarfFile: *const c_char,
2159     ) -> Option<&'static mut TargetMachine>;
2160     pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2161     pub fn LLVMRustAddBuilderLibraryInfo(
2162         PMB: &'a PassManagerBuilder,
2163         M: &'a Module,
2164         DisableSimplifyLibCalls: bool,
2165     );
2166     pub fn LLVMRustConfigurePassManagerBuilder(
2167         PMB: &PassManagerBuilder,
2168         OptLevel: CodeGenOptLevel,
2169         MergeFunctions: bool,
2170         SLPVectorize: bool,
2171         LoopVectorize: bool,
2172         PrepareForThinLTO: bool,
2173         PGOGenPath: *const c_char,
2174         PGOUsePath: *const c_char,
2175     );
2176     pub fn LLVMRustAddLibraryInfo(
2177         PM: &PassManager<'a>,
2178         M: &'a Module,
2179         DisableSimplifyLibCalls: bool,
2180     );
2181     pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
2182     pub fn LLVMRustWriteOutputFile(
2183         T: &'a TargetMachine,
2184         PM: &PassManager<'a>,
2185         M: &'a Module,
2186         Output: *const c_char,
2187         DwoOutput: *const c_char,
2188         FileType: FileType,
2189     ) -> LLVMRustResult;
2190     pub fn LLVMRustOptimizeWithNewPassManager(
2191         M: &'a Module,
2192         TM: &'a TargetMachine,
2193         OptLevel: PassBuilderOptLevel,
2194         OptStage: OptStage,
2195         NoPrepopulatePasses: bool,
2196         VerifyIR: bool,
2197         UseThinLTOBuffers: bool,
2198         MergeFunctions: bool,
2199         UnrollLoops: bool,
2200         SLPVectorize: bool,
2201         LoopVectorize: bool,
2202         DisableSimplifyLibCalls: bool,
2203         EmitLifetimeMarkers: bool,
2204         SanitizerOptions: Option<&SanitizerOptions>,
2205         PGOGenPath: *const c_char,
2206         PGOUsePath: *const c_char,
2207         InstrumentCoverage: bool,
2208         InstrumentGCOV: bool,
2209         llvm_selfprofiler: *mut c_void,
2210         begin_callback: SelfProfileBeforePassCallback,
2211         end_callback: SelfProfileAfterPassCallback,
2212         ExtraPasses: *const c_char,
2213         ExtraPassesLen: size_t,
2214     ) -> LLVMRustResult;
2215     pub fn LLVMRustPrintModule(
2216         M: &'a Module,
2217         Output: *const c_char,
2218         Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2219     ) -> LLVMRustResult;
2220     pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2221     pub fn LLVMRustPrintPasses();
2222     pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2223     pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2224     pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2225     pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2226     pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2227
2228     pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2229     pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2230     pub fn LLVMRustArchiveIteratorNext(
2231         AIR: &ArchiveIterator<'a>,
2232     ) -> Option<&'a mut ArchiveChild<'a>>;
2233     pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2234     pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2235     pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2236     pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2237     pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2238
2239     #[allow(improper_ctypes)]
2240     pub fn LLVMRustGetSectionName(
2241         SI: &SectionIterator<'_>,
2242         data: &mut Option<std::ptr::NonNull<c_char>>,
2243     ) -> size_t;
2244
2245     #[allow(improper_ctypes)]
2246     pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2247
2248     pub fn LLVMContextSetDiagnosticHandler(
2249         C: &Context,
2250         Handler: DiagnosticHandler,
2251         DiagnosticContext: *mut c_void,
2252     );
2253
2254     #[allow(improper_ctypes)]
2255     pub fn LLVMRustUnpackOptimizationDiagnostic(
2256         DI: &'a DiagnosticInfo,
2257         pass_name_out: &RustString,
2258         function_out: &mut Option<&'a Value>,
2259         loc_line_out: &mut c_uint,
2260         loc_column_out: &mut c_uint,
2261         loc_filename_out: &RustString,
2262         message_out: &RustString,
2263     );
2264
2265     pub fn LLVMRustUnpackInlineAsmDiagnostic(
2266         DI: &'a DiagnosticInfo,
2267         level_out: &mut DiagnosticLevel,
2268         cookie_out: &mut c_uint,
2269         message_out: &mut Option<&'a Twine>,
2270         instruction_out: &mut Option<&'a Value>,
2271     );
2272
2273     #[allow(improper_ctypes)]
2274     pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2275     pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2276
2277     pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2278         C: &Context,
2279         H: InlineAsmDiagHandler,
2280         CX: *mut c_void,
2281     );
2282
2283     #[allow(improper_ctypes)]
2284     pub fn LLVMRustUnpackSMDiagnostic(
2285         d: &SMDiagnostic,
2286         message_out: &RustString,
2287         buffer_out: &RustString,
2288         level_out: &mut DiagnosticLevel,
2289         loc_out: &mut c_uint,
2290         ranges_out: *mut c_uint,
2291         num_ranges: &mut usize,
2292     ) -> bool;
2293
2294     pub fn LLVMRustWriteArchive(
2295         Dst: *const c_char,
2296         NumMembers: size_t,
2297         Members: *const &RustArchiveMember<'_>,
2298         WriteSymbtab: bool,
2299         Kind: ArchiveKind,
2300     ) -> LLVMRustResult;
2301     pub fn LLVMRustArchiveMemberNew(
2302         Filename: *const c_char,
2303         Name: *const c_char,
2304         Child: Option<&ArchiveChild<'a>>,
2305     ) -> &'a mut RustArchiveMember<'a>;
2306     pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2307
2308     pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2309
2310     pub fn LLVMRustBuildOperandBundleDef(
2311         Name: *const c_char,
2312         Inputs: *const &'a Value,
2313         NumInputs: c_uint,
2314     ) -> &'a mut OperandBundleDef<'a>;
2315     pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2316
2317     pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2318
2319     pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2320     pub fn LLVMRustUnsetComdat(V: &Value);
2321     pub fn LLVMRustSetModulePICLevel(M: &Module);
2322     pub fn LLVMRustSetModulePIELevel(M: &Module);
2323     pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2324     pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2325     pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2326     pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2327     pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2328     pub fn LLVMRustModuleCost(M: &Module) -> u64;
2329
2330     pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2331     pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2332     pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2333     pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2334     pub fn LLVMRustCreateThinLTOData(
2335         Modules: *const ThinLTOModule,
2336         NumModules: c_uint,
2337         PreservedSymbols: *const *const c_char,
2338         PreservedSymbolsLen: c_uint,
2339     ) -> Option<&'static mut ThinLTOData>;
2340     pub fn LLVMRustPrepareThinLTORename(
2341         Data: &ThinLTOData,
2342         Module: &Module,
2343         Target: &TargetMachine,
2344     ) -> bool;
2345     pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2346     pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2347     pub fn LLVMRustPrepareThinLTOImport(
2348         Data: &ThinLTOData,
2349         Module: &Module,
2350         Target: &TargetMachine,
2351     ) -> bool;
2352     pub fn LLVMRustGetThinLTOModuleImports(
2353         Data: *const ThinLTOData,
2354         ModuleNameCallback: ThinLTOModuleNameCallback,
2355         CallbackPayload: *mut c_void,
2356     );
2357     pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2358     pub fn LLVMRustParseBitcodeForLTO(
2359         Context: &Context,
2360         Data: *const u8,
2361         len: usize,
2362         Identifier: *const c_char,
2363     ) -> Option<&Module>;
2364     pub fn LLVMRustGetBitcodeSliceFromObjectData(
2365         Data: *const u8,
2366         len: usize,
2367         out_len: &mut usize,
2368     ) -> *const u8;
2369     pub fn LLVMRustThinLTOGetDICompileUnit(
2370         M: &Module,
2371         CU1: &mut *mut c_void,
2372         CU2: &mut *mut c_void,
2373     );
2374     pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2375
2376     pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2377     pub fn LLVMRustLinkerAdd(
2378         linker: &Linker<'_>,
2379         bytecode: *const c_char,
2380         bytecode_len: usize,
2381     ) -> bool;
2382     pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
2383     #[allow(improper_ctypes)]
2384     pub fn LLVMRustComputeLTOCacheKey(
2385         key_out: &RustString,
2386         mod_id: *const c_char,
2387         data: &ThinLTOData,
2388     );
2389 }