test_4553_matrix_align.odin 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package test_internal
  2. import "core:testing"
  3. // See: https://github.com/odin-lang/Odin/issues/4553
  4. // It would be great if Odin had the ability to test against LLVM output since
  5. // this test erronously passing is dependent on alignment of the stack.
  6. //
  7. // Right now, I am manually checking LLVM ir
  8. @test
  9. test_4553_matrix_align :: proc(t: ^testing.T) {
  10. test_mat :: proc($T: typeid, $R: u32, $C: u32) {
  11. when R * C <= 16 {
  12. return_matrix :: proc() -> matrix[R, C]T {
  13. ret : matrix[R, C]T
  14. return ret
  15. }
  16. // the origin of the bug had to do with a temporary
  17. // created by a function return being loaded with bad
  18. // alignment. The bug only affected 4-element f32
  19. // matrices, but it would be prudent to test more than
  20. // that
  21. _ = return_matrix() * [C]T{}
  22. }
  23. }
  24. test_mat_set :: proc($T: typeid) {
  25. test_mat_row :: proc($T: typeid, $R: u32) {
  26. test_mat(T, R, 1)
  27. test_mat(T, R, 2)
  28. test_mat(T, R, 3)
  29. test_mat(T, R, 4)
  30. test_mat(T, R, 5)
  31. test_mat(T, R, 6)
  32. }
  33. test_mat_row(T, 1)
  34. test_mat_row(T, 2)
  35. test_mat_row(T, 3)
  36. test_mat_row(T, 4)
  37. test_mat_row(T, 5)
  38. test_mat_row(T, 6)
  39. }
  40. test_mat_set(f16)
  41. test_mat_set(f32)
  42. test_mat_set(f64)
  43. test_mat_set(i8)
  44. test_mat_set(i16)
  45. test_mat_set(i32)
  46. test_mat_set(i64)
  47. test_mat_set(i128)
  48. }