-
-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4564 from gfaster/4553-regression-test
Add regression test for #4553
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package test_internal | ||
|
||
import "core:testing" | ||
|
||
// See: https://github.com/odin-lang/Odin/issues/4553 | ||
// It would be great if Odin had the ability to test against LLVM output since | ||
// this test erronously passing is dependent on alignment of the stack. | ||
// | ||
// Right now, I am manually checking LLVM ir | ||
|
||
@test | ||
test_4553_matrix_align :: proc(t: ^testing.T) { | ||
test_mat :: proc($T: typeid, $R: u32, $C: u32) { | ||
when R * C <= 16 { | ||
return_matrix :: proc() -> matrix[R, C]T { | ||
ret : matrix[R, C]T | ||
return ret | ||
} | ||
// the origin of the bug had to do with a temporary | ||
// created by a function return being loaded with bad | ||
// alignment. The bug only affected 4-element f32 | ||
// matrices, but it would be prudent to test more than | ||
// that | ||
_ = return_matrix() * [C]T{} | ||
} | ||
} | ||
|
||
test_mat_set :: proc($T: typeid) { | ||
test_mat_row :: proc($T: typeid, $R: u32) { | ||
test_mat(T, R, 1) | ||
test_mat(T, R, 2) | ||
test_mat(T, R, 3) | ||
test_mat(T, R, 4) | ||
test_mat(T, R, 5) | ||
test_mat(T, R, 6) | ||
} | ||
test_mat_row(T, 1) | ||
test_mat_row(T, 2) | ||
test_mat_row(T, 3) | ||
test_mat_row(T, 4) | ||
test_mat_row(T, 5) | ||
test_mat_row(T, 6) | ||
|
||
} | ||
test_mat_set(f16) | ||
test_mat_set(f32) | ||
test_mat_set(f64) | ||
test_mat_set(i8) | ||
test_mat_set(i16) | ||
test_mat_set(i32) | ||
test_mat_set(i64) | ||
test_mat_set(i128) | ||
} |