diff options
author | flywind <xzsflywind@gmail.com> | 2022-02-08 15:34:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-08 08:34:44 +0100 |
commit | 27e548140b0f51a8dbc6f6094764e02f08ae509e (patch) | |
tree | 6d88cdba51cde343054d8adf8f5fedfed9475052 | |
parent | 801c0f0369779a47da2ef6618abea11feb390973 (diff) | |
download | Nim-27e548140b0f51a8dbc6f6094764e02f08ae509e.tar.gz |
don't use a temp for addr [backport: 1.6] (#19503)
* don't use a temp for addr fix #19497 * Update compiler/ccgcalls.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * add a test Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
-rw-r--r-- | compiler/ccgcalls.nim | 4 | ||||
-rw-r--r-- | tests/arc/tarc_orc.nim | 22 |
2 files changed, 24 insertions, 2 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 197728ccf..ce5fbfdd7 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -376,8 +376,8 @@ proc genParams(p: BProc, ri: PNode, typ: PType): Rope = if not needTmp[i - 1]: needTmp[i - 1] = potentialAlias(n, potentialWrites) getPotentialWrites(ri[i], false, potentialWrites) - if ri[i].kind == nkHiddenAddr: - # Optimization: don't use a temp, if we would only take the adress anyway + if ri[i].kind in {nkHiddenAddr, nkAddr}: + # Optimization: don't use a temp, if we would only take the address anyway needTmp[i - 1] = false for i in 1..<ri.len: diff --git a/tests/arc/tarc_orc.nim b/tests/arc/tarc_orc.nim new file mode 100644 index 000000000..879ece3c7 --- /dev/null +++ b/tests/arc/tarc_orc.nim @@ -0,0 +1,22 @@ +discard """ + matrix: "--mm:arc; --mm:orc" +""" + +block: + type + PublicKey = array[32, uint8] + PrivateKey = array[64, uint8] + + proc ed25519_create_keypair(publicKey: ptr PublicKey; privateKey: ptr PrivateKey) = + publicKey[][0] = uint8(88) + + type + KeyPair = object + public: PublicKey + private: PrivateKey + + proc initKeyPair(): KeyPair = + ed25519_create_keypair(result.public.addr, result.private.addr) + + let keys = initKeyPair() + doAssert keys.public[0] == 88 |