[llvm] r297161 - Relax the conflicting function arg verifier to allow for inlined debug

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 10:28:24 PST 2017


On Tue, Mar 7, 2017 at 10:11 AM Adrian Prantl <aprantl at apple.com> wrote:

> On Mar 7, 2017, at 9:52 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> On Tue, Mar 7, 2017 at 9:40 AM Adrian Prantl via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
> Author: adrian
> Date: Tue Mar  7 11:28:54 2017
> New Revision: 297161
>
> URL: http://llvm.org/viewvc/llvm-project?rev=297161&view=rev
> Log:
> Relax the conflicting function arg verifier to allow for inlined debug
> info in nodebug functions.
>
> Added:
>     llvm/trunk/test/Verifier/fnarg-nodebug.ll
> Modified:
>     llvm/trunk/lib/IR/Verifier.cpp
>
> Modified: llvm/trunk/lib/IR/Verifier.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=297161&r1=297160&r2=297161&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/Verifier.cpp (original)
> +++ llvm/trunk/lib/IR/Verifier.cpp Tue Mar  7 11:28:54 2017
> @@ -277,6 +277,9 @@ class Verifier : public InstVisitor<Veri
>    /// already.
>    bool SawFrameEscape;
>
> +  /// Whether the current function has a DISubprogram attached to it.
> +  bool HasDebugInfo = false;
> +
>    /// Stores the count of how many objects were passed to
> llvm.localescape for a
>    /// given function and the largest index passed to llvm.localrecover.
>    DenseMap<Function *, std::pair<unsigned, unsigned>> FrameEscapeInfo;
> @@ -2122,6 +2125,7 @@ void Verifier::visitFunction(const Funct
>           "Function is marked as dllimport, but not external.", &F);
>
>    auto *N = F.getSubprogram();
> +  HasDebugInfo = (N != nullptr);
>    if (!N)
>
>
> Might be nice to rephrase ^ as "if (HasDebugInfo)" for readability?
>
>
>      return;
>
> @@ -4425,6 +4429,12 @@ void Verifier::verifyFragmentExpression(
>  }
>
>  void Verifier::verifyFnArgs(const DbgInfoIntrinsic &I) {
> +  // This function does not take the scope of noninlined function
> arguments into
> +  // account. Don't run it if current function is nodebug, because it may
> +  // contain inlined debug intrinsics.
> +  if (!HasDebugInfo)
> +    return;
> +
>    DILocalVariable *Var;
>    if (auto *DV = dyn_cast<DbgValueInst>(&I)) {
>      // For performance reasons only check non-inlined ones.
>
> Added: llvm/trunk/test/Verifier/fnarg-nodebug.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/fnarg-nodebug.ll?rev=297161&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/Verifier/fnarg-nodebug.ll (added)
> +++ llvm/trunk/test/Verifier/fnarg-nodebug.ll Tue Mar  7 11:28:54 2017
> @@ -0,0 +1,70 @@
> +; RUN: llvm-as < %s -o %t
> +; RUN: llvm-dis < %t -o - | FileCheck %s
> +; Created at -02 from:
> +; bool alpha(int);
> +; bool bravo(int charlie) { return (alpha(charlie)); }
> +; static int delta(int charlie) { return charlie + 1; }
> +; __attribute__((nodebug)) bool echo(int foxtrot) {
> +;   return (bravo(delta(foxtrot)));
> +; }
>
>
> Rather than using -O2, I usually try to add alwaysinline attributes to the
> relevant functions to simplify the test (though the need for parameters in
> this test case may make it a bit nice to have it optimized anyway to
> simplify that code)
>
>
> Yes & yes.
>
>
> Also there's some extra () around both the return-of-function call in that
> example text.
>
>
> Removed in 297170.
>
> Any particular reason delta needs to be static?
>
>
> It probably doesn't matter.
>
> & why are delta and bravo required, rather than only one inlined function?
>
>
> I copied and pasted this testcase from PR32042 without attempting to
> reduce it further since the IR already seemed small enough.
>

Please see about reducing it further or documenting in a comment why it
needs the extra layers - it'd be helpful to understand what's being tested.


>
> -- adrian
>
>
>
> +
> +source_filename = "t.c"
> +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
> +target triple = "x86_64-apple-macosx10.12.0"
> +
> +define zeroext i1 @_Z5bravoi(i32 %charlie) local_unnamed_addr #0 !dbg !7 {
> +entry:
> +  tail call void @llvm.dbg.value(metadata i32 %charlie, i64 0, metadata
> !13, metadata !14), !dbg !15
> +  %call = tail call zeroext i1 @_Z5alphai(i32 %charlie), !dbg !16
> +  ret i1 %call, !dbg !17
> +}
> +
> +declare zeroext i1 @_Z5alphai(i32) local_unnamed_addr
> +
> +define zeroext i1 @_Z4echoi(i32 %foxtrot) local_unnamed_addr #0 {
> +entry:
> +; This should not set off the FnArg Verifier. The two variables are in
> differrent scopes.
> +  tail call void @llvm.dbg.value(metadata i32 %foxtrot, i64 0, metadata
> !18, metadata !14), !dbg !23
> +  %add.i = add nsw i32 %foxtrot, 1, !dbg !24
> +  tail call void @llvm.dbg.value(metadata i32 %add.i, i64 0, metadata
> !13, metadata !14), !dbg !15
> +  %call.i = tail call zeroext i1 @_Z5alphai(i32 %add.i), !dbg !16
> +  ret i1 %call.i
> +}
> +
> +; Function Attrs: nounwind readnone
> +declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
> +
> +attributes #0 = { ssp uwtable }
> +attributes #2 = { nounwind readnone }
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!3, !4, !5}
> +!llvm.ident = !{!6}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
> producer: "clang version 5.0.0 (trunk 297153) (llvm/trunk 297155)",
> isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
> +!1 = !DIFile(filename: "t.c", directory: "/tmp")
> +!2 = !{}
> +!3 = !{i32 2, !"Dwarf Version", i32 4}
> +!4 = !{i32 2, !"Debug Info Version", i32 3}
> +!5 = !{i32 1, !"PIC Level", i32 2}
> +!6 = !{!"clang version 5.0.0 (trunk 297153) (llvm/trunk 297155)"}
> +!7 = distinct !DISubprogram(name: "bravo", linkageName: "_Z5bravoi",
> scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true,
> scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0,
> variables: !12)
> +!8 = !DISubroutineType(types: !9)
> +!9 = !{!10, !11}
> +!10 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
> +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
> +!12 = !{!13}
> +; CHECK: !DILocalVariable(name: "charlie", arg: 1
> +!13 = !DILocalVariable(name: "charlie", arg: 1, scope: !7, file: !1,
> line: 2, type: !11)
> +!14 = !DIExpression()
> +!15 = !DILocation(line: 2, column: 16, scope: !7)
> +!16 = !DILocation(line: 2, column: 35, scope: !7)
> +!17 = !DILocation(line: 2, column: 27, scope: !7)
> +; CHECK: !DILocalVariable(name: "charlie", arg: 1
> +!18 = !DILocalVariable(name: "charlie", arg: 1, scope: !19, file: !1,
> line: 3, type: !11)
> +!19 = distinct !DISubprogram(name: "delta", linkageName: "_ZL5deltai",
> scope: !1, file: !1, line: 3, type: !20, isLocal: true, isDefinition: true,
> scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0,
> variables: !22)
> +!20 = !DISubroutineType(types: !21)
> +!21 = !{!11, !11}
> +!22 = !{!18}
> +!23 = !DILocation(line: 3, column: 22, scope: !19)
> +!24 = !DILocation(line: 3, column: 48, scope: !19)
>
>
> _______________________________________________
> 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/20170307/49eb920c/attachment.html>


More information about the llvm-commits mailing list