On Thu, Feb 20, 2014 at 05:13:36PM +0800, lin zuojian wrote: > > You certainly don't want to do any of the extra aligning > > on non-strict alignment targets, so all the changes must be > > if (STRICT_ALIGNMENT) guarded, as they are quite expensive (you need one > > extra register in that case). > > I have to do realignment.And llvm's backend also do the realignment.I > just refers to its implementation.
On !STRICT_ALIGNMENT, you don't need to do the realignment, it just works as is. I don't care what llvm does. > > Also, I don't think you want to align for ASAN_RED_ZONE_SIZE, > > but instead (GET_MODE_ALIGNMENT (SImode) << ASAN_SHADOW_SHIFT) / > > BITS_PER_UNIT, > > and if you do (of course for STRICT_ALIGNMENT targets only), you should > > set_mem_align on shadow_mem when it is created. > > I agree with you on the alignment value.May invoking set_mem_align on > shadow_mem happen too late at this point?Given RTL has been expanded. I meant to do: shadow_mem = gen_rtx_MEM (SImode, shadow_base); set_mem_alias_set (shadow_mem, asan_shadow_set); + if (STRICT_ALIGNMENT) + set_mem_align (shadow_mem, ...); (the default alignment is BITS_PER_UNIT). No RTL has been expanded with that yet at that point. > And again I have to do realignment on non STRICT_ALIGNMENT whatever cost > it take or there are always alignment faults. No. > > Or, if ARM supports unaligned loads/stores using special instructions, > > perhaps you should also benchmark the alternative of not realigning, but > > instead making sure those unaligned instructions are used for the shadow > > memory loads/stores in the asan prologue/epilogue. > I have tried to use -fno-peephole2 to shutdown instructions > combinations,but that makes me feel uncomfortable. You mean that for the prologues right now on ARM we emit unaligned store insns during expansion and that they are later peepholed into aligned stores? Jakub