jasmin-lang / jasmin

Language for high-assurance and high-speed cryptography
MIT License
268 stars 55 forks source link

Variable allocation: (...) : variable already set #165

Closed tfaoliveira closed 1 year ago

tfaoliveira commented 2 years ago

This issue describes a compilation error in the context of libjade, more precisely kyber768/avx2, and Jasmin glob_array3_slh.

To reproduce the compilation error, the following commands can be used:

$ git checkout 5c26b27cd90532e150989512ab989d30b6a576e0
$ cd src/crypto_kem/kyber/kyber768/amd64/avx2/
$ make 
"(...)/libjade/src/crypto_kem/kyber/common/amd64/avx2/poly.jinc", line 783 (0) to line 813 (1):
internal compilation error in function _poly_getnoise_eta1122_4x:
  Variable allocation: seed (defined at line 784) and RAX (defined at line -1) : variable already set
Please report at https://github.com/jasmin-lang/jasmin/issues
make: *** [../../../../../Makefile.common:73: kem.s] Error 1

If we change src/crypto_kem/kyber/kyber768/amd64/avx2/Makefile JFLAGS variable to JFLAGS := -lazy-regalloc -lea, the error changes to:

$ make 
compilation error:
register allocation: no more register to allocate “ms.49137; (...)

Function _poly_getnoise_eta1122_4x is a non-inline function that is used by Kyber512 but not by Kyber768 if I'm not mistaken. The current, and temporary, fix for this problem is to declare _poly_getnoise_eta1122_4x as inline (which can be observed in recent commits of libjade sslh branch).

I think that it would be important:

tfaoliveira commented 1 year ago

This issue is no longer relevant since that, in the meantime, the error message changed. The experiment is described next:

"kem.jpp", line 2364 (8-22)
warning: vector suffix simplified from 8u32 to 256
"kem.jpp", line 5716 (2-16)
  from "kem.jpp", line 5790 (2-49):
compilation error:
register allocation: conflicting variables “skp.3667” and “hp.96853” must be merged due to:
  at "kem.jpp", line 5716 (2-16)
       from "kem.jpp", line 5790 (2-49):
    ( _15.96848,  _16.96849,  _17.96850,  _18.96851,  _19.96852, hp.96853) =
      #ADD_64(skp.3667, ((64u) 32)); /*  */
  at "kem.jpp", line 5717 (2-34)
       from "kem.jpp", line 5790 (2-49):
    ( _20.96854,  _21.96855,  _22.96856,  _23.96857,  _24.96858, hp.96859) =
      #ADD_64(hp.96853, ((64u) 2304)); /*  */