diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-11-12 14:00:01 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-11-12 14:00:01 +0000 |
commit | 582d7de7093e9d9609036dd6905f1fbdcec703e4 (patch) | |
tree | e906137a2570e0ec3fb4453a484394256aa11f01 /llvm/lib/Transforms | |
parent | ea5fa1004f39786eae5a9844cddb033f3e87d3f5 (diff) | |
download | bcm5719-llvm-582d7de7093e9d9609036dd6905f1fbdcec703e4.tar.gz bcm5719-llvm-582d7de7093e9d9609036dd6905f1fbdcec703e4.zip |
[ASan]: Add minimalistic support for turning off initialization-order checking for globals of specified types. Tests for this behavior will go to ASan test suite in compiler-rt.
llvm-svn: 167725
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/BlackList.cpp | 17 | ||||
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/BlackList.h | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/BlackList.cpp b/llvm/lib/Transforms/Instrumentation/BlackList.cpp index ef34b8a56d8..5b65ea66495 100644 --- a/llvm/lib/Transforms/Instrumentation/BlackList.cpp +++ b/llvm/lib/Transforms/Instrumentation/BlackList.cpp @@ -20,6 +20,7 @@ #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/GlobalVariable.h" #include "llvm/Module.h" @@ -92,12 +93,24 @@ bool BlackList::isIn(const Module &M) { return inSection("src", M.getModuleIdentifier()); } +static StringRef GetGVTypeString(const GlobalVariable &G) { + // Types of GlobalVariables are always pointer types. + Type *GType = G.getType()->getElementType(); + // For now we support blacklisting struct types only. + if (GType->isStructTy()) { + return GType->getStructName(); + } + return "<unknown type>"; +} + bool BlackList::isInInit(const GlobalVariable &G) { - return isIn(*G.getParent()) || inSection("global-init", G.getName()); + return (isIn(*G.getParent()) || + inSection("global-init", G.getName()) || + inSection("global-init-type", GetGVTypeString(G))); } bool BlackList::inSection(const StringRef Section, - const StringRef Query) { + const StringRef Query) { Regex *FunctionRegex = Entries[Section]; return FunctionRegex ? FunctionRegex->match(Query) : false; } diff --git a/llvm/lib/Transforms/Instrumentation/BlackList.h b/llvm/lib/Transforms/Instrumentation/BlackList.h index f3c05a5058c..ee18a985674 100644 --- a/llvm/lib/Transforms/Instrumentation/BlackList.h +++ b/llvm/lib/Transforms/Instrumentation/BlackList.h @@ -18,6 +18,7 @@ // fun:*_ZN4base6subtle* // global:*global_with_bad_access_or_initialization* // global-init:*global_with_initialization_issues* +// global-init-type:*Namespace::ClassName* // src:file_with_tricky_code.cc // --- // Note that the wild card is in fact an llvm::Regex, but * is automatically |