Fwd: [PATCH] Teach MergeFunctions about address spaces

Matt Arsenault Matthew.Arsenault at amd.com
Tue Sep 17 15:14:23 PDT 2013


On 09/16/2013 11:44 PM, Stepan Dyatkovskiy wrote:
> Hi Matt,
> Then, I think logic should be next:
> 1. In function definition (function type), we mark function types
> 'voo(i8*)' and 'voo2(i8 addrspace(1)*)' as equal.
> 2. While enumerating instructions in BBs: it depends on context should 
> we ignore 'addrspace' or not.
> 2.1. In common case we mark 'inst0 i8*' and 'inst1 i8 addrspace(1)*' 
> as different.
> 2.2. In particular cases (inc, add, sub) we mark instructions as equal.
>
> On output we get equal 'voo' and 'voo2' only in case if it uses 
> pointer arithmetic only.

OK, I can try working on that as a second patch. I've tried a few cases 
like in your example with 2 functions with same sized integers as a 
pointer, but they already aren't merged:

target datalayout = "p:32:32:32"

Example:
define void @foo_i32(i32 %x) {
   %y = inttoptr i32 %x to i32*
   store i32 7, i32* %y
   ret void
}

define void @foo_i32p0(i32* %y) {
   %y = inttoptr i32 %x to i32*
   store i32 7, i32* %y
   ret void
}

I was hoping it was only because the functions are too small, but it 
turns out there isn't any threshold (which I have another patch to fix).




More information about the llvm-commits mailing list