[llvm-commits] [llvm] r167725 - in /llvm/trunk/lib/Transforms/Instrumentation: BlackList.cpp BlackList.h

Alexey Samsonov samsonov at google.com
Mon Nov 12 06:00:02 PST 2012


Author: samsonov
Date: Mon Nov 12 08:00:01 2012
New Revision: 167725

URL: http://llvm.org/viewvc/llvm-project?rev=167725&view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp
    llvm/trunk/lib/Transforms/Instrumentation/BlackList.h

Modified: llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp?rev=167725&r1=167724&r2=167725&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp Mon Nov 12 08:00:01 2012
@@ -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 @@
   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;
 }

Modified: llvm/trunk/lib/Transforms/Instrumentation/BlackList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlackList.h?rev=167725&r1=167724&r2=167725&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BlackList.h (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/BlackList.h Mon Nov 12 08:00:01 2012
@@ -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





More information about the llvm-commits mailing list