From 7420874a97a268d1c75dbc0e95231e4c8a1d513a Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Wed, 13 Jul 2016 00:38:30 +0200 Subject: [LLVM-3.9] Rename custom methods to Rust-specific ones --- src/rustllvm/RustWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rustllvm/RustWrapper.cpp') diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index fadd95c9a72..bc38245d351 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -99,7 +99,7 @@ extern "C" LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) { return wrap(Type::getMetadataTy(*unwrap(C))); } -extern "C" void LLVMAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, uint64_t Val) { +extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, uint64_t Val) { CallSite Call = CallSite(unwrap(Instr)); AttrBuilder B; B.addRawValue(Val); @@ -203,7 +203,7 @@ extern "C" LLVMValueRef LLVMBuildAtomicStore(LLVMBuilderRef B, return wrap(unwrap(B)->Insert(si)); } -extern "C" LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, +extern "C" LLVMValueRef LLVMRustBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef target, LLVMValueRef old, LLVMValueRef source, -- cgit 1.4.1-3-g733a5 From d091ef802f5aa6d5b81e711ecd7e5f66a76b01a9 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 2 Aug 2016 02:35:09 +0300 Subject: begin auditing the C++ types in RustWrapper --- src/librustc_driver/lib.rs | 2 +- src/librustc_llvm/diagnostic.rs | 55 +- src/librustc_llvm/lib.rs | 628 ++++++++++++----------- src/librustc_trans/attributes.rs | 8 +- src/librustc_trans/back/write.rs | 4 +- src/librustc_trans/base.rs | 3 +- src/librustc_trans/builder.rs | 10 +- src/librustc_trans/consts.rs | 4 +- src/librustc_trans/debuginfo/create_scope_map.rs | 6 +- src/librustc_trans/debuginfo/metadata.rs | 67 +-- src/librustc_trans/debuginfo/mod.rs | 16 +- src/librustc_trans/debuginfo/namespace.rs | 2 +- src/librustc_trans/debuginfo/source_loc.rs | 2 +- src/librustc_trans/debuginfo/utils.rs | 2 +- src/librustc_trans/declare.rs | 6 +- src/librustc_trans/intrinsic.rs | 26 +- src/librustc_trans/mir/mod.rs | 10 +- src/librustc_trans/type_.rs | 4 +- src/librustc_trans/value.rs | 2 +- src/rustllvm/RustWrapper.cpp | 516 ++++++++++++------- 20 files changed, 771 insertions(+), 602 deletions(-) (limited to 'src/rustllvm/RustWrapper.cpp') diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index f49d47fb081..772c59b34dd 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -186,7 +186,7 @@ pub fn run_compiler_with_file_loader<'a, L>(args: &[String], let sopts = config::build_session_options(&matches); if sopts.debugging_opts.debug_llvm { - unsafe { llvm::LLVMSetDebug(1); } + unsafe { llvm::LLVMRustSetDebug(1); } } let descriptions = diagnostics_registry(); diff --git a/src/librustc_llvm/diagnostic.rs b/src/librustc_llvm/diagnostic.rs index 44e01561464..4938a0216ee 100644 --- a/src/librustc_llvm/diagnostic.rs +++ b/src/librustc_llvm/diagnostic.rs @@ -23,15 +23,21 @@ pub enum OptimizationDiagnosticKind { OptimizationRemark, OptimizationMissed, OptimizationAnalysis, + OptimizationAnalysisFPCommute, + OptimizationAnalysisAliasing, OptimizationFailure, + OptimizationRemarkOther, } impl OptimizationDiagnosticKind { pub fn describe(self) -> &'static str { match self { - OptimizationRemark => "remark", + OptimizationRemark | + OptimizationRemarkOther => "remark", OptimizationMissed => "missed", OptimizationAnalysis => "analysis", + OptimizationAnalysisFPCommute => "floating-point", + OptimizationAnalysisAliasing => "aliasing", OptimizationFailure => "failure", } } @@ -58,11 +64,11 @@ impl OptimizationDiagnostic { message: ptr::null_mut(), }; - super::LLVMUnpackOptimizationDiagnostic(di, - &mut opt.pass_name, - &mut opt.function, - &mut opt.debug_loc, - &mut opt.message); + super::LLVMRustUnpackOptimizationDiagnostic(di, + &mut opt.pass_name, + &mut opt.function, + &mut opt.debug_loc, + &mut opt.message); opt } @@ -84,10 +90,10 @@ impl InlineAsmDiagnostic { instruction: ptr::null_mut(), }; - super::LLVMUnpackInlineAsmDiagnostic(di, - &mut opt.cookie, - &mut opt.message, - &mut opt.instruction); + super::LLVMRustUnpackInlineAsmDiagnostic(di, + &mut opt.cookie, + &mut opt.message, + &mut opt.instruction); opt } @@ -103,24 +109,39 @@ pub enum Diagnostic { impl Diagnostic { pub unsafe fn unpack(di: DiagnosticInfoRef) -> Diagnostic { - let kind = super::LLVMGetDiagInfoKind(di); + use super::DiagnosticKind as Dk; + let kind = super::LLVMRustGetDiagInfoKind(di); match kind { - super::DK_InlineAsm => InlineAsm(InlineAsmDiagnostic::unpack(di)), + Dk::InlineAsm => InlineAsm(InlineAsmDiagnostic::unpack(di)), - super::DK_OptimizationRemark => { + Dk::OptimizationRemark => { Optimization(OptimizationDiagnostic::unpack(OptimizationRemark, di)) } - - super::DK_OptimizationRemarkMissed => { + Dk::OptimizationRemarkOther => { + Optimization(OptimizationDiagnostic::unpack(OptimizationRemarkOther, di)) + } + Dk::OptimizationRemarkMissed => { Optimization(OptimizationDiagnostic::unpack(OptimizationMissed, di)) } - super::DK_OptimizationRemarkAnalysis => { + Dk::OptimizationRemarkAnalysis => { Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di)) } - super::DK_OptimizationFailure => { + + Dk::OptimizationRemarkAnalysisFPCommute => { + Optimization(OptimizationDiagnostic::unpack( + OptimizationAnalysisFPCommute, di)) + } + + Dk::OptimizationRemarkAnalysisAliasing => { + Optimization(OptimizationDiagnostic::unpack( + OptimizationAnalysisAliasing, di)) + } + + + Dk::OptimizationFailure => { Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di)) } diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 4019732221f..622e7923d8f 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -38,8 +38,6 @@ pub use self::IntPredicate::*; pub use self::RealPredicate::*; pub use self::TypeKind::*; pub use self::AtomicBinOp::*; -pub use self::AtomicOrdering::*; -pub use self::SynchronizationScope::*; pub use self::MetadataType::*; pub use self::AsmDialect::*; pub use self::CodeGenOptSize::*; @@ -48,7 +46,6 @@ pub use self::CallConv::*; pub use self::Visibility::*; pub use self::DiagnosticSeverity::*; pub use self::Linkage::*; -pub use self::DLLStorageClassTypes::*; use std::str::FromStr; use std::ffi::{CString, CStr}; @@ -132,19 +129,20 @@ pub enum Linkage { #[repr(C)] #[derive(Copy, Clone, Debug)] pub enum DiagnosticSeverity { - Error, - Warning, - Remark, - Note, + Error = 0, + Warning = 1, + Remark = 2, + Note = 3, } #[repr(C)] #[derive(Copy, Clone)] pub enum DLLStorageClassTypes { - DefaultStorageClass = 0, - DLLImportStorageClass = 1, - DLLExportStorageClass = 2, + Other, + Default, + DllImport, + DllExport, } bitflags! { @@ -231,10 +229,10 @@ impl Attributes { pub fn apply_llfn(&self, idx: usize, llfn: ValueRef) { unsafe { - LLVMAddFunctionAttribute(llfn, idx as c_uint, self.regular.bits()); + LLVMRustAddFunctionAttribute(llfn, idx as c_uint, self.regular.bits()); if self.dereferenceable_bytes != 0 { - LLVMAddDereferenceableAttr(llfn, idx as c_uint, - self.dereferenceable_bytes); + LLVMRustAddDereferenceableAttr(llfn, idx as c_uint, + self.dereferenceable_bytes); } } } @@ -243,8 +241,8 @@ impl Attributes { unsafe { LLVMRustAddCallSiteAttribute(callsite, idx as c_uint, self.regular.bits()); if self.dereferenceable_bytes != 0 { - LLVMAddDereferenceableCallSiteAttr(callsite, idx as c_uint, - self.dereferenceable_bytes); + LLVMRustAddDereferenceableCallSiteAttr(callsite, idx as c_uint, + self.dereferenceable_bytes); } } } @@ -348,8 +346,9 @@ pub enum AtomicOrdering { #[repr(C)] #[derive(Copy, Clone)] pub enum SynchronizationScope { - SingleThread = 0, - CrossThread = 1 + Other, + SingleThread, + CrossThread, } #[repr(C)] @@ -425,14 +424,18 @@ pub enum CodeModel { #[repr(C)] #[derive(Copy, Clone)] pub enum DiagnosticKind { - DK_InlineAsm = 0, - DK_StackSize, - DK_DebugMetadataVersion, - DK_SampleProfile, - DK_OptimizationRemark, - DK_OptimizationRemarkMissed, - DK_OptimizationRemarkAnalysis, - DK_OptimizationFailure, + Other, + InlineAsm, + StackSize, + DebugMetadataVersion, + SampleProfile, + OptimizationRemark, + OptimizationRemarkMissed, + OptimizationRemarkAnalysis, + OptimizationRemarkAnalysisFPCommute, + OptimizationRemarkAnalysisAliasing, + OptimizationRemarkOther, + OptimizationFailure, } #[repr(C)] @@ -705,7 +708,7 @@ extern { /* Operations on other types */ pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef; pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef; - pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef; + pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef; /* Operations on all values */ pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef; @@ -957,8 +960,13 @@ extern { Name: *const c_char, AddressSpace: c_uint) -> ValueRef; - pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef; - pub fn LLVMGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef; + pub fn LLVMGetNamedGlobal(M: ModuleRef, + Name: *const c_char) + -> ValueRef; + pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef, + Name: *const c_char, + T: TypeRef) + -> ValueRef; pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef; pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef; pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef; @@ -971,7 +979,7 @@ extern { pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool); pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool; pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool); - pub fn LLVMGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef; + pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef; /* Operations on aliases */ pub fn LLVMAddAlias(M: ModuleRef, @@ -991,23 +999,27 @@ extern { pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef; pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef; pub fn LLVMDeleteFunction(Fn: ValueRef); - pub fn LLVMGetOrInsertFunction(M: ModuleRef, - Name: *const c_char, - FunctionTy: TypeRef) - -> ValueRef; + pub fn LLVMRustGetOrInsertFunction(M: ModuleRef, + Name: *const c_char, + FunctionTy: TypeRef) + -> ValueRef; pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint; pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint; pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint); pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char; pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char); - pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t); - pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t); - pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char); - pub fn LLVMAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint, - Name: *const c_char, - Value: *const c_char); - pub fn LLVMRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: uint64_t); - pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char); + pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t); + pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t); + pub fn LLVMRustAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char); + pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint, + Name: *const c_char, + Value: *const c_char); + pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, + index: c_uint, + attr: uint64_t); + pub fn LLVMRustRemoveFunctionAttrString(Fn: ValueRef, + index: c_uint, + Name: *const c_char); pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_uint; pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_uint); @@ -1077,9 +1089,9 @@ extern { pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, Val: uint64_t); - pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef, - index: c_uint, - bytes: uint64_t); + pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, + index: c_uint, + bytes: uint64_t); /* Operations on call instructions (only) */ pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool; @@ -1556,28 +1568,29 @@ extern { -> ValueRef; /* Atomic Operations */ - pub fn LLVMBuildAtomicLoad(B: BuilderRef, - PointerVal: ValueRef, - Name: *const c_char, - Order: AtomicOrdering, - Alignment: c_uint) - -> ValueRef; + pub fn LLVMRustBuildAtomicLoad(B: BuilderRef, + PointerVal: ValueRef, + Name: *const c_char, + Order: AtomicOrdering, + Alignment: c_uint) + -> ValueRef; - pub fn LLVMBuildAtomicStore(B: BuilderRef, - Val: ValueRef, - Ptr: ValueRef, - Order: AtomicOrdering, - Alignment: c_uint) - -> ValueRef; + pub fn LLVMRustBuildAtomicStore(B: BuilderRef, + Val: ValueRef, + Ptr: ValueRef, + Order: AtomicOrdering, + Alignment: c_uint) + -> ValueRef; pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef, - LHS: ValueRef, - CMP: ValueRef, - RHS: ValueRef, - Order: AtomicOrdering, - FailureOrder: AtomicOrdering, - Weak: Bool) - -> ValueRef; + LHS: ValueRef, + CMP: ValueRef, + RHS: ValueRef, + Order: AtomicOrdering, + FailureOrder: AtomicOrdering, + Weak: Bool) + -> ValueRef; + pub fn LLVMBuildAtomicRMW(B: BuilderRef, Op: AtomicBinOp, LHS: ValueRef, @@ -1586,9 +1599,9 @@ extern { SingleThreaded: Bool) -> ValueRef; - pub fn LLVMBuildAtomicFence(B: BuilderRef, - Order: AtomicOrdering, - Scope: SynchronizationScope); + pub fn LLVMRustBuildAtomicFence(B: BuilderRef, + Order: AtomicOrdering, + Scope: SynchronizationScope); /* Selected entries from the downcasts. */ @@ -1791,248 +1804,248 @@ extern { -> ValueRef; /// Enables LLVM debug output. - pub fn LLVMSetDebug(Enabled: c_int); + pub fn LLVMRustSetDebug(Enabled: c_int); /// Prepares inline assembly. - pub fn LLVMInlineAsm(Ty: TypeRef, - AsmString: *const c_char, - Constraints: *const c_char, - SideEffects: Bool, - AlignStack: Bool, - Dialect: c_uint) - -> ValueRef; + pub fn LLVMRustInlineAsm(Ty: TypeRef, + AsmString: *const c_char, + Constraints: *const c_char, + SideEffects: Bool, + AlignStack: Bool, + Dialect: c_uint) + -> ValueRef; pub fn LLVMRustDebugMetadataVersion() -> u32; - pub fn LLVMVersionMajor() -> u32; - pub fn LLVMVersionMinor() -> u32; + pub fn LLVMRustVersionMajor() -> u32; + pub fn LLVMRustVersionMinor() -> u32; pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, value: u32); - pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef; - - pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef); - - pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef); - - pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef, - Lang: c_uint, - File: *const c_char, - Dir: *const c_char, - Producer: *const c_char, - isOptimized: bool, - Flags: *const c_char, - RuntimeVer: c_uint, - SplitName: *const c_char) - -> DIDescriptor; - - pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef, - Filename: *const c_char, - Directory: *const c_char) - -> DIFile; - - pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef, - File: DIFile, - ParameterTypes: DIArray) - -> DICompositeType; + pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef; + + pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef); + + pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef); + + pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef, + Lang: c_uint, + File: *const c_char, + Dir: *const c_char, + Producer: *const c_char, + isOptimized: bool, + Flags: *const c_char, + RuntimeVer: c_uint, + SplitName: *const c_char) + -> DIDescriptor; + + pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef, + Filename: *const c_char, + Directory: *const c_char) + -> DIFile; + + pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef, + File: DIFile, + ParameterTypes: DIArray) + -> DICompositeType; + + pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef, + Scope: DIDescriptor, + Name: *const c_char, + LinkageName: *const c_char, + File: DIFile, + LineNo: c_uint, + Ty: DIType, + isLocalToUnit: bool, + isDefinition: bool, + ScopeLine: c_uint, + Flags: c_uint, + isOptimized: bool, + Fn: ValueRef, + TParam: DIArray, + Decl: DIDescriptor) + -> DISubprogram; + + pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef, + Name: *const c_char, + SizeInBits: u64, + AlignInBits: u64, + Encoding: c_uint) + -> DIBasicType; - pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef, - Scope: DIDescriptor, - Name: *const c_char, - LinkageName: *const c_char, - File: DIFile, - LineNo: c_uint, - Ty: DIType, - isLocalToUnit: bool, - isDefinition: bool, - ScopeLine: c_uint, - Flags: c_uint, - isOptimized: bool, - Fn: ValueRef, - TParam: DIArray, - Decl: DIDescriptor) - -> DISubprogram; - - pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef, - Name: *const c_char, - SizeInBits: c_ulonglong, - AlignInBits: c_ulonglong, - Encoding: c_uint) - -> DIBasicType; - - pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef, + pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef, PointeeTy: DIType, - SizeInBits: c_ulonglong, - AlignInBits: c_ulonglong, + SizeInBits: u64, + AlignInBits: u64, Name: *const c_char) -> DIDerivedType; - pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef, - Scope: DIDescriptor, - Name: *const c_char, - File: DIFile, - LineNumber: c_uint, - SizeInBits: c_ulonglong, - AlignInBits: c_ulonglong, - Flags: c_uint, - DerivedFrom: DIType, - Elements: DIArray, - RunTimeLang: c_uint, - VTableHolder: DIType, - UniqueId: *const c_char) - -> DICompositeType; - - pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef, - Scope: DIDescriptor, - Name: *const c_char, - File: DIFile, - LineNo: c_uint, - SizeInBits: c_ulonglong, - AlignInBits: c_ulonglong, - OffsetInBits: c_ulonglong, - Flags: c_uint, - Ty: DIType) - -> DIDerivedType; - - pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef, - Scope: DIScope, - File: DIFile, - Line: c_uint, - Col: c_uint) - -> DILexicalBlock; + pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef, + Scope: DIDescriptor, + Name: *const c_char, + File: DIFile, + LineNumber: c_uint, + SizeInBits: u64, + AlignInBits: u64, + Flags: c_uint, + DerivedFrom: DIType, + Elements: DIArray, + RunTimeLang: c_uint, + VTableHolder: DIType, + UniqueId: *const c_char) + -> DICompositeType; - pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef, - Context: DIScope, + pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef, + Scope: DIDescriptor, Name: *const c_char, - LinkageName: *const c_char, File: DIFile, LineNo: c_uint, + SizeInBits: u64, + AlignInBits: u64, + OffsetInBits: u64, + Flags: c_uint, + Ty: DIType) + -> DIDerivedType; + + pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef, + Scope: DIScope, + File: DIFile, + Line: c_uint, + Col: c_uint) + -> DILexicalBlock; + + pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef, + Context: DIScope, + Name: *const c_char, + LinkageName: *const c_char, + File: DIFile, + LineNo: c_uint, + Ty: DIType, + isLocalToUnit: bool, + Val: ValueRef, + Decl: DIDescriptor) + -> DIGlobalVariable; + + pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef, + Tag: c_uint, + Scope: DIDescriptor, + Name: *const c_char, + File: DIFile, + LineNo: c_uint, + Ty: DIType, + AlwaysPreserve: bool, + Flags: c_uint, + AddrOps: *const i64, + AddrOpsCount: c_uint, + ArgNo: c_uint) + -> DIVariable; + + pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef, + Size: u64, + AlignInBits: u64, + Ty: DIType, + Subscripts: DIArray) + -> DIType; + + pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef, + Size: u64, + AlignInBits: u64, Ty: DIType, - isLocalToUnit: bool, - Val: ValueRef, - Decl: DIDescriptor) - -> DIGlobalVariable; - - pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef, - Tag: c_uint, - Scope: DIDescriptor, + Subscripts: DIArray) + -> DIType; + + pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef, + Lo: i64, + Count: i64) + -> DISubrange; + + pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef, + Ptr: *const DIDescriptor, + Count: c_uint) + -> DIArray; + + pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef, + Val: ValueRef, + VarInfo: DIVariable, + AddrOps: *const i64, + AddrOpsCount: c_uint, + DL: ValueRef, + InsertAtEnd: BasicBlockRef) + -> ValueRef; + + pub fn LLVMRustDIBuilderInsertDeclareBefore(Builder: DIBuilderRef, + Val: ValueRef, + VarInfo: DIVariable, + AddrOps: *const i64, + AddrOpsCount: c_uint, + DL: ValueRef, + InsertBefore: ValueRef) + -> ValueRef; + + pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef, + Name: *const c_char, + Val: u64) + -> DIEnumerator; + + pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef, + Scope: DIScope, + Name: *const c_char, + File: DIFile, + LineNumber: c_uint, + SizeInBits: u64, + AlignInBits: u64, + Elements: DIArray, + ClassType: DIType) + -> DIType; + + pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef, + Scope: DIScope, Name: *const c_char, File: DIFile, - LineNo: c_uint, - Ty: DIType, - AlwaysPreserve: bool, + LineNumber: c_uint, + SizeInBits: u64, + AlignInBits: u64, Flags: c_uint, - AddrOps: *const i64, - AddrOpsCount: c_uint, - ArgNo: c_uint) - -> DIVariable; - - pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef, - Size: c_ulonglong, - AlignInBits: c_ulonglong, - Ty: DIType, - Subscripts: DIArray) - -> DIType; - - pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef, - Size: c_ulonglong, - AlignInBits: c_ulonglong, - Ty: DIType, - Subscripts: DIArray) - -> DIType; - - pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef, - Lo: c_longlong, - Count: c_longlong) - -> DISubrange; - - pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef, - Ptr: *const DIDescriptor, - Count: c_uint) - -> DIArray; - - pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef, - Val: ValueRef, - VarInfo: DIVariable, - AddrOps: *const i64, - AddrOpsCount: c_uint, - DL: ValueRef, - InsertAtEnd: BasicBlockRef) - -> ValueRef; - - pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef, - Val: ValueRef, - VarInfo: DIVariable, - AddrOps: *const i64, - AddrOpsCount: c_uint, - DL: ValueRef, - InsertBefore: ValueRef) - -> ValueRef; - - pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef, - Name: *const c_char, - Val: c_ulonglong) - -> DIEnumerator; - - pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef, - Scope: DIScope, - Name: *const c_char, - File: DIFile, - LineNumber: c_uint, - SizeInBits: c_ulonglong, - AlignInBits: c_ulonglong, - Elements: DIArray, - ClassType: DIType) - -> DIType; - - pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef, - Scope: DIScope, - Name: *const c_char, - File: DIFile, - LineNumber: c_uint, - SizeInBits: c_ulonglong, - AlignInBits: c_ulonglong, - Flags: c_uint, - Elements: DIArray, - RunTimeLang: c_uint, - UniqueId: *const c_char) - -> DIType; + Elements: DIArray, + RunTimeLang: c_uint, + UniqueId: *const c_char) + -> DIType; pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool); - pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef, - Scope: DIScope, - Name: *const c_char, - Ty: DIType, - File: DIFile, - LineNo: c_uint, - ColumnNo: c_uint) - -> DITemplateTypeParameter; - - pub fn LLVMDIBuilderCreateOpDeref() -> i64; - - pub fn LLVMDIBuilderCreateOpPlus() -> i64; - - pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef, - Scope: DIScope, - Name: *const c_char, - File: DIFile, - LineNo: c_uint) - -> DINameSpace; - - pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef, - Line: c_uint, - Column: c_uint, + pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef, + Scope: DIScope, + Name: *const c_char, + Ty: DIType, + File: DIFile, + LineNo: c_uint, + ColumnNo: c_uint) + -> DITemplateTypeParameter; + + + pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef, Scope: DIScope, - InlinedAt: MetadataRef) - -> ValueRef; + Name: *const c_char, + File: DIFile, + LineNo: c_uint) + -> DINameSpace; + pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef, + CompositeType: DIType, + TypeArray: DIArray); + + + pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef, + Line: c_uint, + Column: c_uint, + Scope: DIScope, + InlinedAt: MetadataRef) + -> ValueRef; + pub fn LLVMRustDIBuilderCreateOpDeref() -> i64; + pub fn LLVMRustDIBuilderCreateOpPlus() -> i64; - pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef, - CompositeType: DIType, - TypeArray: DIArray); - pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef); - pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef); + pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef); + pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef); pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef; @@ -2108,35 +2121,38 @@ extern { C: DLLStorageClassTypes); pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, - data: *mut *const c_char) -> c_int; + data: *mut *const c_char) -> size_t; - pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef); + pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef); pub fn LLVMContextSetDiagnosticHandler(C: ContextRef, Handler: DiagnosticHandler, DiagnosticContext: *mut c_void); - pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef, - pass_name_out: *mut *const c_char, - function_out: *mut ValueRef, - debugloc_out: *mut DebugLocRef, - message_out: *mut TwineRef); - pub fn LLVMUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef, - cookie_out: *mut c_uint, - message_out: *mut TwineRef, - instruction_out: *mut ValueRef); - - pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef); + pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef, + pass_name_out: *mut *const c_char, + function_out: *mut ValueRef, + debugloc_out: *mut DebugLocRef, + message_out: *mut TwineRef); + pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef, + cookie_out: *mut c_uint, + message_out: *mut TwineRef, + instruction_out: *mut ValueRef); + + pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, + s: RustStringRef); pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity; - pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind; + pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind; - pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef); + pub fn LLVMRustWriteDebugLocToString(C: ContextRef, + DL: DebugLocRef, + s: RustStringRef); - pub fn LLVMSetInlineAsmDiagnosticHandler(C: ContextRef, - H: InlineAsmDiagHandler, - CX: *mut c_void); + pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef, + H: InlineAsmDiagHandler, + CX: *mut c_void); - pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef); + pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef); pub fn LLVMRustWriteArchive(Dst: *const c_char, NumMembers: size_t, @@ -2237,15 +2253,15 @@ pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef { pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) { unsafe { - LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, - attr.bits() as uint64_t) + LLVMRustAddFunctionAttribute(fn_, FunctionIndex as c_uint, + attr.bits() as uint64_t) } } pub fn RemoveFunctionAttributes(fn_: ValueRef, attr: Attribute) { unsafe { - LLVMRemoveFunctionAttributes(fn_, FunctionIndex as c_uint, - attr.bits() as uint64_t) + LLVMRustRemoveFunctionAttributes(fn_, FunctionIndex as c_uint, + attr.bits() as uint64_t) } } @@ -2366,12 +2382,12 @@ pub fn build_string(f: F) -> Option where F: FnOnce(RustStringRef){ } pub unsafe fn twine_to_string(tr: TwineRef) -> String { - build_string(|s| LLVMWriteTwineToString(tr, s)) + build_string(|s| LLVMRustWriteTwineToString(tr, s)) .expect("got a non-UTF8 Twine from LLVM") } pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String { - build_string(|s| LLVMWriteDebugLocToString(c, tr, s)) + build_string(|s| LLVMRustWriteDebugLocToString(c, tr, s)) .expect("got a non-UTF8 DebugLoc from LLVM") } diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs index 01e9970dc76..9c121ae9bfc 100644 --- a/src/librustc_trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -80,10 +80,10 @@ pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) { unsafe { let attr = "no-frame-pointer-elim\0".as_ptr() as *const _; let val = "true\0".as_ptr() as *const _; - llvm::LLVMAddFunctionAttrStringValue(llfn, - llvm::FunctionIndex as c_uint, - attr, - val); + llvm::LLVMRustAddFunctionAttrStringValue(llfn, + llvm::FunctionIndex as c_uint, + attr, + val); } } } diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 0f3a45a7cff..8ce2fa762f9 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -365,7 +365,7 @@ unsafe extern "C" fn inline_asm_handler(diag: SMDiagnosticRef, cookie: c_uint) { let HandlerFreeVars { cgcx, .. } = *(user as *const HandlerFreeVars); - let msg = llvm::build_string(|s| llvm::LLVMWriteSMDiagnosticToString(diag, s)) + let msg = llvm::build_string(|s| llvm::LLVMRustWriteSMDiagnosticToString(diag, s)) .expect("non-UTF8 SMDiagnostic"); report_inline_asm(cgcx, &msg[..], cookie); @@ -421,7 +421,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext, }; let fv = &fv as *const HandlerFreeVars as *mut c_void; - llvm::LLVMSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, fv); + llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, fv); llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, fv); let module_name = Some(&mtrans.name[..]); diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 5a19ddff746..3e66f6de242 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -2348,7 +2348,8 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session, if !is_referenced_somewhere && !is_reachable && !has_fixed_linkage { llvm::SetLinkage(val, llvm::InternalLinkage); - llvm::SetDLLStorageClass(val, llvm::DefaultStorageClass); + llvm::SetDLLStorageClass(val, + llvm::DLLStorageClassTypes::Default); llvm::UnsetComdat(val); } } diff --git a/src/librustc_trans/builder.rs b/src/librustc_trans/builder.rs index 7495f2b753b..12809ab2684 100644 --- a/src/librustc_trans/builder.rs +++ b/src/librustc_trans/builder.rs @@ -503,8 +503,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { unsafe { let ty = Type::from_ref(llvm::LLVMTypeOf(ptr)); let align = llalign_of_pref(self.ccx, ty.element_type()); - llvm::LLVMBuildAtomicLoad(self.llbuilder, ptr, noname(), order, - align as c_uint) + llvm::LLVMRustBuildAtomicLoad(self.llbuilder, ptr, noname(), order, + align as c_uint) } } @@ -565,7 +565,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { unsafe { let ty = Type::from_ref(llvm::LLVMTypeOf(ptr)); let align = llalign_of_pref(self.ccx, ty.element_type()); - llvm::LLVMBuildAtomicStore(self.llbuilder, val, ptr, order, align as c_uint); + llvm::LLVMRustBuildAtomicStore(self.llbuilder, val, ptr, order, align as c_uint); } } @@ -840,7 +840,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug!("Asm Output Type: {:?}", output); let fty = Type::func(&argtys[..], &output); unsafe { - let v = llvm::LLVMInlineAsm( + let v = llvm::LLVMRustInlineAsm( fty.to_ref(), asm, cons, volatile, alignstack, dia as c_uint); self.call(v, inputs, None) } @@ -1097,7 +1097,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope) { unsafe { - llvm::LLVMBuildAtomicFence(self.llbuilder, order, scope); + llvm::LLVMRustBuildAtomicFence(self.llbuilder, order, scope); } } } diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 27048994254..996efc9c113 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -1126,7 +1126,7 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId) } } if ccx.use_dll_storage_attrs() { - llvm::SetDLLStorageClass(g, llvm::DLLImportStorageClass); + llvm::SetDLLStorageClass(g, llvm::DLLStorageClassTypes::DllImport); } g }; @@ -1182,7 +1182,7 @@ pub fn trans_static(ccx: &CrateContext, let name_str_ref = CStr::from_ptr(llvm::LLVMGetValueName(datum.val)); let name_string = CString::new(name_str_ref.to_bytes()).unwrap(); llvm::LLVMSetValueName(datum.val, empty_string.as_ptr()); - let new_g = llvm::LLVMGetOrInsertGlobal( + let new_g = llvm::LLVMRustGetOrInsertGlobal( ccx.llmod(), name_string.as_ptr(), val_llty.to_ref()); // To avoid breaking any invariants, we leave around the old // global for the moment; we'll replace all references to it diff --git a/src/librustc_trans/debuginfo/create_scope_map.rs b/src/librustc_trans/debuginfo/create_scope_map.rs index 0b754024868..fe6a48d4c55 100644 --- a/src/librustc_trans/debuginfo/create_scope_map.rs +++ b/src/librustc_trans/debuginfo/create_scope_map.rs @@ -133,7 +133,7 @@ fn make_mir_scope(ccx: &CrateContext, let loc = span_start(ccx, scope_data.span); scopes[scope] = unsafe { let file_metadata = file_metadata(ccx, &loc.file.name, &loc.file.abs_path); - llvm::LLVMDIBuilderCreateLexicalBlock( + llvm::LLVMRustDIBuilderCreateLexicalBlock( DIB(ccx), parent_scope, file_metadata, @@ -156,7 +156,7 @@ fn with_new_scope(cx: &CrateContext, let parent_scope = scope_stack.last().unwrap().scope_metadata; let scope_metadata = unsafe { - llvm::LLVMDIBuilderCreateLexicalBlock( + llvm::LLVMRustDIBuilderCreateLexicalBlock( DIB(cx), parent_scope, file_metadata, @@ -272,7 +272,7 @@ fn walk_pattern(cx: &CrateContext, let parent_scope = scope_stack.last().unwrap().scope_metadata; let scope_metadata = unsafe { - llvm::LLVMDIBuilderCreateLexicalBlock( + llvm::LLVMRustDIBuilderCreateLexicalBlock( DIB(cx), parent_scope, file_metadata, diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 1d718d4b57a..8011347d3eb 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -504,12 +504,12 @@ fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, }; let subrange = unsafe { - llvm::LLVMDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) + llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) }; let subscripts = create_DIArray(DIB(cx), &[subrange]); let metadata = unsafe { - llvm::LLVMDIBuilderCreateArrayType( + llvm::LLVMRustDIBuilderCreateArrayType( DIB(cx), bytes_to_bits(array_size_in_bytes), bytes_to_bits(element_type_align), @@ -612,7 +612,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, return MetadataCreationResult::new( unsafe { - llvm::LLVMDIBuilderCreateSubroutineType( + llvm::LLVMRustDIBuilderCreateSubroutineType( DIB(cx), unknown_file_metadata(cx), create_DIArray(DIB(cx), &signature_metadata[..])) @@ -885,8 +885,8 @@ fn file_metadata_(cx: &CrateContext, key: &str, file_name: &str, work_dir: &str) let file_name = CString::new(file_name).unwrap(); let work_dir = CString::new(work_dir).unwrap(); let file_metadata = unsafe { - llvm::LLVMDIBuilderCreateFile(DIB(cx), file_name.as_ptr(), - work_dir.as_ptr()) + llvm::LLVMRustDIBuilderCreateFile(DIB(cx), file_name.as_ptr(), + work_dir.as_ptr()) }; let mut created_files = debug_context(cx).created_files.borrow_mut(); @@ -916,7 +916,7 @@ pub fn scope_metadata(fcx: &FunctionContext, pub fn diverging_type_metadata(cx: &CrateContext) -> DIType { unsafe { - llvm::LLVMDIBuilderCreateBasicType( + llvm::LLVMRustDIBuilderCreateBasicType( DIB(cx), "!\0".as_ptr() as *const _, bytes_to_bits(0), @@ -951,7 +951,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let (size, align) = size_and_align_of(cx, llvm_type); let name = CString::new(name).unwrap(); let ty_metadata = unsafe { - llvm::LLVMDIBuilderCreateBasicType( + llvm::LLVMRustDIBuilderCreateBasicType( DIB(cx), name.as_ptr(), bytes_to_bits(size), @@ -971,7 +971,7 @@ fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let name = compute_debuginfo_type_name(cx, pointer_type, false); let name = CString::new(name).unwrap(); let ptr_metadata = unsafe { - llvm::LLVMDIBuilderCreatePointerType( + llvm::LLVMRustDIBuilderCreatePointerType( DIB(cx), pointee_type_metadata, bytes_to_bits(pointer_size), @@ -1017,7 +1017,7 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext, let flags = "\0"; let split_name = "\0"; return unsafe { - llvm::LLVMDIBuilderCreateCompileUnit( + llvm::LLVMRustDIBuilderCreateCompileUnit( debug_context.builder, DW_LANG_RUST, compile_unit_name, @@ -1596,7 +1596,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let token = v.name.as_str(); let name = CString::new(token.as_bytes()).unwrap(); unsafe { - llvm::LLVMDIBuilderCreateEnumerator( + llvm::LLVMRustDIBuilderCreateEnumerator( DIB(cx), name.as_ptr(), v.disr_val.to_u64_unchecked()) @@ -1623,7 +1623,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let name = CString::new(discriminant_name.as_bytes()).unwrap(); let discriminant_type_metadata = unsafe { - llvm::LLVMDIBuilderCreateEnumerationType( + llvm::LLVMRustDIBuilderCreateEnumerationType( DIB(cx), containing_scope, name.as_ptr(), @@ -1667,7 +1667,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let enum_name = CString::new(enum_name).unwrap(); let unique_type_id_str = CString::new(unique_type_id_str.as_bytes()).unwrap(); let enum_metadata = unsafe { - llvm::LLVMDIBuilderCreateUnionType( + llvm::LLVMRustDIBuilderCreateUnionType( DIB(cx), containing_scope, enum_name.as_ptr(), @@ -1769,7 +1769,7 @@ fn set_members_of_composite_type(cx: &CrateContext, let member_name = member_description.name.as_bytes(); let member_name = CString::new(member_name).unwrap(); unsafe { - llvm::LLVMDIBuilderCreateMemberType( + llvm::LLVMRustDIBuilderCreateMemberType( DIB(cx), composite_type_metadata, member_name.as_ptr(), @@ -1786,13 +1786,14 @@ fn set_members_of_composite_type(cx: &CrateContext, unsafe { let type_array = create_DIArray(DIB(cx), &member_metadata[..]); - llvm::LLVMDICompositeTypeSetTypeArray(DIB(cx), composite_type_metadata, type_array); + llvm::LLVMRustDICompositeTypeSetTypeArray( + DIB(cx), composite_type_metadata, type_array); } } -// A convenience wrapper around LLVMDIBuilderCreateStructType(). Does not do any -// caching, does not add any fields to the struct. This can be done later with -// set_members_of_composite_type(). +// A convenience wrapper around LLVMRustDIBuilderCreateStructType(). Does not do +// any caching, does not add any fields to the struct. This can be done later +// with set_members_of_composite_type(). fn create_struct_stub(cx: &CrateContext, struct_llvm_type: Type, struct_type_name: &str, @@ -1807,12 +1808,12 @@ fn create_struct_stub(cx: &CrateContext, let name = CString::new(struct_type_name).unwrap(); let unique_type_id = CString::new(unique_type_id_str.as_bytes()).unwrap(); let metadata_stub = unsafe { - // LLVMDIBuilderCreateStructType() wants an empty array. A null + // LLVMRustDIBuilderCreateStructType() wants an empty array. A null // pointer will lead to hard to trace and debug LLVM assertions // later on in llvm/lib/IR/Value.cpp. let empty_array = create_DIArray(DIB(cx), &[]); - llvm::LLVMDIBuilderCreateStructType( + llvm::LLVMRustDIBuilderCreateStructType( DIB(cx), containing_scope, name.as_ptr(), @@ -1868,16 +1869,16 @@ pub fn create_global_var_metadata(cx: &CrateContext, let var_name = CString::new(var_name).unwrap(); let linkage_name = CString::new(linkage_name).unwrap(); unsafe { - llvm::LLVMDIBuilderCreateStaticVariable(DIB(cx), - var_scope, - var_name.as_ptr(), - linkage_name.as_ptr(), - file_metadata, - line_number, - type_metadata, - is_local_to_unit, - global, - ptr::null_mut()); + llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx), + var_scope, + var_name.as_ptr(), + linkage_name.as_ptr(), + file_metadata, + line_number, + type_metadata, + is_local_to_unit, + global, + ptr::null_mut()); } } @@ -1980,10 +1981,10 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, env_index); let address_operations = unsafe { - [llvm::LLVMDIBuilderCreateOpDeref(), - llvm::LLVMDIBuilderCreateOpPlus(), + [llvm::LLVMRustDIBuilderCreateOpDeref(), + llvm::LLVMRustDIBuilderCreateOpPlus(), byte_offset_of_var_in_env as i64, - llvm::LLVMDIBuilderCreateOpDeref()] + llvm::LLVMRustDIBuilderCreateOpDeref()] }; let address_op_count = if captured_by_ref { @@ -2021,7 +2022,7 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let scope_metadata = scope_metadata(bcx.fcx, binding.id, binding.span); let aops = unsafe { - [llvm::LLVMDIBuilderCreateOpDeref()] + [llvm::LLVMRustDIBuilderCreateOpDeref()] }; // Regardless of the actual type (`T`) we're always passed the stack slot // (alloca) for the binding. For ByRef bindings that's a `T*` but for ByMove diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 0cb52c8768b..915999f07a1 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -88,7 +88,7 @@ pub struct CrateDebugContext<'tcx> { impl<'tcx> CrateDebugContext<'tcx> { pub fn new(llmod: ModuleRef) -> CrateDebugContext<'tcx> { debug!("CrateDebugContext::new"); - let builder = unsafe { llvm::LLVMDIBuilderCreate(llmod) }; + let builder = unsafe { llvm::LLVMRustDIBuilderCreate(llmod) }; // DIBuilder inherits context from the module, so we'd better use the same one let llcontext = unsafe { llvm::LLVMGetModuleContext(llmod) }; return CrateDebugContext { @@ -178,8 +178,8 @@ pub fn finalize(cx: &CrateContext) { } unsafe { - llvm::LLVMDIBuilderFinalize(DIB(cx)); - llvm::LLVMDIBuilderDispose(DIB(cx)); + llvm::LLVMRustDIBuilderFinalize(DIB(cx)); + llvm::LLVMRustDIBuilderDispose(DIB(cx)); // Debuginfo generation in LLVM by default uses a higher // version of dwarf than OS X currently understands. We can // instruct LLVM to emit an older version of dwarf, however, @@ -250,7 +250,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let function_type_metadata = unsafe { let fn_signature = get_function_signature(cx, sig, abi); - llvm::LLVMDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature) + llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature) }; // Find the enclosing function, in case this is a closure. @@ -284,7 +284,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let linkage_name = CString::new(linkage_name).unwrap(); let fn_metadata = unsafe { - llvm::LLVMDIBuilderCreateFunction( + llvm::LLVMRustDIBuilderCreateFunction( DIB(cx), containing_scope, function_name.as_ptr(), @@ -388,7 +388,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); let name = CString::new(param.name.as_str().as_bytes()).unwrap(); unsafe { - llvm::LLVMDIBuilderCreateTemplateTypeParameter( + llvm::LLVMRustDIBuilderCreateTemplateTypeParameter( DIB(cx), ptr::null_mut(), name.as_ptr(), @@ -492,7 +492,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, (DirectVariable { alloca }, address_operations) | (IndirectVariable {alloca, address_operations}, _) => { let metadata = unsafe { - llvm::LLVMDIBuilderCreateVariable( + llvm::LLVMRustDIBuilderCreateVariable( DIB(cx), dwarf_tag, scope_metadata, @@ -510,7 +510,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize())); unsafe { let debug_loc = llvm::LLVMGetCurrentDebugLocation(cx.raw_builder()); - let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd( + let instr = llvm::LLVMRustDIBuilderInsertDeclareAtEnd( DIB(cx), alloca, metadata, diff --git a/src/librustc_trans/debuginfo/namespace.rs b/src/librustc_trans/debuginfo/namespace.rs index 736a8c1c7d7..5953ec4aaed 100644 --- a/src/librustc_trans/debuginfo/namespace.rs +++ b/src/librustc_trans/debuginfo/namespace.rs @@ -78,7 +78,7 @@ pub fn item_namespace(ccx: &CrateContext, def_id: DefId) -> DIScope { }; let scope = unsafe { - llvm::LLVMDIBuilderCreateNameSpace( + llvm::LLVMRustDIBuilderCreateNameSpace( DIB(ccx), parent_scope, namespace_name.as_ptr(), diff --git a/src/librustc_trans/debuginfo/source_loc.rs b/src/librustc_trans/debuginfo/source_loc.rs index 9726001b4d4..d288b9dcef7 100644 --- a/src/librustc_trans/debuginfo/source_loc.rs +++ b/src/librustc_trans/debuginfo/source_loc.rs @@ -206,7 +206,7 @@ pub fn set_debug_location(cx: &CrateContext, debug!("setting debug location to {} {}", line, col); unsafe { - llvm::LLVMDIBuilderCreateDebugLocation( + llvm::LLVMRustDIBuilderCreateDebugLocation( debug_context(cx).llcontext, line as c_uint, col as c_uint, diff --git a/src/librustc_trans/debuginfo/utils.rs b/src/librustc_trans/debuginfo/utils.rs index facdfe73ddc..5734a123941 100644 --- a/src/librustc_trans/debuginfo/utils.rs +++ b/src/librustc_trans/debuginfo/utils.rs @@ -40,7 +40,7 @@ pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool #[allow(non_snake_case)] pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray { return unsafe { - llvm::LLVMDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) + llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) }; } diff --git a/src/librustc_trans/declare.rs b/src/librustc_trans/declare.rs index 2746d3fb6b0..15d90504ee7 100644 --- a/src/librustc_trans/declare.rs +++ b/src/librustc_trans/declare.rs @@ -40,7 +40,7 @@ pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRe bug!("name {:?} contains an interior null byte", name) }); unsafe { - llvm::LLVMGetOrInsertGlobal(ccx.llmod(), namebuf.as_ptr(), ty.to_ref()) + llvm::LLVMRustGetOrInsertGlobal(ccx.llmod(), namebuf.as_ptr(), ty.to_ref()) } } @@ -55,7 +55,7 @@ fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: bug!("name {:?} contains an interior null byte", name) }); let llfn = unsafe { - llvm::LLVMGetOrInsertFunction(ccx.llmod(), namebuf.as_ptr(), ty.to_ref()) + llvm::LLVMRustGetOrInsertFunction(ccx.llmod(), namebuf.as_ptr(), ty.to_ref()) }; llvm::SetFunctionCallConv(llfn, callconv); @@ -173,7 +173,7 @@ pub fn get_declared_value(ccx: &CrateContext, name: &str) -> Option { let namebuf = CString::new(name).unwrap_or_else(|_|{ bug!("name {:?} contains an interior null byte", name) }); - let val = unsafe { llvm::LLVMGetNamedValue(ccx.llmod(), namebuf.as_ptr()) }; + let val = unsafe { llvm::LLVMRustGetNamedValue(ccx.llmod(), namebuf.as_ptr()) }; if val.is_null() { debug!("get_declared_value: {:?} value is null", name); None diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index 1e4a2748182..2f27aed065d 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -640,28 +640,30 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, // This requires that atomic intrinsics follow a specific naming pattern: // "atomic_[_]", and no ordering means SeqCst (_, name) if name.starts_with("atomic_") => { + use llvm::AtomicOrdering::*; + let split: Vec<&str> = name.split('_').collect(); let is_cxchg = split[1] == "cxchg" || split[1] == "cxchgweak"; let (order, failorder) = match split.len() { - 2 => (llvm::SequentiallyConsistent, llvm::SequentiallyConsistent), + 2 => (SequentiallyConsistent, SequentiallyConsistent), 3 => match split[2] { - "unordered" => (llvm::Unordered, llvm::Unordered), - "relaxed" => (llvm::Monotonic, llvm::Monotonic), - "acq" => (llvm::Acquire, llvm::Acquire), - "rel" => (llvm::Release, llvm::Monotonic), - "acqrel" => (llvm::AcquireRelease, llvm::Acquire), + "unordered" => (Unordered, Unordered), + "relaxed" => (Monotonic, Monotonic), + "acq" => (Acquire, Acquire), + "rel" => (Release, Monotonic), + "acqrel" => (AcquireRelease, Acquire), "failrelaxed" if is_cxchg => - (llvm::SequentiallyConsistent, llvm::Monotonic), + (SequentiallyConsistent, Monotonic), "failacq" if is_cxchg => - (llvm::SequentiallyConsistent, llvm::Acquire), + (SequentiallyConsistent, Acquire), _ => ccx.sess().fatal("unknown ordering in atomic intrinsic") }, 4 => match (split[2], split[3]) { ("acq", "failrelaxed") if is_cxchg => - (llvm::Acquire, llvm::Monotonic), + (Acquire, Monotonic), ("acqrel", "failrelaxed") if is_cxchg => - (llvm::AcquireRelease, llvm::Monotonic), + (AcquireRelease, Monotonic), _ => ccx.sess().fatal("unknown ordering in atomic intrinsic") }, _ => ccx.sess().fatal("Atomic intrinsic not in correct format"), @@ -714,12 +716,12 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } "fence" => { - AtomicFence(bcx, order, llvm::CrossThread); + AtomicFence(bcx, order, llvm::SynchronizationScope::CrossThread); C_nil(ccx) } "singlethreadfence" => { - AtomicFence(bcx, order, llvm::SingleThread); + AtomicFence(bcx, order, llvm::SynchronizationScope::SingleThread); C_nil(ccx) } diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index 0221232a77d..8f723d288c9 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -324,8 +324,8 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>, machine::llelement_offset(bcx.ccx(), lltuplety, i); let ops = unsafe { - [llvm::LLVMDIBuilderCreateOpDeref(), - llvm::LLVMDIBuilderCreateOpPlus(), + [llvm::LLVMRustDIBuilderCreateOpDeref(), + llvm::LLVMRustDIBuilderCreateOpPlus(), byte_offset_of_var_in_tuple as i64] }; @@ -450,10 +450,10 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>, machine::llelement_offset(bcx.ccx(), llclosurety, i); let ops = unsafe { - [llvm::LLVMDIBuilderCreateOpDeref(), - llvm::LLVMDIBuilderCreateOpPlus(), + [llvm::LLVMRustDIBuilderCreateOpDeref(), + llvm::LLVMRustDIBuilderCreateOpPlus(), byte_offset_of_var_in_env as i64, - llvm::LLVMDIBuilderCreateOpDeref()] + llvm::LLVMRustDIBuilderCreateOpDeref()] }; // The environment and the capture can each be indirect. diff --git a/src/librustc_trans/type_.rs b/src/librustc_trans/type_.rs index 001cd197e60..c09515a5138 100644 --- a/src/librustc_trans/type_.rs +++ b/src/librustc_trans/type_.rs @@ -36,7 +36,7 @@ pub struct Type { impl fmt::Debug for Type { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&llvm::build_string(|s| unsafe { - llvm::LLVMWriteTypeToString(self.to_ref(), s); + llvm::LLVMRustWriteTypeToString(self.to_ref(), s); }).expect("non-UTF8 type description from LLVM")) } } @@ -72,7 +72,7 @@ impl Type { } pub fn metadata(ccx: &CrateContext) -> Type { - ty!(llvm::LLVMMetadataTypeInContext(ccx.llcx())) + ty!(llvm::LLVMRustMetadataTypeInContext(ccx.llcx())) } pub fn i1(ccx: &CrateContext) -> Type { diff --git a/src/librustc_trans/value.rs b/src/librustc_trans/value.rs index 00b316cc420..79e0c11515f 100644 --- a/src/librustc_trans/value.rs +++ b/src/librustc_trans/value.rs @@ -23,7 +23,7 @@ pub struct Value(pub ValueRef); impl fmt::Debug for Value { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&llvm::build_string(|s| unsafe { - llvm::LLVMWriteValueToString(self.0, s); + llvm::LLVMRustWriteValueToString(self.0, s); }).expect("nun-UTF8 value description from LLVM")) } } diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index bc38245d351..a9c31bc33e0 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -13,6 +13,7 @@ #include "llvm/Object/ObjectFile.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/IR/Instructions.h" #include "llvm/IR/CallSite.h" @@ -27,6 +28,30 @@ using namespace llvm; using namespace llvm::sys; using namespace llvm::object; +// LLVMAtomicOrdering is already an enum - don't create another +// one. +static AtomicOrdering from_rust(LLVMAtomicOrdering Ordering) { + switch (Ordering) { + case LLVMAtomicOrderingNotAtomic: + return AtomicOrdering::NotAtomic; + case LLVMAtomicOrderingUnordered: + return AtomicOrdering::Unordered; + case LLVMAtomicOrderingMonotonic: + return AtomicOrdering::Monotonic; + case LLVMAtomicOrderingAcquire: + return AtomicOrdering::Acquire; + case LLVMAtomicOrderingRelease: + return AtomicOrdering::Release; + case LLVMAtomicOrderingAcquireRelease: + return AtomicOrdering::AcquireRelease; + case LLVMAtomicOrderingSequentiallyConsistent: + return AtomicOrdering::SequentiallyConsistent; + } + + llvm_unreachable("Invalid LLVMAtomicOrdering value!"); +} + + static char *LastError; extern "C" LLVMMemoryBufferRef @@ -57,45 +82,30 @@ LLVMRustSetNormalizedTarget(LLVMModuleRef M, const char *triple) { unwrap(M)->setTargetTriple(Triple::normalize(triple)); } -extern "C" LLVMValueRef LLVMRustConstSmallInt(LLVMTypeRef IntTy, unsigned N, - LLVMBool SignExtend) { - return LLVMConstInt(IntTy, (unsigned long long)N, SignExtend); -} - -extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy, - unsigned N_hi, - unsigned N_lo, - LLVMBool SignExtend) { - unsigned long long N = N_hi; - N <<= 32; - N |= N_lo; - return LLVMConstInt(IntTy, N, SignExtend); -} - extern "C" void LLVMRustPrintPassTimings() { raw_fd_ostream OS (2, false); // stderr. TimerGroup::printAll(OS); } -extern "C" LLVMValueRef LLVMGetNamedValue(LLVMModuleRef M, - const char* Name) { +extern "C" LLVMValueRef LLVMRustGetNamedValue(LLVMModuleRef M, + const char* Name) { return wrap(unwrap(M)->getNamedValue(Name)); } -extern "C" LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M, - const char* Name, - LLVMTypeRef FunctionTy) { +extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M, + const char* Name, + LLVMTypeRef FunctionTy) { return wrap(unwrap(M)->getOrInsertFunction(Name, unwrap(FunctionTy))); } -extern "C" LLVMValueRef LLVMGetOrInsertGlobal(LLVMModuleRef M, - const char* Name, - LLVMTypeRef Ty) { +extern "C" LLVMValueRef LLVMRustGetOrInsertGlobal(LLVMModuleRef M, + const char* Name, + LLVMTypeRef Ty) { return wrap(unwrap(M)->getOrInsertGlobal(Name, unwrap(Ty))); } -extern "C" LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) { +extern "C" LLVMTypeRef LLVMRustMetadataTypeInContext(LLVMContextRef C) { return wrap(Type::getMetadataTy(*unwrap(C))); } @@ -110,7 +120,10 @@ extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, } -extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef Instr, unsigned idx, uint64_t b) { +extern "C" void LLVMRustAddDereferenceableCallSiteAttr(LLVMValueRef Instr, + unsigned idx, + uint64_t b) +{ CallSite Call = CallSite(unwrap(Instr)); AttrBuilder B; B.addDereferenceableAttr(b); @@ -120,38 +133,50 @@ extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef Instr, unsigned idx, B))); } -extern "C" void LLVMAddFunctionAttribute(LLVMValueRef Fn, unsigned index, - uint64_t Val) { +extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn, + unsigned index, + uint64_t Val) +{ Function *A = unwrap(Fn); AttrBuilder B; B.addRawValue(Val); A->addAttributes(index, AttributeSet::get(A->getContext(), index, B)); } -extern "C" void LLVMAddDereferenceableAttr(LLVMValueRef Fn, unsigned index, uint64_t bytes) { +extern "C" void LLVMRustAddDereferenceableAttr(LLVMValueRef Fn, + unsigned index, + uint64_t bytes) +{ Function *A = unwrap(Fn); AttrBuilder B; B.addDereferenceableAttr(bytes); A->addAttributes(index, AttributeSet::get(A->getContext(), index, B)); } -extern "C" void LLVMAddFunctionAttrString(LLVMValueRef Fn, unsigned index, const char *Name) { +extern "C" void LLVMRustAddFunctionAttrString(LLVMValueRef Fn, + unsigned index, + const char *Name) +{ Function *F = unwrap(Fn); AttrBuilder B; B.addAttribute(Name); F->addAttributes(index, AttributeSet::get(F->getContext(), index, B)); } -extern "C" void LLVMAddFunctionAttrStringValue(LLVMValueRef Fn, unsigned index, - const char *Name, - const char *Value) { +extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn, + unsigned index, + const char *Name, + const char *Value) { Function *F = unwrap(Fn); AttrBuilder B; B.addAttribute(Name, Value); F->addAttributes(index, AttributeSet::get(F->getContext(), index, B)); } -extern "C" void LLVMRemoveFunctionAttributes(LLVMValueRef Fn, unsigned index, uint64_t Val) { +extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn, + unsigned index, + uint64_t Val) +{ Function *A = unwrap(Fn); const AttributeSet PAL = A->getAttributes(); AttrBuilder B(Val); @@ -161,7 +186,10 @@ extern "C" void LLVMRemoveFunctionAttributes(LLVMValueRef Fn, unsigned index, ui A->setAttributes(PALnew); } -extern "C" void LLVMRemoveFunctionAttrString(LLVMValueRef fn, unsigned index, const char *Name) { +extern "C" void LLVMRustRemoveFunctionAttrString(LLVMValueRef fn, + unsigned index, + const char *Name) +{ Function *f = unwrap(fn); LLVMContext &C = f->getContext(); AttrBuilder B; @@ -181,24 +209,24 @@ extern "C" void LLVMRustSetHasUnsafeAlgebra(LLVMValueRef V) { } } -extern "C" LLVMValueRef LLVMBuildAtomicLoad(LLVMBuilderRef B, - LLVMValueRef source, - const char* Name, - AtomicOrdering order, - unsigned alignment) { +extern "C" LLVMValueRef LLVMRustBuildAtomicLoad(LLVMBuilderRef B, + LLVMValueRef source, + const char* Name, + LLVMAtomicOrdering order, + unsigned alignment) { LoadInst* li = new LoadInst(unwrap(source),0); - li->setAtomic(order); + li->setAtomic(from_rust(order)); li->setAlignment(alignment); return wrap(unwrap(B)->Insert(li, Name)); } -extern "C" LLVMValueRef LLVMBuildAtomicStore(LLVMBuilderRef B, - LLVMValueRef val, - LLVMValueRef target, - AtomicOrdering order, - unsigned alignment) { +extern "C" LLVMValueRef LLVMRustBuildAtomicStore(LLVMBuilderRef B, + LLVMValueRef val, + LLVMValueRef target, + LLVMAtomicOrdering order, + unsigned alignment) { StoreInst* si = new StoreInst(unwrap(val),unwrap(target)); - si->setAtomic(order); + si->setAtomic(from_rust(order)); si->setAlignment(alignment); return wrap(unwrap(B)->Insert(si)); } @@ -207,54 +235,77 @@ extern "C" LLVMValueRef LLVMRustBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef target, LLVMValueRef old, LLVMValueRef source, - AtomicOrdering order, - AtomicOrdering failure_order, + LLVMAtomicOrdering order, + LLVMAtomicOrdering failure_order, LLVMBool weak) { - AtomicCmpXchgInst* acxi = unwrap(B)->CreateAtomicCmpXchg(unwrap(target), - unwrap(old), - unwrap(source), - order, - failure_order); + AtomicCmpXchgInst* acxi = unwrap(B)->CreateAtomicCmpXchg( + unwrap(target), + unwrap(old), + unwrap(source), + from_rust(order), + from_rust(failure_order)); acxi->setWeak(weak); return wrap(acxi); } -extern "C" LLVMValueRef LLVMBuildAtomicFence(LLVMBuilderRef B, - AtomicOrdering order, - SynchronizationScope scope) { - return wrap(unwrap(B)->CreateFence(order, scope)); + +enum class LLVMRustSynchronizationScope { + Other, + SingleThread, + CrossThread, +}; + +static SynchronizationScope +from_rust(LLVMRustSynchronizationScope scope) +{ + switch (scope) { + case LLVMRustSynchronizationScope::SingleThread: + return SingleThread; + case LLVMRustSynchronizationScope::CrossThread: + return CrossThread; + default: + abort(); + } +} + +extern "C" LLVMValueRef LLVMRustBuildAtomicFence( + LLVMBuilderRef B, + LLVMAtomicOrdering order, + LLVMRustSynchronizationScope scope) +{ + return wrap(unwrap(B)->CreateFence(from_rust(order), from_rust(scope))); } -extern "C" void LLVMSetDebug(int Enabled) { +extern "C" void LLVMRustSetDebug(int Enabled) { #ifndef NDEBUG DebugFlag = Enabled; #endif } -extern "C" LLVMValueRef LLVMInlineAsm(LLVMTypeRef Ty, - char *AsmString, - char *Constraints, - LLVMBool HasSideEffects, - LLVMBool IsAlignStack, - unsigned Dialect) { +extern "C" LLVMValueRef LLVMRustInlineAsm(LLVMTypeRef Ty, + char *AsmString, + char *Constraints, + LLVMBool HasSideEffects, + LLVMBool IsAlignStack, + unsigned Dialect) { return wrap(InlineAsm::get(unwrap(Ty), AsmString, Constraints, HasSideEffects, IsAlignStack, (InlineAsm::AsmDialect) Dialect)); } -typedef DIBuilder* DIBuilderRef; +typedef DIBuilder* LLVMRustDIBuilderRef; -typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; +typedef struct LLVMOpaqueMetadata *LLVMRustMetadataRef; namespace llvm { -DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef) +DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMRustMetadataRef) -inline Metadata **unwrap(LLVMMetadataRef *Vals) { +inline Metadata **unwrap(LLVMRustMetadataRef *Vals) { return reinterpret_cast(Vals); } } template -DIT* unwrapDIptr(LLVMMetadataRef ref) { +DIT* unwrapDIptr(LLVMRustMetadataRef ref) { return (DIT*) (ref ? unwrap(ref) : NULL); } @@ -266,11 +317,11 @@ extern "C" uint32_t LLVMRustDebugMetadataVersion() { return DEBUG_METADATA_VERSION; } -extern "C" uint32_t LLVMVersionMinor() { +extern "C" uint32_t LLVMRustVersionMinor() { return LLVM_VERSION_MINOR; } -extern "C" uint32_t LLVMVersionMajor() { +extern "C" uint32_t LLVMRustVersionMajor() { return LLVM_VERSION_MAJOR; } @@ -280,20 +331,20 @@ extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M, unwrap(M)->addModuleFlag(Module::Warning, name, value); } -extern "C" DIBuilderRef LLVMDIBuilderCreate(LLVMModuleRef M) { +extern "C" LLVMRustDIBuilderRef LLVMRustDIBuilderCreate(LLVMModuleRef M) { return new DIBuilder(*unwrap(M)); } -extern "C" void LLVMDIBuilderDispose(DIBuilderRef Builder) { +extern "C" void LLVMRustDIBuilderDispose(LLVMRustDIBuilderRef Builder) { delete Builder; } -extern "C" void LLVMDIBuilderFinalize(DIBuilderRef Builder) { +extern "C" void LLVMRustDIBuilderFinalize(LLVMRustDIBuilderRef Builder) { Builder->finalize(); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateCompileUnit( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateCompileUnit( + LLVMRustDIBuilderRef Builder, unsigned Lang, const char* File, const char* Dir, @@ -312,17 +363,17 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateCompileUnit( SplitName)); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateFile( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateFile( + LLVMRustDIBuilderRef Builder, const char* Filename, const char* Directory) { return wrap(Builder->createFile(Filename, Directory)); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateSubroutineType( - DIBuilderRef Builder, - LLVMMetadataRef File, - LLVMMetadataRef ParameterTypes) { +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateSubroutineType( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef File, + LLVMRustMetadataRef ParameterTypes) { return wrap(Builder->createSubroutineType( #if LLVM_VERSION_MINOR == 7 unwrapDI(File), @@ -330,22 +381,22 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateSubroutineType( DITypeRefArray(unwrap(ParameterTypes)))); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateFunction( - DIBuilderRef Builder, - LLVMMetadataRef Scope, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateFunction( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, const char* Name, const char* LinkageName, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNo, - LLVMMetadataRef Ty, + LLVMRustMetadataRef Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized, LLVMValueRef Fn, - LLVMMetadataRef TParam, - LLVMMetadataRef Decl) { + LLVMRustMetadataRef TParam, + LLVMRustMetadataRef Decl) { #if LLVM_VERSION_MINOR >= 8 DITemplateParameterArray TParams = DITemplateParameterArray(unwrap(TParam)); @@ -370,8 +421,8 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateFunction( #endif } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateBasicType( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateBasicType( + LLVMRustDIBuilderRef Builder, const char* Name, uint64_t SizeInBits, uint64_t AlignInBits, @@ -381,9 +432,9 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateBasicType( AlignInBits, Encoding)); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreatePointerType( - DIBuilderRef Builder, - LLVMMetadataRef PointeeTy, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreatePointerType( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef PointeeTy, uint64_t SizeInBits, uint64_t AlignInBits, const char* Name) { @@ -391,19 +442,19 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreatePointerType( unwrapDI(PointeeTy), SizeInBits, AlignInBits, Name)); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType( - DIBuilderRef Builder, - LLVMMetadataRef Scope, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStructType( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, const char* Name, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, - LLVMMetadataRef DerivedFrom, - LLVMMetadataRef Elements, + LLVMRustMetadataRef DerivedFrom, + LLVMRustMetadataRef Elements, unsigned RunTimeLang, - LLVMMetadataRef VTableHolder, + LLVMRustMetadataRef VTableHolder, const char *UniqueId) { return wrap(Builder->createStructType( unwrapDI(Scope), @@ -421,17 +472,17 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType( )); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateMemberType( - DIBuilderRef Builder, - LLVMMetadataRef Scope, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateMemberType( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, const char* Name, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, - LLVMMetadataRef Ty) { + LLVMRustMetadataRef Ty) { return wrap(Builder->createMemberType( unwrapDI(Scope), Name, unwrapDI(File), LineNo, @@ -439,10 +490,10 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateMemberType( unwrapDI(Ty))); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock( - DIBuilderRef Builder, - LLVMMetadataRef Scope, - LLVMMetadataRef File, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateLexicalBlock( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, + LLVMRustMetadataRef File, unsigned Line, unsigned Col) { return wrap(Builder->createLexicalBlock( @@ -451,17 +502,17 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock( )); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable( - DIBuilderRef Builder, - LLVMMetadataRef Context, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Context, const char* Name, const char* LinkageName, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNo, - LLVMMetadataRef Ty, + LLVMRustMetadataRef Ty, bool isLocalToUnit, LLVMValueRef Val, - LLVMMetadataRef Decl = NULL) { + LLVMRustMetadataRef Decl = NULL) { return wrap(Builder->createGlobalVariable(unwrapDI(Context), Name, LinkageName, @@ -473,14 +524,14 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable( unwrapDIptr(Decl))); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable( + LLVMRustDIBuilderRef Builder, unsigned Tag, - LLVMMetadataRef Scope, + LLVMRustMetadataRef Scope, const char* Name, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNo, - LLVMMetadataRef Ty, + LLVMRustMetadataRef Ty, bool AlwaysPreserve, unsigned Flags, int64_t* AddrOps, @@ -509,50 +560,50 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable( #endif } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateArrayType( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateArrayType( + LLVMRustDIBuilderRef Builder, uint64_t Size, uint64_t AlignInBits, - LLVMMetadataRef Ty, - LLVMMetadataRef Subscripts) { + LLVMRustMetadataRef Ty, + LLVMRustMetadataRef Subscripts) { return wrap(Builder->createArrayType(Size, AlignInBits, unwrapDI(Ty), DINodeArray(unwrapDI(Subscripts)) )); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateVectorType( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVectorType( + LLVMRustDIBuilderRef Builder, uint64_t Size, uint64_t AlignInBits, - LLVMMetadataRef Ty, - LLVMMetadataRef Subscripts) { + LLVMRustMetadataRef Ty, + LLVMRustMetadataRef Subscripts) { return wrap(Builder->createVectorType(Size, AlignInBits, unwrapDI(Ty), DINodeArray(unwrapDI(Subscripts)) )); } -extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderGetOrCreateSubrange( + LLVMRustDIBuilderRef Builder, int64_t Lo, int64_t Count) { return wrap(Builder->getOrCreateSubrange(Lo, Count)); } -extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray( - DIBuilderRef Builder, - LLVMMetadataRef* Ptr, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderGetOrCreateArray( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef* Ptr, unsigned Count) { Metadata **DataValue = unwrap(Ptr); return wrap(Builder->getOrCreateArray( ArrayRef(DataValue, Count)).get()); } -extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( - DIBuilderRef Builder, +extern "C" LLVMValueRef LLVMRustDIBuilderInsertDeclareAtEnd( + LLVMRustDIBuilderRef Builder, LLVMValueRef Val, - LLVMMetadataRef VarInfo, + LLVMRustMetadataRef VarInfo, int64_t* AddrOps, unsigned AddrOpsCount, LLVMValueRef DL, @@ -566,10 +617,10 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( unwrap(InsertAtEnd))); } -extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore( - DIBuilderRef Builder, +extern "C" LLVMValueRef LLVMRustDIBuilderInsertDeclareBefore( + LLVMRustDIBuilderRef Builder, LLVMValueRef Val, - LLVMMetadataRef VarInfo, + LLVMRustMetadataRef VarInfo, int64_t* AddrOps, unsigned AddrOpsCount, LLVMValueRef DL, @@ -583,24 +634,24 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore( unwrap(InsertBefore))); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerator( - DIBuilderRef Builder, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateEnumerator( + LLVMRustDIBuilderRef Builder, const char* Name, uint64_t Val) { return wrap(Builder->createEnumerator(Name, Val)); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerationType( - DIBuilderRef Builder, - LLVMMetadataRef Scope, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateEnumerationType( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, const char* Name, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, - LLVMMetadataRef Elements, - LLVMMetadataRef ClassType) + LLVMRustMetadataRef Elements, + LLVMRustMetadataRef ClassType) { return wrap(Builder->createEnumerationType( unwrapDI(Scope), @@ -613,16 +664,16 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerationType( unwrapDI(ClassType))); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType( - DIBuilderRef Builder, - LLVMMetadataRef Scope, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateUnionType( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, const char* Name, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, - LLVMMetadataRef Elements, + LLVMRustMetadataRef Elements, unsigned RunTimeLang, const char* UniqueId) { @@ -640,12 +691,12 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType( )); } -extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter( - DIBuilderRef Builder, - LLVMMetadataRef Scope, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, const char* Name, - LLVMMetadataRef Ty, - LLVMMetadataRef File, + LLVMRustMetadataRef Ty, + LLVMRustMetadataRef File, unsigned LineNo, unsigned ColumnNo) { @@ -656,21 +707,11 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter( )); } -extern "C" int64_t LLVMDIBuilderCreateOpDeref() -{ - return dwarf::DW_OP_deref; -} - -extern "C" int64_t LLVMDIBuilderCreateOpPlus() -{ - return dwarf::DW_OP_plus; -} - -extern "C" LLVMMetadataRef LLVMDIBuilderCreateNameSpace( - DIBuilderRef Builder, - LLVMMetadataRef Scope, +extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateNameSpace( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef Scope, const char* Name, - LLVMMetadataRef File, + LLVMRustMetadataRef File, unsigned LineNo) { return wrap(Builder->createNameSpace( @@ -680,22 +721,22 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateNameSpace( LineNo)); } -extern "C" void LLVMDICompositeTypeSetTypeArray( - DIBuilderRef Builder, - LLVMMetadataRef CompositeType, - LLVMMetadataRef TypeArray) +extern "C" void LLVMRustDICompositeTypeSetTypeArray( + LLVMRustDIBuilderRef Builder, + LLVMRustMetadataRef CompositeType, + LLVMRustMetadataRef TypeArray) { DICompositeType *tmp = unwrapDI(CompositeType); Builder->replaceArrays(tmp, DINodeArray(unwrap(TypeArray))); } -extern "C" LLVMValueRef LLVMDIBuilderCreateDebugLocation( +extern "C" LLVMValueRef LLVMRustDIBuilderCreateDebugLocation( LLVMContextRef Context, unsigned Line, unsigned Column, - LLVMMetadataRef Scope, - LLVMMetadataRef InlinedAt) { - + LLVMRustMetadataRef Scope, + LLVMRustMetadataRef InlinedAt) +{ LLVMContext& context = *unwrap(Context); DebugLoc debug_loc = DebugLoc::get(Line, @@ -706,12 +747,22 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateDebugLocation( return wrap(MetadataAsValue::get(context, debug_loc.getAsMDNode())); } -extern "C" void LLVMWriteTypeToString(LLVMTypeRef Type, RustStringRef str) { +extern "C" int64_t LLVMRustDIBuilderCreateOpDeref() +{ + return dwarf::DW_OP_deref; +} + +extern "C" int64_t LLVMRustDIBuilderCreateOpPlus() +{ + return dwarf::DW_OP_plus; +} + +extern "C" void LLVMRustWriteTypeToString(LLVMTypeRef Type, RustStringRef str) { raw_rust_string_ostream os(str); unwrap(Type)->print(os); } -extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) { +extern "C" void LLVMRustWriteValueToString(LLVMValueRef Value, RustStringRef str) { raw_rust_string_ostream os(str); os << "("; unwrap(Value)->getType()->print(os); @@ -746,11 +797,33 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { return true; } +enum class LLVMRustDLLStorageClassTypes { + Other, + Default, + DllImport, + DllExport, +}; + +static GlobalValue::DLLStorageClassTypes +from_rust(LLVMRustDLLStorageClassTypes Class) +{ + switch (Class) { + case LLVMRustDLLStorageClassTypes::Default: + return GlobalValue::DefaultStorageClass; + case LLVMRustDLLStorageClassTypes::DllImport: + return GlobalValue::DLLImportStorageClass; + case LLVMRustDLLStorageClassTypes::DllExport: + return GlobalValue::DLLExportStorageClass; + default: + abort(); + } +} + extern "C" void LLVMRustSetDLLStorageClass(LLVMValueRef Value, - GlobalValue::DLLStorageClassTypes Class) { + LLVMRustDLLStorageClassTypes Class) { GlobalValue *V = unwrap(Value); - V->setDLLStorageClass(Class); + V->setDLLStorageClass(from_rust(Class)); } // Note that the two following functions look quite similar to the @@ -768,7 +841,7 @@ inline section_iterator *unwrap(LLVMSectionIteratorRef SI) { return reinterpret_cast(SI); } -extern "C" int +extern "C" size_t LLVMRustGetSectionName(LLVMSectionIteratorRef SI, const char **ptr) { StringRef ret; if (std::error_code ec = (*unwrap(SI))->getName(ret)) @@ -787,13 +860,13 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Twine, LLVMTwineRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DebugLoc, LLVMDebugLocRef) extern "C" void -LLVMWriteTwineToString(LLVMTwineRef T, RustStringRef str) { +LLVMRustWriteTwineToString(LLVMTwineRef T, RustStringRef str) { raw_rust_string_ostream os(str); unwrap(T)->print(os); } extern "C" void -LLVMUnpackOptimizationDiagnostic( +LLVMRustUnpackOptimizationDiagnostic( LLVMDiagnosticInfoRef di, const char **pass_name_out, LLVMValueRef *function_out, @@ -811,7 +884,7 @@ LLVMUnpackOptimizationDiagnostic( } extern "C" void -LLVMUnpackInlineAsmDiagnostic( +LLVMRustUnpackInlineAsmDiagnostic( LLVMDiagnosticInfoRef di, unsigned *cookie_out, LLVMTwineRef *message_out, @@ -826,17 +899,68 @@ LLVMUnpackInlineAsmDiagnostic( *instruction_out = wrap(ia->getInstruction()); } -extern "C" void LLVMWriteDiagnosticInfoToString(LLVMDiagnosticInfoRef di, RustStringRef str) { +extern "C" void LLVMRustWriteDiagnosticInfoToString(LLVMDiagnosticInfoRef di, RustStringRef str) { raw_rust_string_ostream os(str); DiagnosticPrinterRawOStream dp(os); unwrap(di)->print(dp); } -extern "C" int LLVMGetDiagInfoKind(LLVMDiagnosticInfoRef di) { - return unwrap(di)->getKind(); +enum class LLVMRustDiagnosticKind { + Other, + InlineAsm, + StackSize, + DebugMetadataVersion, + SampleProfile, + OptimizationRemark, + OptimizationRemarkMissed, + OptimizationRemarkAnalysis, + OptimizationRemarkAnalysisFPCommute, + OptimizationRemarkAnalysisAliasing, + OptimizationRemarkOther, + OptimizationFailure, +}; + +static LLVMRustDiagnosticKind +to_rust(DiagnosticKind kind) +{ + switch (kind) { + case DK_InlineAsm: + return LLVMRustDiagnosticKind::InlineAsm; + case DK_StackSize: + return LLVMRustDiagnosticKind::StackSize; + case DK_DebugMetadataVersion: + return LLVMRustDiagnosticKind::DebugMetadataVersion; + case DK_SampleProfile: + return LLVMRustDiagnosticKind::SampleProfile; + case DK_OptimizationRemark: + return LLVMRustDiagnosticKind::OptimizationRemark; + case DK_OptimizationRemarkMissed: + return LLVMRustDiagnosticKind::OptimizationRemarkMissed; + case DK_OptimizationRemarkAnalysis: + return LLVMRustDiagnosticKind::OptimizationRemarkAnalysis; +#if LLVM_VERSION_MINOR >= 8 + case DK_OptimizationRemarkAnalysisFPCommute: + return LLVMRustDiagnosticKind::OptimizationRemarkAnalysisFPCommute; + case DK_OptimizationRemarkAnalysisAliasing: + return LLVMRustDiagnosticKind::OptimizationRemarkAnalysisAliasing; +#endif + default: +#if LLVM_VERSION_MINOR >= 9 + return (kind >= DK_FirstRemark && kind <= DK_LastRemark) ? + LLVMRustDiagnosticKind::OptimizationRemarkOther : + LLVMRustDiagnosticKind::Other; +#else + return LLVMRustDiagnosticKind::Other; +#endif + } +} + + +extern "C" LLVMRustDiagnosticKind LLVMRustGetDiagInfoKind(LLVMDiagnosticInfoRef di) { + return to_rust((DiagnosticKind) unwrap(di)->getKind()); } -extern "C" void LLVMWriteDebugLocToString( +extern "C" void LLVMRustWriteDebugLocToString( LLVMContextRef C, LLVMDebugLocRef dl, RustStringRef str) @@ -847,7 +971,8 @@ extern "C" void LLVMWriteDebugLocToString( DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef) -extern "C" void LLVMSetInlineAsmDiagnosticHandler( +// FIXME(type-audit): assume this function-pointer type does not change +extern "C" void LLVMRustSetInlineAsmDiagnosticHandler( LLVMContextRef C, LLVMContext::InlineAsmDiagHandlerTy H, void *CX) @@ -855,7 +980,8 @@ extern "C" void LLVMSetInlineAsmDiagnosticHandler( unwrap(C)->setInlineAsmDiagnosticHandler(H, CX); } -extern "C" void LLVMWriteSMDiagnosticToString(LLVMSMDiagnosticRef d, RustStringRef str) { +extern "C" void LLVMRustWriteSMDiagnosticToString(LLVMSMDiagnosticRef d, + RustStringRef str) { raw_rust_string_ostream os(str); unwrap(d)->print("", os); } @@ -902,6 +1028,8 @@ LLVMRustBuildCleanupRet(LLVMBuilderRef Builder, #endif } +// FIXME: to here. + extern "C" LLVMValueRef LLVMRustBuildCatchPad(LLVMBuilderRef Builder, LLVMValueRef ParentPad, -- cgit 1.4.1-3-g733a5 From 3041a97b1acef4f8549d9e297db8deaf571341f2 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 3 Aug 2016 00:25:19 +0300 Subject: finish type-auditing rustllvm --- src/librustc_llvm/ffi.rs | 71 +++++++++++----------- src/librustc_llvm/lib.rs | 114 +++++++++++++++++++++++------------- src/librustc_trans/abi.rs | 8 +-- src/librustc_trans/asm.rs | 4 +- src/librustc_trans/attributes.rs | 62 +++++++------------- src/librustc_trans/base.rs | 8 +-- src/librustc_trans/builder.rs | 2 +- src/librustc_trans/closure.rs | 12 ++-- src/librustc_trans/common.rs | 2 +- src/librustc_trans/consts.rs | 16 ++--- src/librustc_trans/debuginfo/gdb.rs | 2 +- src/librustc_trans/declare.rs | 13 ++-- src/librustc_trans/mir/constant.rs | 4 +- src/librustc_trans/monomorphize.rs | 4 +- src/librustc_trans/trans_item.rs | 6 +- src/librustc_trans/type_.rs | 2 +- src/rustllvm/ArchiveWrapper.cpp | 2 +- src/rustllvm/PassWrapper.cpp | 6 +- src/rustllvm/RustWrapper.cpp | 102 ++++++++++++++++++++------------ 19 files changed, 246 insertions(+), 194 deletions(-) (limited to 'src/rustllvm/RustWrapper.cpp') diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index 53a287ea8ec..6301c57c555 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -13,19 +13,20 @@ use debuginfo::{DIBuilderRef, DIDescriptor, DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable, DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator, DINameSpace}; -use RustStringRef; -use libc::{c_uint, c_ushort, c_int, size_t, c_char}; +use libc::{c_uint, c_int, size_t, c_char}; use libc::{c_longlong, c_ulonglong, c_void}; +use RustStringRef; + pub type Opcode = u32; pub type Bool = c_uint; pub const True: Bool = 1 as Bool; pub const False: Bool = 0 as Bool; -#[repr(C)] #[derive(Copy, Clone, PartialEq)] +#[repr(C)] pub enum LLVMRustResult { Success, Failure, @@ -68,8 +69,8 @@ pub enum Linkage { } /// LLVMDiagnosticSeverity -#[repr(C)] #[derive(Copy, Clone, Debug)] +#[repr(C)] pub enum DiagnosticSeverity { Error = 0, Warning = 1, @@ -77,14 +78,13 @@ pub enum DiagnosticSeverity { Note = 3, } -/// LLVMRustDLLStorageClassTypes -#[repr(C)] +/// LLVMDLLStorageClass #[derive(Copy, Clone)] -pub enum DLLStorageClassTypes { - Other, - Default, - DllImport, - DllExport, +#[repr(C)] +pub enum DLLStorageClass { + Default = 0, + DllImport = 1, /* Function to be imported from DLL. */ + DllExport = 2, /* Function to be accessible from DLL. */ } bitflags! { @@ -144,6 +144,7 @@ bitflags! { /// LLVMIntPredicate #[derive(Copy, Clone)] +#[repr(C)] pub enum IntPredicate { IntEQ = 32, IntNE = 33, @@ -159,6 +160,7 @@ pub enum IntPredicate { /// LLVMRealPredicate #[derive(Copy, Clone)] +#[repr(C)] pub enum RealPredicate { RealPredicateFalse = 0, RealOEQ = 1, @@ -178,7 +180,7 @@ pub enum RealPredicate { RealPredicateTrue = 15, } -/// LLVMTypeKind; FIXME: wrap +/// LLVMTypeKind #[derive(Copy, Clone, PartialEq, Debug)] #[repr(C)] pub enum TypeKind { @@ -198,11 +200,12 @@ pub enum TypeKind { Vector = 13, Metadata = 14, X86_MMX = 15, + Token = 16, } /// LLVMAtomicRmwBinOp -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub enum AtomicRmwBinOp { AtomicXchg = 0, AtomicAdd = 1, @@ -218,8 +221,8 @@ pub enum AtomicRmwBinOp { } /// LLVMAtomicOrdering -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub enum AtomicOrdering { NotAtomic = 0, Unordered = 1, @@ -232,8 +235,8 @@ pub enum AtomicOrdering { } /// LLVMRustSynchronizationScope -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub enum SynchronizationScope { Other, SingleThread, @@ -241,16 +244,18 @@ pub enum SynchronizationScope { } /// LLVMRustFileType -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub enum FileType { Other, AssemblyFile, ObjectFile, } -/// FIXME: ? +/// Enum pinned in LLVMContext, used in +/// LLVMSetMetadata so ABI-stable. #[derive(Copy, Clone)] +#[repr(C)] pub enum MetadataType { MD_dbg = 0, MD_tbaa = 1, @@ -266,11 +271,13 @@ pub enum MetadataType { MD_nonnull = 11, } -/// FIXME: ? +/// LLVMRustAsmDialect #[derive(Copy, Clone)] +#[repr(C)] pub enum AsmDialect { - AD_ATT = 0, - AD_Intel = 1 + Other, + Att, + Intel, } /// LLVMRustCodeGenOptLevel @@ -295,8 +302,8 @@ pub enum RelocMode { } /// LLVMRustCodeModel -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub enum CodeModel { Other, Default, @@ -308,8 +315,8 @@ pub enum CodeModel { } /// LLVMRustDiagnosticKind -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub enum DiagnosticKind { Other, InlineAsm, @@ -326,8 +333,8 @@ pub enum DiagnosticKind { } /// LLVMRustArchiveKind -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub enum ArchiveKind { Other, K_GNU, @@ -335,6 +342,7 @@ pub enum ArchiveKind { K_BSD, K_COFF, } + /// LLVMRustPassKind #[derive(Copy, Clone, PartialEq, Debug)] #[repr(C)] @@ -519,7 +527,7 @@ extern { pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char); /// See llvm::LLVMTypeKind::getTypeID. - pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind; + pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind; /// See llvm::LLVMType::getContext. pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef; @@ -589,8 +597,6 @@ extern { pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char); pub fn LLVMDumpValue(Val: ValueRef); pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef); - pub fn LLVMHasMetadata(Val: ValueRef) -> c_int; - pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef; pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef); /* Operations on Uses */ @@ -608,9 +614,9 @@ extern { pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef; /* all zeroes */ pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef; - pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef) + pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef; - pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef) + pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef; /* only for isize/vector */ pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef; @@ -815,13 +821,15 @@ extern { pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef; pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool; pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint; - pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint); + pub fn LLVMSetLinkage(Global: ValueRef, Link: Linkage); pub fn LLVMGetSection(Global: ValueRef) -> *const c_char; pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char); pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint; pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint); pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint; pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint); + pub fn LLVMSetDLLStorageClass(V: ValueRef, + C: DLLStorageClass); /* Operations on global variables */ @@ -1685,7 +1693,7 @@ extern { Constraints: *const c_char, SideEffects: Bool, AlignStack: Bool, - Dialect: c_uint) + Dialect: AsmDialect) -> ValueRef; pub fn LLVMRustDebugMetadataVersion() -> u32; @@ -1990,9 +1998,6 @@ extern { pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef); pub fn LLVMRustDestroyArchive(AR: ArchiveRef); - pub fn LLVMRustSetDLLStorageClass(V: ValueRef, - C: DLLStorageClassTypes); - pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t; diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index f451b167196..6c4e1a54ea7 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -33,13 +33,11 @@ extern crate libc; #[macro_use] #[no_link] extern crate rustc_bitflags; -pub use self::AttributeSet::*; pub use self::IntPredicate::*; pub use self::RealPredicate::*; pub use self::TypeKind::*; pub use self::AtomicRmwBinOp::*; pub use self::MetadataType::*; -pub use self::AsmDialect::*; pub use self::CodeGenOptSize::*; pub use self::DiagnosticKind::*; pub use self::CallConv::*; @@ -50,7 +48,7 @@ use std::str::FromStr; use std::slice; use std::ffi::{CString, CStr}; use std::cell::RefCell; -use libc::{c_uint, c_ushort, c_char, size_t}; +use libc::{c_uint, c_char, size_t}; pub mod archive_ro; pub mod diagnostic; @@ -94,32 +92,64 @@ impl Attributes { self } - pub fn apply_llfn(&self, idx: usize, llfn: ValueRef) { + pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) { unsafe { - LLVMRustAddFunctionAttribute(llfn, idx as c_uint, self.regular.bits()); + self.regular.apply_llfn(idx, llfn); if self.dereferenceable_bytes != 0 { - LLVMRustAddDereferenceableAttr(llfn, idx as c_uint, - self.dereferenceable_bytes); + LLVMRustAddDereferenceableAttr( + llfn, + idx.as_uint(), + self.dereferenceable_bytes); } } } - pub fn apply_callsite(&self, idx: usize, callsite: ValueRef) { + pub fn apply_callsite(&self, idx: AttributePlace, callsite: ValueRef) { unsafe { - LLVMRustAddCallSiteAttribute(callsite, idx as c_uint, self.regular.bits()); + self.regular.apply_callsite(idx, callsite); if self.dereferenceable_bytes != 0 { - LLVMRustAddDereferenceableCallSiteAttr(callsite, idx as c_uint, - self.dereferenceable_bytes); + LLVMRustAddDereferenceableCallSiteAttr( + callsite, + idx.as_uint(), + self.dereferenceable_bytes); } } } } +pub fn AddFunctionAttrStringValue( + llfn: ValueRef, + idx: AttributePlace, + attr: &'static str, + value: &'static str +) { + unsafe { + LLVMRustAddFunctionAttrStringValue( + llfn, + idx.as_uint(), + attr.as_ptr() as *const _, + value.as_ptr() as *const _) + } +} + #[repr(C)] #[derive(Copy, Clone)] -pub enum AttributeSet { - ReturnIndex = 0, - FunctionIndex = !0 +pub enum AttributePlace { + Argument(u32), + Function, +} + +impl AttributePlace { + pub fn ReturnValue() -> Self { + AttributePlace::Argument(0) + } + + fn as_uint(self) -> c_uint { + match self { + AttributePlace::Function => !0, + AttributePlace::Argument(i) => i, + } + } } #[derive(Copy, Clone, PartialEq)] @@ -170,11 +200,6 @@ pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) { LLVMSetFunctionCallConv(fn_, cc as c_uint); } } -pub fn SetLinkage(global: ValueRef, link: Linkage) { - unsafe { - LLVMSetLinkage(global, link as c_uint); - } -} // Externally visible symbols that might appear in multiple translation units need to appear in // their own comdat section so that the duplicates can be discarded at link time. This can for @@ -194,12 +219,6 @@ pub fn UnsetComdat(val: ValueRef) { } } -pub fn SetDLLStorageClass(global: ValueRef, class: DLLStorageClassTypes) { - unsafe { - LLVMRustSetDLLStorageClass(global, class); - } -} - pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) { unsafe { LLVMSetUnnamedAddr(global, unnamed as Bool); @@ -212,29 +231,40 @@ pub fn set_thread_local(global: ValueRef, is_thread_local: bool) { } } -pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef { - unsafe { - LLVMConstICmp(pred as c_ushort, v1, v2) +impl Attribute { + pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) { + unsafe { + LLVMRustAddFunctionAttribute( + llfn, idx.as_uint(), self.bits()) + } } -} -pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef { - unsafe { - LLVMConstFCmp(pred as c_ushort, v1, v2) + + pub fn apply_callsite(&self, idx: AttributePlace, callsite: ValueRef) { + unsafe { + LLVMRustAddCallSiteAttribute( + callsite, idx.as_uint(), self.bits()) + } } -} -pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) { - unsafe { - LLVMRustAddFunctionAttribute(fn_, FunctionIndex as c_uint, - attr.bits() as u64) + pub fn unapply_llfn(&self, idx: AttributePlace, llfn: ValueRef) { + unsafe { + LLVMRustRemoveFunctionAttributes( + llfn, idx.as_uint(), self.bits()) + } } -} -pub fn RemoveFunctionAttributes(fn_: ValueRef, attr: Attribute) { - unsafe { - LLVMRustRemoveFunctionAttributes(fn_, FunctionIndex as c_uint, - attr.bits() as u64) + pub fn toggle_llfn(&self, + idx: AttributePlace, + llfn: ValueRef, + set: bool) + { + if set { + self.apply_llfn(idx, llfn); + } else { + self.unapply_llfn(idx, llfn); + } } + } /* Memory-managed interface to target data. */ diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index 6c2a09f8060..587c03af3ab 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -552,13 +552,13 @@ impl FnType { pub fn apply_attrs_llfn(&self, llfn: ValueRef) { let mut i = if self.ret.is_indirect() { 1 } else { 0 }; if !self.ret.is_ignore() { - self.ret.attrs.apply_llfn(i, llfn); + self.ret.attrs.apply_llfn(llvm::AttributePlace::Argument(i), llfn); } i += 1; for arg in &self.args { if !arg.is_ignore() { if arg.pad.is_some() { i += 1; } - arg.attrs.apply_llfn(i, llfn); + arg.attrs.apply_llfn(llvm::AttributePlace::Argument(i), llfn); i += 1; } } @@ -567,13 +567,13 @@ impl FnType { pub fn apply_attrs_callsite(&self, callsite: ValueRef) { let mut i = if self.ret.is_indirect() { 1 } else { 0 }; if !self.ret.is_ignore() { - self.ret.attrs.apply_callsite(i, callsite); + self.ret.attrs.apply_callsite(llvm::AttributePlace::Argument(i), callsite); } i += 1; for arg in &self.args { if !arg.is_ignore() { if arg.pad.is_some() { i += 1; } - arg.attrs.apply_callsite(i, callsite); + arg.attrs.apply_callsite(llvm::AttributePlace::Argument(i), callsite); i += 1; } } diff --git a/src/librustc_trans/asm.rs b/src/librustc_trans/asm.rs index e27bec68375..5514fb0f4ef 100644 --- a/src/librustc_trans/asm.rs +++ b/src/librustc_trans/asm.rs @@ -83,8 +83,8 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, }; let dialect = match ia.dialect { - AsmDialect::Att => llvm::AD_ATT, - AsmDialect::Intel => llvm::AD_Intel + AsmDialect::Att => llvm::AsmDialect::Att, + AsmDialect::Intel => llvm::AsmDialect::Intel, }; let asm = CString::new(ia.asm.as_bytes()).unwrap(); diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs index 9c121ae9bfc..62eac35e0ab 100644 --- a/src/librustc_trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -9,8 +9,8 @@ // except according to those terms. //! Set and unset common attributes on LLVM values. -use libc::c_uint; -use llvm::{self, ValueRef}; +use llvm::{self, Attribute, ValueRef}; +use llvm::AttributePlace::Function; pub use syntax::attr::InlineAttr; use syntax::ast; use context::CrateContext; @@ -20,14 +20,14 @@ use context::CrateContext; pub fn inline(val: ValueRef, inline: InlineAttr) { use self::InlineAttr::*; match inline { - Hint => llvm::SetFunctionAttribute(val, llvm::Attribute::InlineHint), - Always => llvm::SetFunctionAttribute(val, llvm::Attribute::AlwaysInline), - Never => llvm::SetFunctionAttribute(val, llvm::Attribute::NoInline), + Hint => Attribute::InlineHint.apply_llfn(Function, val), + Always => Attribute::AlwaysInline.apply_llfn(Function, val), + Never => Attribute::NoInline.apply_llfn(Function, val), None => { - let attr = llvm::Attribute::InlineHint | - llvm::Attribute::AlwaysInline | - llvm::Attribute::NoInline; - llvm::RemoveFunctionAttributes(val, attr) + let attr = Attribute::InlineHint | + Attribute::AlwaysInline | + Attribute::NoInline; + attr.unapply_llfn(Function, val) }, }; } @@ -35,56 +35,37 @@ pub fn inline(val: ValueRef, inline: InlineAttr) { /// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function. #[inline] pub fn emit_uwtable(val: ValueRef, emit: bool) { - if emit { - llvm::SetFunctionAttribute(val, llvm::Attribute::UWTable); - } else { - llvm::RemoveFunctionAttributes(val, llvm::Attribute::UWTable); - } + Attribute::UWTable.toggle_llfn(Function, val, emit); } /// Tell LLVM whether the function can or cannot unwind. #[inline] pub fn unwind(val: ValueRef, can_unwind: bool) { - if can_unwind { - llvm::RemoveFunctionAttributes(val, llvm::Attribute::NoUnwind); - } else { - llvm::SetFunctionAttribute(val, llvm::Attribute::NoUnwind); - } + Attribute::NoUnwind.toggle_llfn(Function, val, !can_unwind); } /// Tell LLVM whether it should optimise function for size. #[inline] #[allow(dead_code)] // possibly useful function pub fn set_optimize_for_size(val: ValueRef, optimize: bool) { - if optimize { - llvm::SetFunctionAttribute(val, llvm::Attribute::OptimizeForSize); - } else { - llvm::RemoveFunctionAttributes(val, llvm::Attribute::OptimizeForSize); - } + Attribute::OptimizeForSize.toggle_llfn(Function, val, optimize); } /// Tell LLVM if this function should be 'naked', i.e. skip the epilogue and prologue. #[inline] pub fn naked(val: ValueRef, is_naked: bool) { - if is_naked { - llvm::SetFunctionAttribute(val, llvm::Attribute::Naked); - } else { - llvm::RemoveFunctionAttributes(val, llvm::Attribute::Naked); - } + Attribute::Naked.toggle_llfn(Function, val, is_naked); } pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) { // FIXME: #11906: Omitting frame pointers breaks retrieving the value of a // parameter. if ccx.sess().must_not_eliminate_frame_pointers() { - unsafe { - let attr = "no-frame-pointer-elim\0".as_ptr() as *const _; - let val = "true\0".as_ptr() as *const _; - llvm::LLVMRustAddFunctionAttrStringValue(llfn, - llvm::FunctionIndex as c_uint, - attr, - val); - } + llvm::AddFunctionAttrStringValue( + llfn, + llvm::AttributePlace::Function, + "no-frame-pointer-elim\0", + "true\0") } } @@ -98,13 +79,12 @@ pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRe for attr in attrs { if attr.check_name("cold") { - llvm::Attributes::default().set(llvm::Attribute::Cold) - .apply_llfn(llvm::FunctionIndex as usize, llfn) + Attribute::Cold.apply_llfn(Function, llfn); } else if attr.check_name("naked") { naked(llfn, true); } else if attr.check_name("allocator") { - llvm::Attributes::default().set(llvm::Attribute::NoAlias) - .apply_llfn(llvm::ReturnIndex as usize, llfn) + Attribute::NoAlias.apply_llfn( + llvm::AttributePlace::ReturnValue(), llfn); } else if attr.check_name("unwind") { unwind(llfn, true); } diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 3e66f6de242..7fb19fefee2 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -2347,9 +2347,9 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session, let has_fixed_linkage = linkage_fixed_explicitly.contains(&name_cow); if !is_referenced_somewhere && !is_reachable && !has_fixed_linkage { - llvm::SetLinkage(val, llvm::InternalLinkage); - llvm::SetDLLStorageClass(val, - llvm::DLLStorageClassTypes::Default); + llvm::LLVMSetLinkage(val, llvm::InternalLinkage); + llvm::LLVMSetDLLStorageClass(val, + llvm::DLLStorageClass::Default); llvm::UnsetComdat(val); } } @@ -2394,7 +2394,7 @@ fn create_imps(cx: &CrateContextList) { imp_name.as_ptr() as *const _); let init = llvm::LLVMConstBitCast(val, i8p_ty.to_ref()); llvm::LLVMSetInitializer(imp, init); - llvm::SetLinkage(imp, llvm::ExternalLinkage); + llvm::LLVMSetLinkage(imp, llvm::ExternalLinkage); } } } diff --git a/src/librustc_trans/builder.rs b/src/librustc_trans/builder.rs index 28d69d4815f..90f96af5496 100644 --- a/src/librustc_trans/builder.rs +++ b/src/librustc_trans/builder.rs @@ -841,7 +841,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let fty = Type::func(&argtys[..], &output); unsafe { let v = llvm::LLVMRustInlineAsm( - fty.to_ref(), asm, cons, volatile, alignstack, dia as c_uint); + fty.to_ref(), asm, cons, volatile, alignstack, dia); self.call(v, inputs, None) } } diff --git a/src/librustc_trans/closure.rs b/src/librustc_trans/closure.rs index 6b9de4a4878..e53a5edfc66 100644 --- a/src/librustc_trans/closure.rs +++ b/src/librustc_trans/closure.rs @@ -249,11 +249,13 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>, if !ccx.instances().borrow().contains_key(&instance) { let llfn = get_or_create_closure_declaration(ccx, closure_def_id, closure_substs); - if ccx.sess().target.target.options.allows_weak_linkage { - llvm::SetLinkage(llfn, llvm::WeakODRLinkage); - llvm::SetUniqueComdat(ccx.llmod(), llfn); - } else { - llvm::SetLinkage(llfn, llvm::InternalLinkage); + unsafe { + if ccx.sess().target.target.options.allows_weak_linkage { + llvm::LLVMSetLinkage(llfn, llvm::WeakODRLinkage); + llvm::SetUniqueComdat(ccx.llmod(), llfn); + } else { + llvm::LLVMSetLinkage(llfn, llvm::InternalLinkage); + } } // set an inline hint for all closures diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 61d8a0837c1..a1783e9c0a3 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -980,7 +980,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va }); llvm::LLVMSetInitializer(g, sc); llvm::LLVMSetGlobalConstant(g, True); - llvm::SetLinkage(g, llvm::InternalLinkage); + llvm::LLVMSetLinkage(g, llvm::InternalLinkage); cx.const_cstr_cache().borrow_mut().insert(s, g); g diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 996efc9c113..7afb5257258 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -10,7 +10,7 @@ use llvm; -use llvm::{ConstFCmp, ConstICmp, SetLinkage, SetUnnamedAddr}; +use llvm::{SetUnnamedAddr}; use llvm::{InternalLinkage, ValueRef, Bool, True}; use middle::const_qualif::ConstQualif; use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, lookup_const_by_id, ErrKind}; @@ -125,7 +125,7 @@ pub fn addr_of_mut(ccx: &CrateContext, }); llvm::LLVMSetInitializer(gv, cv); llvm::LLVMSetAlignment(gv, align); - SetLinkage(gv, InternalLinkage); + llvm::LLVMSetLinkage(gv, InternalLinkage); SetUnnamedAddr(gv, true); gv } @@ -637,10 +637,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, hir::BiEq | hir::BiNe | hir::BiLt | hir::BiLe | hir::BiGt | hir::BiGe => { if is_float { let cmp = base::bin_op_to_fcmp_predicate(b.node); - ConstFCmp(cmp, te1, te2) + llvm::LLVMConstFCmp(cmp, te1, te2) } else { let cmp = base::bin_op_to_icmp_predicate(b.node, signed); - ConstICmp(cmp, te1, te2) + llvm::LLVMConstICmp(cmp, te1, te2) } }, } } // unsafe { match b.node { @@ -1072,7 +1072,7 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId) unsafe { // Declare a symbol `foo` with the desired linkage. let g1 = declare::declare_global(ccx, &sym, llty2); - llvm::SetLinkage(g1, linkage); + llvm::LLVMSetLinkage(g1, linkage); // Declare an internal global `extern_with_linkage_foo` which // is initialized with the address of `foo`. If `foo` is @@ -1086,7 +1086,7 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId) ccx.sess().span_fatal(span, &format!("symbol `{}` is already defined", &sym)) }); - llvm::SetLinkage(g2, llvm::InternalLinkage); + llvm::LLVMSetLinkage(g2, llvm::InternalLinkage); llvm::LLVMSetInitializer(g2, g1); g2 } @@ -1126,7 +1126,9 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId) } } if ccx.use_dll_storage_attrs() { - llvm::SetDLLStorageClass(g, llvm::DLLStorageClassTypes::DllImport); + unsafe { + llvm::LLVMSetDLLStorageClass(g, llvm::DLLStorageClass::DllImport); + } } g }; diff --git a/src/librustc_trans/debuginfo/gdb.rs b/src/librustc_trans/debuginfo/gdb.rs index cf312855d75..0a8d490dcd2 100644 --- a/src/librustc_trans/debuginfo/gdb.rs +++ b/src/librustc_trans/debuginfo/gdb.rs @@ -77,7 +77,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext) llvm::LLVMSetInitializer(section_var, C_bytes(ccx, section_contents)); llvm::LLVMSetGlobalConstant(section_var, llvm::True); llvm::LLVMSetUnnamedAddr(section_var, llvm::True); - llvm::SetLinkage(section_var, llvm::Linkage::LinkOnceODRLinkage); + llvm::LLVMSetLinkage(section_var, llvm::Linkage::LinkOnceODRLinkage); // This should make sure that the whole section is not larger than // the string it contains. Otherwise we get a warning from GDB. llvm::LLVMSetAlignment(section_var, 1); diff --git a/src/librustc_trans/declare.rs b/src/librustc_trans/declare.rs index 15d90504ee7..324e8697eca 100644 --- a/src/librustc_trans/declare.rs +++ b/src/librustc_trans/declare.rs @@ -20,6 +20,7 @@ //! * Use define_* family of methods when you might be defining the ValueRef. //! * When in doubt, define. use llvm::{self, ValueRef}; +use llvm::AttributePlace::Function; use rustc::ty; use abi::{Abi, FnType}; use attributes; @@ -65,16 +66,16 @@ fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: if ccx.tcx().sess.opts.cg.no_redzone .unwrap_or(ccx.tcx().sess.target.target.options.disable_redzone) { - llvm::SetFunctionAttribute(llfn, llvm::Attribute::NoRedZone) + llvm::Attribute::NoRedZone.apply_llfn(Function, llfn); } match ccx.tcx().sess.opts.cg.opt_level.as_ref().map(String::as_ref) { Some("s") => { - llvm::SetFunctionAttribute(llfn, llvm::Attribute::OptimizeForSize); + llvm::Attribute::OptimizeForSize.apply_llfn(Function, llfn); }, Some("z") => { - llvm::SetFunctionAttribute(llfn, llvm::Attribute::MinSize); - llvm::SetFunctionAttribute(llfn, llvm::Attribute::OptimizeForSize); + llvm::Attribute::MinSize.apply_llfn(Function, llfn); + llvm::Attribute::OptimizeForSize.apply_llfn(Function, llfn); }, _ => {}, } @@ -111,7 +112,7 @@ pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, let llfn = declare_raw_fn(ccx, name, fty.cconv, fty.llvm_type(ccx)); if sig.output == ty::FnDiverging { - llvm::SetFunctionAttribute(llfn, llvm::Attribute::NoReturn); + llvm::Attribute::NoReturn.apply_llfn(Function, llfn); } if abi != Abi::Rust && abi != Abi::RustCall { @@ -162,7 +163,7 @@ pub fn define_internal_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, fn_type: ty::Ty<'tcx>) -> ValueRef { let llfn = define_fn(ccx, name, fn_type); - llvm::SetLinkage(llfn, llvm::InternalLinkage); + unsafe { llvm::LLVMSetLinkage(llfn, llvm::InternalLinkage) }; llfn } diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index 8dc5e5f993f..00db19d2739 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -824,11 +824,11 @@ pub fn const_scalar_binop(op: mir::BinOp, mir::BinOp::Gt | mir::BinOp::Ge => { if is_float { let cmp = base::bin_op_to_fcmp_predicate(op.to_hir_binop()); - llvm::ConstFCmp(cmp, lhs, rhs) + llvm::LLVMConstFCmp(cmp, lhs, rhs) } else { let cmp = base::bin_op_to_icmp_predicate(op.to_hir_binop(), signed); - llvm::ConstICmp(cmp, lhs, rhs) + llvm::LLVMConstICmp(cmp, lhs, rhs) } } } diff --git a/src/librustc_trans/monomorphize.rs b/src/librustc_trans/monomorphize.rs index 96a05f11bfd..e9aacaa0f95 100644 --- a/src/librustc_trans/monomorphize.rs +++ b/src/librustc_trans/monomorphize.rs @@ -125,7 +125,9 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, if ccx.shared().translation_items().borrow().contains(&trans_item) { attributes::from_fn_attrs(ccx, attrs, lldecl); - llvm::SetLinkage(lldecl, llvm::ExternalLinkage); + unsafe { + llvm::LLVMSetLinkage(lldecl, llvm::ExternalLinkage); + } } else { // FIXME: #34151 // Normally, getting here would indicate a bug in trans::collector, diff --git a/src/librustc_trans/trans_item.rs b/src/librustc_trans/trans_item.rs index fc2758e50f2..35bb0481c8e 100644 --- a/src/librustc_trans/trans_item.rs +++ b/src/librustc_trans/trans_item.rs @@ -208,7 +208,7 @@ impl<'a, 'tcx> TransItem<'tcx> { &format!("symbol `{}` is already defined", symbol_name)) }); - llvm::SetLinkage(g, linkage); + unsafe { llvm::LLVMSetLinkage(g, linkage) }; } item => bug!("predefine_static: expected static, found {:?}", item) @@ -250,7 +250,7 @@ impl<'a, 'tcx> TransItem<'tcx> { ref attrs, node: hir::ImplItemKind::Method(..), .. }) => { let lldecl = declare::declare_fn(ccx, symbol_name, mono_ty); - llvm::SetLinkage(lldecl, linkage); + unsafe { llvm::LLVMSetLinkage(lldecl, linkage) }; base::set_link_section(ccx, lldecl, attrs); if linkage == llvm::LinkOnceODRLinkage || linkage == llvm::WeakODRLinkage { @@ -287,7 +287,7 @@ impl<'a, 'tcx> TransItem<'tcx> { assert!(declare::get_defined_value(ccx, symbol_name).is_none()); let llfn = declare::declare_cfn(ccx, symbol_name, llfnty); - llvm::SetLinkage(llfn, linkage); + unsafe { llvm::LLVMSetLinkage(llfn, linkage) }; if linkage == llvm::LinkOnceODRLinkage || linkage == llvm::WeakODRLinkage { llvm::SetUniqueComdat(ccx.llmod(), llfn); diff --git a/src/librustc_trans/type_.rs b/src/librustc_trans/type_.rs index c09515a5138..d191591e082 100644 --- a/src/librustc_trans/type_.rs +++ b/src/librustc_trans/type_.rs @@ -208,7 +208,7 @@ impl Type { pub fn kind(&self) -> TypeKind { unsafe { - llvm::LLVMGetTypeKind(self.to_ref()) + llvm::LLVMRustGetTypeKind(self.to_ref()) } } diff --git a/src/rustllvm/ArchiveWrapper.cpp b/src/rustllvm/ArchiveWrapper.cpp index 059cc40d511..1e873b5345c 100644 --- a/src/rustllvm/ArchiveWrapper.cpp +++ b/src/rustllvm/ArchiveWrapper.cpp @@ -61,7 +61,7 @@ from_rust(LLVMRustArchiveKind kind) case LLVMRustArchiveKind::COFF: return Archive::K_COFF; default: - abort(); + llvm_unreachable("Bad ArchiveKind."); } } diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 9e72724d8ab..e3dcf45cf0f 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -196,7 +196,7 @@ from_rust(LLVMRustCodeModel model) case LLVMRustCodeModel::Large: return CodeModel::Large; default: - abort(); + llvm_unreachable("Bad CodeModel."); } } @@ -221,7 +221,7 @@ from_rust(LLVMRustCodeGenOptLevel level) case LLVMRustCodeGenOptLevel::Aggressive: return CodeGenOpt::Aggressive; default: - abort(); + llvm_unreachable("Bad CodeGenOptLevel."); } } @@ -395,7 +395,7 @@ from_rust(LLVMRustFileType type) case LLVMRustFileType::ObjectFile: return TargetMachine::CGFT_ObjectFile; default: - abort(); + llvm_unreachable("Bad FileType."); } } diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index a9c31bc33e0..0da25e7ac57 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -263,7 +263,7 @@ from_rust(LLVMRustSynchronizationScope scope) case LLVMRustSynchronizationScope::CrossThread: return CrossThread; default: - abort(); + llvm_unreachable("bad SynchronizationScope."); } } @@ -281,15 +281,34 @@ extern "C" void LLVMRustSetDebug(int Enabled) { #endif } +enum class LLVMRustAsmDialect { + Other, + Att, + Intel, +}; + +static InlineAsm::AsmDialect +from_rust(LLVMRustAsmDialect dialect) +{ + switch (dialect) { + case LLVMRustAsmDialect::Att: + return InlineAsm::AD_ATT; + case LLVMRustAsmDialect::Intel: + return InlineAsm::AD_Intel; + default: + llvm_unreachable("bad AsmDialect."); + } +} + extern "C" LLVMValueRef LLVMRustInlineAsm(LLVMTypeRef Ty, char *AsmString, char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack, - unsigned Dialect) { + LLVMRustAsmDialect Dialect) { return wrap(InlineAsm::get(unwrap(Ty), AsmString, Constraints, HasSideEffects, - IsAlignStack, (InlineAsm::AsmDialect) Dialect)); + IsAlignStack, from_rust(Dialect))); } typedef DIBuilder* LLVMRustDIBuilderRef; @@ -797,35 +816,6 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { return true; } -enum class LLVMRustDLLStorageClassTypes { - Other, - Default, - DllImport, - DllExport, -}; - -static GlobalValue::DLLStorageClassTypes -from_rust(LLVMRustDLLStorageClassTypes Class) -{ - switch (Class) { - case LLVMRustDLLStorageClassTypes::Default: - return GlobalValue::DefaultStorageClass; - case LLVMRustDLLStorageClassTypes::DllImport: - return GlobalValue::DLLImportStorageClass; - case LLVMRustDLLStorageClassTypes::DllExport: - return GlobalValue::DLLExportStorageClass; - default: - abort(); - } -} - -extern "C" void -LLVMRustSetDLLStorageClass(LLVMValueRef Value, - LLVMRustDLLStorageClassTypes Class) { - GlobalValue *V = unwrap(Value); - V->setDLLStorageClass(from_rust(Class)); -} - // Note that the two following functions look quite similar to the // LLVMGetSectionName function. Sadly, it appears that this function only // returns a char* pointer, which isn't guaranteed to be null-terminated. The @@ -955,10 +945,53 @@ to_rust(DiagnosticKind kind) } } - extern "C" LLVMRustDiagnosticKind LLVMRustGetDiagInfoKind(LLVMDiagnosticInfoRef di) { return to_rust((DiagnosticKind) unwrap(di)->getKind()); } +// This is kept distinct from LLVMGetTypeKind, because when +// a new type kind is added, the Rust-side enum must be +// updated or UB will result. +extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) { + switch (unwrap(Ty)->getTypeID()) { + case Type::VoidTyID: + return LLVMVoidTypeKind; + case Type::HalfTyID: + return LLVMHalfTypeKind; + case Type::FloatTyID: + return LLVMFloatTypeKind; + case Type::DoubleTyID: + return LLVMDoubleTypeKind; + case Type::X86_FP80TyID: + return LLVMX86_FP80TypeKind; + case Type::FP128TyID: + return LLVMFP128TypeKind; + case Type::PPC_FP128TyID: + return LLVMPPC_FP128TypeKind; + case Type::LabelTyID: + return LLVMLabelTypeKind; + case Type::MetadataTyID: + return LLVMMetadataTypeKind; + case Type::IntegerTyID: + return LLVMIntegerTypeKind; + case Type::FunctionTyID: + return LLVMFunctionTypeKind; + case Type::StructTyID: + return LLVMStructTypeKind; + case Type::ArrayTyID: + return LLVMArrayTypeKind; + case Type::PointerTyID: + return LLVMPointerTypeKind; + case Type::VectorTyID: + return LLVMVectorTypeKind; + case Type::X86_MMXTyID: + return LLVMX86_MMXTypeKind; +#if LLVM_VERSION_MINOR >= 8 + case Type::TokenTyID: + return LLVMTokenTypeKind; +#endif + } + llvm_unreachable("Unhandled TypeID."); +} extern "C" void LLVMRustWriteDebugLocToString( LLVMContextRef C, @@ -971,7 +1004,6 @@ extern "C" void LLVMRustWriteDebugLocToString( DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef) -// FIXME(type-audit): assume this function-pointer type does not change extern "C" void LLVMRustSetInlineAsmDiagnosticHandler( LLVMContextRef C, LLVMContext::InlineAsmDiagHandlerTy H, @@ -1028,8 +1060,6 @@ LLVMRustBuildCleanupRet(LLVMBuilderRef Builder, #endif } -// FIXME: to here. - extern "C" LLVMValueRef LLVMRustBuildCatchPad(LLVMBuilderRef Builder, LLVMValueRef ParentPad, -- cgit 1.4.1-3-g733a5