0xMiden / 0xMiden/compiler

Test multiple data segment with a global var that holds a pointer to a data in one of the data segments

Đang mở
#574 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
115
Fork
84
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
15

Mô tả

From https://github.com/0xMiden/compiler/pull/572#issuecomment-3000997752

> My suggestion was that we create a test that does the following:
>
> * Creates a basic component skeleton in HIR
> * In randomized order (e.g. using `[]::shuffle`), insert N non-overlapping data segments (where N is `1..=3`) and 2 global variables. Where one of the global variables is a pointer to data in one of the inserted data segments, one of them is just a simple integer value (like a counter basically) - the differing types here are just to represent global variables that have a dependency on a data segment vs those that don't.
> * Emit a program entrypoint in the component module that reads the value of both global variables and asserts that their values match what is expected. NOTE: The global variable referencing a data segment requires that the data segment contain some non-zero data at the address referenced by the global variable so that this test is useful.
> * Compute the data/global layout for the component, and verify that none of the computed layouts overlap, and that the global variables are always laid out following the last data segment, and that in the case of the global variable that is a pointer; that the computed address of that pointer refers to a location in the corresponding data segment.
> * Convert the component to MASM and execute it to verify that all of the test assertions in the emitted code pass.
>
> The idea here is to capture a few different details:
>
> 1. That the order in which data segments and global variables are encountered during lowering does not affect the correctness of the data layout computed by the backend. If the order of the global variables is random, we'd expect that the order they appear in the final layout could differ, but it should never be the case that they overlap with any of the data segments that were defined.
> 2. That the number of data segments does not affect the correctness of the data layout
> 3. That whether a global variable references data in a data segment or not does not affect the correctness of the data layout (we currently don't do anything that would cause a difference in behavior, but in the future we may, and this will ensure we catch if any changes in behavior break the data layout).
> 4. That the computed layout information is correctly reflected in the compiled code, and verified by executing that code.
> 5. Catch future regressions

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.