From 55c5b1db92c89a3eb10261b05e99ef26b1ef5163 Mon Sep 17 00:00:00 2001 From: flywind Date: Tue, 8 Feb 2022 10:44:44 +0800 Subject: [PATCH 1/3] don't use a temp for addr fix #19497 --- compiler/ccgcalls.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 197728ccfc7b9..2372131fbed2e 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -376,7 +376,7 @@ 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: + if ri[i].kind in {nkHiddenAddr, nkAddr}: # Optimization: don't use a temp, if we would only take the adress anyway needTmp[i - 1] = false From 14e8a0bd45dc2e05b4a71bb374012e7a7c5bf9e1 Mon Sep 17 00:00:00 2001 From: flywind Date: Tue, 8 Feb 2022 10:54:02 +0800 Subject: [PATCH 2/3] Update compiler/ccgcalls.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> --- compiler/ccgcalls.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 2372131fbed2e..ce5fbfdd785a0 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -377,7 +377,7 @@ proc genParams(p: BProc, ri: PNode, typ: PType): Rope = needTmp[i - 1] = potentialAlias(n, potentialWrites) getPotentialWrites(ri[i], false, potentialWrites) if ri[i].kind in {nkHiddenAddr, nkAddr}: - # Optimization: don't use a temp, if we would only take the adress anyway + # Optimization: don't use a temp, if we would only take the address anyway needTmp[i - 1] = false for i in 1.. Date: Tue, 8 Feb 2022 13:19:33 +0800 Subject: [PATCH 3/3] add a test --- tests/arc/tarc_orc.nim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/arc/tarc_orc.nim diff --git a/tests/arc/tarc_orc.nim b/tests/arc/tarc_orc.nim new file mode 100644 index 0000000000000..879ece3c7c648 --- /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