Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d091ef8

Browse files
arielb1Ariel Ben-Yehuda
authored and
Ariel Ben-Yehuda
committedAug 3, 2016
begin auditing the C++ types in RustWrapper
1 parent 696691e commit d091ef8

20 files changed

+771
-602
lines changed
 

‎src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn run_compiler_with_file_loader<'a, L>(args: &[String],
186186
let sopts = config::build_session_options(&matches);
187187

188188
if sopts.debugging_opts.debug_llvm {
189-
unsafe { llvm::LLVMSetDebug(1); }
189+
unsafe { llvm::LLVMRustSetDebug(1); }
190190
}
191191

192192
let descriptions = diagnostics_registry();

‎src/librustc_llvm/diagnostic.rs

+38-17
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ pub enum OptimizationDiagnosticKind {
2323
OptimizationRemark,
2424
OptimizationMissed,
2525
OptimizationAnalysis,
26+
OptimizationAnalysisFPCommute,
27+
OptimizationAnalysisAliasing,
2628
OptimizationFailure,
29+
OptimizationRemarkOther,
2730
}
2831

2932
impl OptimizationDiagnosticKind {
3033
pub fn describe(self) -> &'static str {
3134
match self {
32-
OptimizationRemark => "remark",
35+
OptimizationRemark |
36+
OptimizationRemarkOther => "remark",
3337
OptimizationMissed => "missed",
3438
OptimizationAnalysis => "analysis",
39+
OptimizationAnalysisFPCommute => "floating-point",
40+
OptimizationAnalysisAliasing => "aliasing",
3541
OptimizationFailure => "failure",
3642
}
3743
}
@@ -58,11 +64,11 @@ impl OptimizationDiagnostic {
5864
message: ptr::null_mut(),
5965
};
6066

61-
super::LLVMUnpackOptimizationDiagnostic(di,
62-
&mut opt.pass_name,
63-
&mut opt.function,
64-
&mut opt.debug_loc,
65-
&mut opt.message);
67+
super::LLVMRustUnpackOptimizationDiagnostic(di,
68+
&mut opt.pass_name,
69+
&mut opt.function,
70+
&mut opt.debug_loc,
71+
&mut opt.message);
6672

6773
opt
6874
}
@@ -84,10 +90,10 @@ impl InlineAsmDiagnostic {
8490
instruction: ptr::null_mut(),
8591
};
8692

87-
super::LLVMUnpackInlineAsmDiagnostic(di,
88-
&mut opt.cookie,
89-
&mut opt.message,
90-
&mut opt.instruction);
93+
super::LLVMRustUnpackInlineAsmDiagnostic(di,
94+
&mut opt.cookie,
95+
&mut opt.message,
96+
&mut opt.instruction);
9197

9298
opt
9399
}
@@ -103,24 +109,39 @@ pub enum Diagnostic {
103109

104110
impl Diagnostic {
105111
pub unsafe fn unpack(di: DiagnosticInfoRef) -> Diagnostic {
106-
let kind = super::LLVMGetDiagInfoKind(di);
112+
use super::DiagnosticKind as Dk;
113+
let kind = super::LLVMRustGetDiagInfoKind(di);
107114

108115
match kind {
109-
super::DK_InlineAsm => InlineAsm(InlineAsmDiagnostic::unpack(di)),
116+
Dk::InlineAsm => InlineAsm(InlineAsmDiagnostic::unpack(di)),
110117

111-
super::DK_OptimizationRemark => {
118+
Dk::OptimizationRemark => {
112119
Optimization(OptimizationDiagnostic::unpack(OptimizationRemark, di))
113120
}
114-
115-
super::DK_OptimizationRemarkMissed => {
121+
Dk::OptimizationRemarkOther => {
122+
Optimization(OptimizationDiagnostic::unpack(OptimizationRemarkOther, di))
123+
}
124+
Dk::OptimizationRemarkMissed => {
116125
Optimization(OptimizationDiagnostic::unpack(OptimizationMissed, di))
117126
}
118127

119-
super::DK_OptimizationRemarkAnalysis => {
128+
Dk::OptimizationRemarkAnalysis => {
120129
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di))
121130
}
122131

123-
super::DK_OptimizationFailure => {
132+
133+
Dk::OptimizationRemarkAnalysisFPCommute => {
134+
Optimization(OptimizationDiagnostic::unpack(
135+
OptimizationAnalysisFPCommute, di))
136+
}
137+
138+
Dk::OptimizationRemarkAnalysisAliasing => {
139+
Optimization(OptimizationDiagnostic::unpack(
140+
OptimizationAnalysisAliasing, di))
141+
}
142+
143+
144+
Dk::OptimizationFailure => {
124145
Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di))
125146
}
126147

‎src/librustc_llvm/lib.rs

+322-306
Large diffs are not rendered by default.

‎src/librustc_trans/attributes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) {
8080
unsafe {
8181
let attr = "no-frame-pointer-elim\0".as_ptr() as *const _;
8282
let val = "true\0".as_ptr() as *const _;
83-
llvm::LLVMAddFunctionAttrStringValue(llfn,
84-
llvm::FunctionIndex as c_uint,
85-
attr,
86-
val);
83+
llvm::LLVMRustAddFunctionAttrStringValue(llfn,
84+
llvm::FunctionIndex as c_uint,
85+
attr,
86+
val);
8787
}
8888
}
8989
}

‎src/librustc_trans/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ unsafe extern "C" fn inline_asm_handler(diag: SMDiagnosticRef,
365365
cookie: c_uint) {
366366
let HandlerFreeVars { cgcx, .. } = *(user as *const HandlerFreeVars);
367367

368-
let msg = llvm::build_string(|s| llvm::LLVMWriteSMDiagnosticToString(diag, s))
368+
let msg = llvm::build_string(|s| llvm::LLVMRustWriteSMDiagnosticToString(diag, s))
369369
.expect("non-UTF8 SMDiagnostic");
370370

371371
report_inline_asm(cgcx, &msg[..], cookie);
@@ -421,7 +421,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
421421
};
422422
let fv = &fv as *const HandlerFreeVars as *mut c_void;
423423

424-
llvm::LLVMSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, fv);
424+
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, fv);
425425
llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, fv);
426426

427427
let module_name = Some(&mtrans.name[..]);

‎src/librustc_trans/base.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,8 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session,
23482348

23492349
if !is_referenced_somewhere && !is_reachable && !has_fixed_linkage {
23502350
llvm::SetLinkage(val, llvm::InternalLinkage);
2351-
llvm::SetDLLStorageClass(val, llvm::DefaultStorageClass);
2351+
llvm::SetDLLStorageClass(val,
2352+
llvm::DLLStorageClassTypes::Default);
23522353
llvm::UnsetComdat(val);
23532354
}
23542355
}

‎src/librustc_trans/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
503503
unsafe {
504504
let ty = Type::from_ref(llvm::LLVMTypeOf(ptr));
505505
let align = llalign_of_pref(self.ccx, ty.element_type());
506-
llvm::LLVMBuildAtomicLoad(self.llbuilder, ptr, noname(), order,
507-
align as c_uint)
506+
llvm::LLVMRustBuildAtomicLoad(self.llbuilder, ptr, noname(), order,
507+
align as c_uint)
508508
}
509509
}
510510

@@ -565,7 +565,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
565565
unsafe {
566566
let ty = Type::from_ref(llvm::LLVMTypeOf(ptr));
567567
let align = llalign_of_pref(self.ccx, ty.element_type());
568-
llvm::LLVMBuildAtomicStore(self.llbuilder, val, ptr, order, align as c_uint);
568+
llvm::LLVMRustBuildAtomicStore(self.llbuilder, val, ptr, order, align as c_uint);
569569
}
570570
}
571571

@@ -840,7 +840,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
840840
debug!("Asm Output Type: {:?}", output);
841841
let fty = Type::func(&argtys[..], &output);
842842
unsafe {
843-
let v = llvm::LLVMInlineAsm(
843+
let v = llvm::LLVMRustInlineAsm(
844844
fty.to_ref(), asm, cons, volatile, alignstack, dia as c_uint);
845845
self.call(v, inputs, None)
846846
}
@@ -1097,7 +1097,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10971097

10981098
pub fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope) {
10991099
unsafe {
1100-
llvm::LLVMBuildAtomicFence(self.llbuilder, order, scope);
1100+
llvm::LLVMRustBuildAtomicFence(self.llbuilder, order, scope);
11011101
}
11021102
}
11031103
}

‎src/librustc_trans/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId)
11261126
}
11271127
}
11281128
if ccx.use_dll_storage_attrs() {
1129-
llvm::SetDLLStorageClass(g, llvm::DLLImportStorageClass);
1129+
llvm::SetDLLStorageClass(g, llvm::DLLStorageClassTypes::DllImport);
11301130
}
11311131
g
11321132
};
@@ -1182,7 +1182,7 @@ pub fn trans_static(ccx: &CrateContext,
11821182
let name_str_ref = CStr::from_ptr(llvm::LLVMGetValueName(datum.val));
11831183
let name_string = CString::new(name_str_ref.to_bytes()).unwrap();
11841184
llvm::LLVMSetValueName(datum.val, empty_string.as_ptr());
1185-
let new_g = llvm::LLVMGetOrInsertGlobal(
1185+
let new_g = llvm::LLVMRustGetOrInsertGlobal(
11861186
ccx.llmod(), name_string.as_ptr(), val_llty.to_ref());
11871187
// To avoid breaking any invariants, we leave around the old
11881188
// global for the moment; we'll replace all references to it

‎src/librustc_trans/debuginfo/create_scope_map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn make_mir_scope(ccx: &CrateContext,
133133
let loc = span_start(ccx, scope_data.span);
134134
scopes[scope] = unsafe {
135135
let file_metadata = file_metadata(ccx, &loc.file.name, &loc.file.abs_path);
136-
llvm::LLVMDIBuilderCreateLexicalBlock(
136+
llvm::LLVMRustDIBuilderCreateLexicalBlock(
137137
DIB(ccx),
138138
parent_scope,
139139
file_metadata,
@@ -156,7 +156,7 @@ fn with_new_scope<F>(cx: &CrateContext,
156156
let parent_scope = scope_stack.last().unwrap().scope_metadata;
157157

158158
let scope_metadata = unsafe {
159-
llvm::LLVMDIBuilderCreateLexicalBlock(
159+
llvm::LLVMRustDIBuilderCreateLexicalBlock(
160160
DIB(cx),
161161
parent_scope,
162162
file_metadata,
@@ -272,7 +272,7 @@ fn walk_pattern(cx: &CrateContext,
272272
let parent_scope = scope_stack.last().unwrap().scope_metadata;
273273

274274
let scope_metadata = unsafe {
275-
llvm::LLVMDIBuilderCreateLexicalBlock(
275+
llvm::LLVMRustDIBuilderCreateLexicalBlock(
276276
DIB(cx),
277277
parent_scope,
278278
file_metadata,

‎src/librustc_trans/debuginfo/metadata.rs

+34-33
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,12 @@ fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
504504
};
505505

506506
let subrange = unsafe {
507-
llvm::LLVMDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)
507+
llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)
508508
};
509509

510510
let subscripts = create_DIArray(DIB(cx), &[subrange]);
511511
let metadata = unsafe {
512-
llvm::LLVMDIBuilderCreateArrayType(
512+
llvm::LLVMRustDIBuilderCreateArrayType(
513513
DIB(cx),
514514
bytes_to_bits(array_size_in_bytes),
515515
bytes_to_bits(element_type_align),
@@ -612,7 +612,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
612612

613613
return MetadataCreationResult::new(
614614
unsafe {
615-
llvm::LLVMDIBuilderCreateSubroutineType(
615+
llvm::LLVMRustDIBuilderCreateSubroutineType(
616616
DIB(cx),
617617
unknown_file_metadata(cx),
618618
create_DIArray(DIB(cx), &signature_metadata[..]))
@@ -885,8 +885,8 @@ fn file_metadata_(cx: &CrateContext, key: &str, file_name: &str, work_dir: &str)
885885
let file_name = CString::new(file_name).unwrap();
886886
let work_dir = CString::new(work_dir).unwrap();
887887
let file_metadata = unsafe {
888-
llvm::LLVMDIBuilderCreateFile(DIB(cx), file_name.as_ptr(),
889-
work_dir.as_ptr())
888+
llvm::LLVMRustDIBuilderCreateFile(DIB(cx), file_name.as_ptr(),
889+
work_dir.as_ptr())
890890
};
891891

892892
let mut created_files = debug_context(cx).created_files.borrow_mut();
@@ -916,7 +916,7 @@ pub fn scope_metadata(fcx: &FunctionContext,
916916

917917
pub fn diverging_type_metadata(cx: &CrateContext) -> DIType {
918918
unsafe {
919-
llvm::LLVMDIBuilderCreateBasicType(
919+
llvm::LLVMRustDIBuilderCreateBasicType(
920920
DIB(cx),
921921
"!\0".as_ptr() as *const _,
922922
bytes_to_bits(0),
@@ -951,7 +951,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
951951
let (size, align) = size_and_align_of(cx, llvm_type);
952952
let name = CString::new(name).unwrap();
953953
let ty_metadata = unsafe {
954-
llvm::LLVMDIBuilderCreateBasicType(
954+
llvm::LLVMRustDIBuilderCreateBasicType(
955955
DIB(cx),
956956
name.as_ptr(),
957957
bytes_to_bits(size),
@@ -971,7 +971,7 @@ fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
971971
let name = compute_debuginfo_type_name(cx, pointer_type, false);
972972
let name = CString::new(name).unwrap();
973973
let ptr_metadata = unsafe {
974-
llvm::LLVMDIBuilderCreatePointerType(
974+
llvm::LLVMRustDIBuilderCreatePointerType(
975975
DIB(cx),
976976
pointee_type_metadata,
977977
bytes_to_bits(pointer_size),
@@ -1017,7 +1017,7 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext,
10171017
let flags = "\0";
10181018
let split_name = "\0";
10191019
return unsafe {
1020-
llvm::LLVMDIBuilderCreateCompileUnit(
1020+
llvm::LLVMRustDIBuilderCreateCompileUnit(
10211021
debug_context.builder,
10221022
DW_LANG_RUST,
10231023
compile_unit_name,
@@ -1596,7 +1596,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
15961596
let token = v.name.as_str();
15971597
let name = CString::new(token.as_bytes()).unwrap();
15981598
unsafe {
1599-
llvm::LLVMDIBuilderCreateEnumerator(
1599+
llvm::LLVMRustDIBuilderCreateEnumerator(
16001600
DIB(cx),
16011601
name.as_ptr(),
16021602
v.disr_val.to_u64_unchecked())
@@ -1623,7 +1623,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
16231623

16241624
let name = CString::new(discriminant_name.as_bytes()).unwrap();
16251625
let discriminant_type_metadata = unsafe {
1626-
llvm::LLVMDIBuilderCreateEnumerationType(
1626+
llvm::LLVMRustDIBuilderCreateEnumerationType(
16271627
DIB(cx),
16281628
containing_scope,
16291629
name.as_ptr(),
@@ -1667,7 +1667,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
16671667
let enum_name = CString::new(enum_name).unwrap();
16681668
let unique_type_id_str = CString::new(unique_type_id_str.as_bytes()).unwrap();
16691669
let enum_metadata = unsafe {
1670-
llvm::LLVMDIBuilderCreateUnionType(
1670+
llvm::LLVMRustDIBuilderCreateUnionType(
16711671
DIB(cx),
16721672
containing_scope,
16731673
enum_name.as_ptr(),
@@ -1769,7 +1769,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
17691769
let member_name = member_description.name.as_bytes();
17701770
let member_name = CString::new(member_name).unwrap();
17711771
unsafe {
1772-
llvm::LLVMDIBuilderCreateMemberType(
1772+
llvm::LLVMRustDIBuilderCreateMemberType(
17731773
DIB(cx),
17741774
composite_type_metadata,
17751775
member_name.as_ptr(),
@@ -1786,13 +1786,14 @@ fn set_members_of_composite_type(cx: &CrateContext,
17861786

17871787
unsafe {
17881788
let type_array = create_DIArray(DIB(cx), &member_metadata[..]);
1789-
llvm::LLVMDICompositeTypeSetTypeArray(DIB(cx), composite_type_metadata, type_array);
1789+
llvm::LLVMRustDICompositeTypeSetTypeArray(
1790+
DIB(cx), composite_type_metadata, type_array);
17901791
}
17911792
}
17921793

1793-
// A convenience wrapper around LLVMDIBuilderCreateStructType(). Does not do any
1794-
// caching, does not add any fields to the struct. This can be done later with
1795-
// set_members_of_composite_type().
1794+
// A convenience wrapper around LLVMRustDIBuilderCreateStructType(). Does not do
1795+
// any caching, does not add any fields to the struct. This can be done later
1796+
// with set_members_of_composite_type().
17961797
fn create_struct_stub(cx: &CrateContext,
17971798
struct_llvm_type: Type,
17981799
struct_type_name: &str,
@@ -1807,12 +1808,12 @@ fn create_struct_stub(cx: &CrateContext,
18071808
let name = CString::new(struct_type_name).unwrap();
18081809
let unique_type_id = CString::new(unique_type_id_str.as_bytes()).unwrap();
18091810
let metadata_stub = unsafe {
1810-
// LLVMDIBuilderCreateStructType() wants an empty array. A null
1811+
// LLVMRustDIBuilderCreateStructType() wants an empty array. A null
18111812
// pointer will lead to hard to trace and debug LLVM assertions
18121813
// later on in llvm/lib/IR/Value.cpp.
18131814
let empty_array = create_DIArray(DIB(cx), &[]);
18141815

1815-
llvm::LLVMDIBuilderCreateStructType(
1816+
llvm::LLVMRustDIBuilderCreateStructType(
18161817
DIB(cx),
18171818
containing_scope,
18181819
name.as_ptr(),
@@ -1868,16 +1869,16 @@ pub fn create_global_var_metadata(cx: &CrateContext,
18681869
let var_name = CString::new(var_name).unwrap();
18691870
let linkage_name = CString::new(linkage_name).unwrap();
18701871
unsafe {
1871-
llvm::LLVMDIBuilderCreateStaticVariable(DIB(cx),
1872-
var_scope,
1873-
var_name.as_ptr(),
1874-
linkage_name.as_ptr(),
1875-
file_metadata,
1876-
line_number,
1877-
type_metadata,
1878-
is_local_to_unit,
1879-
global,
1880-
ptr::null_mut());
1872+
llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx),
1873+
var_scope,
1874+
var_name.as_ptr(),
1875+
linkage_name.as_ptr(),
1876+
file_metadata,
1877+
line_number,
1878+
type_metadata,
1879+
is_local_to_unit,
1880+
global,
1881+
ptr::null_mut());
18811882
}
18821883
}
18831884

@@ -1980,10 +1981,10 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
19801981
env_index);
19811982

19821983
let address_operations = unsafe {
1983-
[llvm::LLVMDIBuilderCreateOpDeref(),
1984-
llvm::LLVMDIBuilderCreateOpPlus(),
1984+
[llvm::LLVMRustDIBuilderCreateOpDeref(),
1985+
llvm::LLVMRustDIBuilderCreateOpPlus(),
19851986
byte_offset_of_var_in_env as i64,
1986-
llvm::LLVMDIBuilderCreateOpDeref()]
1987+
llvm::LLVMRustDIBuilderCreateOpDeref()]
19871988
};
19881989

19891990
let address_op_count = if captured_by_ref {
@@ -2021,7 +2022,7 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
20212022

20222023
let scope_metadata = scope_metadata(bcx.fcx, binding.id, binding.span);
20232024
let aops = unsafe {
2024-
[llvm::LLVMDIBuilderCreateOpDeref()]
2025+
[llvm::LLVMRustDIBuilderCreateOpDeref()]
20252026
};
20262027
// Regardless of the actual type (`T`) we're always passed the stack slot
20272028
// (alloca) for the binding. For ByRef bindings that's a `T*` but for ByMove

‎src/librustc_trans/debuginfo/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub struct CrateDebugContext<'tcx> {
8888
impl<'tcx> CrateDebugContext<'tcx> {
8989
pub fn new(llmod: ModuleRef) -> CrateDebugContext<'tcx> {
9090
debug!("CrateDebugContext::new");
91-
let builder = unsafe { llvm::LLVMDIBuilderCreate(llmod) };
91+
let builder = unsafe { llvm::LLVMRustDIBuilderCreate(llmod) };
9292
// DIBuilder inherits context from the module, so we'd better use the same one
9393
let llcontext = unsafe { llvm::LLVMGetModuleContext(llmod) };
9494
return CrateDebugContext {
@@ -178,8 +178,8 @@ pub fn finalize(cx: &CrateContext) {
178178
}
179179

180180
unsafe {
181-
llvm::LLVMDIBuilderFinalize(DIB(cx));
182-
llvm::LLVMDIBuilderDispose(DIB(cx));
181+
llvm::LLVMRustDIBuilderFinalize(DIB(cx));
182+
llvm::LLVMRustDIBuilderDispose(DIB(cx));
183183
// Debuginfo generation in LLVM by default uses a higher
184184
// version of dwarf than OS X currently understands. We can
185185
// 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>,
250250

251251
let function_type_metadata = unsafe {
252252
let fn_signature = get_function_signature(cx, sig, abi);
253-
llvm::LLVMDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature)
253+
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature)
254254
};
255255

256256
// 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>,
284284
let linkage_name = CString::new(linkage_name).unwrap();
285285

286286
let fn_metadata = unsafe {
287-
llvm::LLVMDIBuilderCreateFunction(
287+
llvm::LLVMRustDIBuilderCreateFunction(
288288
DIB(cx),
289289
containing_scope,
290290
function_name.as_ptr(),
@@ -388,7 +388,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
388388
let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP);
389389
let name = CString::new(param.name.as_str().as_bytes()).unwrap();
390390
unsafe {
391-
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
391+
llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
392392
DIB(cx),
393393
ptr::null_mut(),
394394
name.as_ptr(),
@@ -492,7 +492,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
492492
(DirectVariable { alloca }, address_operations) |
493493
(IndirectVariable {alloca, address_operations}, _) => {
494494
let metadata = unsafe {
495-
llvm::LLVMDIBuilderCreateVariable(
495+
llvm::LLVMRustDIBuilderCreateVariable(
496496
DIB(cx),
497497
dwarf_tag,
498498
scope_metadata,
@@ -510,7 +510,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
510510
InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize()));
511511
unsafe {
512512
let debug_loc = llvm::LLVMGetCurrentDebugLocation(cx.raw_builder());
513-
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
513+
let instr = llvm::LLVMRustDIBuilderInsertDeclareAtEnd(
514514
DIB(cx),
515515
alloca,
516516
metadata,

‎src/librustc_trans/debuginfo/namespace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn item_namespace(ccx: &CrateContext, def_id: DefId) -> DIScope {
7878
};
7979

8080
let scope = unsafe {
81-
llvm::LLVMDIBuilderCreateNameSpace(
81+
llvm::LLVMRustDIBuilderCreateNameSpace(
8282
DIB(ccx),
8383
parent_scope,
8484
namespace_name.as_ptr(),

‎src/librustc_trans/debuginfo/source_loc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub fn set_debug_location(cx: &CrateContext,
206206
debug!("setting debug location to {} {}", line, col);
207207

208208
unsafe {
209-
llvm::LLVMDIBuilderCreateDebugLocation(
209+
llvm::LLVMRustDIBuilderCreateDebugLocation(
210210
debug_context(cx).llcontext,
211211
line as c_uint,
212212
col as c_uint,

‎src/librustc_trans/debuginfo/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool
4040
#[allow(non_snake_case)]
4141
pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
4242
return unsafe {
43-
llvm::LLVMDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32)
43+
llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32)
4444
};
4545
}
4646

‎src/librustc_trans/declare.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRe
4040
bug!("name {:?} contains an interior null byte", name)
4141
});
4242
unsafe {
43-
llvm::LLVMGetOrInsertGlobal(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
43+
llvm::LLVMRustGetOrInsertGlobal(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
4444
}
4545
}
4646

@@ -55,7 +55,7 @@ fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty:
5555
bug!("name {:?} contains an interior null byte", name)
5656
});
5757
let llfn = unsafe {
58-
llvm::LLVMGetOrInsertFunction(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
58+
llvm::LLVMRustGetOrInsertFunction(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
5959
};
6060

6161
llvm::SetFunctionCallConv(llfn, callconv);
@@ -173,7 +173,7 @@ pub fn get_declared_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
173173
let namebuf = CString::new(name).unwrap_or_else(|_|{
174174
bug!("name {:?} contains an interior null byte", name)
175175
});
176-
let val = unsafe { llvm::LLVMGetNamedValue(ccx.llmod(), namebuf.as_ptr()) };
176+
let val = unsafe { llvm::LLVMRustGetNamedValue(ccx.llmod(), namebuf.as_ptr()) };
177177
if val.is_null() {
178178
debug!("get_declared_value: {:?} value is null", name);
179179
None

‎src/librustc_trans/intrinsic.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -640,28 +640,30 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
640640
// This requires that atomic intrinsics follow a specific naming pattern:
641641
// "atomic_<operation>[_<ordering>]", and no ordering means SeqCst
642642
(_, name) if name.starts_with("atomic_") => {
643+
use llvm::AtomicOrdering::*;
644+
643645
let split: Vec<&str> = name.split('_').collect();
644646

645647
let is_cxchg = split[1] == "cxchg" || split[1] == "cxchgweak";
646648
let (order, failorder) = match split.len() {
647-
2 => (llvm::SequentiallyConsistent, llvm::SequentiallyConsistent),
649+
2 => (SequentiallyConsistent, SequentiallyConsistent),
648650
3 => match split[2] {
649-
"unordered" => (llvm::Unordered, llvm::Unordered),
650-
"relaxed" => (llvm::Monotonic, llvm::Monotonic),
651-
"acq" => (llvm::Acquire, llvm::Acquire),
652-
"rel" => (llvm::Release, llvm::Monotonic),
653-
"acqrel" => (llvm::AcquireRelease, llvm::Acquire),
651+
"unordered" => (Unordered, Unordered),
652+
"relaxed" => (Monotonic, Monotonic),
653+
"acq" => (Acquire, Acquire),
654+
"rel" => (Release, Monotonic),
655+
"acqrel" => (AcquireRelease, Acquire),
654656
"failrelaxed" if is_cxchg =>
655-
(llvm::SequentiallyConsistent, llvm::Monotonic),
657+
(SequentiallyConsistent, Monotonic),
656658
"failacq" if is_cxchg =>
657-
(llvm::SequentiallyConsistent, llvm::Acquire),
659+
(SequentiallyConsistent, Acquire),
658660
_ => ccx.sess().fatal("unknown ordering in atomic intrinsic")
659661
},
660662
4 => match (split[2], split[3]) {
661663
("acq", "failrelaxed") if is_cxchg =>
662-
(llvm::Acquire, llvm::Monotonic),
664+
(Acquire, Monotonic),
663665
("acqrel", "failrelaxed") if is_cxchg =>
664-
(llvm::AcquireRelease, llvm::Monotonic),
666+
(AcquireRelease, Monotonic),
665667
_ => ccx.sess().fatal("unknown ordering in atomic intrinsic")
666668
},
667669
_ => 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>,
714716
}
715717

716718
"fence" => {
717-
AtomicFence(bcx, order, llvm::CrossThread);
719+
AtomicFence(bcx, order, llvm::SynchronizationScope::CrossThread);
718720
C_nil(ccx)
719721
}
720722

721723
"singlethreadfence" => {
722-
AtomicFence(bcx, order, llvm::SingleThread);
724+
AtomicFence(bcx, order, llvm::SynchronizationScope::SingleThread);
723725
C_nil(ccx)
724726
}
725727

‎src/librustc_trans/mir/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
324324
machine::llelement_offset(bcx.ccx(), lltuplety, i);
325325

326326
let ops = unsafe {
327-
[llvm::LLVMDIBuilderCreateOpDeref(),
328-
llvm::LLVMDIBuilderCreateOpPlus(),
327+
[llvm::LLVMRustDIBuilderCreateOpDeref(),
328+
llvm::LLVMRustDIBuilderCreateOpPlus(),
329329
byte_offset_of_var_in_tuple as i64]
330330
};
331331

@@ -450,10 +450,10 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
450450
machine::llelement_offset(bcx.ccx(), llclosurety, i);
451451

452452
let ops = unsafe {
453-
[llvm::LLVMDIBuilderCreateOpDeref(),
454-
llvm::LLVMDIBuilderCreateOpPlus(),
453+
[llvm::LLVMRustDIBuilderCreateOpDeref(),
454+
llvm::LLVMRustDIBuilderCreateOpPlus(),
455455
byte_offset_of_var_in_env as i64,
456-
llvm::LLVMDIBuilderCreateOpDeref()]
456+
llvm::LLVMRustDIBuilderCreateOpDeref()]
457457
};
458458

459459
// The environment and the capture can each be indirect.

‎src/librustc_trans/type_.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Type {
3636
impl fmt::Debug for Type {
3737
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3838
f.write_str(&llvm::build_string(|s| unsafe {
39-
llvm::LLVMWriteTypeToString(self.to_ref(), s);
39+
llvm::LLVMRustWriteTypeToString(self.to_ref(), s);
4040
}).expect("non-UTF8 type description from LLVM"))
4141
}
4242
}
@@ -72,7 +72,7 @@ impl Type {
7272
}
7373

7474
pub fn metadata(ccx: &CrateContext) -> Type {
75-
ty!(llvm::LLVMMetadataTypeInContext(ccx.llcx()))
75+
ty!(llvm::LLVMRustMetadataTypeInContext(ccx.llcx()))
7676
}
7777

7878
pub fn i1(ccx: &CrateContext) -> Type {

‎src/librustc_trans/value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct Value(pub ValueRef);
2323
impl fmt::Debug for Value {
2424
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2525
f.write_str(&llvm::build_string(|s| unsafe {
26-
llvm::LLVMWriteValueToString(self.0, s);
26+
llvm::LLVMRustWriteValueToString(self.0, s);
2727
}).expect("nun-UTF8 value description from LLVM"))
2828
}
2929
}

‎src/rustllvm/RustWrapper.cpp

+322-194
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.