PR17925 bugfix.
authorStepan Dyatkovskiy <stpworld@narod.ru>
Tue, 26 Nov 2013 16:11:03 +0000 (16:11 +0000)
committerStepan Dyatkovskiy <stpworld@narod.ru>
Tue, 26 Nov 2013 16:11:03 +0000 (16:11 +0000)
commitdff57f19a14560e7ce9d5dbba17a62f1cb85021e
treeb41aec0d2fb2ba7883e3ae40a30f15896f550ee9
parent45ab4750de5729c2e80c7cfb0818b10f68263e35
PR17925 bugfix.

Short description.

This issue is about case of treating pointers as integers.
We treat pointers as different if they references different address space.
At the same time, we treat pointers equal to integers (with machine address
width). It was a point of false-positive. Consider next case on 32bit machine:

void foo0(i32 addrespace(1)* %p)
void foo1(i32 addrespace(2)* %p)
void foo2(i32 %p)

foo0 != foo1, while
foo1 == foo2 and foo0 == foo2.

As you can see it breaks transitivity. That means that result depends on order
of how functions are presented in module. Next order causes merging of foo0
and foo1: foo2, foo0, foo1
First foo0 will be merged with foo2, foo0 will be erased. Second foo1 will be
merged with foo2.
Depending on order, things could be merged we don't expect to.

The fix:
Forbid to treat any pointer as integer, except for those, who belong to address space 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195769 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/MergeFunctions.cpp
test/Transforms/MergeFunc/inttoptr-address-space-2.ll [deleted file]
test/Transforms/MergeFunc/ptr-int-transitivity-1.ll [new file with mode: 0644]
test/Transforms/MergeFunc/ptr-int-transitivity-2.ll [new file with mode: 0644]
test/Transforms/MergeFunc/ptr-int-transitivity-3.ll [new file with mode: 0644]