[llvm] r343827 - [WebAssembly] Ignore DBG_VALUE in WebAssemblyCFGStackify pass when looking for block start

Yury Delendik via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 4 16:31:00 PDT 2018


Author: yurydelendik
Date: Thu Oct  4 16:31:00 2018
New Revision: 343827

URL: http://llvm.org/viewvc/llvm-project?rev=343827&view=rev
Log:
[WebAssembly] Ignore DBG_VALUE in WebAssemblyCFGStackify pass when looking for block start

Summary:
Fixes https://bugs.llvm.org/show_bug.cgi?id=39158 and regression caused by
D49034. Though it is possible the problem was existed before and was exposed by
additional DBG_VALUEs.

Reviewers: sunfish, dschuff, aheejin

Reviewed By: aheejin

Subscribers: sbc100, aheejin, llvm-commits, alexcrichton, jgravelle-google

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

Added:
    llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-dbg-skip.ll
Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp?rev=343827&r1=343826&r2=343827&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp Thu Oct  4 16:31:00 2018
@@ -309,6 +309,8 @@ void WebAssemblyCFGStackify::placeBlockM
   // Local expression tree should go after the BLOCK.
   for (auto I = Header->getFirstTerminator(), E = Header->begin(); I != E;
        --I) {
+    if (std::prev(I)->isDebugInstr() || std::prev(I)->isPosition())
+      continue;
     if (WebAssembly::isChild(*std::prev(I), MFI))
       AfterSet.insert(&*std::prev(I));
     else
@@ -531,6 +533,8 @@ void WebAssemblyCFGStackify::placeTryMar
   // Local expression tree should go after the TRY.
   for (auto I = Header->getFirstTerminator(), E = Header->begin(); I != E;
        --I) {
+    if (std::prev(I)->isDebugInstr() || std::prev(I)->isPosition())
+      continue;
     if (WebAssembly::isChild(*std::prev(I), MFI))
       AfterSet.insert(&*std::prev(I));
     else

Added: llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-dbg-skip.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-dbg-skip.ll?rev=343827&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-dbg-skip.ll (added)
+++ llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-dbg-skip.ll Thu Oct  4 16:31:00 2018
@@ -0,0 +1,48 @@
+; RUN: llc %s -stop-after wasm-cfg-stackify -o - | FileCheck %s
+
+; The test ensures "block" instruction is not inserted in the middle of a group
+; of instructions that form a stackified expression when DBG_VALUE is present
+; among them.
+
+; CHECK: body:
+; CHECK: BLOCK
+;                       <-- Stackified expression starts
+; CHECK-NEXT: GET_LOCAL_I64
+; CHECK-NEXT: I32_WRAP_I64
+; CHECK-NEXT: DBG_VALUE
+;                       <-- BLOCK should NOT be placed here!
+; CHECK-NEXT: BR_UNLESS
+;                       <-- Stackified expression ends
+
+target triple = "wasm32-unknown-unknown"
+
+define void @foo(i64 %arg) {
+start:
+  %val = trunc i64 %arg to i32
+  %cmp = icmp eq i32 %val, 0
+  call void @llvm.dbg.value(metadata i32 %val, metadata !46, metadata !DIExpression()), !dbg !105
+  br i1 %cmp, label %bb2, label %bb1
+bb1:                                              ; preds = %start
+  call void @bar()
+  br label %bb2
+bb2:                                              ; preds = %bb1, start
+  ret void
+}
+
+declare void @bar()
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!33}
+!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !6, producer: "clang LLVM (rustc version 1.30.0-dev)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
+!2 = !{}
+!6 = !DIFile(filename: "<unknown>", directory: "")
+!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "&str", file: !6, size: 64, align: 32, elements: !{}, identifier: "111094d970b097647de579f9c509ef08")
+!33 = !{i32 2, !"Debug Info Version", i32 3}
+!35 = distinct !DILexicalBlock(scope: !37, file: !6, line: 357, column: 8)
+!37 = distinct !DISubprogram(name: "foobar", linkageName: "_fooba", scope: !38, file: !6, line: 353, type: !39, isLocal: true, isDefinition: true, scopeLine: 353, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !2, retainedNodes: !42)
+!38 = !DINamespace(name: "ptr", scope: null)
+!39 = !DISubroutineType(types: !2)
+!42 = !{!46}
+!46 = !DILocalVariable(name: "z", scope: !35, file: !6, line: 357, type: !22, align: 4)
+!105 = !DILocation(line: 357, column: 12, scope: !35)




More information about the llvm-commits mailing list