[PATCH] D45648: [WebAssembly] Fix a bug in MachineBasicBlock::findDebugLoc() call
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 13 16:54:25 PDT 2018
aheejin created this revision.
aheejin added a reviewer: yurydelendik.
Herald added subscribers: llvm-commits, JDevlieghere, sunfish, jgravelle-google, sbc100, aprantl, dschuff, jfb.
- InsertPos is within the bacic block `Header`, so `findDebugLoc()`
should be call on not `MBB` but `Header` instead.
- In case a basic block that `findDebugLoc()` is called on does not have
a terminator or is empty, we should have a backup. (`findPrevDebugLoc()
returns UnknownLoc if no instruction is available to provide debug info)
Repository:
rL LLVM
https://reviews.llvm.org/D45648
Files:
lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
Index: lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -147,9 +147,12 @@
}
// Add the BLOCK.
- MachineInstr *Begin = BuildMI(*Header, InsertPos, MBB.findDebugLoc(InsertPos),
- TII.get(WebAssembly::BLOCK))
- .addImm(int64_t(WebAssembly::ExprType::Void));
+ DebugLoc DL = InsertPos != Header->end()
+ ? Header->findDebugLoc(InsertPos)
+ : Header->findPrevDebugLoc(InsertPos);
+ MachineInstr *Begin =
+ BuildMI(*Header, InsertPos, DL, TII.get(WebAssembly::BLOCK))
+ .addImm(int64_t(WebAssembly::ExprType::Void));
// Mark the end of the block.
InsertPos = MBB.begin();
@@ -197,8 +200,10 @@
while (InsertPos != MBB.end() &&
InsertPos->getOpcode() == WebAssembly::END_LOOP)
++InsertPos;
- MachineInstr *Begin = BuildMI(MBB, InsertPos, MBB.findDebugLoc(InsertPos),
- TII.get(WebAssembly::LOOP))
+
+ DebugLoc DL = InsertPos != MBB.end() ? MBB.findDebugLoc(InsertPos)
+ : MBB.findPrevDebugLoc(InsertPos);
+ MachineInstr *Begin = BuildMI(MBB, InsertPos, DL, TII.get(WebAssembly::LOOP))
.addImm(int64_t(WebAssembly::ExprType::Void));
// Mark the end of the loop (using arbitrary debug location that branched
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45648.142494.patch
Type: text/x-patch
Size: 1531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180413/6d8275d2/attachment.bin>
More information about the llvm-commits
mailing list