-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[InstrRef][nfc] Remove usage of unique_ptrs of arrays #74203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,11 +205,11 @@ namespace LiveDebugValues { | |
using namespace llvm; | ||
|
||
/// Type for a table of values in a block. | ||
using ValueTable = std::unique_ptr<ValueIDNum[]>; | ||
using ValueTable = SmallVector<ValueIDNum, 0>; | ||
|
||
/// Type for a table-of-table-of-values, i.e., the collection of either | ||
/// live-in or live-out values for each block in the function. | ||
using FuncValueTable = std::unique_ptr<ValueTable[]>; | ||
using FuncValueTable = SmallVector<ValueTable, 0>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (personally, I find code easier to read when it doesn't obscure these outer templates like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM! |
||
|
||
/// Thin wrapper around an integer -- designed to give more type safety to | ||
/// spill location numbers. | ||
|
@@ -1200,21 +1200,21 @@ class InstrRefBasedLDV : public LDVImpl { | |
/// exists, otherwise returns std::nullopt. | ||
std::optional<ValueIDNum> getValueForInstrRef(unsigned InstNo, unsigned OpNo, | ||
MachineInstr &MI, | ||
const ValueTable *MLiveOuts, | ||
const ValueTable *MLiveIns); | ||
const FuncValueTable *MLiveOuts, | ||
const FuncValueTable *MLiveIns); | ||
dwblaikie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Observe a single instruction while stepping through a block. | ||
void process(MachineInstr &MI, const ValueTable *MLiveOuts, | ||
const ValueTable *MLiveIns); | ||
void process(MachineInstr &MI, const FuncValueTable *MLiveOuts, | ||
const FuncValueTable *MLiveIns); | ||
|
||
/// Examines whether \p MI is a DBG_VALUE and notifies trackers. | ||
/// \returns true if MI was recognized and processed. | ||
bool transferDebugValue(const MachineInstr &MI); | ||
|
||
/// Examines whether \p MI is a DBG_INSTR_REF and notifies trackers. | ||
/// \returns true if MI was recognized and processed. | ||
bool transferDebugInstrRef(MachineInstr &MI, const ValueTable *MLiveOuts, | ||
const ValueTable *MLiveIns); | ||
bool transferDebugInstrRef(MachineInstr &MI, const FuncValueTable *MLiveOuts, | ||
const FuncValueTable *MLiveIns); | ||
|
||
/// Stores value-information about where this PHI occurred, and what | ||
/// instruction number is associated with it. | ||
|
@@ -1246,14 +1246,14 @@ class InstrRefBasedLDV : public LDVImpl { | |
/// \p InstrNum Debug instruction number defined by DBG_PHI instructions. | ||
/// \returns The machine value number at position Here, or std::nullopt. | ||
std::optional<ValueIDNum> resolveDbgPHIs(MachineFunction &MF, | ||
const ValueTable *MLiveOuts, | ||
const ValueTable *MLiveIns, | ||
const FuncValueTable &MLiveOuts, | ||
const FuncValueTable &MLiveIns, | ||
MachineInstr &Here, | ||
uint64_t InstrNum); | ||
|
||
std::optional<ValueIDNum> resolveDbgPHIsImpl(MachineFunction &MF, | ||
const ValueTable *MLiveOuts, | ||
const ValueTable *MLiveIns, | ||
const FuncValueTable &MLiveOuts, | ||
const FuncValueTable &MLiveIns, | ||
MachineInstr &Here, | ||
uint64_t InstrNum); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My recollection of this (which may be faulty) is that blocks should only get ejected once, in the order determined just above this block (it reduces the working-set size during compilation). If the added code fires I'd suggest there's a bug somewhere else, is there a reproducer for that? I'd imagine it'd only reduce performance a bit.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale for this code is because I removed the check on line 3596 of the "green" side of the diff.
I.e., before:
After:
Prior to this change, we were testing whether something had been ejected by querying whether we had called "reset" on the unique pointer. There are no unique pointers anymore, and checking for whether the length of the vector is 0 not the equivalent, so the only solution was to add this set.
So, with this mind, the patch is 100% intended to be NFC. Do you agree with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, I see the rationale. I'm struggling to remember where that came from -- I thought it should be the case that the set of ArtificialBlocks and the set of blocks produced by
makeDepthFirstEjectionMap
shouldn't overlap anyway because the artificial blocks shouldn't be in any lexical scopes? But maybe they can, as LexicalScopes only stores a start/end block-number pair.Either way, I'm not confident enough to say the is-null test isn't double-ejection prevention so it should be kept. For performance, could you use a
SmallDenseMap
instead of SmallPtrSet with a call toreserve
as we'll know the maximum number of blocks that might get inserted. That limits the worst-case map-growth to a single allocation while providing a local scratchpad for small functions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there may be some miscommunication going here: the check is kept, it just takes a different form.
I moved it inside the lambda, and instead of checking for a nullptr (pointers don't exist anymore, so we can't check that), I am using an "has been ejected" check.
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes perfect sense and you're correct; I'm just second-guessing whether the check had a different purpose, or was something I'd gratuitously added in the past without reason.