Home | History | Annotate | Download | only in ArgumentPromotion
      1 ; RUN: opt < %s -argpromotion -S | FileCheck %s
      2 
      3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      4 target triple = "x86_64-unknown-linux-gnu"
      5 
      6 %union.u = type { x86_fp80 }
      7 %struct.s = type { double, i16, i8, [5 x i8] }
      8 
      9 @b = internal global %struct.s { double 3.14, i16 9439, i8 25, [5 x i8] undef }, align 16
     10 
     11 %struct.Foo = type { i32, i64 }
     12 @a = internal global %struct.Foo { i32 1, i64 2 }, align 8
     13 
     14 define void @run() {
     15 entry:
     16   tail call i8 @UseLongDoubleUnsafely(%union.u* byval align 16 bitcast (%struct.s* @b to %union.u*))
     17   tail call x86_fp80 @UseLongDoubleSafely(%union.u* byval align 16 bitcast (%struct.s* @b to %union.u*))
     18   call i64 @AccessPaddingOfStruct(%struct.Foo* @a)
     19   call i64 @CaptureAStruct(%struct.Foo* @a)
     20   ret void
     21 }
     22 
     23 ; CHECK: internal i8 @UseLongDoubleUnsafely(%union.u* byval align 16 %arg) {
     24 define internal i8 @UseLongDoubleUnsafely(%union.u* byval align 16 %arg) {
     25 entry:
     26   %bitcast = bitcast %union.u* %arg to %struct.s*
     27   %gep = getelementptr inbounds %struct.s, %struct.s* %bitcast, i64 0, i32 2
     28   %result = load i8, i8* %gep
     29   ret i8 %result
     30 }
     31 
     32 ; CHECK: internal x86_fp80 @UseLongDoubleSafely(x86_fp80 {{%.*}}) {
     33 define internal x86_fp80 @UseLongDoubleSafely(%union.u* byval align 16 %arg) {
     34   %gep = getelementptr inbounds %union.u, %union.u* %arg, i64 0, i32 0
     35   %fp80 = load x86_fp80, x86_fp80* %gep
     36   ret x86_fp80 %fp80
     37 }
     38 
     39 ; CHECK: define internal i64 @AccessPaddingOfStruct(%struct.Foo* byval %a) {
     40 define internal i64 @AccessPaddingOfStruct(%struct.Foo* byval %a) {
     41   %p = bitcast %struct.Foo* %a to i64*
     42   %v = load i64, i64* %p
     43   ret i64 %v
     44 }
     45 
     46 ; CHECK: define internal i64 @CaptureAStruct(%struct.Foo* byval %a) {
     47 define internal i64 @CaptureAStruct(%struct.Foo* byval %a) {
     48 entry:
     49   %a_ptr = alloca %struct.Foo*
     50   br label %loop
     51 
     52 loop:
     53   %phi = phi %struct.Foo* [ null, %entry ], [ %gep, %loop ]
     54   %0   = phi %struct.Foo* [ %a, %entry ],   [ %0, %loop ]
     55   store %struct.Foo* %phi, %struct.Foo** %a_ptr
     56   %gep = getelementptr %struct.Foo, %struct.Foo* %a, i64 0
     57   br label %loop
     58 }
     59