[PATCH] Add new debug kind LocTrackingOnly.

David Blaikie dblaikie at gmail.com
Fri Jun 20 11:55:27 PDT 2014


Probably worth wiring up the command line support in the same patch &
including test coverage.

I'd probably start with the LLVM change (using a local Clang change to
generate IR, or just hand-hacking the removal of the llvm.dbg.cu node
in an IR sample) to make sure this strategy is plausible and that just
dropping the llvm.dbg.cu node is all that's required from the
front-end.

Have you tested this through LLVM? How's it look?

On Fri, Jun 20, 2014 at 11:48 AM, Diego Novillo <dnovillo at google.com> wrote:
> Hi echristo, dblaikie,
>
> This new debug emission kind supports emitting line location
> information in all instructions, but stops code generation
> from emitting debug info to the final output.
>
> This mode is useful when the backend wants to track source
> locations during code generation, but it does not want to
> produce debug info. This is currently used by optimization
> remarks (-pass-remarks, -pass-remarks-missed and
> -pass-remarks-analysis).
>
> To prevent debug info emission, DIBuilder never inserts the
> annotation 'llvm.dbg.cu' when LocTrackingOnly is enabled.
>
> http://reviews.llvm.org/D4234
>
> Files:
>   include/llvm/IR/DIBuilder.h
>   lib/IR/DIBuilder.cpp
>
> Index: include/llvm/IR/DIBuilder.h
> ===================================================================
> --- include/llvm/IR/DIBuilder.h
> +++ include/llvm/IR/DIBuilder.h
> @@ -87,7 +87,7 @@
>      public:
>      explicit DIBuilder(Module &M);
>      enum ComplexAddrKind { OpPlus=1, OpDeref };
> -    enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
> +    enum DebugEmissionKind { FullDebug=1, LineTablesOnly, LocTrackingOnly };
>
>      /// finalize - Construct any deferred debug info descriptors.
>      void finalize();
> @@ -108,6 +108,7 @@
>      ///                 Objective-C.
>      /// @param SplitName The name of the file that we'll split debug info out
>      ///                  into.
> +    /// @param Kind     The kind of debug information to generate.
>      DICompileUnit createCompileUnit(unsigned Lang, StringRef File,
>                                      StringRef Dir, StringRef Producer,
>                                      bool isOptimized, StringRef Flags,
> Index: lib/IR/DIBuilder.cpp
> ===================================================================
> --- lib/IR/DIBuilder.cpp
> +++ lib/IR/DIBuilder.cpp
> @@ -140,8 +140,14 @@
>    MDNode *CUNode = MDNode::get(VMContext, Elts);
>
>    // Create a named metadata so that it is easier to find cu in a module.
> -  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
> -  NMD->addOperand(CUNode);
> +  // Note that we only generate this when the caller wants to actually
> +  // emit debug information. When we are only interested in tracking
> +  // source line locations throughout the backend, we prevent codegen from
> +  // emitting debug info in the final output by not generating llvm.dbg.cu.
> +  if (Kind != LocTrackingOnly) {
> +    NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
> +    NMD->addOperand(CUNode);
> +  }
>
>    return DICompileUnit(CUNode);
>  }



More information about the llvm-commits mailing list