[llvm] r185975 - Rename BlackList class to SpecialCaseList and move it to Transforms/Utils.
Peter Collingbourne
peter at pcc.me.uk
Tue Jul 9 15:02:49 PDT 2013
Author: pcc
Date: Tue Jul 9 17:02:49 2013
New Revision: 185975
URL: http://llvm.org/viewvc/llvm-project?rev=185975&view=rev
Log:
Rename BlackList class to SpecialCaseList and move it to Transforms/Utils.
Differential Revision: http://llvm-reviews.chandlerc.com/D1089
Added:
llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h
- copied, changed from r185972, llvm/trunk/include/llvm/Transforms/Utils/BlackList.h
llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp
- copied, changed from r185972, llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp
Removed:
llvm/trunk/include/llvm/Transforms/Utils/BlackList.h
llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/lib/Transforms/Instrumentation/CMakeLists.txt
llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/trunk/lib/Transforms/Utils/CMakeLists.txt
Removed: llvm/trunk/include/llvm/Transforms/Utils/BlackList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BlackList.h?rev=185974&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/BlackList.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/BlackList.h (removed)
@@ -1,59 +0,0 @@
-//===-- BlackList.h - blacklist for sanitizers ------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//===----------------------------------------------------------------------===//
-//
-// This is a utility class for instrumentation passes (like AddressSanitizer
-// or ThreadSanitizer) to avoid instrumenting some functions or global
-// variables based on a user-supplied blacklist.
-//
-// The blacklist disables instrumentation of various functions and global
-// variables. Each line contains a prefix, followed by a wild card expression.
-// Empty lines and lines starting with "#" are ignored.
-// ---
-// # Blacklisted items:
-// 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
-// global-init-src:ignore-global-initializers-issues.cc
-// ---
-// Note that the wild card is in fact an llvm::Regex, but * is automatically
-// replaced with .*
-// This is similar to the "ignore" feature of ThreadSanitizer.
-// http://code.google.com/p/data-race-test/wiki/ThreadSanitizerIgnores
-//
-//===----------------------------------------------------------------------===//
-//
-
-#include "llvm/ADT/StringMap.h"
-
-namespace llvm {
-class Function;
-class GlobalVariable;
-class Module;
-class Regex;
-class StringRef;
-
-class BlackList {
- public:
- BlackList(const StringRef Path);
- // Returns whether either this function or it's source file are blacklisted.
- bool isIn(const Function &F) const;
- // Returns whether either this global or it's source file are blacklisted.
- bool isIn(const GlobalVariable &G) const;
- // Returns whether this module is blacklisted by filename.
- bool isIn(const Module &M) const;
- // Returns whether a global should be excluded from initialization checking.
- bool isInInit(const GlobalVariable &G) const;
- private:
- StringMap<Regex*> Entries;
-
- bool inSection(const StringRef Section, const StringRef Query) const;
-};
-
-} // namespace llvm
Copied: llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h (from r185972, llvm/trunk/include/llvm/Transforms/Utils/BlackList.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h?p2=llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h&p1=llvm/trunk/include/llvm/Transforms/Utils/BlackList.h&r1=185972&r2=185975&rev=185975&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/BlackList.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h Tue Jul 9 17:02:49 2013
@@ -1,4 +1,4 @@
-//===-- BlackList.h - blacklist for sanitizers ------------------*- C++ -*-===//
+//===-- SpecialCaseList.h - blacklist for sanitizers ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -39,9 +39,9 @@ class Module;
class Regex;
class StringRef;
-class BlackList {
+class SpecialCaseList {
public:
- BlackList(const StringRef Path);
+ SpecialCaseList(const StringRef Path);
// Returns whether either this function or it's source file are blacklisted.
bool isIn(const Function &F) const;
// Returns whether either this global or it's source file are blacklisted.
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=185975&r1=185974&r2=185975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Tue Jul 9 17:02:49 2013
@@ -43,10 +43,10 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/Transforms/Utils/BlackList.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
+#include "llvm/Transforms/Utils/SpecialCaseList.h"
#include <algorithm>
#include <string>
@@ -318,7 +318,7 @@ struct AddressSanitizer : public Functio
Function *AsanCtorFunction;
Function *AsanInitFunction;
Function *AsanHandleNoReturnFunc;
- OwningPtr<BlackList> BL;
+ OwningPtr<SpecialCaseList> BL;
// This array is indexed by AccessIsWrite and log2(AccessSize).
Function *AsanErrorCallback[2][kNumberOfAccessSizes];
// This array is indexed by AccessIsWrite.
@@ -358,7 +358,7 @@ class AddressSanitizerModule : public Mo
SmallString<64> BlacklistFile;
bool ZeroBaseShadow;
- OwningPtr<BlackList> BL;
+ OwningPtr<SpecialCaseList> BL;
SetOfDynamicallyInitializedGlobals DynamicallyInitializedGlobals;
Type *IntptrTy;
LLVMContext *C;
@@ -880,7 +880,7 @@ bool AddressSanitizerModule::runOnModule
TD = getAnalysisIfAvailable<DataLayout>();
if (!TD)
return false;
- BL.reset(new BlackList(BlacklistFile));
+ BL.reset(new SpecialCaseList(BlacklistFile));
if (BL->isIn(M)) return false;
C = &(M.getContext());
int LongSize = TD->getPointerSizeInBits();
@@ -1070,7 +1070,7 @@ bool AddressSanitizer::doInitialization(
if (!TD)
return false;
- BL.reset(new BlackList(BlacklistFile));
+ BL.reset(new SpecialCaseList(BlacklistFile));
DynamicallyInitializedGlobals.Init(M);
C = &(M.getContext());
Removed: llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp?rev=185974&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp (removed)
@@ -1,126 +0,0 @@
-//===-- BlackList.cpp - blacklist for sanitizers --------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This is a utility class for instrumentation passes (like AddressSanitizer
-// or ThreadSanitizer) to avoid instrumenting some functions or global
-// variables based on a user-supplied blacklist.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Transforms/Utils/BlackList.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/Function.h"
-#include "llvm/IR/GlobalVariable.h"
-#include "llvm/IR/Module.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Regex.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/system_error.h"
-#include <string>
-#include <utility>
-
-namespace llvm {
-
-BlackList::BlackList(const StringRef Path) {
- // Validate and open blacklist file.
- if (Path.empty()) return;
- OwningPtr<MemoryBuffer> File;
- if (error_code EC = MemoryBuffer::getFile(Path, File)) {
- report_fatal_error("Can't open blacklist file: " + Path + ": " +
- EC.message());
- }
-
- // Iterate through each line in the blacklist file.
- SmallVector<StringRef, 16> Lines;
- SplitString(File.take()->getBuffer(), Lines, "\n\r");
- StringMap<std::string> Regexps;
- for (SmallVectorImpl<StringRef>::iterator I = Lines.begin(), E = Lines.end();
- I != E; ++I) {
- // Ignore empty lines and lines starting with "#"
- if (I->empty() || I->startswith("#"))
- continue;
- // Get our prefix and unparsed regexp.
- std::pair<StringRef, StringRef> SplitLine = I->split(":");
- StringRef Prefix = SplitLine.first;
- std::string Regexp = SplitLine.second;
- if (Regexp.empty()) {
- // Missing ':' in the line.
- report_fatal_error("malformed blacklist line: " + SplitLine.first);
- }
-
- // Replace * with .*
- for (size_t pos = 0; (pos = Regexp.find("*", pos)) != std::string::npos;
- pos += strlen(".*")) {
- Regexp.replace(pos, strlen("*"), ".*");
- }
-
- // Check that the regexp is valid.
- Regex CheckRE(Regexp);
- std::string Error;
- if (!CheckRE.isValid(Error)) {
- report_fatal_error("malformed blacklist regex: " + SplitLine.second +
- ": " + Error);
- }
-
- // Add this regexp into the proper group by its prefix.
- if (!Regexps[Prefix].empty())
- Regexps[Prefix] += "|";
- Regexps[Prefix] += Regexp;
- }
-
- // Iterate through each of the prefixes, and create Regexs for them.
- for (StringMap<std::string>::const_iterator I = Regexps.begin(),
- E = Regexps.end(); I != E; ++I) {
- Entries[I->getKey()] = new Regex(I->getValue());
- }
-}
-
-bool BlackList::isIn(const Function &F) const {
- return isIn(*F.getParent()) || inSection("fun", F.getName());
-}
-
-bool BlackList::isIn(const GlobalVariable &G) const {
- return isIn(*G.getParent()) || inSection("global", G.getName());
-}
-
-bool BlackList::isIn(const Module &M) const {
- 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 (StructType *SGType = dyn_cast<StructType>(GType)) {
- if (!SGType->isLiteral())
- return SGType->getName();
- }
- return "<unknown type>";
-}
-
-bool BlackList::isInInit(const GlobalVariable &G) const {
- return (isIn(*G.getParent()) ||
- inSection("global-init", G.getName()) ||
- inSection("global-init-type", GetGVTypeString(G)) ||
- inSection("global-init-src", G.getParent()->getModuleIdentifier()));
-}
-
-bool BlackList::inSection(const StringRef Section,
- const StringRef Query) const {
- StringMap<Regex*>::const_iterator I = Entries.find(Section);
- if (I == Entries.end()) return false;
-
- Regex *FunctionRegex = I->getValue();
- return FunctionRegex->match(Query);
-}
-
-} // namespace llvm
Modified: llvm/trunk/lib/Transforms/Instrumentation/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/CMakeLists.txt?rev=185975&r1=185974&r2=185975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/CMakeLists.txt (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/CMakeLists.txt Tue Jul 9 17:02:49 2013
@@ -1,6 +1,5 @@
add_llvm_library(LLVMInstrumentation
AddressSanitizer.cpp
- BlackList.cpp
BoundsChecking.cpp
DebugIR.cpp
EdgeProfiling.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=185975&r1=185974&r2=185975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Tue Jul 9 17:02:49 2013
@@ -91,9 +91,9 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/Transforms/Utils/BlackList.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
+#include "llvm/Transforms/Utils/SpecialCaseList.h"
using namespace llvm;
@@ -232,7 +232,7 @@ class MemorySanitizer : public FunctionP
/// \brief Path to blacklist file.
SmallString<64> BlacklistFile;
/// \brief The blacklist.
- OwningPtr<BlackList> BL;
+ OwningPtr<SpecialCaseList> BL;
/// \brief An empty volatile inline asm that prevents callback merge.
InlineAsm *EmptyAsm;
@@ -338,7 +338,7 @@ bool MemorySanitizer::doInitialization(M
TD = getAnalysisIfAvailable<DataLayout>();
if (!TD)
return false;
- BL.reset(new BlackList(BlacklistFile));
+ BL.reset(new SpecialCaseList(BlacklistFile));
C = &(M.getContext());
unsigned PtrSize = TD->getPointerSizeInBits(/* AddressSpace */0);
switch (PtrSize) {
Modified: llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp?rev=185975&r1=185974&r2=185975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp Tue Jul 9 17:02:49 2013
@@ -41,8 +41,8 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/Transforms/Utils/BlackList.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
+#include "llvm/Transforms/Utils/SpecialCaseList.h"
using namespace llvm;
@@ -99,7 +99,7 @@ struct ThreadSanitizer : public Function
DataLayout *TD;
Type *IntptrTy;
SmallString<64> BlacklistFile;
- OwningPtr<BlackList> BL;
+ OwningPtr<SpecialCaseList> BL;
IntegerType *OrdTy;
// Callbacks to run-time library are computed in doInitialization.
Function *TsanFuncEntry;
@@ -227,7 +227,7 @@ bool ThreadSanitizer::doInitialization(M
TD = getAnalysisIfAvailable<DataLayout>();
if (!TD)
return false;
- BL.reset(new BlackList(BlacklistFile));
+ BL.reset(new SpecialCaseList(BlacklistFile));
// Always insert a call to __tsan_init into the module's CTORs.
IRBuilder<> IRB(M.getContext());
Modified: llvm/trunk/lib/Transforms/Utils/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CMakeLists.txt?rev=185975&r1=185974&r2=185975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CMakeLists.txt (original)
+++ llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Tue Jul 9 17:02:49 2013
@@ -28,6 +28,7 @@ add_llvm_library(LLVMTransformUtils
SimplifyIndVar.cpp
SimplifyInstructions.cpp
SimplifyLibCalls.cpp
+ SpecialCaseList.cpp
UnifyFunctionExitNodes.cpp
Utils.cpp
ValueMapper.cpp
Copied: llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp (from r185972, llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp?p2=llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp&p1=llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp&r1=185972&r2=185975&rev=185975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp Tue Jul 9 17:02:49 2013
@@ -1,4 +1,4 @@
-//===-- BlackList.cpp - blacklist for sanitizers --------------------------===//
+//===-- SpecialCaseList.cpp - blacklist for sanitizers --------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,7 +13,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Transforms/Utils/BlackList.h"
+#include "llvm/Transforms/Utils/SpecialCaseList.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -30,7 +30,7 @@
namespace llvm {
-BlackList::BlackList(const StringRef Path) {
+SpecialCaseList::SpecialCaseList(const StringRef Path) {
// Validate and open blacklist file.
if (Path.empty()) return;
OwningPtr<MemoryBuffer> File;
@@ -84,15 +84,15 @@ BlackList::BlackList(const StringRef Pat
}
}
-bool BlackList::isIn(const Function &F) const {
+bool SpecialCaseList::isIn(const Function &F) const {
return isIn(*F.getParent()) || inSection("fun", F.getName());
}
-bool BlackList::isIn(const GlobalVariable &G) const {
+bool SpecialCaseList::isIn(const GlobalVariable &G) const {
return isIn(*G.getParent()) || inSection("global", G.getName());
}
-bool BlackList::isIn(const Module &M) const {
+bool SpecialCaseList::isIn(const Module &M) const {
return inSection("src", M.getModuleIdentifier());
}
@@ -107,15 +107,15 @@ static StringRef GetGVTypeString(const G
return "<unknown type>";
}
-bool BlackList::isInInit(const GlobalVariable &G) const {
+bool SpecialCaseList::isInInit(const GlobalVariable &G) const {
return (isIn(*G.getParent()) ||
inSection("global-init", G.getName()) ||
inSection("global-init-type", GetGVTypeString(G)) ||
inSection("global-init-src", G.getParent()->getModuleIdentifier()));
}
-bool BlackList::inSection(const StringRef Section,
- const StringRef Query) const {
+bool SpecialCaseList::inSection(const StringRef Section,
+ const StringRef Query) const {
StringMap<Regex*>::const_iterator I = Entries.find(Section);
if (I == Entries.end()) return false;
More information about the llvm-commits
mailing list