#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/SpecialCaseList.h"
#include <iterator>
Constant *DFSanUnionFn;
Constant *DFSanUnionLoadFn;
MDNode *ColdCallWeights;
- SpecialCaseList Greylist;
+ OwningPtr<SpecialCaseList> Greylist;
DenseMap<Value *, Function *> UnwrappedFnMap;
Value *getShadowAddress(Value *Addr, Instruction *Pos);
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;
ShadowPtrTy = PointerType::getUnqual(ShadowTy);
IntptrTy = DL->getIntPtrType(*Ctx);
ZeroShadow = ConstantInt::getSigned(ShadowTy, 0);
- ShadowPtrMask = ConstantInt::getSigned(IntptrTy, ~0x700000000000);
+ ShadowPtrMask = ConstantInt::getSigned(IntptrTy, ~0x700000000000LL);
ShadowPtrMul = ConstantInt::getSigned(IntptrTy, ShadowWidth / 8);
Type *DFSanUnionArgs[2] = { ShadowTy, ShadowTy };
DataFlowSanitizer::InstrumentedABI
DataFlowSanitizer::getInstrumentedABI(Function *F) {
- if (Greylist.isIn(*F))
+ if (Greylist->isIn(*F))
return IA_MemOnly;
else
return getDefaultInstrumentedABI();
if ((*i)->isDeclaration())
continue;
+ removeUnreachableBlocks(**i);
+
DFSanFunction DFSF(*this, *i);
// DFSanVisitor may create new basic blocks, which confuses df_iterator.
// instruction's next pointer and moving the next instruction to the
// tail block from which we should continue.
Instruction *Next = Inst->getNextNode();
+ // DFSanVisitor may delete Inst, so keep track of whether it was a
+ // terminator.
+ bool IsTerminator = isa<TerminatorInst>(Inst);
if (!DFSF.SkipInsts.count(Inst))
DFSanVisitor(DFSF).visit(Inst);
- if (isa<TerminatorInst>(Inst))
+ if (IsTerminator)
break;
Inst = Next;
}