-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't look through addrspacecast in GetPointerBaseWithConstantOffset
Pointers in different addrspaces can have different sizes, so it's not valid to look through addrspace cast calculating base and offset for a value. This is similar to D13008. Reviewed By: reames Differential Revision: https://reviews.llvm.org/D24729 llvm-svn: 282612
- Loading branch information
Showing
4 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
; RUN: opt < %s -default-data-layout="e-p:32:32:32-p1:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basicaa -gvn -S -die | FileCheck %s | ||
|
||
define i8 @coerce_offset0_addrspacecast(i32 %V, i32* %P) { | ||
store i32 %V, i32* %P | ||
|
||
%P2 = addrspacecast i32* %P to i8 addrspace(1)* | ||
%P3 = getelementptr i8, i8 addrspace(1)* %P2, i32 2 | ||
|
||
%A = load i8, i8 addrspace(1)* %P3 | ||
ret i8 %A | ||
; CHECK-LABEL: @coerce_offset0_addrspacecast( | ||
; CHECK-NOT: load | ||
; CHECK: ret i8 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
; RUN: opt < %s -gvn -S | FileCheck %s | ||
target datalayout = "e-m:e-p:16:16-p1:32:16-i32:16-i64:16-n8:16" | ||
|
||
; In cases where two address spaces do not have the same size pointer, the | ||
; input for the addrspacecast should not be used as a substitute for itself | ||
; when manipulating the pointer. | ||
|
||
; Check that we don't hit the assert in this scenario | ||
define i8 @test(i32 %V, i32* %P) { | ||
; CHECK-LABEL: @test( | ||
; CHECK: load | ||
%P1 = getelementptr inbounds i32, i32* %P, i16 16 | ||
|
||
store i32 %V, i32* %P1 | ||
|
||
%P2 = addrspacecast i32* %P1 to i8 addrspace(1)* | ||
%P3 = getelementptr i8, i8 addrspace(1)* %P2, i32 2 | ||
|
||
%A = load i8, i8 addrspace(1)* %P3 | ||
ret i8 %A | ||
} |