This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Merge duplicated Thumb2SizeReduce code (NFC)
AbandonedPublic

Authored by ksyx on Jun 4 2022, 1:14 PM.

Details

Reviewers
efriedma
Summary

Merge duplicated code into procedure for code cleanness and readability and use llvm::dbgs() instead of errs() for consistency with other parts.

Diff Detail

Event Timeline

ksyx created this revision.Jun 4 2022, 1:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2022, 1:14 PM
ksyx requested review of this revision.Jun 4 2022, 1:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2022, 1:14 PM
ksyx updated this revision to Diff 434288.Jun 4 2022, 2:35 PM

Apply suggestions from clangfmt

I don't think the setMIFlags() call belongs in the helper; it's technically duplicated across all the functions, but it's conceptually part of creating an equivalent instruction, and the steps for that are different in each place.

I don't think refactoring the debug counter increment is helpful; counters aren't normally passed around that way, so it's a bit confusing to follow.

At that point, the helper is basically three lines, so I'm not sure the refactoring is worthwhile. Maybe if you wanted to add something else to the refactored function, but I'm not sure what that would be.

llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
413

"llvm::" prefix isn't necessary; this file is "using namespace llvm".

ksyx added a comment.Jun 6 2022, 11:46 AM

Thanks for the review and it sounds a good rationale. I am also wondering whether only changing errs to dbgs on the original code without changing other parts or using helper function a good change for consistency with other code?

Yes, we should do that for consistency.

ksyx abandoned this revision.Jun 6 2022, 12:11 PM

Ok then I would only do that.