summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ASan] Fix comments about __sanitizer_cov functionAlexey Samsonov2014-07-221-3/+2
| | | | llvm-svn: 213673
* [ASan] Don't instrument load/stores with !nosanitize metadata.Alexey Samsonov2014-07-171-0/+3
| | | | | | | | | This is used to avoid instrumentation of instructions added by UBSan in Clang frontend (see r213291). This fixes PR20085. Reviewed in http://reviews.llvm.org/D4544. llvm-svn: 213292
* [ASan] Collect unmangled names of global variables in Clang to print them in ↵Alexey Samsonov2014-07-121-9/+20
| | | | | | | | | | | | | | | | | error reports. Currently ASan instrumentation pass creates a string with global name for each instrumented global (to include global names in the error report). Global name is already mangled at this point, and we may not be able to demangle it at runtime (e.g. there is no __cxa_demangle on Android). Instead, create a string with fully qualified global name in Clang, and pass it to ASan instrumentation pass in llvm.asan.globals metadata. If there is no metadata for some global, ASan will use the original algorithm. This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=264. llvm-svn: 212872
* [ASan] Introduce a struct representing the layout of metadata entry in ↵Alexey Samsonov2014-07-111-47/+37
| | | | | | | | llvm.asan.globals. No functionality change. llvm-svn: 212850
* [ASan/Win] Don't instrument COMDAT globals. Properly fixes PR20244.Timur Iskhodzhanov2014-07-091-8/+4
| | | | llvm-svn: 212596
* [ASan/Win] Don't instrument private COMDAT globals until PR20244 is properly ↵Timur Iskhodzhanov2014-07-081-0/+7
| | | | | | fixed llvm-svn: 212530
* [ASan] Completely remove sanitizer blacklist file from instrumentation pass.Alexey Samsonov2014-07-081-17/+5
| | | | | | | | | | | | | | | | | | | | All blacklisting logic is now moved to the frontend (Clang). If a function (or source file it is in) is blacklisted, it doesn't get sanitize_address attribute and is therefore not instrumented. If a global variable (or source file it is in) is blacklisted, it is reported to be blacklisted by the entry in llvm.asan.globals metadata, and is not modified by the instrumentation. The latter may lead to certain false positives - not all the globals created by Clang are described in llvm.asan.globals metadata (e.g, RTTI descriptors are not), so we may start reporting errors on them even if "module" they appear in is blacklisted. We assume it's fine to take such risk: 1) errors on these globals are rare and usually indicate wild memory access 2) we can lazily add descriptors for these globals into llvm.asan.globals lazily. llvm-svn: 212505
* Remove non-static field initializer to appease MSVCAlexey Samsonov2014-07-021-1/+2
| | | | llvm-svn: 212212
* [ASan] Print exact source location of global variables in error reports.Alexey Samsonov2014-07-021-31/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://code.google.com/p/address-sanitizer/issues/detail?id=299 for the original feature request. Introduce llvm.asan.globals metadata, which Clang (or any other frontend) may use to report extra information about global variables to ASan instrumentation pass in the backend. This metadata replaces llvm.asan.dynamically_initialized_globals that was used to detect init-order bugs. llvm.asan.globals contains the following data for each global: 1) source location (file/line/column info); 2) whether it is dynamically initialized; 3) whether it is blacklisted (shouldn't be instrumented). Source location data is then emitted in the binary and can be picked up by ASan runtime in case it needs to print error report involving some global. For example: 0x... is located 4 bytes to the right of global variable 'C::array' defined in '/path/to/file:17:8' (0x...) of size 40 These source locations are printed even if the binary doesn't have any debug info. This is an ABI-breaking change. ASan initialization is renamed to __asan_init_v4(). Pre-built libraries compiled with older Clang will not work with the fresh runtime. llvm-svn: 212188
* Remove top-level Clang -fsanitize= flags for optional ASan features.Alexey Samsonov2014-06-131-33/+15
| | | | | | | | | | | | | Init-order and use-after-return modes can currently be enabled by runtime flags. use-after-scope mode is not really working at the moment. The only problem I see is that users won't be able to disable extra instrumentation for init-order and use-after-scope by a top-level Clang flag. But this instrumentation was implicitly enabled for quite a while and we didn't hear from users hurt by it. llvm-svn: 210924
* Remove system_error.h.Rafael Espindola2014-06-121-1/+1
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. llvm-svn: 210803
* [asancov] Fix coverage line info some more.Evgeniy Stepanov2014-06-051-2/+4
| | | | | | | Now it should always point to the opening brace of the function (in -asan-coverage=1 mode). llvm-svn: 210266
* [asan] Fix coverage instrumentation with -asan-globals=0.Evgeniy Stepanov2014-06-031-25/+32
| | | | llvm-svn: 210103
* Remove sanitizer blacklist from ASan/TSan/MSan function passes.Alexey Samsonov2014-06-021-12/+5
| | | | | | | | | | | | | | | | | Instrumentation passes now use attributes address_safety/thread_safety/memory_safety which are added by Clang frontend. Clang parses the blacklist file and adds the attributes accordingly. Currently blacklist is still used in ASan module pass to disable instrumentation for certain global variables. We should fix this as well by collecting the set of globals we're going to instrument in Clang and passing it to ASan in metadata (as we already do for dynamically-initialized globals and init-order checking). This change also removes -tsan-blacklist and -msan-blacklist LLVM commandline flags in favor of -fsanitize-blacklist= Clang flag. llvm-svn: 210038
* [ASan] Behave the same for functions w/o sanitize_address attribute and ↵Alexey Samsonov2014-05-311-2/+1
| | | | | | blacklisted functions llvm-svn: 209946
* Use range-based for loops in ASan, TSan and MSanAlexey Samsonov2014-05-291-45/+34
| | | | llvm-svn: 209834
* [ASan] Hoist blacklisting globals from init-order checking to Clang.Alexey Samsonov2014-05-291-2/+0
| | | | | | | | | Clang knows about the sanitizer blacklist and it makes no sense to add global to the list of llvm.asan.dynamically_initialized_globals if it will be blacklisted in the instrumentation pass anyway. Instead, we should do as much blacklisting as possible (if not all) in the frontend. llvm-svn: 209790
* Fix typo in variable nameAlexey Samsonov2014-05-291-3/+3
| | | | llvm-svn: 209784
* [ASan] Use llvm.global_ctors to insert init-order checking calls into ASan ↵Alexey Samsonov2014-05-291-34/+23
| | | | | | | | | | | | runtime. Don't assume that dynamically initialized globals are all initialized from _GLOBAL__<module_name>I_ function. Instead, scan the llvm.global_ctors and insert poison/unpoison calls to each function there. Patch by Nico Weber! llvm-svn: 209780
* [asancov] Don't emit extra runtime calls when compiling without coverage.Evgeniy Stepanov2014-05-281-3/+5
| | | | llvm-svn: 209721
* [asancov] Emit an initializer passing number of coverage code locations in ↵Evgeniy Stepanov2014-05-271-4/+14
| | | | | | each module. llvm-svn: 209654
* [asan] decrease asan-instrumentation-with-call-threshold from 10000 to 7000, ↵Kostya Serebryany2014-05-261-1/+1
| | | | | | see PR17409 llvm-svn: 209623
* [asan] properly instrument memory accesses that have small alignment ↵Kostya Serebryany2014-05-231-9/+19
| | | | | | (smaller than min(8,size)) by making two checks instead of one. This may slowdown some cases, e.g. long long on 32-bit or wide loads produced after loop unrolling. The benefit is higher sencitivity. llvm-svn: 209508
* [asan] Fix compiler warnings.Evgeniy Stepanov2014-05-141-5/+3
| | | | llvm-svn: 208769
* [asan] Set debug location in ASan function prologue.Evgeniy Stepanov2014-05-141-2/+14
| | | | | | | | | Most importantly, it gives debug location info to the coverage callback. This change also removes 2 cases of unnecessary setDebugLoc when IRBuilder is created with the same debug location. llvm-svn: 208767
* Fix ASan init function detection after clang r208128.Nico Weber2014-05-061-3/+24
| | | | llvm-svn: 208141
* [ASan/Win] Fix issue 305 -- don't instrument .CRT initializer/terminator ↵Timur Iskhodzhanov2014-05-051-4/+14
| | | | | | | | | callbacks See https://code.google.com/p/address-sanitizer/issues/detail?id=305 Reviewed at http://reviews.llvm.org/D3607 llvm-svn: 207968
* [C++] Use 'nullptr'. Transforms edition.Craig Topper2014-04-251-15/+15
| | | | llvm-svn: 207196
* [ASan] Move the shadow range on 32-bit iOS (and iOS Simulator)Alexander Potapenko2014-04-231-1/+4
| | | | | | | | to 0x40000000-0x60000000 to avoid address space clash with system libraries. The solution has been proposed by tahabekireren@gmail.com in https://code.google.com/p/address-sanitizer/issues/detail?id=210 This is also known to fix some Chromium iOS tests. llvm-svn: 207002
* Fix handling of missing DataLayout in sanitizers.Evgeniy Stepanov2014-04-231-1/+1
| | | | | | | Pass::doInitialization is supposed to return False when it did not change the program, not when a fatal error occurs. llvm-svn: 206975
* [asan] Support outline instrumentation for wide types and delete dead code, ↵Kostya Serebryany2014-04-221-27/+12
| | | | | | patch by Yuri Gribov llvm-svn: 206883
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-2/+2
| | | | | | | | | | | | | | | | | definition below all of the header #include lines, lib/Transforms/... edition. This one is tricky for two reasons. We again have a couple of passes that define something else before the includes as well. I've sunk their name macros with the DEBUG_TYPE. Also, InstCombine contains headers that need DEBUG_TYPE, so now those headers #define and #undef DEBUG_TYPE around their code, leaving them well formed modular headers. Fixing these headers was a large motivation for all of these changes, as "leaky" macros of this form are hard on the modules implementation. llvm-svn: 206844
* [asan] add a run-time flag detect_container_overflow=true/falseKostya Serebryany2014-04-211-1/+1
| | | | llvm-svn: 206756
* [asan] instead of inserting inline instrumentation around ↵Kostya Serebryany2014-04-211-29/+33
| | | | | | memset/memcpy/memmove, replace the intrinsic with __asan_memset/etc. This makes the memset/etc handling more complete and consistent with what we do in msan. It may slowdown some cases (when the intrinsic was actually inlined) and speedup other cases (when it was not inlined) llvm-svn: 206746
* [asan] temporary disable generating __asan_loadN/__asan_storeNKostya Serebryany2014-04-211-11/+6
| | | | llvm-svn: 206741
* [asan] insert __asan_loadN/__asan_storeN as out-lined asan checks, llvm partKostya Serebryany2014-04-211-3/+15
| | | | llvm-svn: 206734
* [asan] one more workaround for PR17409: don't do BB-level coverage ↵Kostya Serebryany2014-04-181-1/+6
| | | | | | instrumentation if there are more than N (=1500) basic blocks. This makes ASanCoverage work on libjpeg_turbo/jchuff.c used by Chrome, which has 1824 BBs llvm-svn: 206564
* [asan] add two new hidden compile-time flags for asan: ↵Kostya Serebryany2014-04-161-27/+56
| | | | | | asan-instrumentation-with-call-threshold and asan-memory-access-callback-prefix. This is part of the workaround for PR17409 (instrument huge functions with callbacks instead of inlined code). These flags will also help us experiment with kasan (kernel-asan) and clang llvm-svn: 206383
* Implement depth_first and inverse_depth_first range factory functions.David Blaikie2014-04-111-4/+2
| | | | | | | | | | | | | | Also updated as many loops as I could find using df_begin/idf_begin - strangely I found no uses of idf_begin. Is that just used out of tree? Also a few places couldn't use df_begin because either they used the member functions of the depth first iterators or had specific ordering constraints (I added a comment in the latter case). Based on a patch by Jim Grosbach. (Jim - you just had iterator_range<T> where you needed iterator_range<idf_iterator<T>>) llvm-svn: 206016
* remove a bunch of unused private methodsNuno Lopes2014-03-231-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | found with a smarter version of -Wunused-member-function that I'm playwing with. Appologies in advance if I removed someone's WIP code. include/llvm/CodeGen/MachineSSAUpdater.h | 1 include/llvm/IR/DebugInfo.h | 3 lib/CodeGen/MachineSSAUpdater.cpp | 10 -- lib/CodeGen/PostRASchedulerList.cpp | 1 lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 10 -- lib/IR/DebugInfo.cpp | 12 -- lib/MC/MCAsmStreamer.cpp | 2 lib/Support/YAMLParser.cpp | 39 --------- lib/TableGen/TGParser.cpp | 16 --- lib/TableGen/TGParser.h | 1 lib/Target/AArch64/AArch64TargetTransformInfo.cpp | 9 -- lib/Target/ARM/ARMCodeEmitter.cpp | 12 -- lib/Target/ARM/ARMFastISel.cpp | 84 -------------------- lib/Target/Mips/MipsCodeEmitter.cpp | 11 -- lib/Target/Mips/MipsConstantIslandPass.cpp | 12 -- lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp | 21 ----- lib/Target/NVPTX/NVPTXISelDAGToDAG.h | 2 lib/Target/PowerPC/PPCFastISel.cpp | 1 lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 lib/Transforms/Instrumentation/BoundsChecking.cpp | 2 lib/Transforms/Instrumentation/MemorySanitizer.cpp | 1 lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 8 - lib/Transforms/Scalar/SCCP.cpp | 1 utils/TableGen/CodeEmitterGen.cpp | 2 24 files changed, 2 insertions(+), 261 deletions(-) llvm-svn: 204560
* [ASan] Do not instrument globals from the llvm.metadata section.Alexander Potapenko2014-03-201-0/+2
| | | | | | Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=279. llvm-svn: 204331
* [ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=274Alexander Potapenko2014-03-141-3/+9
| | | | | | | by ignoring globals from __TEXT,__cstring,cstring_literals during instrumenation. Add a regression test. llvm-svn: 203916
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-3/+2
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* [Layering] Move InstVisitor.h into the IR library as it is prettyChandler Carruth2014-03-061-1/+1
| | | | | | obviously coupled to the IR. llvm-svn: 203064
* [Layering] Move DIBuilder.h into the IR library where its implementationChandler Carruth2014-03-061-1/+1
| | | | | | already lives. llvm-svn: 203038
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-051-5/+5
| | | | | | class. llvm-svn: 202953
* [Modules] Move CallSite into the IR library where it belogs. It isChandler Carruth2014-03-041-1/+1
| | | | | | | abstracting between a CallInst and an InvokeInst, both of which are IR concepts. llvm-svn: 202816
* [asan] fix a pair of silly typosKostya Serebryany2014-02-271-2/+2
| | | | llvm-svn: 202391
* [asan] disable asan-detect-invalid-pointer-pair (was enabled by mistake)Kostya Serebryany2014-02-271-1/+1
| | | | llvm-svn: 202390
* [asan] *experimental* implementation of invalid-pointer-pair detector (finds ↵Kostya Serebryany2014-02-271-0/+56
| | | | | | when two unrelated pointers are compared or subtracted). This implementation has both false positives and false negatives and is not tuned for performance. A bug report for a proper implementation will follow. llvm-svn: 202389
OpenPOWER on IntegriCloud