diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-11-27 04:52:57 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-11-27 04:52:57 +0000 |
commit | fcb80cc5656e4672702e3150bfe425f4a58b7a65 (patch) | |
tree | 9774d40662c742225e0b7e64358ee3881a6e404e /test/Transforms | |
parent | 1fc07c81a31e192c6a01a8a54a7bc7b3954765b7 (diff) | |
download | external_llvm-fcb80cc5656e4672702e3150bfe425f4a58b7a65.zip external_llvm-fcb80cc5656e4672702e3150bfe425f4a58b7a65.tar.gz external_llvm-fcb80cc5656e4672702e3150bfe425f4a58b7a65.tar.bz2 |
Merging r195769:
------------------------------------------------------------------------
r195769 | dyatkovskiy | 2013-11-26 08:11:03 -0800 (Tue, 26 Nov 2013) | 27 lines
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/branches/release_34@195810 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
4 files changed, 67 insertions, 29 deletions
diff --git a/test/Transforms/MergeFunc/inttoptr-address-space-2.ll b/test/Transforms/MergeFunc/inttoptr-address-space-2.ll deleted file mode 100644 index ea350cc..0000000 --- a/test/Transforms/MergeFunc/inttoptr-address-space-2.ll +++ /dev/null @@ -1,29 +0,0 @@ -; RUN: opt -mergefunc -S < %s | FileCheck %s -target datalayout = "e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-n8:16:32-S128" - -%.qux.2496 = type { i16, %.qux.2497 } -%.qux.2497 = type { i8, i16 } -%.qux.2585 = type { i16, i16, i8 addrspace(1)* } - -@g2 = external addrspace(1) constant [9 x i8], align 1 -@g3 = internal hidden addrspace(1) constant [1 x i8*] [i8* bitcast (i8 addrspace(1)* (%.qux.2585 addrspace(1)*)* @func35 to i8*)] - - -define internal hidden i16 @func10(%.qux.2496 addrspace(1)* nocapture %this) align 2 { -bb: - %tmp = getelementptr inbounds %.qux.2496 addrspace(1)* %this, i32 0, i32 1, i32 1 - %tmp1 = load i16 addrspace(1)* %tmp, align 4 - ret i16 %tmp1 -} - -; Checks that this can be merged with an address space differently sized than 0 -define internal hidden i8 addrspace(1)* @func35(%.qux.2585 addrspace(1)* nocapture %this) align 2 { -bb: -; CHECK-LABEL: @func35( -; CHECK: %[[V2:.+]] = bitcast %.qux.2585 addrspace(1)* %{{.*}} to %.qux.2496 addrspace(1)* -; CHECK: %[[V3:.+]] = tail call i16 @func10(%.qux.2496 addrspace(1)* %[[V2]]) -; CHECK: %{{.*}} = inttoptr i16 %[[V3]] to i8 addrspace(1)* - %tmp = getelementptr inbounds %.qux.2585 addrspace(1)* %this, i32 0, i32 2 - %tmp1 = load i8 addrspace(1)* addrspace(1)* %tmp, align 4 - ret i8 addrspace(1)* %tmp1 -} diff --git a/test/Transforms/MergeFunc/ptr-int-transitivity-1.ll b/test/Transforms/MergeFunc/ptr-int-transitivity-1.ll new file mode 100644 index 0000000..d6ff10f --- /dev/null +++ b/test/Transforms/MergeFunc/ptr-int-transitivity-1.ll @@ -0,0 +1,21 @@ +; RUN: opt -S -mergefunc < %s | not grep "functions merged" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +declare void @stuff() + +define void @f0(i64 %p0) { +entry: + call void @stuff() + call void @stuff() + call void @stuff() + ret void +} + +define void @f2(i64 addrspace(1)* %p0) { +entry: + call void @stuff() + call void @stuff() + call void @stuff() + ret void +} + diff --git a/test/Transforms/MergeFunc/ptr-int-transitivity-2.ll b/test/Transforms/MergeFunc/ptr-int-transitivity-2.ll new file mode 100644 index 0000000..c9fb6a6 --- /dev/null +++ b/test/Transforms/MergeFunc/ptr-int-transitivity-2.ll @@ -0,0 +1,25 @@ +; RUN: opt -S -mergefunc < %s | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +declare void @stuff() + +define void @f0(i64 %p0) { +entry: + call void @stuff() + call void @stuff() + call void @stuff() + ret void +} + +; CHECK-LABEL: @f0 +; CHECK: %2 = ptrtoint i64* %0 to i64 +; CHECK: tail call void @f0(i64 %2) +; CHECK: ret void +define void @f1(i64 addrspace(0)* %p0) { +entry: + call void @stuff() + call void @stuff() + call void @stuff() + ret void +} + diff --git a/test/Transforms/MergeFunc/ptr-int-transitivity-3.ll b/test/Transforms/MergeFunc/ptr-int-transitivity-3.ll new file mode 100644 index 0000000..8f00f03 --- /dev/null +++ b/test/Transforms/MergeFunc/ptr-int-transitivity-3.ll @@ -0,0 +1,21 @@ +; RUN: opt -S -mergefunc < %s | not grep "functions merged" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +declare void @stuff() + +define void @f0(i64 addrspace(0)* %p0) { +entry: + call void @stuff() + call void @stuff() + call void @stuff() + ret void +} + +define void @f2(i64 addrspace(1)* %p0) { +entry: + call void @stuff() + call void @stuff() + call void @stuff() + ret void +} + |