systems-nuts / unifico

Compiler and build harness for heterogeneous-ISA binaries with the same stack layout.
3 stars 1 forks source link

Different alignment of conditional instruction result #279

Closed blackgeorge-boom closed 1 year ago

blackgeorge-boom commented 1 year ago
#include "header.h"

#define BLOCK_SIZE 5

int grid_points[3];
double rhs2[10][10 + 1][10 + 1][5];
double lhs[1][3][5][5];

void y_solve()
{
    int i, j, k, m, n, jsize;

    jsize = grid_points[1];

    for (k = 1; k <= grid_points[2] - 2; k++) {
        for (i = 1; i <= grid_points[0] - 2; i++) {
            lhsinit(lhs, jsize);
            for (j = jsize - 1; j >= 0; j--) {
                for (m = 0; m < BLOCK_SIZE; m++) {
                    for (n = 0; n < BLOCK_SIZE; n++) {
                        rhs2[k][j][i][m] =
                            lhs[0][0][n][m] * rhs2[k][j + 1][i][n];
                    }
                }
            }
        }
    }
}

int main(int argc, char *argv[])
{
    y_solve();

    return 0;
}
make clean; make stackmaps-check -j10 OPT_LEVEL=-O1

WARNING: y_solve: callsite 0, value locations 0/0 have different location offset or  different constant (-44 vs. -41)
ERROR: stackmaps in 'main_aarch64_aligned.out' & 'main_x86_64_aligned.out' differ - different stack layout!
blackgeorge-boom commented 1 year ago

The ccode is defined differently in both architectures:

AArch64: def ccode : Operand<i32> { X86: def ccode : Operand<i8> {

When code is lowered to instructions like:

AArch64: %44:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv X86: %33:gr8 = SETCCr 15, implicit $eflags

in X86, the result is stored as one byte and aligned at one-byte boundary (not sure why our -align-bytes-to-four option does not cover this case.