| OLD | NEW |
| 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file implements the Cfg class, including constant pool | 10 // This file implements the Cfg class, including constant pool |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 | 312 |
| 313 // Traverse every Variable of every Inst and verify that it | 313 // Traverse every Variable of every Inst and verify that it |
| 314 // appears within the Variable's computed live range. | 314 // appears within the Variable's computed live range. |
| 315 bool Cfg::validateLiveness() const { | 315 bool Cfg::validateLiveness() const { |
| 316 TimerMarker T(TimerStack::TT_validateLiveness, this); | 316 TimerMarker T(TimerStack::TT_validateLiveness, this); |
| 317 bool Valid = true; | 317 bool Valid = true; |
| 318 Ostream &Str = Ctx->getStrDump(); | 318 Ostream &Str = Ctx->getStrDump(); |
| 319 for (CfgNode *Node : Nodes) { | 319 for (CfgNode *Node : Nodes) { |
| 320 Inst *FirstInst = NULL; | 320 Inst *FirstInst = NULL; |
| 321 for (Inst *Inst : Node->getInsts()) { | 321 for (auto Inst = Node->getInsts().begin(), E = Node->getInsts().end(); |
| 322 Inst != E; ++Inst) { |
| 322 if (Inst->isDeleted()) | 323 if (Inst->isDeleted()) |
| 323 continue; | 324 continue; |
| 324 if (FirstInst == NULL) | 325 if (FirstInst == NULL) |
| 325 FirstInst = Inst; | 326 FirstInst = Inst; |
| 326 InstNumberT InstNumber = Inst->getNumber(); | 327 InstNumberT InstNumber = Inst->getNumber(); |
| 327 if (Variable *Dest = Inst->getDest()) { | 328 if (Variable *Dest = Inst->getDest()) { |
| 328 if (!Dest->getIgnoreLiveness()) { | 329 if (!Dest->getIgnoreLiveness()) { |
| 329 bool Invalid = false; | 330 bool Invalid = false; |
| 330 const bool IsDest = true; | 331 const bool IsDest = true; |
| 331 if (!Dest->getLiveRange().containsValue(InstNumber, IsDest)) | 332 if (!Dest->getLiveRange().containsValue(InstNumber, IsDest)) |
| 332 Invalid = true; | 333 Invalid = true; |
| 333 // Check that this instruction actually *begins* Dest's live | 334 // Check that this instruction actually *begins* Dest's live |
| 334 // range, by checking that Dest is not live in the previous | 335 // range, by checking that Dest is not live in the previous |
| 335 // instruction. As a special exception, we don't check this | 336 // instruction. As a special exception, we don't check this |
| 336 // for the first instruction of the block, because a Phi | 337 // for the first instruction of the block, because a Phi |
| 337 // temporary may be live at the end of the previous block, | 338 // temporary may be live at the end of the previous block, |
| 338 // and if it is also assigned in the first instruction of | 339 // and if it is also assigned in the first instruction of |
| 339 // this block, the adjacent live ranges get merged. | 340 // this block, the adjacent live ranges get merged. |
| 340 if (Inst != FirstInst && !Inst->isDestNonKillable() && | 341 if (static_cast<class Inst *>(Inst) != FirstInst && |
| 342 !Inst->isDestNonKillable() && |
| 341 Dest->getLiveRange().containsValue(InstNumber - 1, IsDest)) | 343 Dest->getLiveRange().containsValue(InstNumber - 1, IsDest)) |
| 342 Invalid = true; | 344 Invalid = true; |
| 343 if (Invalid) { | 345 if (Invalid) { |
| 344 Valid = false; | 346 Valid = false; |
| 345 Str << "Liveness error: inst " << Inst->getNumber() << " dest "; | 347 Str << "Liveness error: inst " << Inst->getNumber() << " dest "; |
| 346 Dest->dump(this); | 348 Dest->dump(this); |
| 347 Str << " live range " << Dest->getLiveRange() << "\n"; | 349 Str << " live range " << Dest->getLiveRange() << "\n"; |
| 348 } | 350 } |
| 349 } | 351 } |
| 350 } | 352 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 484 } |
| 483 } | 485 } |
| 484 // Print each basic block | 486 // Print each basic block |
| 485 for (CfgNode *Node : Nodes) | 487 for (CfgNode *Node : Nodes) |
| 486 Node->dump(this); | 488 Node->dump(this); |
| 487 if (getContext()->isVerbose(IceV_Instructions)) | 489 if (getContext()->isVerbose(IceV_Instructions)) |
| 488 Str << "}\n"; | 490 Str << "}\n"; |
| 489 } | 491 } |
| 490 | 492 |
| 491 } // end of namespace Ice | 493 } // end of namespace Ice |
| OLD | NEW |