summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/BlackList.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-11-12 14:00:01 +0000
committerAlexey Samsonov <samsonov@google.com>2012-11-12 14:00:01 +0000
commit9cc45d2d7ededa025eaea5d734a9e4659bfa1e34 (patch)
tree49cfe135d4eb6f5409e91890c52d732c9ac874ba /lib/Transforms/Instrumentation/BlackList.cpp
parentd54393153a2d560446881ed4eeacc4d782882d11 (diff)
downloadllvm-9cc45d2d7ededa025eaea5d734a9e4659bfa1e34.tar.gz
llvm-9cc45d2d7ededa025eaea5d734a9e4659bfa1e34.tar.bz2
llvm-9cc45d2d7ededa025eaea5d734a9e4659bfa1e34.tar.xz
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167725 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/BlackList.cpp')
-rw-r--r--lib/Transforms/Instrumentation/BlackList.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Transforms/Instrumentation/BlackList.cpp b/lib/Transforms/Instrumentation/BlackList.cpp
index ef34b8a56d..5b65ea6649 100644
--- a/lib/Transforms/Instrumentation/BlackList.cpp
+++ b/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;
}