[MachineInstrBuilder] Introduce MIMetadata to simplify metadata propagation
authorMarco Elver <elver@google.com>
Tue, 6 Sep 2022 13:49:08 +0000 (15:49 +0200)
committerMarco Elver <elver@google.com>
Wed, 7 Sep 2022 09:22:50 +0000 (11:22 +0200)
commitda695de628d6507924f49b8088c812eeb908b2ee
treeecf86bb53f143cf40e99e302d855f833a78c9910
parent4c58b00801add008e1f2bd0774d9a0d7297c3f93
[MachineInstrBuilder] Introduce MIMetadata to simplify metadata propagation

In many places DebugLoc and PCSections metadata are just copied along to
propagate them through MachineInstrs. Simplify doing so by bundling them
up in a MIMetadata class that replaces the DebugLoc argument to most
BuildMI() variants.

The DebugLoc-only constructors allow implicit construction, so that
existing usage of `BuildMI(.., DL, ..)` works as before, and the rest of
the codebase using BuildMI() does not require changes.

NFC.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130883
llvm/include/llvm/CodeGen/MachineInstrBuilder.h
llvm/unittests/CodeGen/MachineInstrTest.cpp