[Beignet] [PATCH 3/7] Backend: Add debug info to the return lower.

junyan.he at inbox.com junyan.he at inbox.com
Thu Dec 17 01:35:54 PST 2015


From: Junyan He <junyan.he at linux.intel.com>

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 backend/src/ir/lowering.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/backend/src/ir/lowering.cpp b/backend/src/ir/lowering.cpp
index 535f7e6..1746489 100644
--- a/backend/src/ir/lowering.cpp
+++ b/backend/src/ir/lowering.cpp
@@ -43,12 +43,15 @@ namespace ir {
   };
 
   void ContextReturn::lower(const std::string &functionName) {
+    DebugInfo dgInfo;
     if ((this->fn = unit.getFunction(functionName)) == NULL)
       return;
 
     // Append a new block at the end of the function with a return instruction:
     // the only one we are going to have
     this->bb = &this->fn->getBottomBlock();
+    /* Just use the last instruction's debug info, no matter whether it is RET. */
+    dgInfo = this->fn->getBottomBlock().getLastInstruction()->DBGInfo;
     const LabelIndex index = this->label();
     this->LABEL(index);
     const BasicBlock *lastBlock = this->bb;
@@ -60,13 +63,17 @@ namespace ir {
     }
 
     this->RET();
+    Instruction* retInst = lastBlock->getLastInstruction();
+    retInst->DBGInfo = dgInfo;
 
     // Now traverse all instructions and replace all returns by GOTO index
     fn->foreachInstruction([&](Instruction &insn) {
       if (insn.getParent() == lastBlock) return; // This is the last block
       if (insn.getOpcode() != OP_RET) return;
-      const Instruction bra = ir::BRA(index);
+      Instruction bra = ir::BRA(index);
+      dgInfo = insn.DBGInfo;
       bra.replace(&insn);
+      bra.DBGInfo = dgInfo;
     });
   }
 
-- 
1.9.1





More information about the Beignet mailing list