Skip to content

Commit ae900d3

Browse files
committed
[MemorySSA] Update MemorySSA when removing debug.value calls.
llvm-svn: 371084
1 parent 0ce9319 commit ae900d3

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
250250
llvm::findDbgValues(DbgValues, Incoming);
251251
for (auto &DVI : DbgValues) {
252252
auto R = DbgValueSet.insert({DVI->getVariable(), DVI->getExpression()});
253-
if (!R.second)
253+
if (!R.second) {
254+
MSSAU->removeMemoryAccess(DVI);
254255
DVI->eraseFromParent();
256+
}
255257
}
256258
}
257259
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; RUN: opt -disable-basicaa -loop-rotate -enable-mssa-loop-dependency -verify-memoryssa -S %s | FileCheck %s
2+
; REQUIRES: asserts
3+
4+
; CHECK-LABEL: @f_w4_i2
5+
define void @f_w4_i2() {
6+
entry:
7+
br label %for.cond
8+
9+
for.cond: ; preds = %for.body, %entry
10+
%i.0 = phi i16 [ 0, %entry ], [ %inc, %for.body ]
11+
call void @llvm.dbg.value(metadata i16 %i.0, metadata !32, metadata !DIExpression()), !dbg !31
12+
br i1 undef, label %for.body, label %for.cond.cleanup
13+
14+
for.cond.cleanup: ; preds = %for.cond
15+
ret void
16+
17+
for.body: ; preds = %for.cond
18+
store i32 undef, i32* undef, align 1
19+
%inc = add i16 %i.0, 1
20+
call void @llvm.dbg.value(metadata i16 %inc, metadata !32, metadata !DIExpression()), !dbg !31
21+
br label %for.cond
22+
}
23+
24+
; Function Attrs: nounwind readnone speculatable willreturn
25+
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
26+
27+
attributes #1 = { nounwind readnone speculatable willreturn }
28+
29+
!llvm.dbg.cu = !{!0}
30+
!llvm.module.flags = !{!14}
31+
32+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0s", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
33+
!1 = !DIFile(filename: "vec.c", directory: "test")
34+
!2 = !{}
35+
!3 = !{!4}
36+
!4 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
37+
!14 = !{i32 2, !"Debug Info Version", i32 3}
38+
!15 = distinct !DISubprogram(name: "f_w4_i2", scope: !1, file: !1, line: 36, type: !16, scopeLine: 38, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !23)
39+
!16 = !DISubroutineType(types: !17)
40+
!17 = !{null}
41+
!23 = !{}
42+
!30 = distinct !DILexicalBlock(scope: !15, file: !1, line: 43, column: 5)
43+
!31 = !DILocation(line: 0, scope: !30)
44+
!32 = !DILocalVariable(name: "i", scope: !30, file: !1, line: 43, type: !4)

0 commit comments

Comments
 (0)