From 10b313581f5aa3836b8e22570cd4cfaa3d61568d Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 15 Mar 2018 22:06:51 +0000 Subject: [WebAssembly] Add DebugLoc information to WebAssembly block and loop. Patch by Yury Delendik Differential Revision: https://reviews.llvm.org/D44448 llvm-svn: 327673 --- .../lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp index cab21007d3f..5a8ddadb0c9 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -143,9 +143,9 @@ static void PlaceBlockMarker( } // Add the BLOCK. - MachineInstr *Begin = BuildMI(*Header, InsertPos, DebugLoc(), + MachineInstr *Begin = BuildMI(*Header, InsertPos, MBB.findDebugLoc(InsertPos), TII.get(WebAssembly::BLOCK)) - .addImm(int64_t(WebAssembly::ExprType::Void)); + .addImm(int64_t(WebAssembly::ExprType::Void)); // Mark the end of the block. InsertPos = MBB.begin(); @@ -153,7 +153,7 @@ static void PlaceBlockMarker( InsertPos->getOpcode() == WebAssembly::END_LOOP && LoopTops[&*InsertPos]->getParent()->getNumber() >= Header->getNumber()) ++InsertPos; - MachineInstr *End = BuildMI(MBB, InsertPos, DebugLoc(), + MachineInstr *End = BuildMI(MBB, InsertPos, MBB.findPrevDebugLoc(InsertPos), TII.get(WebAssembly::END_BLOCK)); BlockTops[End] = Begin; @@ -193,12 +193,14 @@ static void PlaceLoopMarker( while (InsertPos != MBB.end() && InsertPos->getOpcode() == WebAssembly::END_LOOP) ++InsertPos; - MachineInstr *Begin = BuildMI(MBB, InsertPos, DebugLoc(), + MachineInstr *Begin = BuildMI(MBB, InsertPos, MBB.findDebugLoc(InsertPos), TII.get(WebAssembly::LOOP)) - .addImm(int64_t(WebAssembly::ExprType::Void)); + .addImm(int64_t(WebAssembly::ExprType::Void)); - // Mark the end of the loop. - MachineInstr *End = BuildMI(*AfterLoop, AfterLoop->begin(), DebugLoc(), + // Mark the end of the loop (using arbitrary debug location that branched + // to the loop end as its location). + DebugLoc EndDL = (*AfterLoop->pred_rbegin())->findBranchDebugLoc(); + MachineInstr *End = BuildMI(*AfterLoop, AfterLoop->begin(), EndDL, TII.get(WebAssembly::END_LOOP)); LoopTops[End] = Begin; @@ -276,7 +278,8 @@ static void FixEndsAtEndOfFunction( static void AppendEndToFunction( MachineFunction &MF, const WebAssemblyInstrInfo &TII) { - BuildMI(MF.back(), MF.back().end(), DebugLoc(), + BuildMI(MF.back(), MF.back().end(), + MF.back().findPrevDebugLoc(MF.back().end()), TII.get(WebAssembly::END_FUNCTION)); } -- cgit v1.2.3