[libc-commits] [libc] fbaaa16 - [libc] Add no_sanitize("address") attribute to the getMPFRMatcher function.

Siva Chandra via libc-commits libc-commits at lists.llvm.org
Tue May 5 14:25:10 PDT 2020


I don't understand why, but there is quite some difference. I have attached
what objdump shows me. I am not even sure if it is speaking the truth.

Without asan:

00000000004d2ab0
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE>:
  4d2ab0:       55                      push   %rbp
  4d2ab1:       48 89 e5                mov    %rsp,%rbp
  4d2ab4:       53                      push   %rbx
  4d2ab5:       48 83 ec 18             sub    $0x18,%rsp
  4d2ab9:       48 89 fb                mov    %rdi,%rbx
  4d2abc:       48 89 55 e8             mov    %rdx,-0x18(%rbp)
  4d2ac0:       89 4d f0                mov    %ecx,-0x10(%rbp)
  4d2ac3:       48 8d 55 e8             lea    -0x18(%rbp),%rdx
  4d2ac7:       e8 d4 02 00 00          callq  4d2da0
<_ZN11__llvm_libc7testing4mpfr8internal11MPFRMatcherIfEC2ENS1_9OperationEfRNS1_9ToleranceE>
  4d2acc:       48 89 d8                mov    %rbx,%rax
  4d2acf:       48 83 c4 18             add    $0x18,%rsp
  4d2ad3:       5b                      pop    %rbx
  4d2ad4:       5d                      pop    %rbp
  4d2ad5:       c3                      retq
  4d2ad6:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
  4d2add:       00 00 00

With asan:
  4d2ab0:       55                      push   %rbp
  4d2ab1:       48 89 e5                mov    %rsp,%rbp
  4d2ab4:       41 57                   push   %r15
  4d2ab6:       41 56                   push   %r14
  4d2ab8:       41 55                   push   %r13
  4d2aba:       41 54                   push   %r12
  4d2abc:       53                      push   %rbx
  4d2abd:       48 83 e4 e0             and    $0xffffffffffffffe0,%rsp
  4d2ac1:       48 83 ec 40             sub    $0x40,%rsp
  4d2ac5:       48 89 e3                mov    %rsp,%rbx
  4d2ac8:       f3 0f 11 43 0c          movss  %xmm0,0xc(%rbx)
  4d2acd:       48 89 7b 10             mov    %rdi,0x10(%rbx)
  4d2ad1:       48 8d 05 68 96 2e 00    lea    0x2e9668(%rip),%rax        #
7bc140 <__asan_option_detect_stack_use_after_return>
  4d2ad8:       83 38 00                cmpl   $0x0,(%rax)
  4d2adb:       89 73 08                mov    %esi,0x8(%rbx)
  4d2ade:       89 4b 04                mov    %ecx,0x4(%rbx)
  4d2ae1:       49 89 d6                mov    %rdx,%r14
  4d2ae4:       74 0f                   je     4d2af5
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0x45>
  4d2ae6:       bf 40 00 00 00          mov    $0x40,%edi
  4d2aeb:       e8 50 22 f6 ff          callq  434d40
<__asan_stack_malloc_0>
  4d2af0:       49 89 c4                mov    %rax,%r12
  4d2af3:       eb 03                   jmp    4d2af8
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0x48>
  4d2af5:       45 31 e4                xor    %r12d,%r12d
  4d2af8:       4d 89 e5                mov    %r12,%r13
  4d2afb:       4d 85 e4                test   %r12,%r12
  4d2afe:       75 0e                   jne    4d2b0e
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0x5e>
  4d2b00:       49 89 e5                mov    %rsp,%r13
  4d2b03:       49 83 c5 c0             add    $0xffffffffffffffc0,%r13
  4d2b07:       49 83 e5 e0             and    $0xffffffffffffffe0,%r13
  4d2b0b:       4c 89 ec                mov    %r13,%rsp
  4d2b0e:       4c 89 6b 18             mov    %r13,0x18(%rbx)
  4d2b12:       49 8d 55 20             lea    0x20(%r13),%rdx
  4d2b16:       49 c7 45 00 b3 8a b5    movq   $0x41b58ab3,0x0(%r13)
  4d2b1d:       41
  4d2b1e:       48 8d 05 21 6a 1a 00    lea    0x1a6a21(%rip),%rax        #
679546 <_ZTSN11__llvm_libc7testing11MatcherBaseE+0x3f>
  4d2b25:       49 89 45 08             mov    %rax,0x8(%r13)
  4d2b29:       48 8d 05 80 ff ff ff    lea    -0x80(%rip),%rax        #
4d2ab0
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE>
  4d2b30:       49 89 45 10             mov    %rax,0x10(%r13)
  4d2b34:       4d 89 ef                mov    %r13,%r15
  4d2b37:       49 c1 ef 03             shr    $0x3,%r15
  4d2b3b:       48 b8 f1 f1 f1 f1 00    movabs $0xf3f30400f1f1f1f1,%rax
  4d2b42:       04 f3 f3
  4d2b45:       49 89 87 00 80 ff 7f    mov    %rax,0x7fff8000(%r15)
  4d2b4c:       48 89 d0                mov    %rdx,%rax
  4d2b4f:       48 c1 e8 03             shr    $0x3,%rax
  4d2b53:       80 b8 00 80 ff 7f 00    cmpb   $0x0,0x7fff8000(%rax)
  4d2b5a:       0f 85 89 00 00 00       jne    4d2be9
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0x139>
  4d2b60:       4c 89 32                mov    %r14,(%rdx)
  4d2b63:       48 8d 7a 08             lea    0x8(%rdx),%rdi
  4d2b67:       48 89 f8                mov    %rdi,%rax
  4d2b6a:       48 c1 e8 03             shr    $0x3,%rax
  4d2b6e:       8a 80 00 80 ff 7f       mov    0x7fff8000(%rax),%al
  4d2b74:       84 c0                   test   %al,%al
  4d2b76:       75 60                   jne    4d2bd8
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0x128>
  4d2b78:       8b 43 04                mov    0x4(%rbx),%eax
  4d2b7b:       41 89 45 28             mov    %eax,0x28(%r13)
  4d2b7f:       4c 8b 73 10             mov    0x10(%rbx),%r14
  4d2b83:       4c 89 f7                mov    %r14,%rdi
  4d2b86:       8b 73 08                mov    0x8(%rbx),%esi
  4d2b89:       f3 0f 10 43 0c          movss  0xc(%rbx),%xmm0
  4d2b8e:       e8 2d 03 00 00          callq  4d2ec0
<_ZN11__llvm_libc7testing4mpfr8internal11MPFRMatcherIfEC2ENS1_9OperationEfRNS1_9ToleranceE>
  4d2b93:       49 c7 45 00 0e 36 e0    movq   $0x45e0360e,0x0(%r13)
  4d2b9a:       45
  4d2b9b:       4d 85 e4                test   %r12,%r12
  4d2b9e:       74 1b                   je     4d2bbb
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0x10b>
  4d2ba0:       48 b8 f5 f5 f5 f5 f5    movabs $0xf5f5f5f5f5f5f5f5,%rax
  4d2ba7:       f5 f5 f5
  4d2baa:       49 89 87 00 80 ff 7f    mov    %rax,0x7fff8000(%r15)
  4d2bb1:       49 8b 44 24 38          mov    0x38(%r12),%rax
  4d2bb6:       c6 00 00                movb   $0x0,(%rax)
  4d2bb9:       eb 0b                   jmp    4d2bc6
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0x116>
  4d2bbb:       49 c7 87 00 80 ff 7f    movq   $0x0,0x7fff8000(%r15)
  4d2bc2:       00 00 00 00
  4d2bc6:       4c 89 f0                mov    %r14,%rax
  4d2bc9:       48 8d 65 d8             lea    -0x28(%rbp),%rsp
  4d2bcd:       5b                      pop    %rbx
  4d2bce:       41 5c                   pop    %r12
  4d2bd0:       41 5d                   pop    %r13
  4d2bd2:       41 5e                   pop    %r14
  4d2bd4:       41 5f                   pop    %r15
  4d2bd6:       5d                      pop    %rbp
  4d2bd7:       c3                      retq
  4d2bd8:       89 f9                   mov    %edi,%ecx
  4d2bda:       80 e1 07                and    $0x7,%cl
  4d2bdd:       80 c1 03                add    $0x3,%cl
  4d2be0:       38 c1                   cmp    %al,%cl
  4d2be2:       7c 94                   jl     4d2b78
<_ZN11__llvm_libc7testing4mpfr14getMPFRMatcherIfEENS1_8internal11MPFRMatcherIT_EENS1_9OperationES5_NS1_9ToleranceE+0xc8>
  4d2be4:       e8 17 32 fd ff          callq  4a5e00 <__asan_report_store4>
  4d2be9:       48 89 d7                mov    %rdx,%rdi
  4d2bec:       e8 cf 32 fd ff          callq  4a5ec0 <__asan_report_store8>
  4d2bf1:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
  4d2bf8:       00 00 00
  4d2bfb:       0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)


On Tue, May 5, 2020 at 2:07 PM Alex Brachet-Mialot <
alexbrachetmialot at gmail.com> wrote:

> I'm also curious. Especially given the function which this attribute
> was added is only returning the matcher, and not doing any real work.
>
> On Tue, May 5, 2020 at 4:45 PM Eric Christopher via libc-commits
> <libc-commits at lists.llvm.org> wrote:
> >
> > I'm curious what's taking so long. What's the change in code generation
> in the functions with and without the asan instrumentation?
> >
> > -eric
> >
> > On Tue, May 5, 2020 at 1:37 PM Siva Chandra via libc-commits <
> libc-commits at lists.llvm.org> wrote:
> >>
> >> I submitted this without review to unblock the asan bot. Feel free to
> suggest other ways to improve the run time.
> >>
> >>
> >> On Tue, May 5, 2020 at 1:31 PM Siva Chandra Reddy via libc-commits <
> libc-commits at lists.llvm.org> wrote:
> >>>
> >>>
> >>> Author: Siva Chandra Reddy
> >>> Date: 2020-05-05T13:30:30-07:00
> >>> New Revision: fbaaa16802d7b2fc096c8ed5fa23e0cad56807a2
> >>>
> >>> URL:
> https://github.com/llvm/llvm-project/commit/fbaaa16802d7b2fc096c8ed5fa23e0cad56807a2
> >>> DIFF:
> https://github.com/llvm/llvm-project/commit/fbaaa16802d7b2fc096c8ed5fa23e0cad56807a2.diff
> >>>
> >>> LOG: [libc] Add no_sanitize("address") attribute to the getMPFRMatcher
> function.
> >>>
> >>> This dramtically reduces the run time of tests. For example,
> >>> sincosf_test takes over 25 minutes without this attribute but only 8
> >>> seconds with this attribute.
> >>>
> >>> Added:
> >>>
> >>>
> >>> Modified:
> >>>     libc/utils/MPFRWrapper/MPFRUtils.h
> >>>
> >>> Removed:
> >>>
> >>>
> >>>
> >>>
> ################################################################################
> >>> diff  --git a/libc/utils/MPFRWrapper/MPFRUtils.h
> b/libc/utils/MPFRWrapper/MPFRUtils.h
> >>> index 31afd39b2895..6cdba34882d5 100644
> >>> --- a/libc/utils/MPFRWrapper/MPFRUtils.h
> >>> +++ b/libc/utils/MPFRWrapper/MPFRUtils.h
> >>> @@ -73,6 +73,7 @@ template <typename T> class MPFRMatcher : public
> testing::Matcher<T> {
> >>>  } // namespace internal
> >>>
> >>>  template <typename T>
> >>> +__attribute__((no_sanitize("address")))
> >>>  internal::MPFRMatcher<T> getMPFRMatcher(Operation op, T input,
> Tolerance t) {
> >>>    static_assert(
> >>>        __llvm_libc::cpp::IsFloatingPointType<T>::Value,
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> libc-commits mailing list
> >>> libc-commits at lists.llvm.org
> >>> https://lists.llvm.org/cgi-bin/mailman/listinfo/libc-commits
> >>
> >> _______________________________________________
> >> libc-commits mailing list
> >> libc-commits at lists.llvm.org
> >> https://lists.llvm.org/cgi-bin/mailman/listinfo/libc-commits
> >
> > _______________________________________________
> > libc-commits mailing list
> > libc-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/libc-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200505/d8e06967/attachment-0001.html>


More information about the libc-commits mailing list