[all-commits] [llvm/llvm-project] f6617d: [DebugInfo] Add num_extra_inhabitants to debug inf...

Augusto Noronha via All-commits all-commits at lists.llvm.org
Wed Nov 6 15:48:26 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f6617d65e496823c748236cdbe8e42bf4c8d8a55
      https://github.com/llvm/llvm-project/commit/f6617d65e496823c748236cdbe8e42bf4c8d8a55
  Author: Augusto Noronha <anoronha at apple.com>
  Date:   2024-11-06 (Wed, 06 Nov 2024)

  Changed paths:
    M llvm/include/llvm/BinaryFormat/Dwarf.def
    M llvm/include/llvm/IR/DIBuilder.h
    M llvm/include/llvm/IR/DebugInfoMetadata.h
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/MetadataLoader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/DIBuilder.cpp
    M llvm/lib/IR/DebugInfoMetadata.cpp
    M llvm/lib/IR/LLVMContextImpl.h
    M llvm/test/Assembler/debug-info.ll
    A llvm/test/DebugInfo/AArch64/num_extra_inhabitants.ll
    M llvm/unittests/IR/DebugTypeODRUniquingTest.cpp
    M llvm/unittests/IR/MetadataTest.cpp

  Log Message:
  -----------
  [DebugInfo] Add num_extra_inhabitants to debug info (#112590)

An extra inhabitant is a bit pattern that does not represent a valid
value for instances of a given type. The number of extra inhabitants is
the number of those bit configurations.

This is used by Swift to save space when composing types. For example,
because Bool only needs 2 bit patterns to represent all of its values
(true and false), an Optional<Bool> only occupies 1 byte in memory by
using a bit configuration that is unused by Bool. Which bit patterns are
unused are part of the ABI of the language.

Since Swift generics are not monomorphized, by using dynamic libraries
you can have generic types whose size, alignment, etc, are known only
at runtime (which is why this feature is needed).

This patch adds num_extra_inhabitants to LLVM-IR debug info and in DWARF
as an Apple extension.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list