<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74164>74164</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[aarch64]std::is_permutation function Incorrect input parameter of the same value.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dongjianqiang2
</td>
</tr>
</table>
<pre>
demo.cpp
`#include <algorithm>
#include <iostream>
int main (void) {
bool rv=true;
{
std::initializer_list<int> a{1,2,3,4,5},b{5,4,3,2,1}, c{1,2,3,4};
rv&=std::is_permutation(a.begin(), a.end(), b.begin());
return std::is_permutation(a.begin(), a.end(), c.begin() ); //supposed to return 0;
}
}
`
clang++ demo.cpp -O2
./a.out
echo $?
1
gdb ./a.out
0x0000aaaaaaaaa930 <+76>: ldr q0, [x10, #3520]
0x0000aaaaaaaaa934 <+80>: mov x1, x19
0x0000aaaaaaaaa938 <+84>: str w8, [sp, #32]
0x0000aaaaaaaaa93c <+88>: stp q0, q1, [sp]
0x0000aaaaaaaaa940 <+92>: bl 0xaaaaaaaaa968 <_ZSt16__is_permutationIPKiS1_N9__gnu_cxx5__ops19_Iter_equal_to_iterEEbT_S5_T0_T1_>
0x0000aaaaaaaaa944 <+96>: sub x0, x29, #0x20
0x0000aaaaaaaaa948 <+100>: mov x2, sp
0x0000aaaaaaaaa94c <+104>: mov x1, x19
=> 0x0000aaaaaaaaa950 <+108>: bl 0xaaaaaaaaa968 <_ZSt16__is_permutationIPKiS1_N9__gnu_cxx5__ops19_Iter_equal_to_iterEEbT_S5_T0_T1_>
0x0000aaaaaaaaa954 <+112>: and w0, w0, #0x1
0x0000aaaaaaaaa958 <+116>: ldp x29, x30, [sp, #80]
0x0000aaaaaaaaa95c <+120>: ldr x19, [sp, #96]
0x0000aaaaaaaaa960 <+124>: add sp, sp, #0x70
0x0000aaaaaaaaa964 <+128>: ret
End of assembler dump.
(gdb) x /5wx $x0
0xffffffffe940: 0x00000001 0x00000002 0x00000003 0x00000004
0xffffffffe950: 0x00000005
(gdb) x /5wx $x2
0xffffffffe910: 0x00000001 0x00000002 0x00000003 0x00000004
0xffffffffe920: 0x00000005
The same value is saved in the input space (x0 and x2)。
I look into the assemble and find that they may have used the same rodata.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVkuP4ygX_TU3G9QRDz8XWXReUumTvhmpazUbC2yS0GMbF-CUa379CD-TSqcWo1mMIzngyz0czj3GcGvVuZZyA-EWwv2Kt-6izabQ9fmn4vWb4vWZroQuPjaFrPQ6bxrAe8Dfx3uEgTJV52VbSARsx8uzNspdKmCHcchdXGnrjOQ34Zu7qh2quKoR0OSqVQE0RRBvhyBCCAmtS2SuwPbOtBLYTehunL-sK4B9B_Zd1copXqq_pMlKZZ1nUTtgB8Qh3hKgOwp0x4DuAqC7EOI90J2AeBuOj9g4hAwhlD-kxfs7Lv4yV6ARsP1Cw2aNNFXruFO6BprwtZBn5VtAU4_L17Iulq64j6ePU0jXmhr98xny2zgapkAI6BHo0bZNo60skNPTRPiT4PuxdnMjwrfVzEten4FugW7R5B307Tc6RNdAj3ytW4eGvswvGgENgB2HB-QW61wINGfcBhBCuMMYYz5dKcPeaEC3ceRdxnq2ZWF6zd6wXziE244MLcpYSDGE--d4wYiX4AWv0tcer_NGQB1Jn6cnU3qwpFs30HlPRjq2mdjQL7nkE1hyC9bcrO2NLJBfIAWTSildkEQ5OAt3y8Co55_98cORKMvuPfby-__UD5L9P82yc91medeFWaYbS9LsxUmTybeWl5nTmXLSHA7iNfsRZq84eyXZvAH8itukeHpTQduKQfF-ld3gYKAMdxQ_R5rEJ3gp3lw7_wIj2zzPzufs4DH7vvLA9n5L-QwR4hliqdh_ROZwkpmQxQO8LgZn9jK_41ll8hxnFpks9SqLZhS5L1TH8GenJ1--deGsPcU3oGbUPv2MlkZfoUVzGehSSV4MSx0wZiTcxc8NFc2a0aWeR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