diff options
author | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2018-06-14 11:23:42 +0000 |
---|---|---|
committer | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2018-06-14 11:23:42 +0000 |
commit | e406b29c2295b8d41ebb084ee0dd79f87bcf16fa (patch) | |
tree | 21f2ae4376ec1058b86dd2b0ba8008ab6a1b30ac /llvm/test/Transforms/Mem2Reg | |
parent | 1bbab1e558523e8a3acce350250fc85819a7ebf3 (diff) | |
download | bcm5719-llvm-e406b29c2295b8d41ebb084ee0dd79f87bcf16fa.tar.gz bcm5719-llvm-e406b29c2295b8d41ebb084ee0dd79f87bcf16fa.zip |
[DebugInfo] Check size of variable in ConvertDebugDeclareToDebugValue
Summary:
Do not convert a DbgDeclare to DbgValue if the store
instruction only refer to a fragment of the variable
described by the DbgDeclare.
Problem was seen when for example having an alloca for an
array or struct, and there were stores to individual elements.
In the past we inserted a DbgValue intrinsics for each store,
just as if the store wrote the whole variable.
When handling store instructions we insert a DbgValue that
indicates that the variable is "undefined", as we do not know
which part of the variable that is updated by the store.
When ConvertDebugDeclareToDebugValue is used with a load/phi
instruction we assert that the referenced value is large enough
to cover the whole variable. Afaict this should be true for all
scenarios where those methods are used on trunk. If the assert
blows in the future I guess we could simply skip to insert a
dbg.value instruction.
In the future I think we should examine which part of the variable
that is accessed, and add a DbgValue instrinsic with an appropriate
DW_OP_LLVM_fragment expression.
Reviewers: dblaikie, aprantl, rnk
Reviewed By: aprantl
Subscribers: JDevlieghere, llvm-commits
Tags: #debug-info
Differential Revision: https://reviews.llvm.org/D48024
llvm-svn: 334704
Diffstat (limited to 'llvm/test/Transforms/Mem2Reg')
-rw-r--r-- | llvm/test/Transforms/Mem2Reg/debug-alloca-phi-2.ll | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Mem2Reg/debug-alloca-phi-2.ll b/llvm/test/Transforms/Mem2Reg/debug-alloca-phi-2.ll new file mode 100644 index 00000000000..82144cb228e --- /dev/null +++ b/llvm/test/Transforms/Mem2Reg/debug-alloca-phi-2.ll @@ -0,0 +1,46 @@ +; RUN: opt < %s -mem2reg -S | FileCheck %s +source_filename = "bugpoint-output.bc" +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.12.0" + +define void @scan() #0 !dbg !12 { +entry: + %entry1 = alloca i1, align 8 + call void @llvm.dbg.declare(metadata i1* %entry1, metadata !18, metadata !19), !dbg !20 + store i1 0, i1* %entry1, align 8, !dbg !20 + br label %for.cond, !dbg !20 + +for.cond: +; CHECK: %[[PHI:.*]] = phi i1 [ false, %entry ], [ %0, %for.cond ] + %entryN = load i1, i1* %entry1, align 8, !dbg !20 +; CHECK: call void @llvm.dbg.value(metadata i1 %[[PHI]], +; CHECK-SAME: metadata !DIExpression()) + %0 = add i1 %entryN, 1 +; CHECK: %0 = add i1 %[[PHI]], true +; CHECK: call void @llvm.dbg.value(metadata i1 %0, +; CHECK-SAME: metadata !DIExpression()) + store i1 %0, i1* %entry1, align 8, !dbg !20 + br label %for.cond, !dbg !20 +} + +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { nounwind ssp uwtable } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!10, !11} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "adrian", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) +!1 = !DIFile(filename: "<stdin>", directory: "/") +!2 = !{} +!4 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!10 = !{i32 2, !"Debug Info Version", i32 3} +!11 = !{i32 1, !"PIC Level", i32 2} +!12 = distinct !DISubprogram(name: "scan", scope: !1, file: !1, line: 4, type: !13, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !15) +!13 = !DISubroutineType(types: !14) +!14 = !{null, !4, !4} +!15 = !{!18} +!18 = !DILocalVariable(name: "entry", scope: !12, file: !1, line: 6, type: !4) +!19 = !DIExpression() +!20 = !DILocation(line: 6, scope: !12) |