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