[llvm] r330970 - Fix a bug that prevents global variables from having a DW_OP_deref.

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 26 13:59:06 PDT 2018


This appears to be causing assertion failures in the Chromium build:
https://ci.chromium.org/buildbot/chromium.clang/ToTLinux/2328

The LLVM revision window is:
good: 330945
bad: 330975

I'll prepare a revert and get a repro.

On Thu, Apr 26, 2018 at 11:20 AM Adrian Prantl via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: adrian
> Date: Thu Apr 26 11:17:04 2018
> New Revision: 330970
>
> URL: http://llvm.org/viewvc/llvm-project?rev=330970&view=rev
> Log:
> Fix a bug that prevents global variables from having a DW_OP_deref.
>
> For local variables the first DW_OP_deref is consumed by turning the
> location kind into a memeory location, but that only makes sense for
> values that are in a register to begin with, which cannot happen for
> global variables that are attached to a symbol.
>
> rdar://problem/39741860
>
> Added:
>     llvm/trunk/test/DebugInfo/X86/global-expression.ll
> Modified:
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=330970&r1=330969&r2=330970&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu Apr 26
> 11:17:04 2018
> @@ -230,8 +230,9 @@ DIE *DwarfCompileUnit::getOrCreateGlobal
>          addOpAddress(*Loc, Sym);
>        }
>      }
> -    if (Expr)
> -      DwarfExpr->addExpression(Expr);
> +    // Global variables attached to symbols are memory locations.
> +    DwarfExpr->setMemoryLocationKind();
> +    DwarfExpr->addExpression(Expr);
>    }
>    if (Loc)
>      addBlock(*VariableDIE, dwarf::DW_AT_location, DwarfExpr->finalize());
>
> Added: llvm/trunk/test/DebugInfo/X86/global-expression.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/global-expression.ll?rev=330970&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/X86/global-expression.ll (added)
> +++ llvm/trunk/test/DebugInfo/X86/global-expression.ll Thu Apr 26 11:17:04
> 2018
> @@ -0,0 +1,38 @@
> +; RUN: llc -mtriple=x86_64-apple-darwin %s -o - -filetype=obj | \
> +; RUN:     llvm-dwarfdump --name i --name indirect - | FileCheck %s
> +;
> +; This is a hand-crafted testcase generated from:
> +;   int i = 23;
> +;   int *indirect = &i;
> +
> +; CHECK: DW_TAG_variable
> +; CHECK:   DW_AT_name  ("i")
> +; CHECK:   DW_AT_location      (DW_OP_addr 0x8, DW_OP_deref)
> +; CHECK: DW_TAG_variable
> +; CHECK:   DW_AT_name  ("indirect")
> +; CHECK:   DW_AT_location      (DW_OP_addr 0x8)
> +
> +source_filename = "global-deref.c"
> +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
> +target triple = "x86_64-apple-macosx10.13.0"
> +
> + at i = global i32 23, align 4
> + at indirect = global i32* @i, align 8, !dbg !6, !dbg !0
> +
> +!llvm.dbg.cu = !{!2}
> +!llvm.module.flags = !{!10, !11, !12, !13}
> +
> +!0 = !DIGlobalVariableExpression(var: !1, expr:
> !DIExpression(DW_OP_deref))
> +!1 = distinct !DIGlobalVariable(name: "i", scope: !2, file: !3, line: 1,
> type: !9, isLocal: false, isDefinition: true)
> +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer:
> "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug,
> enums: !4, globals: !5)
> +!3 = !DIFile(filename: "global-deref.c", directory: "/")
> +!4 = !{}
> +!5 = !{!0, !6}
> +!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
> +!7 = distinct !DIGlobalVariable(name: "indirect", scope: !2, file: !3,
> line: 2, type: !8, isLocal: false, isDefinition: true)
> +!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
> +!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
> +!10 = !{i32 2, !"Dwarf Version", i32 4}
> +!11 = !{i32 2, !"Debug Info Version", i32 3}
> +!12 = !{i32 1, !"wchar_size", i32 4}
> +!13 = !{i32 7, !"PIC Level", i32 2}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180426/181a05d3/attachment.html>


More information about the llvm-commits mailing list