byval-2.ll 966 B

12345678910111213141516171819202122232425262728293031
  1. ; RUN: opt < %s -argpromotion -S | FileCheck %s
  2. ; Arg promotion eliminates the struct argument.
  3. ; FIXME: Should it eliminate the i32* argument?
  4. %struct.ss = type { i32, i64 }
  5. define internal void @f(%struct.ss* byval %b, i32* byval %X) nounwind {
  6. ; CHECK-LABEL: define internal void @f(i32 %b.0, i64 %b.1, i32* byval %X)
  7. entry:
  8. %tmp = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 0
  9. %tmp1 = load i32, i32* %tmp, align 4
  10. %tmp2 = add i32 %tmp1, 1
  11. store i32 %tmp2, i32* %tmp, align 4
  12. store i32 0, i32* %X
  13. ret void
  14. }
  15. define i32 @test(i32* %X) {
  16. ; CHECK-LABEL: define i32 @test
  17. entry:
  18. %S = alloca %struct.ss
  19. %tmp1 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 0
  20. store i32 1, i32* %tmp1, align 8
  21. %tmp4 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 1
  22. store i64 2, i64* %tmp4, align 4
  23. call void @f( %struct.ss* byval %S, i32* byval %X)
  24. ; CHECK: call void @f(i32 %{{.*}}, i64 %{{.*}}, i32* byval %{{.*}})
  25. ret i32 0
  26. }