diff --git a/llvm/include/llvm/CodeGen/GCMetadataPrinter.h b/llvm/include/llvm/CodeGen/GCMetadataPrinter.h index 4a6b5ac19c36..47f3aff2da66 100644 --- a/llvm/include/llvm/CodeGen/GCMetadataPrinter.h +++ b/llvm/include/llvm/CodeGen/GCMetadataPrinter.h @@ -55,16 +55,14 @@ namespace llvm { public: GCStrategy &getStrategy() { return *S; } - const Module &getModule() const { return S->getModule(); } /// begin/end - Iterate over the collected function metadata. iterator begin() { return S->begin(); } iterator end() { return S->end(); } /// beginAssembly/finishAssembly - Emit module metadata as assembly code. - virtual void beginAssembly(AsmPrinter &AP); - - virtual void finishAssembly(AsmPrinter &AP); + virtual void beginAssembly(Module &M, AsmPrinter &AP); + virtual void finishAssembly(Module &M, AsmPrinter &AP); virtual ~GCMetadataPrinter(); }; diff --git a/llvm/include/llvm/CodeGen/GCStrategy.h b/llvm/include/llvm/CodeGen/GCStrategy.h index 81e1f85286e1..fa6c6f5d275e 100644 --- a/llvm/include/llvm/CodeGen/GCStrategy.h +++ b/llvm/include/llvm/CodeGen/GCStrategy.h @@ -59,7 +59,6 @@ namespace llvm { private: friend class GCModuleInfo; - const Module *M; std::string Name; list_type Functions; @@ -84,10 +83,6 @@ namespace llvm { /// const std::string &getName() const { return Name; } - /// getModule - The module within which the GC strategy is operating. - /// - const Module &getModule() const { return *M; } - /// needsSafePoitns - True if safe points of any kind are required. By // default, none are recorded. bool needsSafePoints() const { diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 727bdbda31d0..9d5b78a8cf58 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -210,7 +210,7 @@ bool AsmPrinter::doInitialization(Module &M) { assert(MI && "AsmPrinter didn't require GCModuleInfo?"); for (auto &I : *MI) if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(*I)) - MP->beginAssembly(*this); + MP->beginAssembly(M, *this); // Emit module-level inline asm if it exists. if (!M.getModuleInlineAsm().empty()) { @@ -985,7 +985,7 @@ bool AsmPrinter::doFinalization(Module &M) { assert(MI && "AsmPrinter didn't require GCModuleInfo?"); for (GCModuleInfo::iterator I = MI->end(), E = MI->begin(); I != E; ) if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(**--I)) - MP->finishAssembly(*this); + MP->finishAssembly(M, *this); // Emit llvm.ident metadata in an '.ident' directive. EmitModuleIdents(M); diff --git a/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp index 5bda5a95fef2..a1e9c4c358c9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp @@ -36,8 +36,8 @@ namespace { class ErlangGCPrinter : public GCMetadataPrinter { public: - void beginAssembly(AsmPrinter &AP) override; - void finishAssembly(AsmPrinter &AP) override; + void beginAssembly(Module &M, AsmPrinter &AP) override; + void finishAssembly(Module &M, AsmPrinter &AP) override; }; } @@ -47,9 +47,9 @@ X("erlang", "erlang-compatible garbage collector"); void llvm::linkErlangGCPrinter() { } -void ErlangGCPrinter::beginAssembly(AsmPrinter &AP) { } +void ErlangGCPrinter::beginAssembly(Module &M, AsmPrinter &AP) { } -void ErlangGCPrinter::finishAssembly(AsmPrinter &AP) { +void ErlangGCPrinter::finishAssembly(Module &M, AsmPrinter &AP) { MCStreamer &OS = AP.OutStreamer; unsigned IntPtrSize = AP.TM.getSubtargetImpl()->getDataLayout()->getPointerSize(); diff --git a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp index 6480d04808a9..850419c9ee44 100644 --- a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp @@ -34,8 +34,8 @@ namespace { class OcamlGCMetadataPrinter : public GCMetadataPrinter { public: - void beginAssembly(AsmPrinter &AP) override; - void finishAssembly(AsmPrinter &AP) override; + void beginAssembly(Module &M, AsmPrinter &AP) override; + void finishAssembly(Module &M, AsmPrinter &AP) override; }; } @@ -67,12 +67,12 @@ static void EmitCamlGlobal(const Module &M, AsmPrinter &AP, const char *Id) { AP.OutStreamer.EmitLabel(Sym); } -void OcamlGCMetadataPrinter::beginAssembly(AsmPrinter &AP) { +void OcamlGCMetadataPrinter::beginAssembly(Module &M, AsmPrinter &AP) { AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection()); - EmitCamlGlobal(getModule(), AP, "code_begin"); + EmitCamlGlobal(M, AP, "code_begin"); AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); - EmitCamlGlobal(getModule(), AP, "data_begin"); + EmitCamlGlobal(M, AP, "data_begin"); } /// emitAssembly - Print the frametable. The ocaml frametable format is thus: @@ -91,21 +91,21 @@ void OcamlGCMetadataPrinter::beginAssembly(AsmPrinter &AP) { /// (FrameSize and LiveOffsets would overflow). FrameTablePrinter will abort if /// either condition is detected in a function which uses the GC. /// -void OcamlGCMetadataPrinter::finishAssembly(AsmPrinter &AP) { +void OcamlGCMetadataPrinter::finishAssembly(Module &M, AsmPrinter &AP) { unsigned IntPtrSize = AP.TM.getSubtargetImpl()->getDataLayout()->getPointerSize(); AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection()); - EmitCamlGlobal(getModule(), AP, "code_end"); + EmitCamlGlobal(M, AP, "code_end"); AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); - EmitCamlGlobal(getModule(), AP, "data_end"); + EmitCamlGlobal(M, AP, "data_end"); // FIXME: Why does ocaml emit this?? AP.OutStreamer.EmitIntValue(0, IntPtrSize); AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); - EmitCamlGlobal(getModule(), AP, "frametable"); + EmitCamlGlobal(M, AP, "frametable"); int NumDescriptors = 0; for (iterator I = begin(), IE = end(); I != IE; ++I) { diff --git a/llvm/lib/CodeGen/GCMetadata.cpp b/llvm/lib/CodeGen/GCMetadata.cpp index ed40982d4513..5b03d6bb5db8 100644 --- a/llvm/lib/CodeGen/GCMetadata.cpp +++ b/llvm/lib/CodeGen/GCMetadata.cpp @@ -71,7 +71,6 @@ GCStrategy *GCModuleInfo::getOrCreateStrategy(const Module *M, E = GCRegistry::end(); I != E; ++I) { if (Name == I->getName()) { std::unique_ptr S = I->instantiate(); - S->M = M; S->Name = Name; StrategyMap[Name] = S.get(); StrategyList.push_back(std::move(S)); diff --git a/llvm/lib/CodeGen/GCMetadataPrinter.cpp b/llvm/lib/CodeGen/GCMetadataPrinter.cpp index f80e9ced0bc9..ad238cceec07 100644 --- a/llvm/lib/CodeGen/GCMetadataPrinter.cpp +++ b/llvm/lib/CodeGen/GCMetadataPrinter.cpp @@ -18,10 +18,10 @@ GCMetadataPrinter::GCMetadataPrinter() { } GCMetadataPrinter::~GCMetadataPrinter() { } -void GCMetadataPrinter::beginAssembly(AsmPrinter &AP) { +void GCMetadataPrinter::beginAssembly(Module &M, AsmPrinter &AP) { // Default is no action. } -void GCMetadataPrinter::finishAssembly(AsmPrinter &AP) { +void GCMetadataPrinter::finishAssembly(Module &M, AsmPrinter &AP) { // Default is no action. }