This is an archive of the discontinued LLVM Phabricator instance.

[IR]PATCH 1/2: Add AsmWriterContext into AsmWriter
ClosedPublic

Authored by myhsu on Sep 20 2021, 4:25 PM.

Details

Summary

AsmWriterContext is a simple compound that stores TypePrinting, SlotTracker (i.e. "Machine" in AsmWriter), and Module instances -- three of the most commonly used objects in the AsmWriter infrastructure. Previously these three objects are passed as separate function arguments to most of the printer functions in this file. Tidying them up can bring easier code refactoring on printer functions in the future (e.g. when we want to pass additional objects to all printer functions).

This patch is used to prepare the next patch (D110113) in this series, which tries to print MDNode in tree shape.

NOTE: Theoretically, this patch should be NFC.

Diff Detail

Event Timeline

myhsu created this revision.Sep 20 2021, 4:25 PM
myhsu requested review of this revision.Sep 20 2021, 4:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 20 2021, 4:25 PM
myhsu edited the summary of this revision. (Show Details)Sep 20 2021, 4:30 PM

Seems reasonable.

llvm/lib/IR/AsmWriter.cpp
1282

Can you add a Doxygen comment?

1284

= nullptr; ?

myhsu updated this revision to Diff 375409.Sep 27 2021, 2:39 PM
  • Add doxygen comments on AsmWriterContext
  • Initialized some fields in AsmWriterContext to nullptr
myhsu marked 2 inline comments as done.Sep 27 2021, 2:43 PM
aprantl accepted this revision.Oct 1 2021, 1:54 PM
aprantl added inline comments.
llvm/lib/IR/AsmWriter.cpp
1283

does this fit on one line?

This revision is now accepted and ready to land.Oct 1 2021, 1:54 PM
myhsu updated this revision to Diff 376734.Oct 2 2021, 9:18 PM
myhsu marked an inline comment as done.

Minor formatting updates.

This revision was automatically updated to reflect the committed changes.