uselistorder: Start pulling out -preserve-ll-uselistorder

For consistency, start pulling out `-preserve-ll-uselistorder`.  I'll
drop the global state for both eventually.  This pulls it up to
`Module::print()` (but not past there).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234966 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-15 01:36:30 +00:00
parent 64b905a58d
commit c9d5dea0fe

View File

@ -1942,16 +1942,19 @@ class AssemblyWriter {
TypePrinting TypePrinter; TypePrinting TypePrinter;
AssemblyAnnotationWriter *AnnotationWriter; AssemblyAnnotationWriter *AnnotationWriter;
SetVector<const Comdat *> Comdats; SetVector<const Comdat *> Comdats;
bool ShouldPreserveUseListOrder;
UseListOrderStack UseListOrders; UseListOrderStack UseListOrders;
public: public:
/// Construct an AssemblyWriter with an external SlotTracker /// Construct an AssemblyWriter with an external SlotTracker
AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, const Module *M,
const Module *M, AssemblyAnnotationWriter *AAW); AssemblyAnnotationWriter *AAW,
bool ShouldPreserveUseListOrder = false);
/// Construct an AssemblyWriter with an internally allocated SlotTracker /// Construct an AssemblyWriter with an internally allocated SlotTracker
AssemblyWriter(formatted_raw_ostream &o, const Module *M, AssemblyWriter(formatted_raw_ostream &o, const Module *M,
AssemblyAnnotationWriter *AAW); AssemblyAnnotationWriter *AAW,
bool ShouldPreserveUseListOrder = false);
void printMDNodeBody(const MDNode *MD); void printMDNodeBody(const MDNode *MD);
void printNamedMDNode(const NamedMDNode *NMD); void printNamedMDNode(const NamedMDNode *NMD);
@ -2003,18 +2006,20 @@ void AssemblyWriter::init() {
Comdats.insert(C); Comdats.insert(C);
} }
AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
const Module *M, const Module *M, AssemblyAnnotationWriter *AAW,
AssemblyAnnotationWriter *AAW) bool ShouldPreserveUseListOrder)
: Out(o), TheModule(M), Machine(Mac), AnnotationWriter(AAW) { : Out(o), TheModule(M), Machine(Mac), AnnotationWriter(AAW),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
init(); init();
} }
AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, const Module *M, AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, const Module *M,
AssemblyAnnotationWriter *AAW) AssemblyAnnotationWriter *AAW,
: Out(o), TheModule(M), ModuleSlotTracker(createSlotTracker(M)), bool ShouldPreserveUseListOrder)
Machine(*ModuleSlotTracker), AnnotationWriter(AAW) { : Out(o), TheModule(M), ModuleSlotTracker(createSlotTracker(M)),
Machine(*ModuleSlotTracker), AnnotationWriter(AAW),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
init(); init();
} }
@ -2102,7 +2107,7 @@ void AssemblyWriter::writeParamOperand(const Value *Operand,
void AssemblyWriter::printModule(const Module *M) { void AssemblyWriter::printModule(const Module *M) {
Machine.initialize(); Machine.initialize();
if (shouldPreserveAssemblyUseListOrder()) if (ShouldPreserveUseListOrder)
UseListOrders = predictUseListOrder(M); UseListOrders = predictUseListOrder(M);
if (!M->getModuleIdentifier().empty() && if (!M->getModuleIdentifier().empty() &&
@ -3069,7 +3074,8 @@ void Function::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
void Module::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const { void Module::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
SlotTracker SlotTable(this); SlotTracker SlotTable(this);
formatted_raw_ostream OS(ROS); formatted_raw_ostream OS(ROS);
AssemblyWriter W(OS, SlotTable, this, AAW); AssemblyWriter W(OS, SlotTable, this, AAW,
shouldPreserveAssemblyUseListOrder());
W.printModule(this); W.printModule(this);
} }