aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorScott Linder <Scott.Linder@amd.com>2023-07-18 19:22:48 +0000
committerScott Linder <Scott.Linder@amd.com>2023-09-11 17:31:59 +0000
commit58c108cde70bd6f2c39f9d57200c959090fd861a (patch)
tree0bc9b8b2072e3ef7ce33d338eb8c0fff2a0c6ae4 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parent093aa37744462971a71dafba4fe308a5929f26a0 (diff)
downloadllvm-58c108cde70bd6f2c39f9d57200c959090fd861a.zip
llvm-58c108cde70bd6f2c39f9d57200c959090fd861a.tar.gz
llvm-58c108cde70bd6f2c39f9d57200c959090fd861a.tar.bz2
[NFC][AsmPrinter] Refactor DbgVariable as a std::variant
Only a subset of the fields of DbgVariable are meaningful at any time, and some fields are re-used for multiple purposes (for example FrameIndexExprs is used with a throw-away frame-index of 0 to hold a single DIExpression without needing to add another member). The exact invariants must be reverse-engineered by inspecting the actual use of the class, its imprecise/outdated doc-comment, and some asserts. Refactor DbgVariable into a sum type by inheriting from std::variant. This makes the active fields for any given state explicit and removes the need to re-use fields in disparate contexts. As a bonus, it seems to reduce the size on my x86_64 linux box from 144 bytes to 96 bytes. There is some potential cost to `std::get` as it must check the active alternative even when context or an assert obviates it. To try to help ensure the compiler can optimize out the checks the patch also adds a helper `get` method which uses the noexcept `std::get_if`. Some of the extra cost would also be avoided more cleanly with a refactor that exposes the alternative types in the public interface, which will come in another patch. Differential Revision: https://reviews.llvm.org/D158675
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
0 files changed, 0 insertions, 0 deletions