myatsina added a comment.

In https://reviews.llvm.org/D15075#631316, @ahatanak wrote:

> In https://reviews.llvm.org/D15075#631237, @myatsina wrote:
>
> > In https://reviews.llvm.org/D15075#631207, @vitalybuka wrote:
> >
> > > These patches break asan tests: 
> > > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/528/steps/check-asan%20in%20gcc%20build/logs/stdio
> >
> >
> > Vitaly ,
> >
> > This patch is a gcc compatibility issue and it changes clang to output an 
> > error in case of illegal inline assembly syntax related to clobber list.
> >
> > Commit r290540 changed an asan test (asan_asm_test.cc) that used the 
> > illegal syntax and fixed it.
> >  The commit removed from the extended inline assembly clobber list 
> > registers that also appeared in the  input list.
> >  GCC fails as well on the original inline assembly that appeared in this 
> > test, so the fix is correct.
> >  I don't understand why this change has effect the logic of the test - can 
> > you help?
> >
> > Thanks,
> > Marina
>
>
> I believe asm_rep_movs needs something in the output operand list that tells 
> the compiler the inline-asm statement changes the contents of the registers 
> ("S", "D" and "c"). Otherwise, the compiler (register allocator) will not 
> save the old value of dst_good and src_good so that it can be used later in 
> the static_assert:
>
>   asm_rep_movs(dst_good, src_good, 4);
>   ASSERT_EQ(static_cast<T>(0x0), dst_good[0]); // "D" register was 
> incremented 4 times.
>


You are right, the "S" and "D" constraint are wrong as well in both 
DECLARE_ASM_REP_MOVS macros, the right assembly should probably be something 
like:

__asm__("rep movsb \n\t"

  : "D"(dst), "S"(src)
  : "S"(src), "c"(size)
  : "memory");

The different movs instructions change both esi/rsi and edi/rdi (movs copies 
esi to edi and then also increments/decrements both registers), so esi/rdi is 
both input and output while edi/rdi is just output.

The problem is I am not able to build the AsanSanitizer unit test and check if 
this fixes the issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to