[llvm] r188169 - Add SpecialCaseList::createOrDie() factory and use it in sanitizer passes
Alexey Samsonov
samsonov at google.com
Mon Aug 12 04:46:10 PDT 2013
Author: samsonov
Date: Mon Aug 12 06:46:09 2013
New Revision: 188169
URL: http://llvm.org/viewvc/llvm-project?rev=188169&view=rev
Log:
Add SpecialCaseList::createOrDie() factory and use it in sanitizer passes
Modified:
llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h?rev=188169&r1=188168&r2=188169&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h Mon Aug 12 06:46:09 2013
@@ -68,6 +68,9 @@ class SpecialCaseList {
/// Parses the special case list from a memory buffer. On failure, returns
/// 0 and writes an error message to string.
static SpecialCaseList *create(const MemoryBuffer *MB, std::string &Error);
+ /// Parses the special case list from a file. On failure, reports a fatal
+ /// error.
+ static SpecialCaseList *createOrDie(const StringRef Path);
~SpecialCaseList();
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=188169&r1=188168&r2=188169&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Mon Aug 12 06:46:09 2013
@@ -883,7 +883,7 @@ bool AddressSanitizerModule::runOnModule
TD = getAnalysisIfAvailable<DataLayout>();
if (!TD)
return false;
- BL.reset(new SpecialCaseList(BlacklistFile));
+ BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
if (BL->isIn(M)) return false;
C = &(M.getContext());
int LongSize = TD->getPointerSizeInBits();
@@ -1076,7 +1076,7 @@ bool AddressSanitizer::doInitialization(
if (!TD)
return false;
- BL.reset(new SpecialCaseList(BlacklistFile));
+ BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
DynamicallyInitializedGlobals.Init(M);
C = &(M.getContext());
Modified: llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp?rev=188169&r1=188168&r2=188169&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp Mon Aug 12 06:46:09 2013
@@ -129,7 +129,7 @@ class DataFlowSanitizer : public ModuleP
Constant *DFSanUnionFn;
Constant *DFSanUnionLoadFn;
MDNode *ColdCallWeights;
- SpecialCaseList Greylist;
+ OwningPtr<SpecialCaseList> Greylist;
DenseMap<Value *, Function *> UnwrappedFnMap;
Value *getShadowAddress(Value *Addr, Instruction *Pos);
@@ -211,7 +211,7 @@ ModulePass *llvm::createDataFlowSanitize
DataFlowSanitizer::DataFlowSanitizer(void *(*getArgTLS)(),
void *(*getRetValTLS)())
: ModulePass(ID), GetArgTLSPtr(getArgTLS), GetRetvalTLSPtr(getRetValTLS),
- Greylist(ClGreylistFile) {}
+ Greylist(SpecialCaseList::createOrDie(ClGreylistFile)) {}
FunctionType *DataFlowSanitizer::getInstrumentedFunctionType(FunctionType *T) {
llvm::SmallVector<Type *, 4> ArgTypes;
@@ -269,7 +269,7 @@ bool DataFlowSanitizer::doInitialization
DataFlowSanitizer::InstrumentedABI
DataFlowSanitizer::getInstrumentedABI(Function *F) {
- if (Greylist.isIn(*F))
+ if (Greylist->isIn(*F))
return IA_MemOnly;
else
return getDefaultInstrumentedABI();
Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=188169&r1=188168&r2=188169&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Mon Aug 12 06:46:09 2013
@@ -338,7 +338,7 @@ bool MemorySanitizer::doInitialization(M
TD = getAnalysisIfAvailable<DataLayout>();
if (!TD)
return false;
- BL.reset(new SpecialCaseList(BlacklistFile));
+ BL.reset(SpecialCaseList::createOrDie(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=188169&r1=188168&r2=188169&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp Mon Aug 12 06:46:09 2013
@@ -227,7 +227,7 @@ bool ThreadSanitizer::doInitialization(M
TD = getAnalysisIfAvailable<DataLayout>();
if (!TD)
return false;
- BL.reset(new SpecialCaseList(BlacklistFile));
+ BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
// Always insert a call to __tsan_init into the module's CTORs.
IRBuilder<> IRB(M.getContext());
Modified: llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp?rev=188169&r1=188168&r2=188169&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp Mon Aug 12 06:46:09 2013
@@ -91,6 +91,13 @@ SpecialCaseList *SpecialCaseList::create
return SCL.take();
}
+SpecialCaseList *SpecialCaseList::createOrDie(const StringRef Path) {
+ std::string Error;
+ if (SpecialCaseList *SCL = create(Path, Error))
+ return SCL;
+ report_fatal_error(Error);
+}
+
bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) {
// Iterate through each line in the blacklist file.
SmallVector<StringRef, 16> Lines;
More information about the llvm-commits
mailing list