fp80.ll 2.0 KB

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