[all-commits] [llvm/llvm-project] d65bf7: IR: Remove uselist for constantdata

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


  Branch: refs/heads/users/arsenm/ir/remove-uselist-for-constantdata
  Home:   https://github.com/llvm/llvm-project
  Commit: d65bf74380dd1efddd14c4d3e281ae926215fe62
      https://github.com/llvm/llvm-project/commit/d65bf74380dd1efddd14c4d3e281ae926215fe62
  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/Analysis/TypeMetadataUtils.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/CodeGenPrepare.cpp
    M llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/Instruction.cpp
    M llvm/lib/IR/Use.cpp
    M llvm/lib/IR/Value.cpp
    M llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
    M llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/lib/Transforms/Scalar/Reassociate.cpp
    M llvm/test/Analysis/MemorySSA/nondeterminism.ll
    A llvm/test/tools/llvm-diff/uselistorder-issue58629-gv.ll
    M llvm/test/tools/llvm-diff/uselistorder-issue58629.ll
    M llvm/test/tools/llvm-reduce/bitcode-uselistorder.ll
    M llvm/test/tools/llvm-reduce/uselistorder-invalid-ir-output.ll
    M llvm/tools/verify-uselistorder/verify-uselistorder.cpp
    M polly/lib/Support/ScopHelper.cpp

  Log Message:
  -----------
  IR: Remove uselist for constantdata

This is a resurrected version of the patch attached to this RFC:

https://discourse.llvm.org/t/rfc-constantdata-should-not-have-use-lists/42606

In this adaptation, there are a few differences. In the original patch, the Use's
use list was replaced with an unsigned* to the reference count in the value. This
version leaves them as null and leaves the ref counting only in Value.

Remove use-lists from instances of ConstantData (which are shared
across modules and have no operands).

To continue supporting most of the use-list API, store a ref-count in
place of the use-list; this is for API like Value::use_empty and
Value::hasNUses.  Operations that actually need the use-list -- like
Value::use_begin -- will assert.

This change has three benefits:

 1. The compiler output cannot in any way depend on the use-list order
    of instances of ConstantData.

 2. There's no use-list traffic when adding and removing simple
    constants from operand lists (although there is ref-count traffic;
    YMMV).

 3. It's cheaper to serialize use-lists (since we're no longer
    serializing the use-list order of things like i32 0).

The downside is that you can't look at all the users of ConstantData,
but traversals of users of i32 0 are already ill-advised.

Possible follow-ups:
  - Track if an instance of a ConstantVector/ConstantArray/etc. is known
    to have all ConstantData arguments, and drop the use-lists to
    ref-counts in those cases.  Callers need to check Value::hasUseList
    before iterating through the use-list.
  - Remove even the ref-counts.  I'm not sure they have any benefit
    besides minimizing the scope of this commit, and maintaining the
    counts is not free.

Fixes #58629


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

  Changed paths:
    M llvm/tools/verify-uselistorder/verify-uselistorder.cpp

  Log Message:
  -----------
  Use hasUseList instead of isa<ConstantData>


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

  Changed paths:
    M llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

  Log Message:
  -----------
  SPIRV: Try to fix validation errors


Compare: https://github.com/llvm/llvm-project/compare/510129118a63...fc8ab4cd2862

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