[all-commits] [llvm/llvm-project] 9997e0: [RemoveDIs] Update DIBuilder to conditionally inse...

Orlando Cazalet-Hyams via All-commits all-commits at lists.llvm.org
Tue Mar 12 03:26:20 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9997e0397156ff7e01aecbd17bdeb7bfe5fb15b0
      https://github.com/llvm/llvm-project/commit/9997e0397156ff7e01aecbd17bdeb7bfe5fb15b0
  Author: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
  Date:   2024-03-12 (Tue, 12 Mar 2024)

  Changed paths:
    M llvm/include/llvm/IR/DIBuilder.h
    M llvm/lib/IR/BasicBlock.cpp
    M llvm/lib/IR/DIBuilder.cpp
    M llvm/lib/IR/DebugInfo.cpp
    M llvm/lib/IR/Instruction.cpp
    M llvm/lib/Transforms/Scalar/SROA.cpp
    M llvm/lib/Transforms/Utils/Local.cpp
    M llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
    M llvm/unittests/IR/IRBuilderTest.cpp

  Log Message:
  -----------
  [RemoveDIs] Update DIBuilder to conditionally insert DbgRecords (#84739)

Have DIBuilder conditionally insert either debug intrinsics or DbgRecord
depending on the module's IsNewDbgInfoFormat flag. The insertion methods
now return a `DbgInstPtr` (a `PointerUnion<Instruction *, DbgRecord
*>`).

Add a unittest for both modes (I couldn't find an existing test testing
insertion behaviours specifically).

This patch changes the existing assumption that DbgRecords are only ever
inserted if there's an instruction to insert-before because clang
currently inserts debug intrinsics while CodeGening (like any other
instruction) meaning it'll try inserting to the end of a block without a
terminator. We already have machinery in place to maintain the
DbgRecords when a terminator is removed - these become "trailing
DbgRecords" which are re-attached when a new instruction is inserted.
All I've done is allow this state to occur while inserting DbgRecords
too, i.e., it's not only removing terminators that causes this valid
transient state, but inserting DbgRecords into incomplete blocks too.

The C API will be updated in follow up patches.

---

Note: this doesn't mean clang is emitting DbgRecords yet, because the
modules it creates are still always in the old debug mode. That will
come in a future patch.



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