inalloca.ll 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ; RUN: opt %s -argpromotion -scalarrepl -S | FileCheck %s
  2. target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
  3. %struct.ss = type { i32, i32 }
  4. ; Argpromote + scalarrepl should change this to passing the two integers by value.
  5. define internal i32 @f(%struct.ss* inalloca %s) {
  6. entry:
  7. %f0 = getelementptr %struct.ss, %struct.ss* %s, i32 0, i32 0
  8. %f1 = getelementptr %struct.ss, %struct.ss* %s, i32 0, i32 1
  9. %a = load i32, i32* %f0, align 4
  10. %b = load i32, i32* %f1, align 4
  11. %r = add i32 %a, %b
  12. ret i32 %r
  13. }
  14. ; CHECK-LABEL: define internal i32 @f
  15. ; CHECK-NOT: load
  16. ; CHECK: ret
  17. define i32 @main() {
  18. entry:
  19. %S = alloca inalloca %struct.ss
  20. %f0 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 0
  21. %f1 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 1
  22. store i32 1, i32* %f0, align 4
  23. store i32 2, i32* %f1, align 4
  24. %r = call i32 @f(%struct.ss* inalloca %S)
  25. ret i32 %r
  26. }
  27. ; CHECK-LABEL: define i32 @main
  28. ; CHECK-NOT: load
  29. ; CHECK: ret
  30. ; Argpromote can't promote %a because of the icmp use.
  31. define internal i1 @g(%struct.ss* %a, %struct.ss* inalloca %b) nounwind {
  32. ; CHECK: define internal i1 @g(%struct.ss* %a, %struct.ss* inalloca %b)
  33. entry:
  34. %c = icmp eq %struct.ss* %a, %b
  35. ret i1 %c
  36. }
  37. define i32 @test() {
  38. entry:
  39. %S = alloca inalloca %struct.ss
  40. %c = call i1 @g(%struct.ss* %S, %struct.ss* inalloca %S)
  41. ; CHECK: call i1 @g(%struct.ss* %S, %struct.ss* inalloca %S)
  42. ret i32 0
  43. }