]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Rollup merge of #83571 - a1phyr:feature_const_slice_first_last, r=dtolnay
[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 LLVMGetAlignment(Global: &Value) -> c_uint;
1017     pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
1018     pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
1019
1020     // Operations on global variables
1021     pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
1022     pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1023     pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
1024     pub fn LLVMRustGetOrInsertGlobal(
1025         M: &'a Module,
1026         Name: *const c_char,
1027         NameLen: size_t,
1028         T: &'a Type,
1029     ) -> &'a Value;
1030     pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
1031     pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
1032     pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
1033     pub fn LLVMDeleteGlobal(GlobalVar: &Value);
1034     pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
1035     pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
1036     pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
1037     pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
1038     pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
1039     pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
1040     pub fn LLVMRustGetNamedValue(
1041         M: &Module,
1042         Name: *const c_char,
1043         NameLen: size_t,
1044     ) -> Option<&Value>;
1045     pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
1046
1047     // Operations on functions
1048     pub fn LLVMRustGetOrInsertFunction(
1049         M: &'a Module,
1050         Name: *const c_char,
1051         NameLen: size_t,
1052         FunctionTy: &'a Type,
1053     ) -> &'a Value;
1054     pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
1055     pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
1056     pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
1057     pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
1058     pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
1059     pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type);
1060     pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
1061     pub fn LLVMRustAddFunctionAttrStringValue(
1062         Fn: &Value,
1063         index: c_uint,
1064         Name: *const c_char,
1065         Value: *const c_char,
1066     );
1067     pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
1068
1069     // Operations on parameters
1070     pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
1071     pub fn LLVMCountParams(Fn: &Value) -> c_uint;
1072     pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
1073
1074     // Operations on basic blocks
1075     pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
1076     pub fn LLVMAppendBasicBlockInContext(
1077         C: &'a Context,
1078         Fn: &'a Value,
1079         Name: *const c_char,
1080     ) -> &'a BasicBlock;
1081     pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
1082
1083     // Operations on instructions
1084     pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
1085     pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
1086
1087     // Operations on call sites
1088     pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
1089     pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
1090     pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char);
1091     pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
1092     pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1093     pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
1094     pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1095     pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
1096
1097     // Operations on load/store instructions (only)
1098     pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
1099
1100     // Operations on phi nodes
1101     pub fn LLVMAddIncoming(
1102         PhiNode: &'a Value,
1103         IncomingValues: *const &'a Value,
1104         IncomingBlocks: *const &'a BasicBlock,
1105         Count: c_uint,
1106     );
1107
1108     // Instruction builders
1109     pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
1110     pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
1111     pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
1112     pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
1113
1114     // Metadata
1115     pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
1116
1117     // Terminators
1118     pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
1119     pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
1120     pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
1121     pub fn LLVMBuildCondBr(
1122         B: &Builder<'a>,
1123         If: &'a Value,
1124         Then: &'a BasicBlock,
1125         Else: &'a BasicBlock,
1126     ) -> &'a Value;
1127     pub fn LLVMBuildSwitch(
1128         B: &Builder<'a>,
1129         V: &'a Value,
1130         Else: &'a BasicBlock,
1131         NumCases: c_uint,
1132     ) -> &'a Value;
1133     pub fn LLVMRustBuildInvoke(
1134         B: &Builder<'a>,
1135         Fn: &'a Value,
1136         Args: *const &'a Value,
1137         NumArgs: c_uint,
1138         Then: &'a BasicBlock,
1139         Catch: &'a BasicBlock,
1140         Bundle: Option<&OperandBundleDef<'a>>,
1141         Name: *const c_char,
1142     ) -> &'a Value;
1143     pub fn LLVMBuildLandingPad(
1144         B: &Builder<'a>,
1145         Ty: &'a Type,
1146         PersFn: &'a Value,
1147         NumClauses: c_uint,
1148         Name: *const c_char,
1149     ) -> &'a Value;
1150     pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
1151     pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
1152
1153     pub fn LLVMRustBuildCleanupPad(
1154         B: &Builder<'a>,
1155         ParentPad: Option<&'a Value>,
1156         ArgCnt: c_uint,
1157         Args: *const &'a Value,
1158         Name: *const c_char,
1159     ) -> Option<&'a Value>;
1160     pub fn LLVMRustBuildCleanupRet(
1161         B: &Builder<'a>,
1162         CleanupPad: &'a Value,
1163         UnwindBB: Option<&'a BasicBlock>,
1164     ) -> Option<&'a Value>;
1165     pub fn LLVMRustBuildCatchPad(
1166         B: &Builder<'a>,
1167         ParentPad: &'a Value,
1168         ArgCnt: c_uint,
1169         Args: *const &'a Value,
1170         Name: *const c_char,
1171     ) -> Option<&'a Value>;
1172     pub fn LLVMRustBuildCatchRet(
1173         B: &Builder<'a>,
1174         Pad: &'a Value,
1175         BB: &'a BasicBlock,
1176     ) -> Option<&'a Value>;
1177     pub fn LLVMRustBuildCatchSwitch(
1178         Builder: &Builder<'a>,
1179         ParentPad: Option<&'a Value>,
1180         BB: Option<&'a BasicBlock>,
1181         NumHandlers: c_uint,
1182         Name: *const c_char,
1183     ) -> Option<&'a Value>;
1184     pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
1185     pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
1186
1187     // Add a case to the switch instruction
1188     pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
1189
1190     // Add a clause to the landing pad instruction
1191     pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
1192
1193     // Set the cleanup on a landing pad instruction
1194     pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
1195
1196     // Arithmetic
1197     pub fn LLVMBuildAdd(
1198         B: &Builder<'a>,
1199         LHS: &'a Value,
1200         RHS: &'a Value,
1201         Name: *const c_char,
1202     ) -> &'a Value;
1203     pub fn LLVMBuildFAdd(
1204         B: &Builder<'a>,
1205         LHS: &'a Value,
1206         RHS: &'a Value,
1207         Name: *const c_char,
1208     ) -> &'a Value;
1209     pub fn LLVMBuildSub(
1210         B: &Builder<'a>,
1211         LHS: &'a Value,
1212         RHS: &'a Value,
1213         Name: *const c_char,
1214     ) -> &'a Value;
1215     pub fn LLVMBuildFSub(
1216         B: &Builder<'a>,
1217         LHS: &'a Value,
1218         RHS: &'a Value,
1219         Name: *const c_char,
1220     ) -> &'a Value;
1221     pub fn LLVMBuildMul(
1222         B: &Builder<'a>,
1223         LHS: &'a Value,
1224         RHS: &'a Value,
1225         Name: *const c_char,
1226     ) -> &'a Value;
1227     pub fn LLVMBuildFMul(
1228         B: &Builder<'a>,
1229         LHS: &'a Value,
1230         RHS: &'a Value,
1231         Name: *const c_char,
1232     ) -> &'a Value;
1233     pub fn LLVMBuildUDiv(
1234         B: &Builder<'a>,
1235         LHS: &'a Value,
1236         RHS: &'a Value,
1237         Name: *const c_char,
1238     ) -> &'a Value;
1239     pub fn LLVMBuildExactUDiv(
1240         B: &Builder<'a>,
1241         LHS: &'a Value,
1242         RHS: &'a Value,
1243         Name: *const c_char,
1244     ) -> &'a Value;
1245     pub fn LLVMBuildSDiv(
1246         B: &Builder<'a>,
1247         LHS: &'a Value,
1248         RHS: &'a Value,
1249         Name: *const c_char,
1250     ) -> &'a Value;
1251     pub fn LLVMBuildExactSDiv(
1252         B: &Builder<'a>,
1253         LHS: &'a Value,
1254         RHS: &'a Value,
1255         Name: *const c_char,
1256     ) -> &'a Value;
1257     pub fn LLVMBuildFDiv(
1258         B: &Builder<'a>,
1259         LHS: &'a Value,
1260         RHS: &'a Value,
1261         Name: *const c_char,
1262     ) -> &'a Value;
1263     pub fn LLVMBuildURem(
1264         B: &Builder<'a>,
1265         LHS: &'a Value,
1266         RHS: &'a Value,
1267         Name: *const c_char,
1268     ) -> &'a Value;
1269     pub fn LLVMBuildSRem(
1270         B: &Builder<'a>,
1271         LHS: &'a Value,
1272         RHS: &'a Value,
1273         Name: *const c_char,
1274     ) -> &'a Value;
1275     pub fn LLVMBuildFRem(
1276         B: &Builder<'a>,
1277         LHS: &'a Value,
1278         RHS: &'a Value,
1279         Name: *const c_char,
1280     ) -> &'a Value;
1281     pub fn LLVMBuildShl(
1282         B: &Builder<'a>,
1283         LHS: &'a Value,
1284         RHS: &'a Value,
1285         Name: *const c_char,
1286     ) -> &'a Value;
1287     pub fn LLVMBuildLShr(
1288         B: &Builder<'a>,
1289         LHS: &'a Value,
1290         RHS: &'a Value,
1291         Name: *const c_char,
1292     ) -> &'a Value;
1293     pub fn LLVMBuildAShr(
1294         B: &Builder<'a>,
1295         LHS: &'a Value,
1296         RHS: &'a Value,
1297         Name: *const c_char,
1298     ) -> &'a Value;
1299     pub fn LLVMBuildNSWAdd(
1300         B: &Builder<'a>,
1301         LHS: &'a Value,
1302         RHS: &'a Value,
1303         Name: *const c_char,
1304     ) -> &'a Value;
1305     pub fn LLVMBuildNUWAdd(
1306         B: &Builder<'a>,
1307         LHS: &'a Value,
1308         RHS: &'a Value,
1309         Name: *const c_char,
1310     ) -> &'a Value;
1311     pub fn LLVMBuildNSWSub(
1312         B: &Builder<'a>,
1313         LHS: &'a Value,
1314         RHS: &'a Value,
1315         Name: *const c_char,
1316     ) -> &'a Value;
1317     pub fn LLVMBuildNUWSub(
1318         B: &Builder<'a>,
1319         LHS: &'a Value,
1320         RHS: &'a Value,
1321         Name: *const c_char,
1322     ) -> &'a Value;
1323     pub fn LLVMBuildNSWMul(
1324         B: &Builder<'a>,
1325         LHS: &'a Value,
1326         RHS: &'a Value,
1327         Name: *const c_char,
1328     ) -> &'a Value;
1329     pub fn LLVMBuildNUWMul(
1330         B: &Builder<'a>,
1331         LHS: &'a Value,
1332         RHS: &'a Value,
1333         Name: *const c_char,
1334     ) -> &'a Value;
1335     pub fn LLVMBuildAnd(
1336         B: &Builder<'a>,
1337         LHS: &'a Value,
1338         RHS: &'a Value,
1339         Name: *const c_char,
1340     ) -> &'a Value;
1341     pub fn LLVMBuildOr(
1342         B: &Builder<'a>,
1343         LHS: &'a Value,
1344         RHS: &'a Value,
1345         Name: *const c_char,
1346     ) -> &'a Value;
1347     pub fn LLVMBuildXor(
1348         B: &Builder<'a>,
1349         LHS: &'a Value,
1350         RHS: &'a Value,
1351         Name: *const c_char,
1352     ) -> &'a Value;
1353     pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1354     pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1355     pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
1356     pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
1357
1358     // Memory
1359     pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1360     pub fn LLVMBuildArrayAlloca(
1361         B: &Builder<'a>,
1362         Ty: &'a Type,
1363         Val: &'a Value,
1364         Name: *const c_char,
1365     ) -> &'a Value;
1366     pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
1367
1368     pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
1369
1370     pub fn LLVMBuildGEP(
1371         B: &Builder<'a>,
1372         Pointer: &'a Value,
1373         Indices: *const &'a Value,
1374         NumIndices: c_uint,
1375         Name: *const c_char,
1376     ) -> &'a Value;
1377     pub fn LLVMBuildInBoundsGEP(
1378         B: &Builder<'a>,
1379         Pointer: &'a Value,
1380         Indices: *const &'a Value,
1381         NumIndices: c_uint,
1382         Name: *const c_char,
1383     ) -> &'a Value;
1384     pub fn LLVMBuildStructGEP(
1385         B: &Builder<'a>,
1386         Pointer: &'a Value,
1387         Idx: c_uint,
1388         Name: *const c_char,
1389     ) -> &'a Value;
1390
1391     // Casts
1392     pub fn LLVMBuildTrunc(
1393         B: &Builder<'a>,
1394         Val: &'a Value,
1395         DestTy: &'a Type,
1396         Name: *const c_char,
1397     ) -> &'a Value;
1398     pub fn LLVMBuildZExt(
1399         B: &Builder<'a>,
1400         Val: &'a Value,
1401         DestTy: &'a Type,
1402         Name: *const c_char,
1403     ) -> &'a Value;
1404     pub fn LLVMBuildSExt(
1405         B: &Builder<'a>,
1406         Val: &'a Value,
1407         DestTy: &'a Type,
1408         Name: *const c_char,
1409     ) -> &'a Value;
1410     pub fn LLVMBuildFPToUI(
1411         B: &Builder<'a>,
1412         Val: &'a Value,
1413         DestTy: &'a Type,
1414         Name: *const c_char,
1415     ) -> &'a Value;
1416     pub fn LLVMBuildFPToSI(
1417         B: &Builder<'a>,
1418         Val: &'a Value,
1419         DestTy: &'a Type,
1420         Name: *const c_char,
1421     ) -> &'a Value;
1422     pub fn LLVMBuildUIToFP(
1423         B: &Builder<'a>,
1424         Val: &'a Value,
1425         DestTy: &'a Type,
1426         Name: *const c_char,
1427     ) -> &'a Value;
1428     pub fn LLVMBuildSIToFP(
1429         B: &Builder<'a>,
1430         Val: &'a Value,
1431         DestTy: &'a Type,
1432         Name: *const c_char,
1433     ) -> &'a Value;
1434     pub fn LLVMBuildFPTrunc(
1435         B: &Builder<'a>,
1436         Val: &'a Value,
1437         DestTy: &'a Type,
1438         Name: *const c_char,
1439     ) -> &'a Value;
1440     pub fn LLVMBuildFPExt(
1441         B: &Builder<'a>,
1442         Val: &'a Value,
1443         DestTy: &'a Type,
1444         Name: *const c_char,
1445     ) -> &'a Value;
1446     pub fn LLVMBuildPtrToInt(
1447         B: &Builder<'a>,
1448         Val: &'a Value,
1449         DestTy: &'a Type,
1450         Name: *const c_char,
1451     ) -> &'a Value;
1452     pub fn LLVMBuildIntToPtr(
1453         B: &Builder<'a>,
1454         Val: &'a Value,
1455         DestTy: &'a Type,
1456         Name: *const c_char,
1457     ) -> &'a Value;
1458     pub fn LLVMBuildBitCast(
1459         B: &Builder<'a>,
1460         Val: &'a Value,
1461         DestTy: &'a Type,
1462         Name: *const c_char,
1463     ) -> &'a Value;
1464     pub fn LLVMBuildPointerCast(
1465         B: &Builder<'a>,
1466         Val: &'a Value,
1467         DestTy: &'a Type,
1468         Name: *const c_char,
1469     ) -> &'a Value;
1470     pub fn LLVMRustBuildIntCast(
1471         B: &Builder<'a>,
1472         Val: &'a Value,
1473         DestTy: &'a Type,
1474         IsSized: bool,
1475     ) -> &'a Value;
1476
1477     // Comparisons
1478     pub fn LLVMBuildICmp(
1479         B: &Builder<'a>,
1480         Op: c_uint,
1481         LHS: &'a Value,
1482         RHS: &'a Value,
1483         Name: *const c_char,
1484     ) -> &'a Value;
1485     pub fn LLVMBuildFCmp(
1486         B: &Builder<'a>,
1487         Op: c_uint,
1488         LHS: &'a Value,
1489         RHS: &'a Value,
1490         Name: *const c_char,
1491     ) -> &'a Value;
1492
1493     // Miscellaneous instructions
1494     pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
1495     pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
1496     pub fn LLVMRustBuildCall(
1497         B: &Builder<'a>,
1498         Fn: &'a Value,
1499         Args: *const &'a Value,
1500         NumArgs: c_uint,
1501         Bundle: Option<&OperandBundleDef<'a>>,
1502     ) -> &'a Value;
1503     pub fn LLVMRustBuildMemCpy(
1504         B: &Builder<'a>,
1505         Dst: &'a Value,
1506         DstAlign: c_uint,
1507         Src: &'a Value,
1508         SrcAlign: c_uint,
1509         Size: &'a Value,
1510         IsVolatile: bool,
1511     ) -> &'a Value;
1512     pub fn LLVMRustBuildMemMove(
1513         B: &Builder<'a>,
1514         Dst: &'a Value,
1515         DstAlign: c_uint,
1516         Src: &'a Value,
1517         SrcAlign: c_uint,
1518         Size: &'a Value,
1519         IsVolatile: bool,
1520     ) -> &'a Value;
1521     pub fn LLVMRustBuildMemSet(
1522         B: &Builder<'a>,
1523         Dst: &'a Value,
1524         DstAlign: c_uint,
1525         Val: &'a Value,
1526         Size: &'a Value,
1527         IsVolatile: bool,
1528     ) -> &'a Value;
1529     pub fn LLVMBuildSelect(
1530         B: &Builder<'a>,
1531         If: &'a Value,
1532         Then: &'a Value,
1533         Else: &'a Value,
1534         Name: *const c_char,
1535     ) -> &'a Value;
1536     pub fn LLVMBuildVAArg(
1537         B: &Builder<'a>,
1538         list: &'a Value,
1539         Ty: &'a Type,
1540         Name: *const c_char,
1541     ) -> &'a Value;
1542     pub fn LLVMBuildExtractElement(
1543         B: &Builder<'a>,
1544         VecVal: &'a Value,
1545         Index: &'a Value,
1546         Name: *const c_char,
1547     ) -> &'a Value;
1548     pub fn LLVMBuildInsertElement(
1549         B: &Builder<'a>,
1550         VecVal: &'a Value,
1551         EltVal: &'a Value,
1552         Index: &'a Value,
1553         Name: *const c_char,
1554     ) -> &'a Value;
1555     pub fn LLVMBuildShuffleVector(
1556         B: &Builder<'a>,
1557         V1: &'a Value,
1558         V2: &'a Value,
1559         Mask: &'a Value,
1560         Name: *const c_char,
1561     ) -> &'a Value;
1562     pub fn LLVMBuildExtractValue(
1563         B: &Builder<'a>,
1564         AggVal: &'a Value,
1565         Index: c_uint,
1566         Name: *const c_char,
1567     ) -> &'a Value;
1568     pub fn LLVMBuildInsertValue(
1569         B: &Builder<'a>,
1570         AggVal: &'a Value,
1571         EltVal: &'a Value,
1572         Index: c_uint,
1573         Name: *const c_char,
1574     ) -> &'a Value;
1575
1576     pub fn LLVMRustBuildVectorReduceFAdd(
1577         B: &Builder<'a>,
1578         Acc: &'a Value,
1579         Src: &'a Value,
1580     ) -> &'a Value;
1581     pub fn LLVMRustBuildVectorReduceFMul(
1582         B: &Builder<'a>,
1583         Acc: &'a Value,
1584         Src: &'a Value,
1585     ) -> &'a Value;
1586     pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1587     pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1588     pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1589     pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1590     pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
1591     pub fn LLVMRustBuildVectorReduceMin(
1592         B: &Builder<'a>,
1593         Src: &'a Value,
1594         IsSigned: bool,
1595     ) -> &'a Value;
1596     pub fn LLVMRustBuildVectorReduceMax(
1597         B: &Builder<'a>,
1598         Src: &'a Value,
1599         IsSigned: bool,
1600     ) -> &'a Value;
1601     pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1602     -> &'a Value;
1603     pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
1604     -> &'a Value;
1605
1606     pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1607     pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
1608
1609     // Atomic Operations
1610     pub fn LLVMRustBuildAtomicLoad(
1611         B: &Builder<'a>,
1612         PointerVal: &'a Value,
1613         Name: *const c_char,
1614         Order: AtomicOrdering,
1615     ) -> &'a Value;
1616
1617     pub fn LLVMRustBuildAtomicStore(
1618         B: &Builder<'a>,
1619         Val: &'a Value,
1620         Ptr: &'a Value,
1621         Order: AtomicOrdering,
1622     ) -> &'a Value;
1623
1624     pub fn LLVMRustBuildAtomicCmpXchg(
1625         B: &Builder<'a>,
1626         LHS: &'a Value,
1627         CMP: &'a Value,
1628         RHS: &'a Value,
1629         Order: AtomicOrdering,
1630         FailureOrder: AtomicOrdering,
1631         Weak: Bool,
1632     ) -> &'a Value;
1633
1634     pub fn LLVMBuildAtomicRMW(
1635         B: &Builder<'a>,
1636         Op: AtomicRmwBinOp,
1637         LHS: &'a Value,
1638         RHS: &'a Value,
1639         Order: AtomicOrdering,
1640         SingleThreaded: Bool,
1641     ) -> &'a Value;
1642
1643     pub fn LLVMRustBuildAtomicFence(
1644         B: &Builder<'_>,
1645         Order: AtomicOrdering,
1646         Scope: SynchronizationScope,
1647     );
1648
1649     /// Writes a module to the specified path. Returns 0 on success.
1650     pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1651
1652     /// Creates a pass manager.
1653     pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1654
1655     /// Creates a function-by-function pass manager
1656     pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1657
1658     /// Disposes a pass manager.
1659     pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1660
1661     /// Runs a pass manager on a module.
1662     pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1663
1664     pub fn LLVMInitializePasses();
1665
1666     pub fn LLVMTimeTraceProfilerInitialize();
1667
1668     pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
1669
1670     pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
1671
1672     pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1673     pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1674     pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1675     pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1676     pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1677         PMB: &PassManagerBuilder,
1678         threshold: c_uint,
1679     );
1680     pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1681         PMB: &PassManagerBuilder,
1682         PM: &PassManager<'_>,
1683     );
1684
1685     pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1686         PMB: &PassManagerBuilder,
1687         PM: &PassManager<'_>,
1688     );
1689     pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1690         PMB: &PassManagerBuilder,
1691         PM: &PassManager<'_>,
1692         Internalize: Bool,
1693         RunInliner: Bool,
1694     );
1695     pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1696         PMB: &PassManagerBuilder,
1697         PM: &PassManager<'_>,
1698     );
1699
1700     pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
1701
1702     pub fn LLVMDisposeMessage(message: *mut c_char);
1703
1704     // Stuff that's in llvm-wrapper/ because it's not upstream yet.
1705
1706     /// Opens an object file.
1707     pub fn LLVMCreateObjectFile(
1708         MemBuf: &'static mut MemoryBuffer,
1709     ) -> Option<&'static mut ObjectFile>;
1710     /// Closes an object file.
1711     pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1712
1713     /// Enumerates the sections in an object file.
1714     pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1715     /// Destroys a section iterator.
1716     pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1717     /// Returns `true` if the section iterator is at the end of the section
1718     /// list:
1719     pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1720     /// Moves the section iterator to point to the next section.
1721     pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
1722     /// Returns the current section size.
1723     pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
1724     /// Returns the current section contents as a string buffer.
1725     pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
1726
1727     /// Reads the given file and returns it as a memory buffer. Use
1728     /// LLVMDisposeMemoryBuffer() to get rid of it.
1729     pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1730         Path: *const c_char,
1731     ) -> Option<&'static mut MemoryBuffer>;
1732
1733     pub fn LLVMStartMultithreaded() -> Bool;
1734
1735     /// Returns a string describing the last error caused by an LLVMRust* call.
1736     pub fn LLVMRustGetLastError() -> *const c_char;
1737
1738     /// Print the pass timings since static dtors aren't picking them up.
1739     pub fn LLVMRustPrintPassTimings();
1740
1741     pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1742
1743     pub fn LLVMStructSetBody(
1744         StructTy: &'a Type,
1745         ElementTypes: *const &'a Type,
1746         ElementCount: c_uint,
1747         Packed: Bool,
1748     );
1749
1750     /// Prepares inline assembly.
1751     pub fn LLVMRustInlineAsm(
1752         Ty: &Type,
1753         AsmString: *const c_char,
1754         AsmStringLen: size_t,
1755         Constraints: *const c_char,
1756         ConstraintsLen: size_t,
1757         SideEffects: Bool,
1758         AlignStack: Bool,
1759         Dialect: AsmDialect,
1760     ) -> &Value;
1761     pub fn LLVMRustInlineAsmVerify(
1762         Ty: &Type,
1763         Constraints: *const c_char,
1764         ConstraintsLen: size_t,
1765     ) -> bool;
1766
1767     #[allow(improper_ctypes)]
1768     pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
1769         Filenames: *const *const c_char,
1770         FilenamesLen: size_t,
1771         BufferOut: &RustString,
1772     );
1773
1774     #[allow(improper_ctypes)]
1775     pub fn LLVMRustCoverageWriteMappingToBuffer(
1776         VirtualFileMappingIDs: *const c_uint,
1777         NumVirtualFileMappingIDs: c_uint,
1778         Expressions: *const coverage_map::CounterExpression,
1779         NumExpressions: c_uint,
1780         MappingRegions: *const coverageinfo::CounterMappingRegion,
1781         NumMappingRegions: c_uint,
1782         BufferOut: &RustString,
1783     );
1784
1785     pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char)
1786     -> &'a Value;
1787     pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64;
1788     pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
1789
1790     #[allow(improper_ctypes)]
1791     pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
1792
1793     #[allow(improper_ctypes)]
1794     pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
1795
1796     #[allow(improper_ctypes)]
1797     pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
1798
1799     pub fn LLVMRustCoverageMappingVersion() -> u32;
1800     pub fn LLVMRustDebugMetadataVersion() -> u32;
1801     pub fn LLVMRustVersionMajor() -> u32;
1802     pub fn LLVMRustVersionMinor() -> u32;
1803     pub fn LLVMRustVersionPatch() -> u32;
1804
1805     pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1806
1807     pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1808
1809     pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1810
1811     pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1812
1813     pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
1814
1815     pub fn LLVMRustDIBuilderCreateCompileUnit(
1816         Builder: &DIBuilder<'a>,
1817         Lang: c_uint,
1818         File: &'a DIFile,
1819         Producer: *const c_char,
1820         ProducerLen: size_t,
1821         isOptimized: bool,
1822         Flags: *const c_char,
1823         RuntimeVer: c_uint,
1824         SplitName: *const c_char,
1825         SplitNameLen: size_t,
1826         kind: DebugEmissionKind,
1827         DWOId: u64,
1828         SplitDebugInlining: bool,
1829     ) -> &'a DIDescriptor;
1830
1831     pub fn LLVMRustDIBuilderCreateFile(
1832         Builder: &DIBuilder<'a>,
1833         Filename: *const c_char,
1834         FilenameLen: size_t,
1835         Directory: *const c_char,
1836         DirectoryLen: size_t,
1837         CSKind: ChecksumKind,
1838         Checksum: *const c_char,
1839         ChecksumLen: size_t,
1840     ) -> &'a DIFile;
1841
1842     pub fn LLVMRustDIBuilderCreateSubroutineType(
1843         Builder: &DIBuilder<'a>,
1844         ParameterTypes: &'a DIArray,
1845     ) -> &'a DICompositeType;
1846
1847     pub fn LLVMRustDIBuilderCreateFunction(
1848         Builder: &DIBuilder<'a>,
1849         Scope: &'a DIDescriptor,
1850         Name: *const c_char,
1851         NameLen: size_t,
1852         LinkageName: *const c_char,
1853         LinkageNameLen: size_t,
1854         File: &'a DIFile,
1855         LineNo: c_uint,
1856         Ty: &'a DIType,
1857         ScopeLine: c_uint,
1858         Flags: DIFlags,
1859         SPFlags: DISPFlags,
1860         MaybeFn: Option<&'a Value>,
1861         TParam: &'a DIArray,
1862         Decl: Option<&'a DIDescriptor>,
1863     ) -> &'a DISubprogram;
1864
1865     pub fn LLVMRustDIBuilderCreateBasicType(
1866         Builder: &DIBuilder<'a>,
1867         Name: *const c_char,
1868         NameLen: size_t,
1869         SizeInBits: u64,
1870         Encoding: c_uint,
1871     ) -> &'a DIBasicType;
1872
1873     pub fn LLVMRustDIBuilderCreateTypedef(
1874         Builder: &DIBuilder<'a>,
1875         Type: &'a DIBasicType,
1876         Name: *const c_char,
1877         NameLen: size_t,
1878         File: &'a DIFile,
1879         LineNo: c_uint,
1880         Scope: Option<&'a DIScope>,
1881     ) -> &'a DIDerivedType;
1882
1883     pub fn LLVMRustDIBuilderCreatePointerType(
1884         Builder: &DIBuilder<'a>,
1885         PointeeTy: &'a DIType,
1886         SizeInBits: u64,
1887         AlignInBits: u32,
1888         AddressSpace: c_uint,
1889         Name: *const c_char,
1890         NameLen: size_t,
1891     ) -> &'a DIDerivedType;
1892
1893     pub fn LLVMRustDIBuilderCreateStructType(
1894         Builder: &DIBuilder<'a>,
1895         Scope: Option<&'a DIDescriptor>,
1896         Name: *const c_char,
1897         NameLen: size_t,
1898         File: &'a DIFile,
1899         LineNumber: c_uint,
1900         SizeInBits: u64,
1901         AlignInBits: u32,
1902         Flags: DIFlags,
1903         DerivedFrom: Option<&'a DIType>,
1904         Elements: &'a DIArray,
1905         RunTimeLang: c_uint,
1906         VTableHolder: Option<&'a DIType>,
1907         UniqueId: *const c_char,
1908         UniqueIdLen: size_t,
1909     ) -> &'a DICompositeType;
1910
1911     pub fn LLVMRustDIBuilderCreateMemberType(
1912         Builder: &DIBuilder<'a>,
1913         Scope: &'a DIDescriptor,
1914         Name: *const c_char,
1915         NameLen: size_t,
1916         File: &'a DIFile,
1917         LineNo: c_uint,
1918         SizeInBits: u64,
1919         AlignInBits: u32,
1920         OffsetInBits: u64,
1921         Flags: DIFlags,
1922         Ty: &'a DIType,
1923     ) -> &'a DIDerivedType;
1924
1925     pub fn LLVMRustDIBuilderCreateVariantMemberType(
1926         Builder: &DIBuilder<'a>,
1927         Scope: &'a DIScope,
1928         Name: *const c_char,
1929         NameLen: size_t,
1930         File: &'a DIFile,
1931         LineNumber: c_uint,
1932         SizeInBits: u64,
1933         AlignInBits: u32,
1934         OffsetInBits: u64,
1935         Discriminant: Option<&'a Value>,
1936         Flags: DIFlags,
1937         Ty: &'a DIType,
1938     ) -> &'a DIType;
1939
1940     pub fn LLVMRustDIBuilderCreateLexicalBlock(
1941         Builder: &DIBuilder<'a>,
1942         Scope: &'a DIScope,
1943         File: &'a DIFile,
1944         Line: c_uint,
1945         Col: c_uint,
1946     ) -> &'a DILexicalBlock;
1947
1948     pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
1949         Builder: &DIBuilder<'a>,
1950         Scope: &'a DIScope,
1951         File: &'a DIFile,
1952     ) -> &'a DILexicalBlock;
1953
1954     pub fn LLVMRustDIBuilderCreateStaticVariable(
1955         Builder: &DIBuilder<'a>,
1956         Context: Option<&'a DIScope>,
1957         Name: *const c_char,
1958         NameLen: size_t,
1959         LinkageName: *const c_char,
1960         LinkageNameLen: size_t,
1961         File: &'a DIFile,
1962         LineNo: c_uint,
1963         Ty: &'a DIType,
1964         isLocalToUnit: bool,
1965         Val: &'a Value,
1966         Decl: Option<&'a DIDescriptor>,
1967         AlignInBits: u32,
1968     ) -> &'a DIGlobalVariableExpression;
1969
1970     pub fn LLVMRustDIBuilderCreateVariable(
1971         Builder: &DIBuilder<'a>,
1972         Tag: c_uint,
1973         Scope: &'a DIDescriptor,
1974         Name: *const c_char,
1975         NameLen: size_t,
1976         File: &'a DIFile,
1977         LineNo: c_uint,
1978         Ty: &'a DIType,
1979         AlwaysPreserve: bool,
1980         Flags: DIFlags,
1981         ArgNo: c_uint,
1982         AlignInBits: u32,
1983     ) -> &'a DIVariable;
1984
1985     pub fn LLVMRustDIBuilderCreateArrayType(
1986         Builder: &DIBuilder<'a>,
1987         Size: u64,
1988         AlignInBits: u32,
1989         Ty: &'a DIType,
1990         Subscripts: &'a DIArray,
1991     ) -> &'a DIType;
1992
1993     pub fn LLVMRustDIBuilderGetOrCreateSubrange(
1994         Builder: &DIBuilder<'a>,
1995         Lo: i64,
1996         Count: i64,
1997     ) -> &'a DISubrange;
1998
1999     pub fn LLVMRustDIBuilderGetOrCreateArray(
2000         Builder: &DIBuilder<'a>,
2001         Ptr: *const Option<&'a DIDescriptor>,
2002         Count: c_uint,
2003     ) -> &'a DIArray;
2004
2005     pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
2006         Builder: &DIBuilder<'a>,
2007         Val: &'a Value,
2008         VarInfo: &'a DIVariable,
2009         AddrOps: *const i64,
2010         AddrOpsCount: c_uint,
2011         DL: &'a DILocation,
2012         InsertAtEnd: &'a BasicBlock,
2013     ) -> &'a Value;
2014
2015     pub fn LLVMRustDIBuilderCreateEnumerator(
2016         Builder: &DIBuilder<'a>,
2017         Name: *const c_char,
2018         NameLen: size_t,
2019         Value: i64,
2020         IsUnsigned: bool,
2021     ) -> &'a DIEnumerator;
2022
2023     pub fn LLVMRustDIBuilderCreateEnumerationType(
2024         Builder: &DIBuilder<'a>,
2025         Scope: &'a DIScope,
2026         Name: *const c_char,
2027         NameLen: size_t,
2028         File: &'a DIFile,
2029         LineNumber: c_uint,
2030         SizeInBits: u64,
2031         AlignInBits: u32,
2032         Elements: &'a DIArray,
2033         ClassType: &'a DIType,
2034         IsScoped: bool,
2035     ) -> &'a DIType;
2036
2037     pub fn LLVMRustDIBuilderCreateUnionType(
2038         Builder: &DIBuilder<'a>,
2039         Scope: &'a DIScope,
2040         Name: *const c_char,
2041         NameLen: size_t,
2042         File: &'a DIFile,
2043         LineNumber: c_uint,
2044         SizeInBits: u64,
2045         AlignInBits: u32,
2046         Flags: DIFlags,
2047         Elements: Option<&'a DIArray>,
2048         RunTimeLang: c_uint,
2049         UniqueId: *const c_char,
2050         UniqueIdLen: size_t,
2051     ) -> &'a DIType;
2052
2053     pub fn LLVMRustDIBuilderCreateVariantPart(
2054         Builder: &DIBuilder<'a>,
2055         Scope: &'a DIScope,
2056         Name: *const c_char,
2057         NameLen: size_t,
2058         File: &'a DIFile,
2059         LineNo: c_uint,
2060         SizeInBits: u64,
2061         AlignInBits: u32,
2062         Flags: DIFlags,
2063         Discriminator: Option<&'a DIDerivedType>,
2064         Elements: &'a DIArray,
2065         UniqueId: *const c_char,
2066         UniqueIdLen: size_t,
2067     ) -> &'a DIDerivedType;
2068
2069     pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
2070
2071     pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
2072         Builder: &DIBuilder<'a>,
2073         Scope: Option<&'a DIScope>,
2074         Name: *const c_char,
2075         NameLen: size_t,
2076         Ty: &'a DIType,
2077     ) -> &'a DITemplateTypeParameter;
2078
2079     pub fn LLVMRustDIBuilderCreateNameSpace(
2080         Builder: &DIBuilder<'a>,
2081         Scope: Option<&'a DIScope>,
2082         Name: *const c_char,
2083         NameLen: size_t,
2084         ExportSymbols: bool,
2085     ) -> &'a DINameSpace;
2086
2087     pub fn LLVMRustDICompositeTypeReplaceArrays(
2088         Builder: &DIBuilder<'a>,
2089         CompositeType: &'a DIType,
2090         Elements: Option<&'a DIArray>,
2091         Params: Option<&'a DIArray>,
2092     );
2093
2094     pub fn LLVMRustDIBuilderCreateDebugLocation(
2095         Line: c_uint,
2096         Column: c_uint,
2097         Scope: &'a DIScope,
2098         InlinedAt: Option<&'a DILocation>,
2099     ) -> &'a DILocation;
2100     pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
2101     pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
2102
2103     #[allow(improper_ctypes)]
2104     pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
2105     #[allow(improper_ctypes)]
2106     pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
2107
2108     pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
2109
2110     pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
2111     pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
2112     pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
2113     pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2114     pub fn LLVMRustCreateMemorySanitizerPass(
2115         TrackOrigins: c_int,
2116         Recover: bool,
2117     ) -> &'static mut Pass;
2118     pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
2119     pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
2120     pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
2121     pub fn LLVMRustAddLastExtensionPasses(
2122         PMB: &PassManagerBuilder,
2123         Passes: *const &'static mut Pass,
2124         NumPasses: size_t,
2125     );
2126
2127     pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
2128
2129     pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
2130     pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
2131
2132     pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2133     pub fn LLVMRustCreateTargetMachine(
2134         Triple: *const c_char,
2135         CPU: *const c_char,
2136         Features: *const c_char,
2137         Abi: *const c_char,
2138         Model: CodeModel,
2139         Reloc: RelocModel,
2140         Level: CodeGenOptLevel,
2141         UseSoftFP: bool,
2142         FunctionSections: bool,
2143         DataSections: bool,
2144         TrapUnreachable: bool,
2145         Singlethread: bool,
2146         AsmComments: bool,
2147         EmitStackSizeSection: bool,
2148         RelaxELFRelocations: bool,
2149         UseInitArray: bool,
2150         SplitDwarfFile: *const c_char,
2151     ) -> Option<&'static mut TargetMachine>;
2152     pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
2153     pub fn LLVMRustAddBuilderLibraryInfo(
2154         PMB: &'a PassManagerBuilder,
2155         M: &'a Module,
2156         DisableSimplifyLibCalls: bool,
2157     );
2158     pub fn LLVMRustConfigurePassManagerBuilder(
2159         PMB: &PassManagerBuilder,
2160         OptLevel: CodeGenOptLevel,
2161         MergeFunctions: bool,
2162         SLPVectorize: bool,
2163         LoopVectorize: bool,
2164         PrepareForThinLTO: bool,
2165         PGOGenPath: *const c_char,
2166         PGOUsePath: *const c_char,
2167     );
2168     pub fn LLVMRustAddLibraryInfo(
2169         PM: &PassManager<'a>,
2170         M: &'a Module,
2171         DisableSimplifyLibCalls: bool,
2172     );
2173     pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
2174     pub fn LLVMRustWriteOutputFile(
2175         T: &'a TargetMachine,
2176         PM: &PassManager<'a>,
2177         M: &'a Module,
2178         Output: *const c_char,
2179         DwoOutput: *const c_char,
2180         FileType: FileType,
2181     ) -> LLVMRustResult;
2182     pub fn LLVMRustOptimizeWithNewPassManager(
2183         M: &'a Module,
2184         TM: &'a TargetMachine,
2185         OptLevel: PassBuilderOptLevel,
2186         OptStage: OptStage,
2187         NoPrepopulatePasses: bool,
2188         VerifyIR: bool,
2189         UseThinLTOBuffers: bool,
2190         MergeFunctions: bool,
2191         UnrollLoops: bool,
2192         SLPVectorize: bool,
2193         LoopVectorize: bool,
2194         DisableSimplifyLibCalls: bool,
2195         EmitLifetimeMarkers: bool,
2196         SanitizerOptions: Option<&SanitizerOptions>,
2197         PGOGenPath: *const c_char,
2198         PGOUsePath: *const c_char,
2199         llvm_selfprofiler: *mut c_void,
2200         begin_callback: SelfProfileBeforePassCallback,
2201         end_callback: SelfProfileAfterPassCallback,
2202     );
2203     pub fn LLVMRustPrintModule(
2204         M: &'a Module,
2205         Output: *const c_char,
2206         Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
2207     ) -> LLVMRustResult;
2208     pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
2209     pub fn LLVMRustPrintPasses();
2210     pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
2211     pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
2212     pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
2213     pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
2214     pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
2215
2216     pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
2217     pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
2218     pub fn LLVMRustArchiveIteratorNext(
2219         AIR: &ArchiveIterator<'a>,
2220     ) -> Option<&'a mut ArchiveChild<'a>>;
2221     pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2222     pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
2223     pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
2224     pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
2225     pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
2226
2227     #[allow(improper_ctypes)]
2228     pub fn LLVMRustGetSectionName(
2229         SI: &SectionIterator<'_>,
2230         data: &mut Option<std::ptr::NonNull<c_char>>,
2231     ) -> size_t;
2232
2233     #[allow(improper_ctypes)]
2234     pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
2235
2236     pub fn LLVMContextSetDiagnosticHandler(
2237         C: &Context,
2238         Handler: DiagnosticHandler,
2239         DiagnosticContext: *mut c_void,
2240     );
2241
2242     #[allow(improper_ctypes)]
2243     pub fn LLVMRustUnpackOptimizationDiagnostic(
2244         DI: &'a DiagnosticInfo,
2245         pass_name_out: &RustString,
2246         function_out: &mut Option<&'a Value>,
2247         loc_line_out: &mut c_uint,
2248         loc_column_out: &mut c_uint,
2249         loc_filename_out: &RustString,
2250         message_out: &RustString,
2251     );
2252
2253     pub fn LLVMRustUnpackInlineAsmDiagnostic(
2254         DI: &'a DiagnosticInfo,
2255         level_out: &mut DiagnosticLevel,
2256         cookie_out: &mut c_uint,
2257         message_out: &mut Option<&'a Twine>,
2258         instruction_out: &mut Option<&'a Value>,
2259     );
2260
2261     #[allow(improper_ctypes)]
2262     pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
2263     pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
2264
2265     pub fn LLVMRustSetInlineAsmDiagnosticHandler(
2266         C: &Context,
2267         H: InlineAsmDiagHandler,
2268         CX: *mut c_void,
2269     );
2270
2271     #[allow(improper_ctypes)]
2272     pub fn LLVMRustUnpackSMDiagnostic(
2273         d: &SMDiagnostic,
2274         message_out: &RustString,
2275         buffer_out: &RustString,
2276         level_out: &mut DiagnosticLevel,
2277         loc_out: &mut c_uint,
2278         ranges_out: *mut c_uint,
2279         num_ranges: &mut usize,
2280     ) -> bool;
2281
2282     pub fn LLVMRustWriteArchive(
2283         Dst: *const c_char,
2284         NumMembers: size_t,
2285         Members: *const &RustArchiveMember<'_>,
2286         WriteSymbtab: bool,
2287         Kind: ArchiveKind,
2288     ) -> LLVMRustResult;
2289     pub fn LLVMRustArchiveMemberNew(
2290         Filename: *const c_char,
2291         Name: *const c_char,
2292         Child: Option<&ArchiveChild<'a>>,
2293     ) -> &'a mut RustArchiveMember<'a>;
2294     pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
2295
2296     pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
2297
2298     pub fn LLVMRustBuildOperandBundleDef(
2299         Name: *const c_char,
2300         Inputs: *const &'a Value,
2301         NumInputs: c_uint,
2302     ) -> &'a mut OperandBundleDef<'a>;
2303     pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
2304
2305     pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
2306
2307     pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2308     pub fn LLVMRustUnsetComdat(V: &Value);
2309     pub fn LLVMRustSetModulePICLevel(M: &Module);
2310     pub fn LLVMRustSetModulePIELevel(M: &Module);
2311     pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
2312     pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
2313     pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
2314     pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
2315     pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
2316     pub fn LLVMRustModuleCost(M: &Module) -> u64;
2317
2318     pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
2319     pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
2320     pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
2321     pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
2322     pub fn LLVMRustCreateThinLTOData(
2323         Modules: *const ThinLTOModule,
2324         NumModules: c_uint,
2325         PreservedSymbols: *const *const c_char,
2326         PreservedSymbolsLen: c_uint,
2327     ) -> Option<&'static mut ThinLTOData>;
2328     pub fn LLVMRustPrepareThinLTORename(
2329         Data: &ThinLTOData,
2330         Module: &Module,
2331         Target: &TargetMachine,
2332     ) -> bool;
2333     pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
2334     pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2335     pub fn LLVMRustPrepareThinLTOImport(
2336         Data: &ThinLTOData,
2337         Module: &Module,
2338         Target: &TargetMachine,
2339     ) -> bool;
2340     pub fn LLVMRustGetThinLTOModuleImports(
2341         Data: *const ThinLTOData,
2342         ModuleNameCallback: ThinLTOModuleNameCallback,
2343         CallbackPayload: *mut c_void,
2344     );
2345     pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
2346     pub fn LLVMRustParseBitcodeForLTO(
2347         Context: &Context,
2348         Data: *const u8,
2349         len: usize,
2350         Identifier: *const c_char,
2351     ) -> Option<&Module>;
2352     pub fn LLVMRustGetBitcodeSliceFromObjectData(
2353         Data: *const u8,
2354         len: usize,
2355         out_len: &mut usize,
2356     ) -> *const u8;
2357     pub fn LLVMRustThinLTOGetDICompileUnit(
2358         M: &Module,
2359         CU1: &mut *mut c_void,
2360         CU2: &mut *mut c_void,
2361     );
2362     pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
2363
2364     pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
2365     pub fn LLVMRustLinkerAdd(
2366         linker: &Linker<'_>,
2367         bytecode: *const c_char,
2368         bytecode_len: usize,
2369     ) -> bool;
2370     pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
2371     #[allow(improper_ctypes)]
2372     pub fn LLVMRustComputeLTOCacheKey(
2373         key_out: &RustString,
2374         mod_id: *const c_char,
2375         data: &ThinLTOData,
2376     );
2377 }