8 #ifndef MTARESULTVALIDATOR_H_
9 #define MTARESULTVALIDATOR_H_
21 class MTAResultValidator
51 std::vector<std::string> &
split(
const std::string &s,
char delim, std::vector<std::string> &elems);
130 static constexpr
char const *
CXT_THREAD =
"CXT_THREAD";
132 static constexpr
char const *
TCT_ACCESS =
"TCT_ACCESS";
277 std::vector<const CallBase*> csInsts;
284 if(fName.find(
RC_ACCESS) != std::string::npos)
293 for (Value::const_use_iterator it =
F->use_begin(), ie =
294 F->use_end(); it != ie; ++it)
297 const Value *user = u->getUser();
301 csInsts.push_back(csInst);
304 assert(csInsts.size() % 2 == 0 &&
"We should have RC_ACCESS called in pairs.");
307 std::sort(csInsts.begin(), csInsts.end(),
compare);
310 for (
int i = 0, e = csInsts.size(); i != e;)
314 const ConstantInt* C = SVFUtil::dyn_cast<ConstantInt>(CI1->getArgOperand(1));
318 assert(I1 && I2 &&
"RC_ACCESS should be placed immediately after the target memory access.");
319 RC_FLAG flags = C->getZExtValue();
330 for (
int i = 0, e =
accessPairs.size(); i != e; ++i)
374 bool analysisRes,
bool expectedRes)
382 if (analysisRes == expectedRes)
400 const Value *V1 = CI1->getArgOperand(0);
401 const Value *V2 = CI2->getArgOperand(0);
402 const ConstantInt* C1 = SVFUtil::dyn_cast<ConstantInt>(V1);
403 const ConstantInt* C2 = SVFUtil::dyn_cast<ConstantInt>(V2);
404 assert(0 != C1 && 0 != C2);
405 return C1->getZExtValue() < C2->getZExtValue();
416 I = I->getPrevNode();
419 if (SVFUtil::isa<LoadInst, StoreInst>(I))
426 if (callee->getName().find(
"llvm.memset") != std::string::npos)
430 I = I->getPrevNode();
445 static constexpr
char const *
RC_ACCESS =
"RC_ACCESS";
static LLVMModuleSet * getLLVMModuleSet()
SVFInstruction * getSVFInstruction(const Instruction *inst) const
SVFValue * getSVFValue(const Value *value)
TCT * getTCT() const
Get Thread Creation Tree.
ThreadCallGraph * getThreadCallGraph() const
Get ThreadCallGraph.
Map< const SVFInstruction *, CxtThreadStmtSet > InstToThreadStmtSetMap
Map< CxtThreadStmt, NodeBS > ThreadStmtToThreadInterleav
bool collectInterleavingTargets()
void dumpCxt(const CallStrCxt &cxt) const
static const INTERLEV_FLAG INTERLEV_UNSOUND
static constexpr char const * INTERLEV_ACCESS
Map< NodeID, CallStrCxt > vthdToCxtMap
const Instruction * getPreviousMemoryAccessInst(const Instruction *I)
bool matchCxt(const CallStrCxt cxt1, const CallStrCxt cxt2) const
Map< NodeID, const SVFInstruction * > csnumToInst
rthdToChildrenMap rthdToChildren
static const INTERLEV_FLAG INTERLEV_TRUE
Constant INTERLEV_FLAG values.
std::vector< std::string > split(const std::string &s, char delim)
bool collectCxtThreadTargets()
std::vector< std::string > getStringArg(const Instruction *inst, unsigned int arg_num)
INTERLEV_FLAG validateInterleaving()
Map< NodeID, Set< NodeID > > rthdToChildrenMap
Map< NodeID, NodeID > vthdTorthdMap
static const INTERLEV_FLAG INTERLEV_IMPRECISE
std::string getOutput(const char *scenario, bool analysisRes)
MHP::InstToThreadStmtSetMap instToTSMap
std::string getOutputforInterlevAnalysis(const char *scenario, INTERLEV_FLAG analysisRes)
static constexpr char const * CXT_THREAD
Map a statement to its thread interleavings.
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
Map< NodeID, NodeID > rthdTovthdMap
MHP::ThreadStmtToThreadInterleav threadStmtToInterLeaving
NodeID getIntArg(const Instruction *inst, unsigned int arg_num)
static constexpr char const * TCT_ACCESS
CallStrCxt getCxtArg(const Instruction *inst, unsigned int arg_num)
csnumToInst csnumToInstMap
bool collectCallsiteTargets()
SVFModule * getModule() const
MTAResultValidator(MHP *mh)
void dumpInterlev(NodeBS &lev)
bool isFlaged(const RC_FLAG flag) const
Class member access.
AccessPair(const Instruction *I1, const Instruction *I2, const RC_FLAG flags)
Constructor.
const Instruction * getInstruction1() const
const Instruction * getInstruction2() const
Validate the result of concurrent analysis.
static const RC_FLAG RC_ALIASES
RC_FLAG selectedValidationScenarios
virtual bool mayHaveDataRace(const Instruction *I1, const Instruction *I2)
static bool compare(const CallBase *CI1, const CallBase *CI2)
void collectValidationTargets()
void validateAll()
Perform validation for all targets.
void validateAll()
Perform validation for all targets.
void release()
Release resource.
bool hasValidationTarget() const
Check if the input program has validation target.
const Instruction * getPreviousMemoryAccessInst(const Instruction *I)
virtual ~RaceResultValidator()
Destructor.
std::vector< AccessPair > accessPairs
static const RC_FLAG RC_MHP
Constant RC_FLAG values.
static const RC_FLAG RC_RACE
static const RC_FLAG RC_PROTECTED
static constexpr char const * RC_ACCESS
const Instruction * getPreviousMemoryAccessInst(const Instruction *I)
void collectValidationTargets()
virtual bool mayAccessAliases(const Instruction *I1, const Instruction *I2)
virtual bool protectedByCommonLocks(const Instruction *I1, const Instruction *I2)
void init(SVFModule *M)
Initialization.
std::string getOutput(const char *scenario, bool analysisRes, bool expectedRes)
Get the validation result string of a single validation scenario.
virtual bool mayHappenInParallel(const Instruction *I1, const Instruction *I2)
virtual const std::string getSourceLoc() const
SVFModule * getSVFModule() const
Get SVFFModule.
ThreadAPI * getThreadAPI() const
Thread API.
const CallBase * getLLVMCallSite(const Value *value)
Return LLVM callsite given a value.
bool isCallSite(const Instruction *inst)
Whether an instruction is a call or invoke instruction.
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
const SVFFunction * getCallee(const CallSite cs)
Return callee of a callsite. Return null if this is an indirect call.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::ostream & outs()
Overwrite llvm::outs()
llvm::Instruction Instruction
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::Value Value
LLVM Basic classes.
std::vector< u32_t > CallStrCxt
llvm::ConstantInt ConstantInt