[PATCH] [WIP] Use dynamic alloca for stack variables in ASan.

Alexey Samsonov vonosmas at gmail.com
Mon Dec 1 11:56:32 PST 2014


This is an experimental patch that changes the way we
instrument stack variables: instead of merging all static alloca
instructions into one large static alloca, we merge them into
one *dynamic* alloca. There are two main reasons for that:

1) We significantly reduce the stack usage in "use-after-return"
mode. Currently, large static alloca is just unused in use-after-return
mode, as we actually use "fake stack" allocated by the ASan runtime.

2) It can improve debug info for local variables, as their location
will now be calculated via %rbx register, not %rsp, that is assumed
to be clobbered by function calls.

I'm still running a SPEC for this patch to see if it slows down ASan
on benchmarks. I've also ran it on a large internal codebase, and it
unveiled numerous problems. I see problems with inline assembly
(e.g. inline assembly code for fetching cpuid doesn't properly
save/restore %rbx, or compile errors of the form "inline assembly requires
more registers than available"). I also see several runtime errors
on -O2 level, which I haven't debugged yet.

Sadly, deployment of this change will be hard (if possible). Still,
you're welcome to experiment with this patch and see if it solves
some problems you observe (esp. debug info issues).

http://reviews.llvm.org/D6465

Files:
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  projects/compiler-rt/lib/asan/asan_fake_stack.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6465.16778.patch
Type: text/x-patch
Size: 7901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141201/c975c6f6/attachment.bin>


More information about the llvm-commits mailing list