nv50/ir/tgsi: fix handling of early RET
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sun, 29 Apr 2012 15:36:34 +0000 (17:36 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sun, 29 Apr 2012 15:55:36 +0000 (17:55 +0200)
We have to actually emit RET, too, of course, not just the PRERET.

src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp

index 8bd784fa47df5a2b587c840c98189e095f2329c3..82e23602ca0749fb14c50acce5f4ab5fff795cb5 100644 (file)
@@ -2196,12 +2196,13 @@ Converter::handleInstruction(const struct tgsi_full_instruction *insn)
       if (!isEndOfSubroutine(ip + 1)) {
          // insert a PRERET at the entry if this is an early return
          // (only needed for sharing code in the epilogue)
+         BasicBlock *pos = getBB();
+         setPosition(BasicBlock::get(func->cfg.getRoot()), false);
          mkFlow(OP_PRERET, leave, CC_ALWAYS, NULL)->fixed = 1;
-         bb->cfg.attach(&leave->cfg, Graph::Edge::CROSS);
-      } else {
-         mkFlow(OP_RET, NULL, CC_ALWAYS, NULL)->fixed = 1;
-         bb->cfg.attach(&leave->cfg, Graph::Edge::TREE);
+         setPosition(pos, true);
       }
+      mkFlow(OP_RET, NULL, CC_ALWAYS, NULL)->fixed = 1;
+      bb->cfg.attach(&leave->cfg, Graph::Edge::CROSS);
    }
       break;
    case TGSI_OPCODE_END: