Issue 74164
Summary [aarch64]std::is_permutation function Incorrect input parameter of the same value.
Labels new issue
Assignees
Reporter dongjianqiang2
    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.



_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to