Home | History | Annotate | Download | only in SROA
      1 ; RUN: opt -sroa -S < %s | FileCheck %s
      2 
      3 ; This test checks that SROA does not introduce ptrtoint and inttoptr
      4 ; casts from and to non-integral pointers.  The "ni:4" bit in the
      5 ; datalayout states that pointers of address space 4 are to be
      6 ; considered "non-integral".
      7 
      8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:4"
      9 target triple = "x86_64-unknown-linux-gnu"
     10 
     11 define void @f0(i1 %alwaysFalse, i64 %val) {
     12 ; CHECK-LABEL: @f0(
     13 ; CHECK-NOT: inttoptr
     14 ; CHECK-NOT: ptrtoint
     15 entry:
     16   %loc = alloca i64
     17   store i64 %val, i64* %loc
     18   br i1 %alwaysFalse, label %neverTaken, label %alwaysTaken
     19 
     20 neverTaken:
     21   %loc.bc = bitcast i64* %loc to i8 addrspace(4)**
     22   %ptr = load i8 addrspace(4)*, i8 addrspace(4)** %loc.bc
     23   store i8 5, i8 addrspace(4)* %ptr
     24   ret void
     25 
     26 alwaysTaken:
     27   ret void
     28 }
     29 
     30 define i64 @f1(i1 %alwaysFalse, i8 addrspace(4)* %val) {
     31 ; CHECK-LABEL: @f1(
     32 ; CHECK-NOT: inttoptr
     33 ; CHECK-NOT: ptrtoint
     34 entry:
     35   %loc = alloca i8 addrspace(4)*
     36   store i8 addrspace(4)* %val, i8 addrspace(4)** %loc
     37   br i1 %alwaysFalse, label %neverTaken, label %alwaysTaken
     38 
     39 neverTaken:
     40   %loc.bc = bitcast i8 addrspace(4)** %loc to i64*
     41   %int = load i64, i64* %loc.bc
     42   ret i64 %int
     43 
     44 alwaysTaken:
     45   ret i64 42
     46 }
     47