[all-commits] [llvm/llvm-project] 9f7527: [IR] Add per-function numbers to basic blocks (#10...
Alexis Engelke via All-commits
all-commits at lists.llvm.org
Tue Jul 30 11:25:40 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9f75270ceb3a0a3fb9b97980031a59652b7d5473
https://github.com/llvm/llvm-project/commit/9f75270ceb3a0a3fb9b97980031a59652b7d5473
Author: Alexis Engelke <engelke at in.tum.de>
Date: 2024-07-30 (Tue, 30 Jul 2024)
Changed paths:
M llvm/include/llvm/IR/BasicBlock.h
M llvm/include/llvm/IR/Function.h
M llvm/lib/IR/BasicBlock.cpp
M llvm/lib/IR/Function.cpp
M llvm/unittests/IR/FunctionTest.cpp
Log Message:
-----------
[IR] Add per-function numbers to basic blocks (#101052)
Every basic block that is linked into a function now has a unique
number, which can be queried using getNumber(). Numbers are densely
allocated, but not re-assigned on block removal for stability. Block
numbers are intended to be fairly stable and only be updated when
removing a several basic blocks to make sure the numbering doesn't
become too sparse.
To reduce holes in the numbering, renumberBlocks() can be called to
re-assign numbers in block order.
Additionally, getMaxBlockNumber() returns a value larger than the
largest block number, intended to pre-allocate/resize vectors.
Furthermore, this introduces the concept of a "block number epoch" --
an integer that changes after every renumbering. This is useful for
identifying use of block numbers after renumbering: on initialization,
the current epoch is stored, and on all subsequent accesses, equality
with the current epoch can be asserted.
I added a validate method to catch cases where something goes wrong,
even if I can't really imagine how invalid numbers can occur. But I
think it's better to be safe and rule out this potential source of bugs
when more things depend on the numbering.
Previous discussion in:
https://discourse.llvm.org/t/rfc-add-auxiliary-field-for-per-pass-custom-data-to-basicblock/80229
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