[PATCH] Skip promotable allocas to improve performance at -O0

Anna Zaks zaks.anna at gmail.com
Wed Feb 18 17:19:07 PST 2015


Hi kcc, samsonov, kubabrecka,

Currently, the ASan executables built with -O0 are unnecessarily slow. The main reason is that ASan instrumentation pass inserts redundant checks around promotable allocas. These allocas do not get instrumented under -O1 because they get converted to virtual registered by mem2reg. With this patch, ASan instrumentation pass will only instrument non promotable allocas, giving us a speedup of 39% on a collection of benchmarks with -O0. (There is no measurable speedup at -O1.)

Comments/Questions:

- We've initially discussed creating another pass to annotate the uninteresting load and stores. However, the check is simple and having a separate pass seems like an overkill.
- A bunch of ASan llvm tests are written using promotable allocas. I've added volatile stores or marked the existing stores as volatile to make the allocas non-promotable.
- Two of the runtime tests also seem to depend on being run with -O0. With this modification, I am getting the same behavior as when the tests are run with higher optimization levels. I've turned off the mode on those tests since I am not sure if a better fix is available. They fail on comparing values returned by __asan_region_is_poisoned.
- Should "isInterestingAlloca()" be hoisted out of "FunctionStackPoisoner" and used in "isInterestingMemoryAccess"?

http://reviews.llvm.org/D7741

Files:
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  test/Instrumentation/AddressSanitizer/debug_info.ll
  test/Instrumentation/AddressSanitizer/do-not-instrument-promotable-allocas.ll
  test/Instrumentation/AddressSanitizer/instrument-dynamic-allocas.ll
  test/Instrumentation/AddressSanitizer/lifetime-uar.ll
  test/Instrumentation/AddressSanitizer/lifetime.ll
  test/Instrumentation/AddressSanitizer/stack_dynamic_alloca.ll
  test/Instrumentation/AddressSanitizer/stack_layout.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7741.20239.patch
Type: text/x-patch
Size: 10080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150219/3f753d1e/attachment.bin>


More information about the llvm-commits mailing list