// Remove all returns and insert one unique return block at the end of the
// function
lowerReturn(unit, fn->getName());
-
+ // check if there is empty labels at first
+ fn->checkEmptyLabels();
// Properly order labels and compute the CFG, it's needed by FunctionArgumentLower
fn->sortLabels();
fn->computeCFG();
loops.push_back(GBE_NEW(Loop, bbs, exits));
}
+ void Function::checkEmptyLabels(void) {
+ // Empty label map, we map the removed label to the next label.
+ map<LabelIndex, LabelIndex> labelMap;
+ map<LabelIndex, LabelIndex> revLabelMap;
+ foreachBlock([&](BasicBlock &BB) {
+ Instruction * insn = BB.getLastInstruction();
+ if (insn->getOpcode() == OP_LABEL) {
+ GBE_ASSERTM(0, "Found empty block. ");
+ }
+ });
+ }
+
void Function::sortLabels(void) {
uint32_t last = 0;
void computeCFG(void);
/*! Sort labels in increasing orders (top block has the smallest label) */
void sortLabels(void);
+ /*! check empty Label. */
+ void checkEmptyLabels(void);
/*! Get the pointer family */
RegisterFamily getPointerFamily(void) const;
/*! Number of registers in the register file */
passes.add(createGVNPass()); // Remove redundancies
passes.add(createScalarizePass()); // Expand all vector ops
passes.add(createDeadInstEliminationPass()); // Remove simplified instructions
+ passes.add(createCFGSimplificationPass()); // Merge & remove BBs
+ passes.add(createScalarizePass()); // Expand all vector ops
passes.add(createGenPass(unit));
// Print the code extra optimization passes