]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_llvm/llvm/ffi.rs
898d3d67353634b1ece65bfd1e2dd74fea44f9c8
[rust.git] / src / librustc_codegen_llvm / llvm / ffi.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // FIXME: Rename 'DIGlobalVariable' to 'DIGlobalVariableExpression'
12 // once support for LLVM 3.9 is dropped.
13 //
14 // This method was changed in this LLVM patch:
15 // https://reviews.llvm.org/D26769
16
17 use super::debuginfo::{
18     DIBuilder, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
19     DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
20     DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
21     DINameSpace, DIFlags,
22 };
23
24 use libc::{c_uint, c_int, size_t, c_char};
25 use libc::{c_ulonglong, c_void};
26
27 use std::marker::PhantomData;
28
29 use super::RustString;
30
31 pub type Bool = c_uint;
32
33 pub const True: Bool = 1 as Bool;
34 pub const False: Bool = 0 as Bool;
35
36 #[derive(Copy, Clone, PartialEq)]
37 #[repr(C)]
38 #[allow(dead_code)] // Variants constructed by C++.
39 pub enum LLVMRustResult {
40     Success,
41     Failure,
42 }
43 // Consts for the LLVM CallConv type, pre-cast to usize.
44
45 /// LLVM CallingConv::ID. Should we wrap this?
46 #[derive(Copy, Clone, PartialEq, Debug)]
47 #[repr(C)]
48 pub enum CallConv {
49     CCallConv = 0,
50     FastCallConv = 8,
51     ColdCallConv = 9,
52     X86StdcallCallConv = 64,
53     X86FastcallCallConv = 65,
54     ArmAapcsCallConv = 67,
55     Msp430Intr = 69,
56     X86_ThisCall = 70,
57     PtxKernel = 71,
58     X86_64_SysV = 78,
59     X86_64_Win64 = 79,
60     X86_VectorCall = 80,
61     X86_Intr = 83,
62     AmdGpuKernel = 91,
63 }
64
65 /// LLVMRustLinkage
66 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
67 #[repr(C)]
68 pub enum Linkage {
69     ExternalLinkage = 0,
70     AvailableExternallyLinkage = 1,
71     LinkOnceAnyLinkage = 2,
72     LinkOnceODRLinkage = 3,
73     WeakAnyLinkage = 4,
74     WeakODRLinkage = 5,
75     AppendingLinkage = 6,
76     InternalLinkage = 7,
77     PrivateLinkage = 8,
78     ExternalWeakLinkage = 9,
79     CommonLinkage = 10,
80 }
81
82 // LLVMRustVisibility
83 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
84 #[repr(C)]
85 pub enum Visibility {
86     Default = 0,
87     Hidden = 1,
88     Protected = 2,
89 }
90
91 /// LLVMDLLStorageClass
92 #[derive(Copy, Clone)]
93 #[repr(C)]
94 pub enum DLLStorageClass {
95     #[allow(dead_code)]
96     Default = 0,
97     DllImport = 1, // Function to be imported from DLL.
98     #[allow(dead_code)]
99     DllExport = 2, // Function to be accessible from DLL.
100 }
101
102 /// Matches LLVMRustAttribute in rustllvm.h
103 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
104 /// though it is not ABI compatible (since it's a C++ enum)
105 #[repr(C)]
106 #[derive(Copy, Clone, Debug)]
107 pub enum Attribute {
108     AlwaysInline    = 0,
109     ByVal           = 1,
110     Cold            = 2,
111     InlineHint      = 3,
112     MinSize         = 4,
113     Naked           = 5,
114     NoAlias         = 6,
115     NoCapture       = 7,
116     NoInline        = 8,
117     NonNull         = 9,
118     NoRedZone       = 10,
119     NoReturn        = 11,
120     NoUnwind        = 12,
121     OptimizeForSize = 13,
122     ReadOnly        = 14,
123     SExt            = 15,
124     StructRet       = 16,
125     UWTable         = 17,
126     ZExt            = 18,
127     InReg           = 19,
128     SanitizeThread  = 20,
129     SanitizeAddress = 21,
130     SanitizeMemory  = 22,
131 }
132
133 /// LLVMIntPredicate
134 #[derive(Copy, Clone)]
135 #[repr(C)]
136 pub enum IntPredicate {
137     IntEQ = 32,
138     IntNE = 33,
139     IntUGT = 34,
140     IntUGE = 35,
141     IntULT = 36,
142     IntULE = 37,
143     IntSGT = 38,
144     IntSGE = 39,
145     IntSLT = 40,
146     IntSLE = 41,
147 }
148
149 /// LLVMRealPredicate
150 #[derive(Copy, Clone)]
151 #[repr(C)]
152 pub enum RealPredicate {
153     RealPredicateFalse = 0,
154     RealOEQ = 1,
155     RealOGT = 2,
156     RealOGE = 3,
157     RealOLT = 4,
158     RealOLE = 5,
159     RealONE = 6,
160     RealORD = 7,
161     RealUNO = 8,
162     RealUEQ = 9,
163     RealUGT = 10,
164     RealUGE = 11,
165     RealULT = 12,
166     RealULE = 13,
167     RealUNE = 14,
168     RealPredicateTrue = 15,
169 }
170
171 /// LLVMTypeKind
172 #[derive(Copy, Clone, PartialEq, Debug)]
173 #[repr(C)]
174 pub enum TypeKind {
175     Void = 0,
176     Half = 1,
177     Float = 2,
178     Double = 3,
179     X86_FP80 = 4,
180     FP128 = 5,
181     PPC_FP128 = 6,
182     Label = 7,
183     Integer = 8,
184     Function = 9,
185     Struct = 10,
186     Array = 11,
187     Pointer = 12,
188     Vector = 13,
189     Metadata = 14,
190     X86_MMX = 15,
191     Token = 16,
192 }
193
194 /// LLVMAtomicRmwBinOp
195 #[derive(Copy, Clone)]
196 #[repr(C)]
197 pub enum AtomicRmwBinOp {
198     AtomicXchg = 0,
199     AtomicAdd = 1,
200     AtomicSub = 2,
201     AtomicAnd = 3,
202     AtomicNand = 4,
203     AtomicOr = 5,
204     AtomicXor = 6,
205     AtomicMax = 7,
206     AtomicMin = 8,
207     AtomicUMax = 9,
208     AtomicUMin = 10,
209 }
210
211 /// LLVMAtomicOrdering
212 #[derive(Copy, Clone)]
213 #[repr(C)]
214 pub enum AtomicOrdering {
215     #[allow(dead_code)]
216     NotAtomic = 0,
217     Unordered = 1,
218     Monotonic = 2,
219     // Consume = 3,  // Not specified yet.
220     Acquire = 4,
221     Release = 5,
222     AcquireRelease = 6,
223     SequentiallyConsistent = 7,
224 }
225
226 /// LLVMRustSynchronizationScope
227 #[derive(Copy, Clone)]
228 #[repr(C)]
229 pub enum SynchronizationScope {
230     // FIXME: figure out if this variant is needed at all.
231     #[allow(dead_code)]
232     Other,
233     SingleThread,
234     CrossThread,
235 }
236
237 /// LLVMRustFileType
238 #[derive(Copy, Clone)]
239 #[repr(C)]
240 pub enum FileType {
241     // FIXME: figure out if this variant is needed at all.
242     #[allow(dead_code)]
243     Other,
244     AssemblyFile,
245     ObjectFile,
246 }
247
248 /// LLVMMetadataType
249 #[derive(Copy, Clone)]
250 #[repr(C)]
251 pub enum MetadataType {
252     MD_dbg = 0,
253     MD_tbaa = 1,
254     MD_prof = 2,
255     MD_fpmath = 3,
256     MD_range = 4,
257     MD_tbaa_struct = 5,
258     MD_invariant_load = 6,
259     MD_alias_scope = 7,
260     MD_noalias = 8,
261     MD_nontemporal = 9,
262     MD_mem_parallel_loop_access = 10,
263     MD_nonnull = 11,
264 }
265
266 /// LLVMRustAsmDialect
267 #[derive(Copy, Clone)]
268 #[repr(C)]
269 pub enum AsmDialect {
270     // FIXME: figure out if this variant is needed at all.
271     #[allow(dead_code)]
272     Other,
273     Att,
274     Intel,
275 }
276
277 /// LLVMRustCodeGenOptLevel
278 #[derive(Copy, Clone, PartialEq)]
279 #[repr(C)]
280 pub enum CodeGenOptLevel {
281     // FIXME: figure out if this variant is needed at all.
282     #[allow(dead_code)]
283     Other,
284     None,
285     Less,
286     Default,
287     Aggressive,
288 }
289
290 /// LLVMRelocMode
291 #[derive(Copy, Clone, PartialEq)]
292 #[repr(C)]
293 pub enum RelocMode {
294     Default,
295     Static,
296     PIC,
297     DynamicNoPic,
298     ROPI,
299     RWPI,
300     ROPI_RWPI,
301 }
302
303 /// LLVMRustCodeModel
304 #[derive(Copy, Clone)]
305 #[repr(C)]
306 pub enum CodeModel {
307     // FIXME: figure out if this variant is needed at all.
308     #[allow(dead_code)]
309     Other,
310     Small,
311     Kernel,
312     Medium,
313     Large,
314     None,
315 }
316
317 /// LLVMRustDiagnosticKind
318 #[derive(Copy, Clone)]
319 #[repr(C)]
320 #[allow(dead_code)] // Variants constructed by C++.
321 pub enum DiagnosticKind {
322     Other,
323     InlineAsm,
324     StackSize,
325     DebugMetadataVersion,
326     SampleProfile,
327     OptimizationRemark,
328     OptimizationRemarkMissed,
329     OptimizationRemarkAnalysis,
330     OptimizationRemarkAnalysisFPCommute,
331     OptimizationRemarkAnalysisAliasing,
332     OptimizationRemarkOther,
333     OptimizationFailure,
334     PGOProfile,
335 }
336
337 /// LLVMRustArchiveKind
338 #[derive(Copy, Clone)]
339 #[repr(C)]
340 pub enum ArchiveKind {
341     // FIXME: figure out if this variant is needed at all.
342     #[allow(dead_code)]
343     Other,
344     K_GNU,
345     K_BSD,
346     K_COFF,
347 }
348
349 /// LLVMRustPassKind
350 #[derive(Copy, Clone, PartialEq, Debug)]
351 #[repr(C)]
352 #[allow(dead_code)] // Variants constructed by C++.
353 pub enum PassKind {
354     Other,
355     Function,
356     Module,
357 }
358
359 /// LLVMRustThinLTOData
360 extern { pub type ThinLTOData; }
361
362 /// LLVMRustThinLTOBuffer
363 extern { pub type ThinLTOBuffer; }
364
365 /// LLVMRustThinLTOModule
366 #[repr(C)]
367 pub struct ThinLTOModule {
368     pub identifier: *const c_char,
369     pub data: *const u8,
370     pub len: usize,
371 }
372
373 /// LLVMThreadLocalMode
374 #[derive(Copy, Clone)]
375 #[repr(C)]
376 pub enum ThreadLocalMode {
377   NotThreadLocal,
378   GeneralDynamic,
379   LocalDynamic,
380   InitialExec,
381   LocalExec
382 }
383
384 extern { type Opaque; }
385 #[repr(C)]
386 struct InvariantOpaque<'a> {
387     _marker: PhantomData<&'a mut &'a ()>,
388     _opaque: Opaque,
389 }
390
391 // Opaque pointer types
392 extern { pub type Module; }
393 extern { pub type Context; }
394 extern { pub type Type; }
395 extern { pub type Value; }
396 extern { pub type Metadata; }
397 extern { pub type BasicBlock; }
398 #[repr(C)]
399 pub struct Builder<'a>(InvariantOpaque<'a>);
400 extern { pub type MemoryBuffer; }
401 #[repr(C)]
402 pub struct PassManager<'a>(InvariantOpaque<'a>);
403 extern { pub type PassManagerBuilder; }
404 extern { pub type ObjectFile; }
405 #[repr(C)]
406 pub struct SectionIterator<'a>(InvariantOpaque<'a>);
407 extern { pub type Pass; }
408 extern { pub type TargetMachine; }
409 extern { pub type Archive; }
410 #[repr(C)]
411 pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
412 #[repr(C)]
413 pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
414 extern { pub type Twine; }
415 extern { pub type DiagnosticInfo; }
416 extern { pub type SMDiagnostic; }
417 #[repr(C)]
418 pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
419 #[repr(C)]
420 pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
421 #[repr(C)]
422 pub struct Linker<'a>(InvariantOpaque<'a>);
423
424 pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
425 pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
426
427
428 pub mod debuginfo {
429     use super::{InvariantOpaque, Metadata};
430
431     #[repr(C)]
432     pub struct DIBuilder<'a>(InvariantOpaque<'a>);
433
434     pub type DIDescriptor = Metadata;
435     pub type DIScope = DIDescriptor;
436     pub type DIFile = DIScope;
437     pub type DILexicalBlock = DIScope;
438     pub type DISubprogram = DIScope;
439     pub type DINameSpace = DIScope;
440     pub type DIType = DIDescriptor;
441     pub type DIBasicType = DIType;
442     pub type DIDerivedType = DIType;
443     pub type DICompositeType = DIDerivedType;
444     pub type DIVariable = DIDescriptor;
445     pub type DIGlobalVariable = DIDescriptor;
446     pub type DIArray = DIDescriptor;
447     pub type DISubrange = DIDescriptor;
448     pub type DIEnumerator = DIDescriptor;
449     pub type DITemplateTypeParameter = DIDescriptor;
450
451     // These values **must** match with LLVMRustDIFlags!!
452     bitflags! {
453         #[repr(C)]
454         #[derive(Default)]
455         pub struct DIFlags: ::libc::uint32_t {
456             const FlagZero                = 0;
457             const FlagPrivate             = 1;
458             const FlagProtected           = 2;
459             const FlagPublic              = 3;
460             const FlagFwdDecl             = (1 << 2);
461             const FlagAppleBlock          = (1 << 3);
462             const FlagBlockByrefStruct    = (1 << 4);
463             const FlagVirtual             = (1 << 5);
464             const FlagArtificial          = (1 << 6);
465             const FlagExplicit            = (1 << 7);
466             const FlagPrototyped          = (1 << 8);
467             const FlagObjcClassComplete   = (1 << 9);
468             const FlagObjectPointer       = (1 << 10);
469             const FlagVector              = (1 << 11);
470             const FlagStaticMember        = (1 << 12);
471             const FlagLValueReference     = (1 << 13);
472             const FlagRValueReference     = (1 << 14);
473             const FlagExternalTypeRef     = (1 << 15);
474             const FlagIntroducedVirtual   = (1 << 18);
475             const FlagBitField            = (1 << 19);
476             const FlagNoReturn            = (1 << 20);
477             const FlagMainSubprogram      = (1 << 21);
478         }
479     }
480 }
481
482 extern { pub type ModuleBuffer; }
483
484 extern "C" {
485     // Create and destroy contexts.
486     pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
487     pub fn LLVMContextDispose(C: &'static mut Context);
488     pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
489
490     // Create modules.
491     pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
492     pub fn LLVMGetModuleContext(M: &Module) -> &Context;
493     pub fn LLVMCloneModule(M: &Module) -> &Module;
494
495     /// Data layout. See Module::getDataLayout.
496     pub fn LLVMGetDataLayout(M: &Module) -> *const c_char;
497     pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
498
499     /// See Module::setModuleInlineAsm.
500     pub fn LLVMSetModuleInlineAsm(M: &Module, Asm: *const c_char);
501     pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char);
502
503     /// See llvm::LLVMTypeKind::getTypeID.
504     pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
505
506     // Operations on integer types
507     pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
508     pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
509     pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
510     pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
511     pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
512     pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
513
514     pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
515
516     // Operations on real types
517     pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
518     pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
519
520     // Operations on function types
521     pub fn LLVMFunctionType(ReturnType: &'a Type,
522                             ParamTypes: *const &'a Type,
523                             ParamCount: c_uint,
524                             IsVarArg: Bool)
525                             -> &'a Type;
526     pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
527     pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
528
529     // Operations on struct types
530     pub fn LLVMStructTypeInContext(C: &'a Context,
531                                    ElementTypes: *const &'a Type,
532                                    ElementCount: c_uint,
533                                    Packed: Bool)
534                                    -> &'a Type;
535
536     // Operations on array, pointer, and vector types (sequence types)
537     pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
538     pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
539     pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
540
541     pub fn LLVMGetElementType(Ty: &Type) -> &Type;
542     pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
543
544     // Operations on other types
545     pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
546     pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
547     pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
548
549     // Operations on all values
550     pub fn LLVMTypeOf(Val: &Value) -> &Type;
551     pub fn LLVMGetValueName(Val: &Value) -> *const c_char;
552     pub fn LLVMSetValueName(Val: &Value, Name: *const c_char);
553     pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
554     pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
555
556     // Operations on constants of any type
557     pub fn LLVMConstNull(Ty: &Type) -> &Value;
558     pub fn LLVMGetUndef(Ty: &Type) -> &Value;
559
560     // Operations on metadata
561     pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
562     pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
563     pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
564
565     // Operations on scalar constants
566     pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
567     pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
568     pub fn LLVMConstIntGetZExtValue(ConstantVal: &Value) -> c_ulonglong;
569     pub fn LLVMRustConstInt128Get(ConstantVal: &Value, SExt: bool,
570                                   high: &mut u64, low: &mut u64) -> bool;
571     pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: &mut Bool) -> f64;
572
573
574     // Operations on composite constants
575     pub fn LLVMConstStringInContext(C: &Context,
576                                     Str: *const c_char,
577                                     Length: c_uint,
578                                     DontNullTerminate: Bool)
579                                     -> &Value;
580     pub fn LLVMConstStructInContext(C: &'a Context,
581                                     ConstantVals: *const &'a Value,
582                                     Count: c_uint,
583                                     Packed: Bool)
584                                     -> &'a Value;
585
586     pub fn LLVMConstArray(ElementTy: &'a Type,
587                           ConstantVals: *const &'a Value,
588                           Length: c_uint)
589                           -> &'a Value;
590     pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
591
592     // Constant expressions
593     pub fn LLVMConstInBoundsGEP(
594         ConstantVal: &'a Value,
595         ConstantIndices: *const &'a Value,
596         NumIndices: c_uint,
597     ) -> &'a Value;
598     pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
599     pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
600     pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
601     pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
602     pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
603     pub fn LLVMConstExtractValue(AggConstant: &Value,
604                                  IdxList: *const c_uint,
605                                  NumIdx: c_uint)
606                                  -> &Value;
607
608     // Operations on global variables, functions, and aliases (globals)
609     pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
610     pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
611     pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
612     pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
613     pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
614     pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
615     pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
616     pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
617     pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
618
619
620     // Operations on global variables
621     pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
622     pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
623     pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
624     pub fn LLVMRustGetOrInsertGlobal(M: &'a Module, Name: *const c_char, T: &'a Type) -> &'a Value;
625     pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
626     pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
627     pub fn LLVMDeleteGlobal(GlobalVar: &Value);
628     pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
629     pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
630     pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
631     pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
632     pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
633     pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
634     pub fn LLVMRustGetNamedValue(M: &Module, Name: *const c_char) -> Option<&Value>;
635     pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
636
637     // Operations on functions
638     pub fn LLVMRustGetOrInsertFunction(M: &'a Module,
639                                        Name: *const c_char,
640                                        FunctionTy: &'a Type)
641                                        -> &'a Value;
642     pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
643     pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
644     pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
645     pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
646     pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
647     pub fn LLVMRustAddFunctionAttrStringValue(Fn: &Value,
648                                               index: c_uint,
649                                               Name: *const c_char,
650                                               Value: *const c_char);
651     pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
652
653     // Operations on parameters
654     pub fn LLVMCountParams(Fn: &Value) -> c_uint;
655     pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
656
657     // Operations on basic blocks
658     pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
659     pub fn LLVMAppendBasicBlockInContext(C: &'a Context,
660                                          Fn: &'a Value,
661                                          Name: *const c_char)
662                                          -> &'a BasicBlock;
663     pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
664
665     // Operations on instructions
666     pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
667
668     // Operations on call sites
669     pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
670     pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
671     pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
672     pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
673     pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value,
674                                                         index: c_uint,
675                                                         bytes: u64);
676
677     // Operations on load/store instructions (only)
678     pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
679
680     // Operations on phi nodes
681     pub fn LLVMAddIncoming(PhiNode: &'a Value,
682                            IncomingValues: *const &'a Value,
683                            IncomingBlocks: *const &'a BasicBlock,
684                            Count: c_uint);
685
686     // Instruction builders
687     pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
688     pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
689     pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
690     pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
691
692     // Metadata
693     pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: Option<&'a Value>);
694     pub fn LLVMGetCurrentDebugLocation(Builder: &Builder<'a>) -> &'a Value;
695     pub fn LLVMSetInstDebugLocation(Builder: &Builder<'a>, Inst: &'a Value);
696
697     // Terminators
698     pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
699     pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
700     pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
701     pub fn LLVMBuildCondBr(B: &Builder<'a>,
702                            If: &'a Value,
703                            Then: &'a BasicBlock,
704                            Else: &'a BasicBlock)
705                            -> &'a Value;
706     pub fn LLVMBuildSwitch(B: &Builder<'a>,
707                            V: &'a Value,
708                            Else: &'a BasicBlock,
709                            NumCases: c_uint)
710                            -> &'a Value;
711     pub fn LLVMRustBuildInvoke(B: &Builder<'a>,
712                                Fn: &'a Value,
713                                Args: *const &'a Value,
714                                NumArgs: c_uint,
715                                Then: &'a BasicBlock,
716                                Catch: &'a BasicBlock,
717                                Bundle: Option<&OperandBundleDef<'a>>,
718                                Name: *const c_char)
719                                -> &'a Value;
720     pub fn LLVMBuildLandingPad(B: &Builder<'a>,
721                                Ty: &'a Type,
722                                PersFn: &'a Value,
723                                NumClauses: c_uint,
724                                Name: *const c_char)
725                                -> &'a Value;
726     pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
727     pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
728
729     pub fn LLVMRustBuildCleanupPad(B: &Builder<'a>,
730                                    ParentPad: Option<&'a Value>,
731                                    ArgCnt: c_uint,
732                                    Args: *const &'a Value,
733                                    Name: *const c_char)
734                                    -> Option<&'a Value>;
735     pub fn LLVMRustBuildCleanupRet(B: &Builder<'a>,
736                                    CleanupPad: &'a Value,
737                                    UnwindBB: Option<&'a BasicBlock>)
738                                    -> Option<&'a Value>;
739     pub fn LLVMRustBuildCatchPad(B: &Builder<'a>,
740                                  ParentPad: &'a Value,
741                                  ArgCnt: c_uint,
742                                  Args: *const &'a Value,
743                                  Name: *const c_char)
744                                  -> Option<&'a Value>;
745     pub fn LLVMRustBuildCatchRet(
746         B: &Builder<'a>,
747         Pad: &'a Value,
748         BB: &'a BasicBlock,
749     ) -> Option<&'a Value>;
750     pub fn LLVMRustBuildCatchSwitch(Builder: &Builder<'a>,
751                                     ParentPad: Option<&'a Value>,
752                                     BB: Option<&'a BasicBlock>,
753                                     NumHandlers: c_uint,
754                                     Name: *const c_char)
755                                     -> Option<&'a Value>;
756     pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
757     pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
758
759     // Add a case to the switch instruction
760     pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
761
762     // Add a clause to the landing pad instruction
763     pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
764
765     // Set the cleanup on a landing pad instruction
766     pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
767
768     // Arithmetic
769     pub fn LLVMBuildAdd(B: &Builder<'a>,
770                         LHS: &'a Value,
771                         RHS: &'a Value,
772                         Name: *const c_char)
773                         -> &'a Value;
774     pub fn LLVMBuildFAdd(B: &Builder<'a>,
775                          LHS: &'a Value,
776                          RHS: &'a Value,
777                          Name: *const c_char)
778                          -> &'a Value;
779     pub fn LLVMBuildSub(B: &Builder<'a>,
780                         LHS: &'a Value,
781                         RHS: &'a Value,
782                         Name: *const c_char)
783                         -> &'a Value;
784     pub fn LLVMBuildFSub(B: &Builder<'a>,
785                          LHS: &'a Value,
786                          RHS: &'a Value,
787                          Name: *const c_char)
788                          -> &'a Value;
789     pub fn LLVMBuildMul(B: &Builder<'a>,
790                         LHS: &'a Value,
791                         RHS: &'a Value,
792                         Name: *const c_char)
793                         -> &'a Value;
794     pub fn LLVMBuildFMul(B: &Builder<'a>,
795                          LHS: &'a Value,
796                          RHS: &'a Value,
797                          Name: *const c_char)
798                          -> &'a Value;
799     pub fn LLVMBuildUDiv(B: &Builder<'a>,
800                          LHS: &'a Value,
801                          RHS: &'a Value,
802                          Name: *const c_char)
803                          -> &'a Value;
804     pub fn LLVMBuildExactUDiv(B: &Builder<'a>,
805                               LHS: &'a Value,
806                               RHS: &'a Value,
807                               Name: *const c_char)
808                               -> &'a Value;
809     pub fn LLVMBuildSDiv(B: &Builder<'a>,
810                          LHS: &'a Value,
811                          RHS: &'a Value,
812                          Name: *const c_char)
813                          -> &'a Value;
814     pub fn LLVMBuildExactSDiv(B: &Builder<'a>,
815                               LHS: &'a Value,
816                               RHS: &'a Value,
817                               Name: *const c_char)
818                               -> &'a Value;
819     pub fn LLVMBuildFDiv(B: &Builder<'a>,
820                          LHS: &'a Value,
821                          RHS: &'a Value,
822                          Name: *const c_char)
823                          -> &'a Value;
824     pub fn LLVMBuildURem(B: &Builder<'a>,
825                          LHS: &'a Value,
826                          RHS: &'a Value,
827                          Name: *const c_char)
828                          -> &'a Value;
829     pub fn LLVMBuildSRem(B: &Builder<'a>,
830                          LHS: &'a Value,
831                          RHS: &'a Value,
832                          Name: *const c_char)
833                          -> &'a Value;
834     pub fn LLVMBuildFRem(B: &Builder<'a>,
835                          LHS: &'a Value,
836                          RHS: &'a Value,
837                          Name: *const c_char)
838                          -> &'a Value;
839     pub fn LLVMBuildShl(B: &Builder<'a>,
840                         LHS: &'a Value,
841                         RHS: &'a Value,
842                         Name: *const c_char)
843                         -> &'a Value;
844     pub fn LLVMBuildLShr(B: &Builder<'a>,
845                          LHS: &'a Value,
846                          RHS: &'a Value,
847                          Name: *const c_char)
848                          -> &'a Value;
849     pub fn LLVMBuildAShr(B: &Builder<'a>,
850                          LHS: &'a Value,
851                          RHS: &'a Value,
852                          Name: *const c_char)
853                          -> &'a Value;
854     pub fn LLVMBuildAnd(B: &Builder<'a>,
855                         LHS: &'a Value,
856                         RHS: &'a Value,
857                         Name: *const c_char)
858                         -> &'a Value;
859     pub fn LLVMBuildOr(B: &Builder<'a>,
860                        LHS: &'a Value,
861                        RHS: &'a Value,
862                        Name: *const c_char)
863                        -> &'a Value;
864     pub fn LLVMBuildXor(B: &Builder<'a>,
865                         LHS: &'a Value,
866                         RHS: &'a Value,
867                         Name: *const c_char)
868                         -> &'a Value;
869     pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
870     pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
871     pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
872     pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
873
874     // Memory
875     pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
876     pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
877
878     pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
879
880     pub fn LLVMBuildGEP(B: &Builder<'a>,
881                         Pointer: &'a Value,
882                         Indices: *const &'a Value,
883                         NumIndices: c_uint,
884                         Name: *const c_char)
885                         -> &'a Value;
886     pub fn LLVMBuildInBoundsGEP(B: &Builder<'a>,
887                                 Pointer: &'a Value,
888                                 Indices: *const &'a Value,
889                                 NumIndices: c_uint,
890                                 Name: *const c_char)
891                                 -> &'a Value;
892     pub fn LLVMBuildStructGEP(B: &Builder<'a>,
893                               Pointer: &'a Value,
894                               Idx: c_uint,
895                               Name: *const c_char)
896                               -> &'a Value;
897
898     // Casts
899     pub fn LLVMBuildTrunc(B: &Builder<'a>,
900                           Val: &'a Value,
901                           DestTy: &'a Type,
902                           Name: *const c_char)
903                           -> &'a Value;
904     pub fn LLVMBuildZExt(B: &Builder<'a>,
905                          Val: &'a Value,
906                          DestTy: &'a Type,
907                          Name: *const c_char)
908                          -> &'a Value;
909     pub fn LLVMBuildSExt(B: &Builder<'a>,
910                          Val: &'a Value,
911                          DestTy: &'a Type,
912                          Name: *const c_char)
913                          -> &'a Value;
914     pub fn LLVMBuildFPToUI(B: &Builder<'a>,
915                            Val: &'a Value,
916                            DestTy: &'a Type,
917                            Name: *const c_char)
918                            -> &'a Value;
919     pub fn LLVMBuildFPToSI(B: &Builder<'a>,
920                            Val: &'a Value,
921                            DestTy: &'a Type,
922                            Name: *const c_char)
923                            -> &'a Value;
924     pub fn LLVMBuildUIToFP(B: &Builder<'a>,
925                            Val: &'a Value,
926                            DestTy: &'a Type,
927                            Name: *const c_char)
928                            -> &'a Value;
929     pub fn LLVMBuildSIToFP(B: &Builder<'a>,
930                            Val: &'a Value,
931                            DestTy: &'a Type,
932                            Name: *const c_char)
933                            -> &'a Value;
934     pub fn LLVMBuildFPTrunc(B: &Builder<'a>,
935                             Val: &'a Value,
936                             DestTy: &'a Type,
937                             Name: *const c_char)
938                             -> &'a Value;
939     pub fn LLVMBuildFPExt(B: &Builder<'a>,
940                           Val: &'a Value,
941                           DestTy: &'a Type,
942                           Name: *const c_char)
943                           -> &'a Value;
944     pub fn LLVMBuildPtrToInt(B: &Builder<'a>,
945                              Val: &'a Value,
946                              DestTy: &'a Type,
947                              Name: *const c_char)
948                              -> &'a Value;
949     pub fn LLVMBuildIntToPtr(B: &Builder<'a>,
950                              Val: &'a Value,
951                              DestTy: &'a Type,
952                              Name: *const c_char)
953                              -> &'a Value;
954     pub fn LLVMBuildBitCast(B: &Builder<'a>,
955                             Val: &'a Value,
956                             DestTy: &'a Type,
957                             Name: *const c_char)
958                             -> &'a Value;
959     pub fn LLVMBuildPointerCast(B: &Builder<'a>,
960                                 Val: &'a Value,
961                                 DestTy: &'a Type,
962                                 Name: *const c_char)
963                                 -> &'a Value;
964     pub fn LLVMRustBuildIntCast(B: &Builder<'a>,
965                                 Val: &'a Value,
966                                 DestTy: &'a Type,
967                                 IsSized: bool)
968                                 -> &'a Value;
969
970     // Comparisons
971     pub fn LLVMBuildICmp(B: &Builder<'a>,
972                          Op: c_uint,
973                          LHS: &'a Value,
974                          RHS: &'a Value,
975                          Name: *const c_char)
976                          -> &'a Value;
977     pub fn LLVMBuildFCmp(B: &Builder<'a>,
978                          Op: c_uint,
979                          LHS: &'a Value,
980                          RHS: &'a Value,
981                          Name: *const c_char)
982                          -> &'a Value;
983
984     // Miscellaneous instructions
985     pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
986     pub fn LLVMRustBuildCall(B: &Builder<'a>,
987                              Fn: &'a Value,
988                              Args: *const &'a Value,
989                              NumArgs: c_uint,
990                              Bundle: Option<&OperandBundleDef<'a>>,
991                              Name: *const c_char)
992                              -> &'a Value;
993     pub fn LLVMBuildSelect(B: &Builder<'a>,
994                            If: &'a Value,
995                            Then: &'a Value,
996                            Else: &'a Value,
997                            Name: *const c_char)
998                            -> &'a Value;
999     pub fn LLVMBuildVAArg(B: &Builder<'a>,
1000                           list: &'a Value,
1001                           Ty: &'a Type,
1002                           Name: *const c_char)
1003                           -> &'a Value;
1004     pub fn LLVMBuildExtractElement(B: &Builder<'a>,
1005                                    VecVal: &'a Value,
1006                                    Index: &'a Value,
1007                                    Name: *const c_char)
1008                                    -> &'a Value;
1009     pub fn LLVMBuildInsertElement(B: &Builder<'a>,
1010                                   VecVal: &'a Value,
1011                                   EltVal: &'a Value,
1012                                   Index: &'a Value,
1013                                   Name: *const c_char)
1014                                   -> &'a Value;
1015     pub fn LLVMBuildShuffleVector(B: &Builder<'a>,
1016                                   V1: &'a Value,
1017                                   V2: &'a Value,
1018                                   Mask: &'a Value,
1019                                   Name: *const c_char)
1020                                   -> &'a Value;
1021     pub fn LLVMBuildExtractValue(B: &Builder<'a>,
1022                                  AggVal: &'a Value,
1023                                  Index: c_uint,
1024                                  Name: *const c_char)
1025                                  -> &'a Value;
1026     pub fn LLVMBuildInsertValue(B: &Builder<'a>,
1027                                 AggVal: &'a Value,
1028                                 EltVal: &'a Value,
1029                                 Index: c_uint,
1030                                 Name: *const c_char)
1031                                 -> &'a Value;
1032
1033     pub fn LLVMRustBuildVectorReduceFAdd(B: &Builder<'a>,
1034                                          Acc: &'a Value,
1035                                          Src: &'a Value)
1036                                          -> Option<&'a Value>;
1037     pub fn LLVMRustBuildVectorReduceFMul(B: &Builder<'a>,
1038                                          Acc: &'a Value,
1039                                          Src: &'a Value)
1040                                          -> Option<&'a Value>;
1041     pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>,
1042                                         Src: &'a Value)
1043                                         -> Option<&'a Value>;
1044     pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>,
1045                                         Src: &'a Value)
1046                                         -> Option<&'a Value>;
1047     pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>,
1048                                         Src: &'a Value)
1049                                         -> Option<&'a Value>;
1050     pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>,
1051                                        Src: &'a Value)
1052                                        -> Option<&'a Value>;
1053     pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>,
1054                                         Src: &'a Value)
1055                                         -> Option<&'a Value>;
1056     pub fn LLVMRustBuildVectorReduceMin(B: &Builder<'a>,
1057                                         Src: &'a Value,
1058                                         IsSigned: bool)
1059                                         -> Option<&'a Value>;
1060     pub fn LLVMRustBuildVectorReduceMax(B: &Builder<'a>,
1061                                         Src: &'a Value,
1062                                         IsSigned: bool)
1063                                         -> Option<&'a Value>;
1064     pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>,
1065                                          Src: &'a Value,
1066                                          IsNaN: bool)
1067                                          -> Option<&'a Value>;
1068     pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>,
1069                                          Src: &'a Value,
1070                                          IsNaN: bool)
1071                                          -> Option<&'a Value>;
1072
1073     pub fn LLVMRustBuildMinNum(
1074         B: &Builder<'a>,
1075         LHS: &'a Value,
1076         LHS: &'a Value,
1077     ) -> Option<&'a Value>;
1078     pub fn LLVMRustBuildMaxNum(
1079         B: &Builder<'a>,
1080         LHS: &'a Value,
1081         LHS: &'a Value,
1082     ) -> Option<&'a Value>;
1083
1084     // Atomic Operations
1085     pub fn LLVMRustBuildAtomicLoad(B: &Builder<'a>,
1086                                    PointerVal: &'a Value,
1087                                    Name: *const c_char,
1088                                    Order: AtomicOrdering)
1089                                    -> &'a Value;
1090
1091     pub fn LLVMRustBuildAtomicStore(B: &Builder<'a>,
1092                                     Val: &'a Value,
1093                                     Ptr: &'a Value,
1094                                     Order: AtomicOrdering)
1095                                     -> &'a Value;
1096
1097     pub fn LLVMRustBuildAtomicCmpXchg(B: &Builder<'a>,
1098                                       LHS: &'a Value,
1099                                       CMP: &'a Value,
1100                                       RHS: &'a Value,
1101                                       Order: AtomicOrdering,
1102                                       FailureOrder: AtomicOrdering,
1103                                       Weak: Bool)
1104                                       -> &'a Value;
1105
1106     pub fn LLVMBuildAtomicRMW(B: &Builder<'a>,
1107                               Op: AtomicRmwBinOp,
1108                               LHS: &'a Value,
1109                               RHS: &'a Value,
1110                               Order: AtomicOrdering,
1111                               SingleThreaded: Bool)
1112                               -> &'a Value;
1113
1114     pub fn LLVMRustBuildAtomicFence(B: &Builder,
1115                                     Order: AtomicOrdering,
1116                                     Scope: SynchronizationScope);
1117
1118     /// Writes a module to the specified path. Returns 0 on success.
1119     pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
1120
1121     /// Creates a pass manager.
1122     pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
1123
1124     /// Creates a function-by-function pass manager
1125     pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
1126
1127     /// Disposes a pass manager.
1128     pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
1129
1130     /// Runs a pass manager on a module.
1131     pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
1132
1133     pub fn LLVMInitializePasses();
1134
1135     pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1136     pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1137     pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1138     pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1139     pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: &PassManagerBuilder,
1140                                                          threshold: c_uint);
1141     pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: &PassManagerBuilder,
1142                                                            PM: &PassManager);
1143
1144     pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: &PassManagerBuilder,
1145                                                              PM: &PassManager);
1146     pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: &PassManagerBuilder,
1147                                                         PM: &PassManager,
1148                                                         Internalize: Bool,
1149                                                         RunInliner: Bool);
1150     pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1151         PMB: &PassManagerBuilder,
1152         PM: &PassManager) -> bool;
1153
1154     // Stuff that's in rustllvm/ because it's not upstream yet.
1155
1156     /// Opens an object file.
1157     pub fn LLVMCreateObjectFile(
1158         MemBuf: &'static mut MemoryBuffer,
1159     ) -> Option<&'static mut ObjectFile>;
1160     /// Closes an object file.
1161     pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
1162
1163     /// Enumerates the sections in an object file.
1164     pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
1165     /// Destroys a section iterator.
1166     pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
1167     /// Returns true if the section iterator is at the end of the section
1168     /// list:
1169     pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
1170     /// Moves the section iterator to point to the next section.
1171     pub fn LLVMMoveToNextSection(SI: &SectionIterator);
1172     /// Returns the current section size.
1173     pub fn LLVMGetSectionSize(SI: &SectionIterator) -> c_ulonglong;
1174     /// Returns the current section contents as a string buffer.
1175     pub fn LLVMGetSectionContents(SI: &SectionIterator) -> *const c_char;
1176
1177     /// Reads the given file and returns it as a memory buffer. Use
1178     /// LLVMDisposeMemoryBuffer() to get rid of it.
1179     pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
1180         Path: *const c_char,
1181     ) -> Option<&'static mut MemoryBuffer>;
1182
1183     pub fn LLVMStartMultithreaded() -> Bool;
1184
1185     /// Returns a string describing the last error caused by an LLVMRust* call.
1186     pub fn LLVMRustGetLastError() -> *const c_char;
1187
1188     /// Print the pass timings since static dtors aren't picking them up.
1189     pub fn LLVMRustPrintPassTimings();
1190
1191     pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
1192
1193     pub fn LLVMStructSetBody(StructTy: &'a Type,
1194                              ElementTypes: *const &'a Type,
1195                              ElementCount: c_uint,
1196                              Packed: Bool);
1197
1198     /// Prepares inline assembly.
1199     pub fn LLVMRustInlineAsm(Ty: &Type,
1200                              AsmString: *const c_char,
1201                              Constraints: *const c_char,
1202                              SideEffects: Bool,
1203                              AlignStack: Bool,
1204                              Dialect: AsmDialect)
1205                              -> &Value;
1206
1207     pub fn LLVMRustDebugMetadataVersion() -> u32;
1208     pub fn LLVMRustVersionMajor() -> u32;
1209     pub fn LLVMRustVersionMinor() -> u32;
1210
1211     pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
1212
1213     pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
1214
1215     pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
1216
1217     pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
1218
1219     pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder);
1220
1221     pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: &DIBuilder<'a>,
1222                                               Lang: c_uint,
1223                                               File: &'a DIFile,
1224                                               Producer: *const c_char,
1225                                               isOptimized: bool,
1226                                               Flags: *const c_char,
1227                                               RuntimeVer: c_uint,
1228                                               SplitName: *const c_char)
1229                                               -> &'a DIDescriptor;
1230
1231     pub fn LLVMRustDIBuilderCreateFile(Builder: &DIBuilder<'a>,
1232                                        Filename: *const c_char,
1233                                        Directory: *const c_char)
1234                                        -> &'a DIFile;
1235
1236     pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: &DIBuilder<'a>,
1237                                                  File: &'a DIFile,
1238                                                  ParameterTypes: &'a DIArray)
1239                                                  -> &'a DICompositeType;
1240
1241     pub fn LLVMRustDIBuilderCreateFunction(Builder: &DIBuilder<'a>,
1242                                            Scope: &'a DIDescriptor,
1243                                            Name: *const c_char,
1244                                            LinkageName: *const c_char,
1245                                            File: &'a DIFile,
1246                                            LineNo: c_uint,
1247                                            Ty: &'a DIType,
1248                                            isLocalToUnit: bool,
1249                                            isDefinition: bool,
1250                                            ScopeLine: c_uint,
1251                                            Flags: DIFlags,
1252                                            isOptimized: bool,
1253                                            Fn: &'a Value,
1254                                            TParam: &'a DIArray,
1255                                            Decl: Option<&'a DIDescriptor>)
1256                                            -> &'a DISubprogram;
1257
1258     pub fn LLVMRustDIBuilderCreateBasicType(Builder: &DIBuilder<'a>,
1259                                             Name: *const c_char,
1260                                             SizeInBits: u64,
1261                                             AlignInBits: u32,
1262                                             Encoding: c_uint)
1263                                             -> &'a DIBasicType;
1264
1265     pub fn LLVMRustDIBuilderCreatePointerType(Builder: &DIBuilder<'a>,
1266                                               PointeeTy: &'a DIType,
1267                                               SizeInBits: u64,
1268                                               AlignInBits: u32,
1269                                               Name: *const c_char)
1270                                               -> &'a DIDerivedType;
1271
1272     pub fn LLVMRustDIBuilderCreateStructType(Builder: &DIBuilder<'a>,
1273                                              Scope: Option<&'a DIDescriptor>,
1274                                              Name: *const c_char,
1275                                              File: &'a DIFile,
1276                                              LineNumber: c_uint,
1277                                              SizeInBits: u64,
1278                                              AlignInBits: u32,
1279                                              Flags: DIFlags,
1280                                              DerivedFrom: Option<&'a DIType>,
1281                                              Elements: &'a DIArray,
1282                                              RunTimeLang: c_uint,
1283                                              VTableHolder: Option<&'a DIType>,
1284                                              UniqueId: *const c_char)
1285                                              -> &'a DICompositeType;
1286
1287     pub fn LLVMRustDIBuilderCreateMemberType(Builder: &DIBuilder<'a>,
1288                                              Scope: &'a DIDescriptor,
1289                                              Name: *const c_char,
1290                                              File: &'a DIFile,
1291                                              LineNo: c_uint,
1292                                              SizeInBits: u64,
1293                                              AlignInBits: u32,
1294                                              OffsetInBits: u64,
1295                                              Flags: DIFlags,
1296                                              Ty: &'a DIType)
1297                                              -> &'a DIDerivedType;
1298
1299     pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: &DIBuilder<'a>,
1300                                                Scope: &'a DIScope,
1301                                                File: &'a DIFile,
1302                                                Line: c_uint,
1303                                                Col: c_uint)
1304                                                -> &'a DILexicalBlock;
1305
1306     pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: &DIBuilder<'a>,
1307                                                    Scope: &'a DIScope,
1308                                                    File: &'a DIFile)
1309                                                    -> &'a DILexicalBlock;
1310
1311     pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: &DIBuilder<'a>,
1312                                                  Context: Option<&'a DIScope>,
1313                                                  Name: *const c_char,
1314                                                  LinkageName: *const c_char,
1315                                                  File: &'a DIFile,
1316                                                  LineNo: c_uint,
1317                                                  Ty: &'a DIType,
1318                                                  isLocalToUnit: bool,
1319                                                  Val: &'a Value,
1320                                                  Decl: Option<&'a DIDescriptor>,
1321                                                  AlignInBits: u32)
1322                                                  -> &'a DIGlobalVariable;
1323
1324     pub fn LLVMRustDIBuilderCreateVariable(Builder: &DIBuilder<'a>,
1325                                            Tag: c_uint,
1326                                            Scope: &'a DIDescriptor,
1327                                            Name: *const c_char,
1328                                            File: &'a DIFile,
1329                                            LineNo: c_uint,
1330                                            Ty: &'a DIType,
1331                                            AlwaysPreserve: bool,
1332                                            Flags: DIFlags,
1333                                            ArgNo: c_uint,
1334                                            AlignInBits: u32)
1335                                            -> &'a DIVariable;
1336
1337     pub fn LLVMRustDIBuilderCreateArrayType(Builder: &DIBuilder<'a>,
1338                                             Size: u64,
1339                                             AlignInBits: u32,
1340                                             Ty: &'a DIType,
1341                                             Subscripts: &'a DIArray)
1342                                             -> &'a DIType;
1343
1344     pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: &DIBuilder<'a>,
1345                                                 Lo: i64,
1346                                                 Count: i64)
1347                                                 -> &'a DISubrange;
1348
1349     pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: &DIBuilder<'a>,
1350                                              Ptr: *const Option<&'a DIDescriptor>,
1351                                              Count: c_uint)
1352                                              -> &'a DIArray;
1353
1354     pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: &DIBuilder<'a>,
1355                                                Val: &'a Value,
1356                                                VarInfo: &'a DIVariable,
1357                                                AddrOps: *const i64,
1358                                                AddrOpsCount: c_uint,
1359                                                DL: &'a Value,
1360                                                InsertAtEnd: &'a BasicBlock)
1361                                                -> &'a Value;
1362
1363     pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder<'a>,
1364                                              Name: *const c_char,
1365                                              Val: u64)
1366                                              -> &'a DIEnumerator;
1367
1368     pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: &DIBuilder<'a>,
1369                                                   Scope: &'a DIScope,
1370                                                   Name: *const c_char,
1371                                                   File: &'a DIFile,
1372                                                   LineNumber: c_uint,
1373                                                   SizeInBits: u64,
1374                                                   AlignInBits: u32,
1375                                                   Elements: &'a DIArray,
1376                                                   ClassType: &'a DIType)
1377                                                   -> &'a DIType;
1378
1379     pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,
1380                                             Scope: &'a DIScope,
1381                                             Name: *const c_char,
1382                                             File: &'a DIFile,
1383                                             LineNumber: c_uint,
1384                                             SizeInBits: u64,
1385                                             AlignInBits: u32,
1386                                             Flags: DIFlags,
1387                                             Elements: Option<&'a DIArray>,
1388                                             RunTimeLang: c_uint,
1389                                             UniqueId: *const c_char)
1390                                             -> &'a DIType;
1391
1392     pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
1393
1394     pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: &DIBuilder<'a>,
1395                                                         Scope: Option<&'a DIScope>,
1396                                                         Name: *const c_char,
1397                                                         Ty: &'a DIType,
1398                                                         File: &'a DIFile,
1399                                                         LineNo: c_uint,
1400                                                         ColumnNo: c_uint)
1401                                                         -> &'a DITemplateTypeParameter;
1402
1403
1404     pub fn LLVMRustDIBuilderCreateNameSpace(Builder: &DIBuilder<'a>,
1405                                             Scope: Option<&'a DIScope>,
1406                                             Name: *const c_char,
1407                                             File: &'a DIFile,
1408                                             LineNo: c_uint)
1409                                             -> &'a DINameSpace;
1410
1411     pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: &DIBuilder<'a>,
1412                                                CompositeType: &'a DIType,
1413                                                TypeArray: &'a DIArray);
1414
1415
1416     pub fn LLVMRustDIBuilderCreateDebugLocation(Context: &'a Context,
1417                                                 Line: c_uint,
1418                                                 Column: c_uint,
1419                                                 Scope: &'a DIScope,
1420                                                 InlinedAt: Option<&'a Metadata>)
1421                                                 -> &'a Value;
1422     pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1423     pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
1424 }
1425
1426 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1427 extern "C" {
1428     pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
1429     pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
1430 }
1431
1432 extern "C" {
1433     pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&Value>;
1434     pub fn LLVMIsAConstantFP(value_ref: &Value) -> Option<&Value>;
1435
1436     pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
1437     pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
1438     pub fn LLVMRustAddPass(PM: &PassManager, Pass: &'static mut Pass);
1439
1440     pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
1441
1442     pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1443     pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
1444
1445     pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1446                                        CPU: *const c_char,
1447                                        Features: *const c_char,
1448                                        Model: CodeModel,
1449                                        Reloc: RelocMode,
1450                                        Level: CodeGenOptLevel,
1451                                        UseSoftFP: bool,
1452                                        PositionIndependentExecutable: bool,
1453                                        FunctionSections: bool,
1454                                        DataSections: bool,
1455                                        TrapUnreachable: bool,
1456                                        Singlethread: bool)
1457                                        -> Option<&'static mut TargetMachine>;
1458     pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1459     pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module);
1460     pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
1461                                          M: &'a Module,
1462                                          DisableSimplifyLibCalls: bool);
1463     pub fn LLVMRustConfigurePassManagerBuilder(PMB: &PassManagerBuilder,
1464                                                OptLevel: CodeGenOptLevel,
1465                                                MergeFunctions: bool,
1466                                                SLPVectorize: bool,
1467                                                LoopVectorize: bool,
1468                                                PrepareForThinLTO: bool,
1469                                                PGOGenPath: *const c_char,
1470                                                PGOUsePath: *const c_char);
1471     pub fn LLVMRustAddLibraryInfo(PM: &PassManager<'a>,
1472                                   M: &'a Module,
1473                                   DisableSimplifyLibCalls: bool);
1474     pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
1475     pub fn LLVMRustWriteOutputFile(T: &'a TargetMachine,
1476                                    PM: &PassManager<'a>,
1477                                    M: &'a Module,
1478                                    Output: *const c_char,
1479                                    FileType: FileType)
1480                                    -> LLVMRustResult;
1481     pub fn LLVMRustPrintModule(PM: &PassManager<'a>,
1482                                M: &'a Module,
1483                                Output: *const c_char,
1484                                Demangle: extern fn(*const c_char,
1485                                                    size_t,
1486                                                    *mut c_char,
1487                                                    size_t) -> size_t);
1488     pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1489     pub fn LLVMRustPrintPasses();
1490     pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
1491     pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
1492     pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
1493     pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
1494
1495     pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
1496     pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
1497     pub fn LLVMRustArchiveIteratorNext(
1498         AIR: &ArchiveIterator<'a>,
1499     ) -> Option<&'a mut ArchiveChild<'a>>;
1500     pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1501     pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
1502     pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
1503     pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
1504     pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
1505
1506     pub fn LLVMRustGetSectionName(SI: &SectionIterator, data: &mut *const c_char) -> size_t;
1507 }
1508
1509 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1510 extern "C" {
1511     pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
1512 }
1513
1514 extern "C" {
1515     pub fn LLVMContextSetDiagnosticHandler(C: &Context,
1516                                            Handler: DiagnosticHandler,
1517                                            DiagnosticContext: *mut c_void);
1518 }
1519
1520 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1521 extern "C" {
1522     pub fn LLVMRustUnpackOptimizationDiagnostic(DI: &'a DiagnosticInfo,
1523                                                 pass_name_out: &RustString,
1524                                                 function_out: &mut Option<&'a Value>,
1525                                                 loc_line_out: &mut c_uint,
1526                                                 loc_column_out: &mut c_uint,
1527                                                 loc_filename_out: &RustString,
1528                                                 message_out: &RustString);
1529 }
1530
1531 extern "C" {
1532     pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: &'a DiagnosticInfo,
1533                                              cookie_out: &mut c_uint,
1534                                              message_out: &mut Option<&'a Twine>,
1535                                              instruction_out: &mut Option<&'a Value>);
1536 }
1537
1538 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1539 extern "C" {
1540     pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
1541 }
1542
1543 extern "C" {
1544     pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
1545
1546     pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: &Context,
1547                                                  H: InlineAsmDiagHandler,
1548                                                  CX: *mut c_void);
1549 }
1550
1551 #[allow(improper_ctypes)] // FIXME(#52456) needed for RustString.
1552 extern "C" {
1553     pub fn LLVMRustWriteSMDiagnosticToString(d: &SMDiagnostic, s: &RustString);
1554 }
1555
1556 extern "C" {
1557     pub fn LLVMRustWriteArchive(Dst: *const c_char,
1558                                 NumMembers: size_t,
1559                                 Members: *const &RustArchiveMember,
1560                                 WriteSymbtab: bool,
1561                                 Kind: ArchiveKind)
1562                                 -> LLVMRustResult;
1563     pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1564                                     Name: *const c_char,
1565                                     Child: Option<&'a ArchiveChild>)
1566                                     -> &'a mut RustArchiveMember<'a>;
1567     pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
1568
1569     pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
1570
1571     pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1572                                          Inputs: *const &'a Value,
1573                                          NumInputs: c_uint)
1574                                          -> &'a mut OperandBundleDef<'a>;
1575     pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
1576
1577     pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
1578
1579     pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
1580     pub fn LLVMRustUnsetComdat(V: &Value);
1581     pub fn LLVMRustSetModulePIELevel(M: &Module);
1582     pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
1583     pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
1584     pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
1585     pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
1586     pub fn LLVMRustModuleCost(M: &Module) -> u64;
1587
1588     pub fn LLVMRustThinLTOAvailable() -> bool;
1589     pub fn LLVMRustPGOAvailable() -> bool;
1590     pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
1591     pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
1592     pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
1593     pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
1594     pub fn LLVMRustCreateThinLTOData(
1595         Modules: *const ThinLTOModule,
1596         NumModules: c_uint,
1597         PreservedSymbols: *const *const c_char,
1598         PreservedSymbolsLen: c_uint,
1599     ) -> Option<&'static mut ThinLTOData>;
1600     pub fn LLVMRustPrepareThinLTORename(
1601         Data: &ThinLTOData,
1602         Module: &Module,
1603     ) -> bool;
1604     pub fn LLVMRustPrepareThinLTOResolveWeak(
1605         Data: &ThinLTOData,
1606         Module: &Module,
1607     ) -> bool;
1608     pub fn LLVMRustPrepareThinLTOInternalize(
1609         Data: &ThinLTOData,
1610         Module: &Module,
1611     ) -> bool;
1612     pub fn LLVMRustPrepareThinLTOImport(
1613         Data: &ThinLTOData,
1614         Module: &Module,
1615     ) -> bool;
1616     pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
1617     pub fn LLVMRustParseBitcodeForThinLTO(
1618         Context: &Context,
1619         Data: *const u8,
1620         len: usize,
1621         Identifier: *const c_char,
1622     ) -> Option<&Module>;
1623     pub fn LLVMRustThinLTOGetDICompileUnit(M: &Module,
1624                                            CU1: &mut *mut c_void,
1625                                            CU2: &mut *mut c_void);
1626     pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
1627
1628     pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
1629     pub fn LLVMRustLinkerAdd(linker: &Linker,
1630                              bytecode: *const c_char,
1631                              bytecode_len: usize) -> bool;
1632     pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
1633 }