[all-commits] [llvm/llvm-project] 664910: IR: Remove reference counts from ConstantData

Matt Arsenault via All-commits all-commits at lists.llvm.org
Tue May 6 08:21:13 PDT 2025


  Branch: refs/heads/users/arsenm/ir/remove-constantdata-reference-counts
  Home:   https://github.com/llvm/llvm-project
  Commit: 664910b5c8fae23e3b5f0fcc0a6e69a10d242862
      https://github.com/llvm/llvm-project/commit/664910b5c8fae23e3b5f0fcc0a6e69a10d242862
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2025-05-06 (Tue, 06 May 2025)

  Changed paths:
    M llvm/docs/ReleaseNotes.md
    M llvm/include/llvm/IR/Constants.h
    M llvm/include/llvm/IR/Use.h
    M llvm/include/llvm/IR/Value.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/Instruction.cpp
    M llvm/lib/IR/Value.cpp
    M llvm/unittests/IR/ConstantsTest.cpp

  Log Message:
  -----------
  IR: Remove reference counts from ConstantData

This is a follow up change to eliminating uselists for ConstantData.
In the previous revision, ConstantData had a replacement reference count
instead of a uselist. This reference count was misleading, and not useful
in the same way as it would be for another value. The references may not
have even been in the current module, since these are shared throughout
the LLVMContext.

This doesn't space leak any more than we previously did; nothing was
attempting to garbage collect unused constants.

Previously the use_empty, and hasNUses type of APIs were supported through
the reference count. These now behave as if the uses are always empty.
Ideally it would be illegal to inspect these, but this forces API complexity
into quite a few places. It may be doable to make it illegal to check these
counts, but I would like there to be a targeted fuzzing effort to make sure
every transform properly deals with a constant in every operand position.

All tests pass if I turn the hasNUses* and getNumUses queries into assertions,
only hasOneUse in particular appears to hit in some set of contexts. I've
added unit tests to ensure logical consistency between these cases


  Commit: 6e8990ea20b397951c960fc3ca1104ddfe079c47
      https://github.com/llvm/llvm-project/commit/6e8990ea20b397951c960fc3ca1104ddfe079c47
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2025-05-06 (Tue, 06 May 2025)

  Changed paths:
    M llvm/lib/IR/Value.cpp
    M llvm/unittests/IR/ConstantsTest.cpp

  Log Message:
  -----------
  make hasNUses(0) equivalent to use_empty for constants


  Commit: 1105d7c122c49840b6908bab06a9974129cb17d8
      https://github.com/llvm/llvm-project/commit/1105d7c122c49840b6908bab06a9974129cb17d8
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2025-05-06 (Tue, 06 May 2025)

  Changed paths:
    M llvm/include/llvm/IR/Use.h
    M llvm/include/llvm/IR/Value.h

  Log Message:
  -----------
  Move addToList/removeFromList back to Use.h


Compare: https://github.com/llvm/llvm-project/compare/a029e7657414...1105d7c122c4

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