本文整理汇总了C++中PEdge类的典型用法代码示例。如果您正苦于以下问题:C++ PEdge类的具体用法?C++ PEdge怎么用?C++ PEdge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PEdge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintUI
void WherePostcondition::PrintUI(OutStream &out) const
{
PEdge *edge = m_frame->CFG()->GetSingleOutgoingEdge(m_point);
Location *loc = m_frame->CFG()->GetPointLocation(m_point);
if (edge->IsLoop()) {
const char *loop_name = edge->AsLoop()->GetLoopId()->LoopName();
out << "LoopInvariant [" << loop_name << "]";
}
else {
out << "Postcondition [";
PEdgeCall *nedge = edge->AsCall();
Exp *function = nedge->GetFunction();
function->PrintUI(out, true);
out << ":" << loc->Line() << "]";
}
if (m_bit) {
Bit *new_bit = BitConvertExitClobber(m_bit);
out << " :: ";
new_bit->PrintUI(out, true);
new_bit->DecRef();
}
}
示例2: GetEntryReachable
// compute the points in the CFG reachable from the entry point.
void GetEntryReachable(BlockCFG *cfg)
{
// worklist items are reachable points whose outgoing edges have
// not been examined
Vector<PPoint> worklist;
PPoint entry = cfg->GetEntryPoint();
entry_reach_table->Insert(entry);
worklist.PushBack(entry);
while (!worklist.Empty()) {
PPoint back = worklist.Back();
worklist.PopBack();
const Vector<PEdge*>& outgoing = cfg->GetOutgoingEdges(back);
for (size_t oind = 0; oind < outgoing.Size(); oind++) {
PEdge *edge = outgoing[oind];
PPoint next = edge->GetTarget();
// already did this target
if (entry_reach_table->Lookup(next))
continue;
entry_reach_table->Insert(next);
worklist.PushBack(next);
}
}
}
示例3: CopyCFGPointsEdges
void CopyCFGPointsEdges(BlockCFG *old_cfg, BlockCFG *new_cfg)
{
// duplicate the CFG's points list.
for (size_t pind = 0; pind < old_cfg->GetPointCount(); pind++) {
Location *loc = old_cfg->GetPointLocation(pind + 1);
loc->IncRef();
new_cfg->AddPoint(loc);
}
// set the entry/exit points.
new_cfg->SetEntryPoint(old_cfg->GetEntryPoint());
new_cfg->SetExitPoint(old_cfg->GetExitPoint());
// duplicate the CFG's loop heads list.
for (size_t lind = 0; lind < old_cfg->GetLoopHeadCount(); lind++) {
const LoopHead &head = old_cfg->GetLoopHead(lind);
if (head.end_location)
head.end_location->IncRef();
new_cfg->AddLoopHead(head.point, head.end_location);
}
// duplicate the CFG's edges list.
for (size_t eind = 0; eind < old_cfg->GetEdgeCount(); eind++) {
PEdge *edge = old_cfg->GetEdge(eind);
edge->IncRef();
new_cfg->AddEdge(edge);
}
}
示例4: FollowSkipEdges
// get the result of transitively following skip edges from point
PPoint FollowSkipEdges(BlockCFG *cfg, PPoint point)
{
PPoint cur = point;
bool changed = true;
while (changed) {
changed = false;
const Vector<PEdge*> &outgoing = cfg->GetOutgoingEdges(cur);
if (outgoing.Size() == 1) {
PEdge *edge = outgoing[0];
if (edge->IsSkip()) {
PPoint next = edge->GetTarget();
// watch out for skip edges aborting the function.
if (next) {
cur = next;
changed = true;
}
}
}
}
return cur;
}
示例5: GetLoopIsomorphicPoints
// marks the points in cfg which are isomorphic to points in the loop_cfg
// invoked by cfg at the specified edge. code in a syntactic loop body
// will be reflected in CFGs for both the loop and its parent if it may
// reach both the recursive loop edge and a loop exit point. this common
// code will be isomorphic between the two CFGs.
void GetLoopIsomorphicPoints(BlockCFG *cfg, PEdge *loop_edge,
BlockCFG *loop_cfg)
{
// mapping from points in cfg to isomorphic points in loop_cfg.
PPointListHash remapping;
// worklist items are isomorphic points whose outgoing edges have not
// been examined.
Vector<PPoint> worklist;
PPoint target = loop_edge->GetTarget();
remapping.Insert(target, loop_cfg->GetEntryPoint());
cfg->AddLoopIsomorphic(target);
worklist.PushBack(target);
while (!worklist.Empty()) {
PPoint cfg_point = worklist.Back();
worklist.PopBack();
PPoint loop_point = remapping.LookupSingle(cfg_point);
const Vector<PEdge*> &cfg_outgoing =
cfg->GetOutgoingEdges(cfg_point);
const Vector<PEdge*> &loop_outgoing =
loop_cfg->GetOutgoingEdges(loop_point);
for (size_t eind = 0; eind < cfg_outgoing.Size(); eind++) {
PEdge *edge = cfg_outgoing[eind];
PPoint target = edge->GetTarget();
// check for an existing remapping entry. some isomorphic points have
// multiple incoming edges. we don't need to check all such incoming
// edges; if any edge is isomorphic, they all will be.
if (remapping.Lookup(target, false))
continue;
// look for an equivalent outgoing edge from the loop.
PPoint loop_target = 0;
for (size_t lind = 0; lind < loop_outgoing.Size(); lind++) {
PEdge *loop_edge = loop_outgoing[lind];
if (PEdge::CompareInner(edge, loop_edge) == 0) {
loop_target = loop_edge->GetTarget();
break;
}
}
if (!loop_target) {
Assert(edge->IsAssume());
continue;
}
remapping.Insert(target, loop_target);
cfg->AddLoopIsomorphic(target);
worklist.PushBack(target);
}
}
}
示例6:
void R_s_k_2::draw_pedges(const float line_width)
{
int nb_edges = 0;
int nb_pinned = 0;
int nb_cyclic = 0;
int nb_discart = 0;
FT min_value = (std::numeric_limits<FT>::max)();
FT max_value = -(std::numeric_limits<FT>::max)();
std::vector<FT> values;
std::vector<Edge> edges;
for (Finite_edges_iterator ei = m_dt.finite_edges_begin(); ei != m_dt.finite_edges_end(); ++ei)
{
Edge edge = *ei;
for (unsigned int i = 0; i < 2; ++i)
{
if (m_dt.is_pinned(edge))
{
nb_pinned++;
continue;
}
if (m_dt.is_target_cyclic(edge))
{
nb_cyclic++;
continue;
}
PEdge pedge;
bool ok = create_pedge(edge, pedge);
if (ok)
{
edges.push_back(edge);
values.push_back(pedge.priority());
min_value = (std::min)(min_value, values.back());
max_value = (std::max)(max_value, values.back());
}
else
{
nb_discart++;
viewer->glColor3f(1.0, 0.0, 1.0);
draw_edge(edge);
}
edge = m_dt.twin_edge(edge);
nb_edges++;
}
}
if (min_value == max_value) max_value += 1.0;
std::size_t N = values.size();
for (unsigned int i = 0; i < N; ++i)
draw_one_pedge(edges[i], values[i], min_value, max_value, line_width);
std::cout << "There are: " << N << " pedges"
<< " x " << nb_discart << " discarted"
<< " x " << nb_pinned << " pinned"
<< " x " << nb_cyclic << " cyclic"
<< " = " << nb_edges << " edges"
<< std::endl;
}
示例7: GetLoopBody
// fill in the body of loophead. points in the body are those which
// are reachable from loophead over non-backedges, and which themselves
// reach a backedge for loophead. note that in the case of loop nesting,
// a point may be contained in the body of multiple loops.
// if any irreducible edges are found (edges incoming to a body point
// other than loophead whose source is not in the body), those edges
// are added to irreducible_edges
void GetLoopBody(BlockCFG *cfg, PPoint loophead,
Vector<PEdge*> *irreducible_edges)
{
Vector<PPoint> *body_list = body_list_table->Lookup(loophead, true);
Assert(body_list->Empty());
// worklist items are points which reach a loop backedge but whose
// incoming edges have not yet been examined.
Vector<PPoint> worklist;
const Vector<PEdge*> &head_incoming = cfg->GetIncomingEdges(loophead);
for (size_t iind = 0; iind < head_incoming.Size(); iind++) {
PEdge *edge = head_incoming[iind];
PPoint source = edge->GetSource();
if (backedge_table->Lookup(edge)) {
Assert(reach_table->Lookup(PPointPair(loophead, source)));
if (!body_table->Insert(PPointPair(loophead, source))) {
body_list->PushBack(source);
worklist.PushBack(source);
}
}
}
// this should only be called on loops that have actual backedges
Assert(!worklist.Empty());
while (!worklist.Empty()) {
PPoint back = worklist.Back();
worklist.PopBack();
if (back == loophead)
continue;
const Vector<PEdge*> &incoming = cfg->GetIncomingEdges(back);
for (size_t iind = 0; iind < incoming.Size(); iind++) {
PEdge *edge = incoming[iind];
PPoint source = edge->GetSource();
if (reach_table->Lookup(PPointPair(loophead, source))) {
if (!body_table->Insert(PPointPair(loophead, source))) {
body_list->PushBack(source);
worklist.PushBack(source);
}
}
else if (entry_reach_table->Lookup(source)) {
// the source is not reachable from the loophead.
// this is an irreducible edge.
irreducible_edges->PushBack(edge);
}
}
}
}
示例8: showGraph
void PGraph::showGraph(){
for(int i = 0; i < nodes.size(); i++){
cout<<nodes[i]->getIndex()<<endl;
for (PEdgeListIterator it = edges[i].begin(); it != edges[i].end(); ++it){
PEdge * e = *it;
cout<<" "<<e->getFromNode()<<","<<e->getToNode()<<endl;
}
}
}
示例9:
list<PNode *> PGraph::getNeighbors(PNode* observer) {
int observerIndex = observer->getIndex();
PEdgeList edgesNeighbors = edges[observerIndex];
list<PNode *> neighbors;
for(PEdgeListIterator it = edgesNeighbors.begin(); it != edgesNeighbors.end(); ++it) {
PEdge * e = *it;
if (nodes[e->getFromNode()] != observer) {
neighbors.push_back(nodes[e->getFromNode()]);
}
else {
neighbors.push_back(nodes[e->getToNode()]);
}
}
return neighbors;
}
示例10: PrintHook
void WherePostcondition::PrintHook(OutStream &out) const
{
BlockId *id = m_frame->CFG()->GetId();
Variable *func_var = id->BaseVar();
PEdge *edge = m_frame->CFG()->GetSingleOutgoingEdge(m_point);
if (edge->IsLoop()) {
PEdgeLoop *nedge = edge->AsLoop();
out << nedge->GetLoopId()->Loop()->Value() << " "
<< func_var->GetName()->Value();
}
else {
PEdgeCall *nedge = edge->AsCall();
if (Variable *callee = nedge->GetDirectFunction()) {
// direct call, just one hook function.
out << "post " << callee->GetName()->Value();
}
else {
// indirect call, one hook function for each callee.
CallEdgeSet *callees = CalleeCache.Lookup(func_var);
bool found_callee = false;
if (callees) {
for (size_t eind = 0; eind < callees->GetEdgeCount(); eind++) {
const CallEdge &edge = callees->GetEdge(eind);
if (edge.where.id == id && edge.where.point == m_point) {
if (found_callee)
out << "$"; // add the separator
found_callee = true;
out << "post " << edge.callee->GetName()->Value();
}
}
}
CalleeCache.Release(func_var);
}
}
}
示例11: GetLoopReachable
// get the set of points reachable from loophead over paths
// that do not go through a backedge. if loophead itself is
// reachable, it is irreducible and those new edges to it are added
// as backedges. return value is true iff the loop is irreducible.
bool GetLoopReachable(BlockCFG *cfg, PPoint loophead)
{
// worklist items are points in reach_table whose outgoing edges
// have not been examined
Vector<PPoint> worklist;
if (!entry_reach_table->Lookup(loophead))
return false;
reach_table->Insert(PPointPair(loophead, loophead));
worklist.PushBack(loophead);
bool found_irreducible = false;
while (!worklist.Empty()) {
PPoint back = worklist.Back();
worklist.PopBack();
const Vector<PEdge*>& outgoing = cfg->GetOutgoingEdges(back);
for (size_t oind = 0; oind < outgoing.Size(); oind++) {
PEdge *edge = outgoing[oind];
PPoint next = edge->GetTarget();
if (backedge_table->Lookup(edge))
continue;
if (next == loophead) {
// we're in an irreducible loop. add the new edge to backedge_table.
backedge_table->Insert(edge);
found_irreducible = true;
continue;
}
if (!reach_table->Insert(PPointPair(loophead, next)))
worklist.PushBack(next);
}
}
return found_irreducible;
}
示例12: int
void R_s_k_2::draw_relevance(const float line_width, const int nb)
{
MultiIndex mindex;
FT min_value = (std::numeric_limits<FT>::max)();
FT max_value = -(std::numeric_limits<FT>::max)();
unsigned int nb_initial = 0;
for (Finite_edges_iterator ei = m_dt.finite_edges_begin(); ei != m_dt.finite_edges_end(); ++ei)
{
Edge edge = *ei;
if (m_dt.is_ghost(edge)) continue;
FT value = m_dt.get_edge_relevance(edge); // >= 0
nb_initial++;
min_value = (std::min)(min_value, value);
max_value = (std::max)(max_value, value);
mindex.insert(PEdge(edge, value));
}
if (min_value == max_value) max_value += 1.0;
viewer->glLineWidth(line_width);
int nb_remove = (std::min)(nb, int(mindex.size()));
viewer->glColor3d(0.5, 0.1, 0.1);
for (int i = 0; i < nb_remove; ++i)
{
PEdge pedge = *(mindex.get<1>()).begin();
(mindex.get<0>()).erase(pedge);
}
viewer->glColor3d(0.0, 0.5, 0.0);
while (!mindex.empty())
{
PEdge pedge = *(mindex.get<1>()).begin();
(mindex.get<0>()).erase(pedge);
draw_edge(pedge.edge());
}
}
示例13: CheckFrame
bool CheckFrame(CheckerState *state, CheckerFrame *frame,
CheckerPropagate *propagate)
{
Assert(!state->GetReportKind());
BlockMemory *mcfg = frame->Memory();
BlockCFG *cfg = mcfg->GetCFG();
BlockId *id = cfg->GetId();
if (checker_verbose.IsSpecified()) {
logout << "CHECK: " << frame << ": Entering " << id << endl;
if (propagate)
propagate->Print();
}
Where *where = propagate ? propagate->m_where : NULL;
// check if we should terminate the search at this point (with or without
// generating a report).
if (where && where->IsNone()) {
WhereNone *nwhere = where->AsNone();
ReportKind kind = nwhere->GetReportKind();
if (kind == RK_None) {
if (checker_verbose.IsSpecified())
logout << "CHECK: " << frame << ": Ignoring" << endl;
return false;
}
else {
if (checker_verbose.IsSpecified())
logout << "CHECK: " << frame << ": Propagation failed" << endl;
state->SetReport(kind);
return true;
}
}
// check for other propagations on the stack with frames for the same block,
// and block the recursion if we exceed the checker's depth. we assume that
// if we're ever going to terminate in the presence of recursion, we will
// do so quickly.
if (propagate) {
if (uint32_t depth = checker_depth.UIntValue()) {
Vector<CheckerFrame*> recurse_frames;
for (size_t ind = 0; ind < state->m_stack.Size(); ind++) {
CheckerFrame *other_frame = state->m_stack[ind]->m_frame;
if (other_frame != frame && other_frame->Memory() == mcfg &&
!recurse_frames.Contains(other_frame))
recurse_frames.PushBack(other_frame);
}
if (recurse_frames.Size() >= depth) {
state->SetReport(RK_Recursion);
return true;
}
}
}
// check if we are propagating into some callee.
if (where && where->IsPostcondition()) {
WherePostcondition *nwhere = where->AsPostcondition();
// expand the callee at the specified point.
PPoint point = nwhere->GetPoint();
PEdge *edge = cfg->GetSingleOutgoingEdge(point);
if (edge->IsLoop()) {
// expanding data from a loop. first try the case that the loop
// does not execute at all.
if (checker_verbose.IsSpecified())
logout << "CHECK: " << frame
<< ": Trying to skip loop at " << point << endl;
state->PushContext();
if (CheckSkipLoop(state, frame, point, nwhere))
return true;
state->PopContext();
}
if (BlockId *callee = edge->GetDirectCallee()) {
// easy case, there is only a single callee.
if (checker_verbose.IsSpecified())
logout << "CHECK: " << frame
<< ": Expanding single callee at " << point
<< ": " << callee << endl;
state->PushContext();
if (CheckSingleCallee(state, frame, point, nwhere, callee, true))
return true;
state->PopContext();
}
else {
// iterate through all the possible callees
//.........这里部分代码省略.........
示例14: GetMatchingHeapWrites
void GetMatchingHeapWrites(const EscapeAccess &heap_write,
Vector<HeapWriteInfo> *writes)
{
BlockId *id = heap_write.where.id;
BlockMemory *mcfg = GetBlockMemory(id);
if (mcfg == NULL) {
logout << "WARNING: Missing memory: '" << id << "'" << endl;
return;
}
BlockCFG *cfg = mcfg->GetCFG();
// for incremental analysis, make sure the write CFG uses the right version.
// as for checking callers, if the CFG has changed but the new one still
// has a matching write, we will see an escape access for the new CFG.
if (cfg->GetVersion() != heap_write.where.version) {
if (checker_verbose.IsSpecified())
logout << "CHECK: Write is an older version: "
<< heap_write.where.id << ": "
<< heap_write.where.version << endl;
mcfg->DecRef();
return;
}
PPoint point = heap_write.where.point;
PPoint exit_point = mcfg->GetCFG()->GetExitPoint();
// find a point-relative lvalue written at the write point with
// the sanitized representation from the heap_write trace.
// TODO: we only match against direct assignments in the CFG for now,
// ignoring structural copies (which are simple recursive writes).
PEdge *edge = cfg->GetSingleOutgoingEdge(point);
Exp *point_lval = NULL;
if (PEdgeAssign *nedge = edge->IfAssign())
point_lval = nedge->GetLeftSide();
else if (PEdgeCall *nedge = edge->IfCall())
point_lval = nedge->GetReturnValue();
bool lval_matches = false;
if (point_lval) {
if (Exp *new_point_lval = Trace::SanitizeExp(point_lval)) {
lval_matches = (new_point_lval == heap_write.target->GetValue());
new_point_lval->DecRef();
}
}
if (!lval_matches) {
mcfg->DecRef();
return;
}
// it would be nice to remove Val() expressions from this list, but we can't
// do that as lvalues in memory assignments can contain Val and we want to
// see the effects of those assignments. TODO: fix.
GuardExpVector lval_res;
mcfg->TranslateExp(TRK_Point, point, point_lval, &lval_res);
for (size_t ind = 0; ind < lval_res.Size(); ind++) {
const GuardExp &lv = lval_res[ind];
HeapWriteInfo info;
info.mcfg = mcfg;
info.lval = lv.exp;
info.base_lval = point_lval;
// look for a condition where the lvalue is not written.
GuardExpVector exit_vals;
info.mcfg->GetValComplete(info.lval, NULL, exit_point, &exit_vals);
for (size_t ind = 0; ind < exit_vals.Size(); ind++) {
const GuardExp &val = exit_vals[ind];
// exclude cases where the lvalue refers to its value at block entry.
if (ExpDrf *nval = val.exp->IfDrf()) {
if (nval->GetTarget() == info.lval)
info.exclude.PushBack(val.guard);
}
}
if (!writes->Contains(info)) {
info.mcfg->IncRef(writes);
info.lval->IncRef(writes);
info.base_lval->IncRef(writes);
IncRefVector<Bit>(info.exclude, writes);
writes->PushBack(info);
}
}
mcfg->DecRef();
}
示例15: compute_timer
void BlockModset::ComputeModset(BlockMemory *mcfg, bool indirect)
{
static BaseTimer compute_timer("modset_compute");
Timer _timer(&compute_timer);
// get any indirect callees for this function, provided they have been
// computed and stored in the callee database (indirect is set).
CallEdgeSet *indirect_callees = NULL;
if (indirect)
indirect_callees = CalleeCache.Lookup(m_id->BaseVar());
BlockCFG *cfg = mcfg->GetCFG();
for (size_t eind = 0; eind < cfg->GetEdgeCount(); eind++) {
PEdge *edge = cfg->GetEdge(eind);
PPoint point = edge->GetSource();
if (edge->IsAssign() || edge->IsCall()) {
// process direct assignments along this edge.
const Vector<GuardAssign>* assigns = mcfg->GetAssigns(point);
if (assigns) {
for (size_t aind = 0; aind < assigns->Size(); aind++) {
const GuardAssign &gasn = assigns->At(aind);
ProcessUpdatedLval(mcfg, gasn.left, NULL, true, false);
Exp *use_lval = NULL;
Exp *kind = mcfg->GetTerminateAssign(point, gasn.left, gasn.right,
&use_lval);
if (kind) {
ProcessUpdatedLval(mcfg, use_lval, kind, false, false);
kind->DecRef();
}
}
}
}
// pull in modsets from the direct and indirect callees of the edge.
if (BlockId *callee = edge->GetDirectCallee()) {
ComputeModsetCall(mcfg, edge, callee, NULL);
callee->DecRef();
}
else if (edge->IsCall() && indirect_callees) {
for (size_t ind = 0; ind < indirect_callees->GetEdgeCount(); ind++) {
const CallEdge &cedge = indirect_callees->GetEdge(ind);
// when comparing watch out for the case that this is a temporary
// modset and does not share the same block kind as the edge point.
if (cedge.where.version == cfg->GetVersion() &&
cedge.where.point == point &&
cedge.where.id->Function() == m_id->Function() &&
cedge.where.id->Loop() == m_id->Loop()) {
cedge.callee->IncRef();
BlockId *callee = BlockId::Make(B_Function, cedge.callee);
ComputeModsetCall(mcfg, edge, callee, cedge.rfld_chain);
callee->DecRef();
}
}
}
}
// sort the modset exps to ensure a consistent representation.
if (m_modset_list)
SortVector<PointValue,compare_PointValue>(m_modset_list);
if (m_assign_list)
SortVector<GuardAssign,compare_GuardAssign>(m_assign_list);
if (indirect)
CalleeCache.Release(m_id->BaseVar());
}