[PATCH] D14687: Macro support in LLVM IR

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 20:10:20 PST 2015


> On 2015-Nov-19, at 07:25, Amjad Aboud <amjad.aboud at intel.com> wrote:
> 
> aaboud updated this revision to Diff 40644.
> aaboud added a comment.
> 
> This new patch contains the following modifications:
> 
> 1. Name change: "MacroNode" -> "DIMacroNode"
> 2. Added documentation for "DIMacro" and "DIMacroFile" to LangRef.
> 
> Note: I did not document "DIMacroNode" in the LangRef as it is not part of the LLVM IR textual representation, similar to "DINode" that is not mentioned either in the LangRef document.
> 
> 
> Repository:
>  rL LLVM
> 
> http://reviews.llvm.org/D14687
> 
> Files:
>  docs/LangRef.rst
>  include/llvm/Bitcode/LLVMBitCodes.h
>  include/llvm/IR/DebugInfoMetadata.h
>  include/llvm/IR/Metadata.def
>  include/llvm/IR/Metadata.h
>  include/llvm/Support/Dwarf.h
>  lib/AsmParser/LLLexer.cpp
>  lib/AsmParser/LLParser.cpp
>  lib/AsmParser/LLToken.h
>  lib/Bitcode/Reader/BitcodeReader.cpp
>  lib/Bitcode/Writer/BitcodeWriter.cpp
>  lib/IR/AsmWriter.cpp
>  lib/IR/DIBuilder.cpp
>  lib/IR/DebugInfoMetadata.cpp
>  lib/IR/LLVMContextImpl.h
>  lib/IR/Verifier.cpp
>  lib/Support/Dwarf.cpp
>  test/Assembler/debug-info.ll
>  test/Assembler/dicompileunit.ll
>  unittests/IR/MetadataTest.cpp
> 
> <D14687.40644.patch>

A couple of nitpicks from me.  IR changes LGTM once you fix those (I'll
leave the direction, etc., to the DWARF experts).

> Index: docs/LangRef.rst
> ===================================================================
> --- docs/LangRef.rst
> +++ docs/LangRef.rst
> @@ -3690,18 +3690,18 @@
>  """""""""""""

I assume these line endings are an artifact of the diff, and won't be
committed?

>  
>  ``DICompileUnit`` nodes represent a compile unit. The ``enums:``,
> -``retainedTypes:``, ``subprograms:``, ``globals:`` and ``imports:`` fields are
> -tuples containing the debug info to be emitted along with the compile unit,
> -regardless of code optimizations (some nodes are only emitted if there are
> +``retainedTypes:``, ``subprograms:``, ``globals:``, ``imports:`` and ``macros:``
> +fields are tuples containing the debug info to be emitted along with the compile
> +unit, regardless of code optimizations (some nodes are only emitted if there are
>  references to them from instructions).
>  
>  .. code-block:: llvm
>  
>      !0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang",
>                          isOptimized: true, flags: "-O2", runtimeVersion: 2,
>                          splitDebugFilename: "abc.debug", emissionKind: 1,
>                          enums: !2, retainedTypes: !3, subprograms: !4,
> -                        globals: !5, imports: !6)
> +                        globals: !5, imports: !6, dwoId: 0x0abcd, macros: !7)

The canonical place for `macros:` should really be *before* `dwoId`.
It's one of the set of arrays.  Same probably makes sense for the C++
APIs.  The most important thing is LangRef and AsmWriter.  Please move
it!

>  ^M
>  Compile unit descriptors provide the root scope for objects declared in a
>  specific compilation unit. File descriptors are defined using this scope.
> @@ -4067,6 +4067,32 @@
>     !2 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0,
>                            entity: !1, line: 7)
>  
> +DIMacro
> +"""""""
> +
> +``DIMacro`` nodes represent definition or undefinition of a macro identifiers.
> +The ``name:`` field is the macro identifier, followed by macro parameters when
> +definining a function-like macro, and the ``value`` field is the token-string
> +used to expand the macro identifier.
> +
> +.. code-block:: llvm
> +
> +   !2 = !DIMacro(macinfo: DW_MACINFO_define, line: 7, name: "foo(x)",
> +                 value: "((x) + 1)")
> +   !3 = !DIMacro(macinfo: DW_MACINFO_undef, line: 30, name: "foo")
> +
> +DIMacroFile
> +"""""""""""
> +
> +``DIMacroFile`` nodes represent inclusion of source files.
> +The ``nodes:`` field is a list of ``DIMacro`` and ``DIMacroFile`` nodes that
> +appear in the included source file.
> +
> +.. code-block:: llvm
> +
> +   !2 = !DIMacroFile(macinfo: DW_MACINFO_start_file, line: 7, file: !2,
> +                     nodes: !3)
> +
>  '``tbaa``' Metadata
>  ^^^^^^^^^^^^^^^^^^^
>  
> 



More information about the llvm-commits mailing list