Skip to content

Commit 1b38776

Browse files
committed
Auto merge of #38302 - Mark-Simulacrum:trans-cleanup, r=eddyb
Cleanup old trans This is a cleanup of old trans, with the following main points: - Remove the `build.rs` API (prefer using `Builder` directly, which is now passed where needed through `BlockAndBuilder`). - Remove `Block` (inlining it into `BlockAndBuilder`) - Remove `Callee::call`, primarily through inlining and simplification of code. - Thinned `FunctionContext`: - `mir`, `debug_scopes`, `scopes`, and `fn_ty` are moved to `MirContext`. - `param_env` is moved to `SharedCrateContext` and renamed to `empty_param_env`. - `llretslotptr` is removed, replaced with more careful management of the return values in calls. - `landingpad_alloca` is inlined into cleanup. - `param_substs` are moved to `MirContext`. - `span` is removed, it was never set to anything but `None`. - `block_arena` and `lpad_arena` are removed, since neither was necessary (landing pads and block are quite small, and neither needs arena allocation). - Fixed `drop_in_place` not running other destructors in the same function. Fixes #35566 (thanks to @est31 for confirming).
2 parents 439c312 + 0013d4c commit 1b38776

37 files changed

+1904
-5020
lines changed

src/liballoc/heap.rs

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ pub fn usable_size(size: usize, align: usize) -> usize {
127127
pub const EMPTY: *mut () = 0x1 as *mut ();
128128

129129
/// The allocator for unique pointers.
130+
// This function must not unwind. If it does, MIR trans will fail.
130131
#[cfg(not(test))]
131132
#[lang = "exchange_malloc"]
132133
#[inline]

src/librustc_llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ extern "C" {
710710

711711
// Operations on instructions
712712
pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
713+
pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
713714
pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
714715
pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
715716

src/librustc_trans/abi.rs

+5-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use llvm::{self, ValueRef, Integer, Pointer, Float, Double, Struct, Array, Vector, AttributePlace};
1212
use base;
13-
use build::AllocaFcx;
1413
use common::{type_is_fat_ptr, BlockAndBuilder, C_uint};
1514
use context::CrateContext;
1615
use cabi_x86;
@@ -99,21 +98,11 @@ impl ArgAttributes {
9998
self
10099
}
101100

102-
pub fn unset(&mut self, attr: ArgAttribute) -> &mut Self {
103-
self.regular = self.regular - attr;
104-
self
105-
}
106-
107101
pub fn set_dereferenceable(&mut self, bytes: u64) -> &mut Self {
108102
self.dereferenceable_bytes = bytes;
109103
self
110104
}
111105

112-
pub fn unset_dereferenceable(&mut self) -> &mut Self {
113-
self.dereferenceable_bytes = 0;
114-
self
115-
}
116-
117106
pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
118107
unsafe {
119108
self.regular.for_each_kind(|attr| attr.apply_llfn(idx, llfn));
@@ -246,7 +235,7 @@ impl ArgType {
246235
if self.is_ignore() {
247236
return;
248237
}
249-
let ccx = bcx.ccx();
238+
let ccx = bcx.ccx;
250239
if self.is_indirect() {
251240
let llsz = llsize_of(ccx, self.ty);
252241
let llalign = llalign_of_min(ccx, self.ty);
@@ -278,7 +267,7 @@ impl ArgType {
278267
// bitcasting to the struct type yields invalid cast errors.
279268

280269
// We instead thus allocate some scratch space...
281-
let llscratch = AllocaFcx(bcx.fcx(), ty, "abi_cast");
270+
let llscratch = bcx.fcx().alloca(ty, "abi_cast");
282271
base::Lifetime::Start.call(bcx, llscratch);
283272

284273
// ...where we first store the value...
@@ -431,7 +420,7 @@ impl FnType {
431420
let ret_ty = sig.output();
432421
let mut ret = arg_of(ret_ty, true);
433422

434-
if !type_is_fat_ptr(ccx.tcx(), ret_ty) {
423+
if !type_is_fat_ptr(ccx, ret_ty) {
435424
// The `noalias` attribute on the return value is useful to a
436425
// function ptr caller.
437426
if let ty::TyBox(_) = ret_ty.sty {
@@ -496,7 +485,7 @@ impl FnType {
496485
for ty in inputs.iter().chain(extra_args.iter()) {
497486
let mut arg = arg_of(ty, false);
498487

499-
if type_is_fat_ptr(ccx.tcx(), ty) {
488+
if type_is_fat_ptr(ccx, ty) {
500489
let original_tys = arg.original_ty.field_types();
501490
let sizing_tys = arg.ty.field_types();
502491
assert_eq!((original_tys.len(), sizing_tys.len()), (2, 2));
@@ -569,7 +558,7 @@ impl FnType {
569558
};
570559
// Fat pointers are returned by-value.
571560
if !self.ret.is_ignore() {
572-
if !type_is_fat_ptr(ccx.tcx(), sig.output()) {
561+
if !type_is_fat_ptr(ccx, sig.output()) {
573562
fixup(&mut self.ret);
574563
}
575564
}

0 commit comments

Comments
 (0)