From b3c3ca331ba0766098d56fa2876b39b2ced5e41b Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Sat, 16 Jun 2018 10:31:52 -0400 Subject: [PATCH] Removed implicit indirection when computing heap base. (#363) Fix expected legalized heap_addr --- .../filetests/isa/x86/legalize-memory.cton | 6 ++---- lib/codegen/src/legalizer/heap.rs | 17 +++-------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/cranelift/filetests/isa/x86/legalize-memory.cton b/cranelift/filetests/isa/x86/legalize-memory.cton index 0a35c841ba..ce6d194507 100644 --- a/cranelift/filetests/isa/x86/legalize-memory.cton +++ b/cranelift/filetests/isa/x86/legalize-memory.cton @@ -53,8 +53,7 @@ ebb0(v0: i32, v999: i64): ; Boundscheck should be eliminated. ; Checks here are assuming that no pipehole opts fold the load offsets. ; nextln: $(xoff=$V) = uextend.i64 v0 - ; nextln: $(haddr=$V) = iadd_imm v999, 64 - ; nextln: $(hbase=$V) = load.i64 notrap aligned $haddr + ; nextln: $(hbase=$V) = iadd_imm v999, 64 ; nextln: v1 = iadd $hbase, $xoff v2 = load.f32 v1+16 ; nextln: v2 = load.f32 v1+16 @@ -101,8 +100,7 @@ ebb0(v0: i32, v999: i64): ; check: $ok: ; Checks here are assuming that no pipehole opts fold the load offsets. ; nextln: $(xoff=$V) = uextend.i64 v0 - ; nextln: $(haddr=$V) = iadd_imm.i64 v999, 64 - ; nextln: $(hbase=$V) = load.i64 notrap aligned $haddr + ; nextln: $(hbase=$V) = iadd_imm.i64 v999, 64 ; nextln: v1 = iadd $hbase, $xoff v2 = load.f32 v1+0x7fff_ffff ; nextln: v2 = load.f32 v1+0x7fff_ffff diff --git a/lib/codegen/src/legalizer/heap.rs b/lib/codegen/src/legalizer/heap.rs index ab68976d57..fdf3fdb094 100644 --- a/lib/codegen/src/legalizer/heap.rs +++ b/lib/codegen/src/legalizer/heap.rs @@ -6,7 +6,7 @@ use cursor::{Cursor, FuncCursor}; use flowgraph::ControlFlowGraph; use ir::condcodes::IntCC; -use ir::{self, InstBuilder, MemFlags}; +use ir::{self, InstBuilder}; use isa::TargetIsa; /// Expand a `heap_addr` instruction according to the definition of the heap. @@ -57,13 +57,7 @@ fn dynamic_addr( pos.use_srcloc(inst); // Start with the bounds check. Trap if `offset + size > bound`. - let bound_addr = pos.ins().global_value(addr_ty, bound_gv); - let mut mflags = MemFlags::new(); - // The bound variable is requied to be accessible and aligned. - mflags.set_notrap(); - mflags.set_aligned(); - let bound = pos.ins().load(offset_ty, mflags, bound_addr, 0); - + let bound = pos.ins().global_value(addr_ty, bound_gv); let oob; if size == 1 { // `offset > bound - 1` is the same as `offset >= bound`. @@ -163,12 +157,7 @@ fn offset_addr( match pos.func.heaps[heap].base { ir::HeapBase::ReservedReg => unimplemented!(), ir::HeapBase::GlobalValue(base_gv) => { - let base_addr = pos.ins().global_value(addr_ty, base_gv); - let mut mflags = MemFlags::new(); - // The base address variable is requied to be accessible and aligned. - mflags.set_notrap(); - mflags.set_aligned(); - let base = pos.ins().load(addr_ty, mflags, base_addr, 0); + let base = pos.ins().global_value(addr_ty, base_gv); pos.func.dfg.replace(inst).iadd(base, offset); } }