[compiler-rt] r212456 - [asan] Remove runtime assembly helpers.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Mon Jul 7 06:59:12 PDT 2014


Author: eugenis
Date: Mon Jul  7 08:59:12 2014
New Revision: 212456

URL: http://llvm.org/viewvc/llvm-project?rev=212456&view=rev
Log:
[asan] Remove runtime assembly helpers.

Remove helper functions that were used in assembly instrumentation.

Patch by Yuri Gorshenin.

Removed:
    compiler-rt/trunk/lib/asan/asan_asm_instrumentation.S
    compiler-rt/trunk/lib/asan/scripts/gen_asm_instrumentation.sh
Modified:
    compiler-rt/trunk/lib/asan/CMakeLists.txt
    compiler-rt/trunk/lib/asan/tests/asan_asm_test.cc

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=212456&r1=212455&r2=212456&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Mon Jul  7 08:59:12 2014
@@ -62,7 +62,6 @@ append_if(COMPILER_RT_HAS_LIBPTHREAD pth
 append_if(COMPILER_RT_HAS_LIBDL dl ASAN_DYNAMIC_LIBS)
 
 if (NOT MSVC)
-  set(ASAN_ASM_SOURCES asan_asm_instrumentation.S)
   set_source_files_properties(${ASAN_ASM_SOURCES} PROPERTIES LANGUAGE C)
   list(APPEND ASAN_SOURCES ${ASAN_ASM_SOURCES})
 endif()

Removed: compiler-rt/trunk/lib/asan/asan_asm_instrumentation.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_asm_instrumentation.S?rev=212455&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_asm_instrumentation.S (original)
+++ compiler-rt/trunk/lib/asan/asan_asm_instrumentation.S (removed)
@@ -1,601 +0,0 @@
-// This file was generated by gen_asm_instrumentation.sh. Please, do not edit
-// manually.
-#ifdef __linux__
-.section .text
-#if defined(__x86_64__) || defined(__i386__)
-.globl __asan_report_store1
-.globl __asan_report_load1
-.globl __asan_report_store2
-.globl __asan_report_load2
-.globl __asan_report_store4
-.globl __asan_report_load4
-.globl __asan_report_store8
-.globl __asan_report_load8
-.globl __asan_report_store16
-.globl __asan_report_load16
-#endif //  defined(__x86_64__) || defined(__i386__)
-#if defined(__i386__)
-// Sanitize 1-byte store. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_store1
-.type __sanitizer_sanitize_store1, @function
-__sanitizer_sanitize_store1:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushl %edx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  movb 0x20000000(%ecx), %cl
-  testb %cl, %cl
-  je .sanitize_store1_done
-  movl %eax, %edx
-  andl $0x7, %edx
-  movsbl %cl, %ecx
-  cmpl %ecx, %edx
-  jl .sanitize_store1_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_store1 at PLT
-.sanitize_store1_done:
-  popfl
-  popl %edx
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 1-byte load. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_load1
-.type __sanitizer_sanitize_load1, @function
-__sanitizer_sanitize_load1:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushl %edx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  movb 0x20000000(%ecx), %cl
-  testb %cl, %cl
-  je .sanitize_load1_done
-  movl %eax, %edx
-  andl $0x7, %edx
-  movsbl %cl, %ecx
-  cmpl %ecx, %edx
-  jl .sanitize_load1_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_load1 at PLT
-.sanitize_load1_done:
-  popfl
-  popl %edx
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 2-byte store. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_store2
-.type __sanitizer_sanitize_store2, @function
-__sanitizer_sanitize_store2:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushl %edx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  movb 0x20000000(%ecx), %cl
-  testb %cl, %cl
-  je .sanitize_store2_done
-  movl %eax, %edx
-  andl $0x7, %edx
-  incl %edx
-  movsbl %cl, %ecx
-  cmpl %ecx, %edx
-  jl .sanitize_store2_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_store2 at PLT
-.sanitize_store2_done:
-  popfl
-  popl %edx
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 2-byte load. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_load2
-.type __sanitizer_sanitize_load2, @function
-__sanitizer_sanitize_load2:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushl %edx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  movb 0x20000000(%ecx), %cl
-  testb %cl, %cl
-  je .sanitize_load2_done
-  movl %eax, %edx
-  andl $0x7, %edx
-  incl %edx
-  movsbl %cl, %ecx
-  cmpl %ecx, %edx
-  jl .sanitize_load2_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_load2 at PLT
-.sanitize_load2_done:
-  popfl
-  popl %edx
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 4-byte store. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_store4
-.type __sanitizer_sanitize_store4, @function
-__sanitizer_sanitize_store4:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushl %edx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  movb 0x20000000(%ecx), %cl
-  testb %cl, %cl
-  je .sanitize_store4_done
-  movl %eax, %edx
-  andl $0x7, %edx
-  addl $0x3, %edx
-  movsbl %cl, %ecx
-  cmpl %ecx, %edx
-  jl .sanitize_store4_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_store4 at PLT
-.sanitize_store4_done:
-  popfl
-  popl %edx
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 4-byte load. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_load4
-.type __sanitizer_sanitize_load4, @function
-__sanitizer_sanitize_load4:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushl %edx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  movb 0x20000000(%ecx), %cl
-  testb %cl, %cl
-  je .sanitize_load4_done
-  movl %eax, %edx
-  andl $0x7, %edx
-  addl $0x3, %edx
-  movsbl %cl, %ecx
-  cmpl %ecx, %edx
-  jl .sanitize_load4_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_load4 at PLT
-.sanitize_load4_done:
-  popfl
-  popl %edx
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 8-byte store. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_store8
-.type __sanitizer_sanitize_store8, @function
-__sanitizer_sanitize_store8:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  cmpb $0x0, 0x20000000(%ecx)
-  je .sanitize_store8_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_store8 at PLT
-.sanitize_store8_done:
-  popfl
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 8-byte load. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_load8
-.type __sanitizer_sanitize_load8, @function
-__sanitizer_sanitize_load8:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  cmpb $0x0, 0x20000000(%ecx)
-  je .sanitize_load8_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_load8 at PLT
-.sanitize_load8_done:
-  popfl
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 16-byte store. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_store16
-.type __sanitizer_sanitize_store16, @function
-__sanitizer_sanitize_store16:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  cmpw $0x0, 0x20000000(%ecx)
-  je .sanitize_store16_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_store16 at PLT
-.sanitize_store16_done:
-  popfl
-  popl %ecx
-  popl %eax
-  leave
-  ret
-// Sanitize 16-byte load. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl __sanitizer_sanitize_load16
-.type __sanitizer_sanitize_load16, @function
-__sanitizer_sanitize_load16:
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl $0x3, %ecx
-  cmpw $0x0, 0x20000000(%ecx)
-  je .sanitize_load16_done
-  pushl %eax
-  cld
-  emms
-  call __asan_report_load16 at PLT
-.sanitize_load16_done:
-  popfl
-  popl %ecx
-  popl %eax
-  leave
-  ret
-#endif // defined(__i386__)
-#if defined(__x86_64__)
-// Sanitize 1-byte store. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_store1
-.type __sanitizer_sanitize_store1, @function
-__sanitizer_sanitize_store1:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushq %rcx
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  movb 0x7fff8000(%rax), %al
-  test %al, %al
-  je .sanitize_store1_done
-  movl %edi, %ecx
-  andl $0x7, %ecx
-  movsbl %al, %eax
-  cmpl %eax, %ecx
-  jl .sanitize_store1_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_store1 at PLT
-.sanitize_store1_done:
-  popfq
-  popq %rcx
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 1-byte load. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_load1
-.type __sanitizer_sanitize_load1, @function
-__sanitizer_sanitize_load1:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushq %rcx
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  movb 0x7fff8000(%rax), %al
-  test %al, %al
-  je .sanitize_load1_done
-  movl %edi, %ecx
-  andl $0x7, %ecx
-  movsbl %al, %eax
-  cmpl %eax, %ecx
-  jl .sanitize_load1_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_load1 at PLT
-.sanitize_load1_done:
-  popfq
-  popq %rcx
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 2-byte store. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_store2
-.type __sanitizer_sanitize_store2, @function
-__sanitizer_sanitize_store2:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushq %rcx
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  movb 0x7fff8000(%rax), %al
-  test %al, %al
-  je .sanitize_store2_done
-  movl %edi, %ecx
-  andl $0x7, %ecx
-  incl %ecx
-  movsbl %al, %eax
-  cmpl %eax, %ecx
-  jl .sanitize_store2_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_store2 at PLT
-.sanitize_store2_done:
-  popfq
-  popq %rcx
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 2-byte load. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_load2
-.type __sanitizer_sanitize_load2, @function
-__sanitizer_sanitize_load2:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushq %rcx
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  movb 0x7fff8000(%rax), %al
-  test %al, %al
-  je .sanitize_load2_done
-  movl %edi, %ecx
-  andl $0x7, %ecx
-  incl %ecx
-  movsbl %al, %eax
-  cmpl %eax, %ecx
-  jl .sanitize_load2_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_load2 at PLT
-.sanitize_load2_done:
-  popfq
-  popq %rcx
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 4-byte store. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_store4
-.type __sanitizer_sanitize_store4, @function
-__sanitizer_sanitize_store4:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushq %rcx
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  movb 0x7fff8000(%rax), %al
-  test %al, %al
-  je .sanitize_store4_done
-  movl %edi, %ecx
-  andl $0x7, %ecx
-  addl $0x3, %ecx
-  movsbl %al, %eax
-  cmpl %eax, %ecx
-  jl .sanitize_store4_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_store4 at PLT
-.sanitize_store4_done:
-  popfq
-  popq %rcx
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 4-byte load. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_load4
-.type __sanitizer_sanitize_load4, @function
-__sanitizer_sanitize_load4:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushq %rcx
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  movb 0x7fff8000(%rax), %al
-  test %al, %al
-  je .sanitize_load4_done
-  movl %edi, %ecx
-  andl $0x7, %ecx
-  addl $0x3, %ecx
-  movsbl %al, %eax
-  cmpl %eax, %ecx
-  jl .sanitize_load4_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_load4 at PLT
-.sanitize_load4_done:
-  popfq
-  popq %rcx
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 8-byte store. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_store8
-.type __sanitizer_sanitize_store8, @function
-__sanitizer_sanitize_store8:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  cmpb $0x0, 0x7fff8000(%rax)
-  je .sanitize_store8_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_store8 at PLT
-.sanitize_store8_done:
-  popfq
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 8-byte load. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_load8
-.type __sanitizer_sanitize_load8, @function
-__sanitizer_sanitize_load8:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  cmpb $0x0, 0x7fff8000(%rax)
-  je .sanitize_load8_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_load8 at PLT
-.sanitize_load8_done:
-  popfq
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 16-byte store. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_store16
-.type __sanitizer_sanitize_store16, @function
-__sanitizer_sanitize_store16:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  cmpw $0x0, 0x7fff8000(%rax)
-  je .sanitize_store16_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_store16 at PLT
-.sanitize_store16_done:
-  popfq
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-// Sanitize 16-byte load. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl __sanitizer_sanitize_load16
-.type __sanitizer_sanitize_load16, @function
-__sanitizer_sanitize_load16:
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushfq
-  movq %rdi, %rax
-  shrq $0x3, %rax
-  cmpw $0x0, 0x7fff8000(%rax)
-  je .sanitize_load16_done
-  subq $8, %rsp
-  andq $-16, %rsp
-  cld
-  emms
-  call __asan_report_load16 at PLT
-.sanitize_load16_done:
-  popfq
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-#endif // defined(__x86_64__)
-/* We do not need executable stack. */
-#if defined(__arm__)
-  .section .note.GNU-stack,"",%progbits
-#else
-  .section .note.GNU-stack,"", at progbits
-#endif // defined(__arm__)
-#endif // __linux__

Removed: compiler-rt/trunk/lib/asan/scripts/gen_asm_instrumentation.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/gen_asm_instrumentation.sh?rev=212455&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/scripts/gen_asm_instrumentation.sh (original)
+++ compiler-rt/trunk/lib/asan/scripts/gen_asm_instrumentation.sh (removed)
@@ -1,266 +0,0 @@
-#!/bin/bash
-
-#===- lib/asan/scripts/gen_asm_instrumentation.sh -------------------------===#
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-# Emit x86 instrumentation functions for asan.
-#
-#===-----------------------------------------------------------------------===#
-
-check() {
-  test $# -eq 2 || (echo "Incorrent number of arguments: $#" 1>&2 && exit 1)
-  case "$1" in
-    store) ;;
-     load) ;;
-        *) echo "Incorrect first argument: $1" 1>&2 && exit 1 ;;
-  esac
-  case "$2" in
-    [0-9]*) ;;
-         *) echo "Incorrect second argument: $2" 1>&2 && exit 1 ;;
-  esac
-}
-
-func_name() {
-  check $1 $2
-  echo "__sanitizer_sanitize_$1$2"
-}
-
-func_label() {
-  check $1 $2
-  echo ".sanitize_$1$2_done"
-}
-
-func_report() {
-  check $1 $2
-  echo "__asan_report_$1$2"
-}
-
-emit_call_report() {
-cat <<EOF
-  cld
-  emms
-  call $(func_report $1 $2)@PLT
-EOF
-}
-
-emit_stack_align() {
-cat <<EOF
-  subq \$8, %rsp
-  andq \$-16, %rsp
-EOF
-}
-
-cat <<EOF
-// This file was generated by $(basename $0). Please, do not edit
-// manually.
-EOF
-
-echo "#ifdef __linux__"
-echo ".section .text"
-
-echo "#if defined(__x86_64__) || defined(__i386__)"
-for as in 1 2 4 8 16
-do
-  for at in store load
-  do
-    echo ".globl $(func_report $at $as)"
-  done
-done
-echo "#endif //  defined(__x86_64__) || defined(__i386__)"
-
-echo "#if defined(__i386__)"
-
-# Functions for i386 1-, 2- and 4-byte accesses.
-for as in 1 2 4
-do
-  for at in store load
-  do
-cat <<EOF
-// Sanitize $as-byte $at. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl $(func_name $at $as)
-.type $(func_name $at $as), @function
-$(func_name $at $as):
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushl %edx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl \$0x3, %ecx
-  movb 0x20000000(%ecx), %cl
-  testb %cl, %cl
-  je $(func_label $at $as)
-  movl %eax, %edx
-  andl \$0x7, %edx
-EOF
-
-    case $as in
-    1) ;;
-    2) echo '  incl %edx' ;;
-    4) echo '  addl $0x3, %edx' ;;
-    *) echo "Incorrect access size: $as" 1>&2; exit 1 ;;
-    esac
-
-cat <<EOF
-  movsbl %cl, %ecx
-  cmpl %ecx, %edx
-  jl $(func_label $at $as)
-  pushl %eax
-$(emit_call_report $at $as)
-$(func_label $at $as):
-  popfl
-  popl %edx
-  popl %ecx
-  popl %eax
-  leave
-  ret
-EOF
-  done
-done
-
-# Functions for i386 8- and 16-byte accesses.
-for as in 8 16
-do
-  for at in store load
-  do
-cat <<EOF
-// Sanitize $as-byte $at. Takes one 4-byte address as an argument on
-// stack, nothing is returned.
-.globl $(func_name $at $as)
-.type $(func_name $at $as), @function
-$(func_name $at $as):
-  pushl %ebp
-  movl %esp, %ebp
-  pushl %eax
-  pushl %ecx
-  pushfl
-  movl 8(%ebp), %eax
-  movl %eax, %ecx
-  shrl \$0x3, %ecx
-EOF
-
-    case ${as} in
-      8) echo '  cmpb $0x0, 0x20000000(%ecx)' ;;
-     16) echo '  cmpw $0x0, 0x20000000(%ecx)' ;;
-      *) echo "Incorrect access size: ${as}" 1>&2; exit 1 ;;
-    esac
-
-cat <<EOF
-  je $(func_label $at $as)
-  pushl %eax
-$(emit_call_report $at $as)
-$(func_label $at $as):
-  popfl
-  popl %ecx
-  popl %eax
-  leave
-  ret
-EOF
-  done
-done
-
-echo "#endif // defined(__i386__)"
-
-echo "#if defined(__x86_64__)"
-
-# Functions for x86-64 1-, 2- and 4-byte accesses.
-for as in 1 2 4
-do
-  for at in store load
-  do
-cat <<EOF
-// Sanitize $as-byte $at. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl $(func_name $at $as)
-.type $(func_name $at $as), @function
-$(func_name $at $as):
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushq %rcx
-  pushfq
-  movq %rdi, %rax
-  shrq \$0x3, %rax
-  movb 0x7fff8000(%rax), %al
-  test %al, %al
-  je $(func_label $at $as)
-  movl %edi, %ecx
-  andl \$0x7, %ecx
-EOF
-
-    case ${as} in
-    1) ;;
-    2) echo '  incl %ecx' ;;
-    4) echo '  addl $0x3, %ecx' ;;
-    *) echo "Incorrect access size: ${as}" 1>&2; exit 1 ;;
-    esac
-
-cat <<EOF
-  movsbl %al, %eax
-  cmpl %eax, %ecx
-  jl $(func_label $at $as)
-$(emit_stack_align)
-$(emit_call_report $at $as)
-$(func_label $at $as):
-  popfq
-  popq %rcx
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-EOF
-  done
-done
-
-# Functions for x86-64 8- and 16-byte accesses.
-for as in 8 16
-do
-  for at in store load
-  do
-cat <<EOF
-// Sanitize $as-byte $at. Takes one 8-byte address as an argument in %rdi,
-// nothing is returned.
-.globl $(func_name $at $as)
-.type $(func_name $at $as), @function
-$(func_name $at $as):
-  leaq -128(%rsp), %rsp
-  pushq %rax
-  pushfq
-  movq %rdi, %rax
-  shrq \$0x3, %rax
-EOF
-
-    case ${as} in
-      8) echo '  cmpb $0x0, 0x7fff8000(%rax)' ;;
-     16) echo '  cmpw $0x0, 0x7fff8000(%rax)' ;;
-      *) echo "Incorrect access size: ${as}" 1>&2; exit 1 ;;
-    esac
-
-cat <<EOF
-  je $(func_label $at $as)
-$(emit_stack_align)
-$(emit_call_report $at $as)
-$(func_label $at $as):
-  popfq
-  popq %rax
-  leaq 128(%rsp), %rsp
-  ret
-EOF
-  done
-done
-echo "#endif // defined(__x86_64__)"
-
-cat <<EOF
-/* We do not need executable stack. */
-#if defined(__arm__)
-  .section .note.GNU-stack,"",%progbits
-#else
-  .section .note.GNU-stack,"", at progbits
-#endif // defined(__arm__)
-#endif // __linux__
-EOF

Modified: compiler-rt/trunk/lib/asan/tests/asan_asm_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_asm_test.cc?rev=212456&r1=212455&r2=212456&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_asm_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_asm_test.cc Mon Jul  7 08:59:12 2014
@@ -12,8 +12,6 @@
 //===----------------------------------------------------------------------===//
 #include "asan_test_utils.h"
 
-// Tests for __sanitizer_sanitize_(store|load)N functions in compiler-rt.
-
 #if defined(__linux__)
 
 #if defined(__x86_64__) || (defined(__i386__) && defined(__SSE2__))
@@ -36,13 +34,10 @@ namespace {
 #define DECLARE_ASM_WRITE(Type, Size, Mov, Reg)        \
 template<> void asm_write<Type>(Type *ptr, Type val) { \
   __asm__(                                             \
-    "leaq (%[ptr]), %%rdi  \n\t"                       \
-    "movabsq $__sanitizer_sanitize_store" Size ", %%r11  \n\t" \
-    "call *%%r11  \n\t"                                 \
     Mov " %[val], (%[ptr])  \n\t"                      \
     :                                                  \
     : [ptr] "r" (ptr), [val] Reg (val)                 \
-    : "memory", "rdi", "r11"                           \
+    : "memory"                                         \
   );                                                   \
 }
 
@@ -50,13 +45,10 @@ template<> void asm_write<Type>(Type *pt
 template<> Type asm_read<Type>(Type *ptr) {        \
   Type res;                                        \
   __asm__(                                         \
-    "leaq (%[ptr]), %%rdi  \n\t"                   \
-    "movabsq $__sanitizer_sanitize_load" Size ", %%r11  \n\t" \
-    "callq *%%r11  \n\t"                           \
     Mov " (%[ptr]), %[res]  \n\t"                  \
     : [res] Reg (res)                              \
     : [ptr] "r" (ptr)                              \
-    : "memory", "rdi", "r11"                       \
+    : "memory"                                     \
   );                                               \
   return res;                                      \
 }
@@ -75,14 +67,10 @@ namespace {
 #define DECLARE_ASM_WRITE(Type, Size, Mov, Reg)        \
 template<> void asm_write<Type>(Type *ptr, Type val) { \
   __asm__(                                             \
-    "leal (%[ptr]), %%eax  \n\t"                       \
-    "pushl %%eax  \n\t"                                \
-    "call __sanitizer_sanitize_store" Size "  \n\t"    \
-    "popl %%eax  \n\t"                                 \
     Mov " %[val], (%[ptr])  \n\t"                      \
     :                                                  \
     : [ptr] "r" (ptr), [val] Reg (val)                 \
-    : "memory", "eax", "esp"                           \
+    : "memory"                                         \
   );                                                   \
 }
 
@@ -90,52 +78,14 @@ template<> void asm_write<Type>(Type *pt
 template<> Type asm_read<Type>(Type *ptr) {        \
   Type res;                                        \
   __asm__(                                         \
-    "leal (%[ptr]), %%eax  \n\t"                   \
-    "pushl %%eax  \n\t"                            \
-    "call __sanitizer_sanitize_load" Size "  \n\t" \
-    "popl %%eax  \n\t"                             \
     Mov " (%[ptr]), %[res]  \n\t"                  \
     : [res] Reg (res)                              \
     : [ptr] "r" (ptr)                              \
-    : "memory", "eax", "esp"                       \
+    : "memory"                                     \
   );                                               \
   return res;                                      \
 }
 
-template<> void asm_write<U8>(U8 *ptr, U8 val) {
-  __asm__(
-    "leal (%[ptr]), %%eax  \n\t"
-    "pushl %%eax  \n\t"
-    "call __sanitizer_sanitize_store8  \n\t"
-    "popl %%eax  \n\t"
-    "movl (%[val]), %%eax  \n\t"
-    "movl %%eax, (%[ptr])  \n\t"
-    "movl 0x4(%[val]), %%eax  \n\t"
-    "movl %%eax, 0x4(%[ptr])  \n\t"
-    :
-    : [ptr] "r" (ptr), [val] "r" (&val)
-    : "memory", "eax", "esp"
-  );
-}
-
-template<> U8 asm_read(U8 *ptr) {
-  U8 res;
-  __asm__(
-    "leal (%[ptr]), %%eax  \n\t"
-    "pushl %%eax  \n\t"
-    "call __sanitizer_sanitize_load8  \n\t"
-    "popl  %%eax  \n\t"
-    "movl (%[ptr]), %%eax  \n\t"
-    "movl %%eax, (%[res])  \n\t"
-    "movl 0x4(%[ptr]), %%eax  \n\t"
-    "movl %%eax, 0x4(%[res])  \n\t"
-    :
-    : [ptr] "r" (ptr), [res] "r" (&res)
-    : "memory", "eax", "esp"
-  );
-  return res;
-}
-
 } // End of anonymous namespace
 
 #endif  // defined(__i386__) && defined(__SSE2__)
@@ -220,13 +170,17 @@ TEST(AddressSanitizer, asm_rw) {
   TestAsmWrite<U1>("WRITE of size 1");
   TestAsmWrite<U2>("WRITE of size 2");
   TestAsmWrite<U4>("WRITE of size 4");
+#if defined(__x86_64__)
   TestAsmWrite<U8>("WRITE of size 8");
+#endif // defined(__x86_64__)
   TestAsmWrite<__m128i>("WRITE of size 16");
 
   TestAsmRead<U1>("READ of size 1");
   TestAsmRead<U2>("READ of size 2");
   TestAsmRead<U4>("READ of size 4");
+#if defined(__x86_64__)
   TestAsmRead<U8>("READ of size 8");
+#endif // defined(__x86_64__)
   TestAsmRead<__m128i>("READ of size 16");
 }
 





More information about the llvm-commits mailing list