[llvm] 10e2e7d - [WebAssembly] iterate stack in DebugFixup from the top.

Wouter van Oortmerssen via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 08:33:50 PDT 2020


Author: Wouter van Oortmerssen
Date: 2020-05-18T08:33:36-07:00
New Revision: 10e2e7de0c0cb73a71eb0047f0a23db1f91361dc

URL: https://github.com/llvm/llvm-project/commit/10e2e7de0c0cb73a71eb0047f0a23db1f91361dc
DIFF: https://github.com/llvm/llvm-project/commit/10e2e7de0c0cb73a71eb0047f0a23db1f91361dc.diff

LOG: [WebAssembly] iterate stack in DebugFixup from the top.

Differential Revision: https://reviews.llvm.org/D80045

Added: 
    

Modified: 
    llvm/lib/Target/WebAssembly/WebAssemblyDebugFixup.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyDebugFixup.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyDebugFixup.cpp
index 8f1f77e23b8e..655e30a29eff 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyDebugFixup.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyDebugFixup.cpp
@@ -86,9 +86,9 @@ bool WebAssemblyDebugFixup::runOnMachineFunction(MachineFunction &MF) {
           // Search for register rather than assume it is on top (which it
           // typically is if it appears right after the def), since
           // DBG_VALUE's may shift under some circumstances.
-          size_t Depth = 0;
-          for (auto &Elem : Stack) {
+          for (auto &Elem : reverse(Stack)) {
             if (MO.getReg() == Elem.Reg) {
+              auto Depth = static_cast<unsigned>(&Elem - &Stack[0]);
               LLVM_DEBUG(dbgs() << "Debug Value VReg " << MO.getReg()
                                 << " -> Stack Relative " << Depth << "\n");
               MO.ChangeToTargetIndex(WebAssembly::TI_OPERAND_STACK, Depth);
@@ -98,7 +98,6 @@ bool WebAssemblyDebugFixup::runOnMachineFunction(MachineFunction &MF) {
               Elem.DebugValue = &MI;
               break;
             }
-            Depth++;
           }
           // If the Reg was not found, we have a DBG_VALUE outside of its
           // def-use range, and we leave it unmodified as reg, which means


        


More information about the llvm-commits mailing list