Skip to content

Commit 409b439

Browse files
committedOct 4, 2018
[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 llvm-svn: 343827
1 parent 173946d commit 409b439

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
 

‎llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ void WebAssemblyCFGStackify::placeBlockMarker(MachineBasicBlock &MBB) {
309309
// Local expression tree should go after the BLOCK.
310310
for (auto I = Header->getFirstTerminator(), E = Header->begin(); I != E;
311311
--I) {
312+
if (std::prev(I)->isDebugInstr() || std::prev(I)->isPosition())
313+
continue;
312314
if (WebAssembly::isChild(*std::prev(I), MFI))
313315
AfterSet.insert(&*std::prev(I));
314316
else
@@ -531,6 +533,8 @@ void WebAssemblyCFGStackify::placeTryMarker(MachineBasicBlock &MBB) {
531533
// Local expression tree should go after the TRY.
532534
for (auto I = Header->getFirstTerminator(), E = Header->begin(); I != E;
533535
--I) {
536+
if (std::prev(I)->isDebugInstr() || std::prev(I)->isPosition())
537+
continue;
534538
if (WebAssembly::isChild(*std::prev(I), MFI))
535539
AfterSet.insert(&*std::prev(I));
536540
else
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; RUN: llc %s -stop-after wasm-cfg-stackify -o - | FileCheck %s
2+
3+
; The test ensures "block" instruction is not inserted in the middle of a group
4+
; of instructions that form a stackified expression when DBG_VALUE is present
5+
; among them.
6+
7+
; CHECK: body:
8+
; CHECK: BLOCK
9+
; <-- Stackified expression starts
10+
; CHECK-NEXT: GET_LOCAL_I64
11+
; CHECK-NEXT: I32_WRAP_I64
12+
; CHECK-NEXT: DBG_VALUE
13+
; <-- BLOCK should NOT be placed here!
14+
; CHECK-NEXT: BR_UNLESS
15+
; <-- Stackified expression ends
16+
17+
target triple = "wasm32-unknown-unknown"
18+
19+
define void @foo(i64 %arg) {
20+
start:
21+
%val = trunc i64 %arg to i32
22+
%cmp = icmp eq i32 %val, 0
23+
call void @llvm.dbg.value(metadata i32 %val, metadata !46, metadata !DIExpression()), !dbg !105
24+
br i1 %cmp, label %bb2, label %bb1
25+
bb1: ; preds = %start
26+
call void @bar()
27+
br label %bb2
28+
bb2: ; preds = %bb1, start
29+
ret void
30+
}
31+
32+
declare void @bar()
33+
declare void @llvm.dbg.value(metadata, metadata, metadata)
34+
35+
!llvm.dbg.cu = !{!0}
36+
!llvm.module.flags = !{!33}
37+
!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)
38+
!2 = !{}
39+
!6 = !DIFile(filename: "<unknown>", directory: "")
40+
!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "&str", file: !6, size: 64, align: 32, elements: !{}, identifier: "111094d970b097647de579f9c509ef08")
41+
!33 = !{i32 2, !"Debug Info Version", i32 3}
42+
!35 = distinct !DILexicalBlock(scope: !37, file: !6, line: 357, column: 8)
43+
!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)
44+
!38 = !DINamespace(name: "ptr", scope: null)
45+
!39 = !DISubroutineType(types: !2)
46+
!42 = !{!46}
47+
!46 = !DILocalVariable(name: "z", scope: !35, file: !6, line: 357, type: !22, align: 4)
48+
!105 = !DILocation(line: 357, column: 12, scope: !35)

0 commit comments

Comments
 (0)
Please sign in to comment.