[PATCH] [lld] Change interface to PassManager

Shankar Easwaran shankare at codeaurora.org
Fri Oct 18 12:26:41 PDT 2013


Ping ?

On 10/17/2013 11:01 PM, Shankar Kalpathi Easwaran wrote:
> Hi kledzik, Bigcheese, rui314,
>
> This changes interface to the PassManager to take File instead of MutableFile.
>
> This is needed to make the ReaderWriterPasses merged into the current design.
>
>
> http://llvm-reviews.chandlerc.com/D1967
>
> Files:
>    include/lld/Core/File.h
>    include/lld/Core/Pass.h
>    include/lld/Core/PassManager.h
>    include/lld/Passes/LayoutPass.h
>    lib/Core/PassManager.cpp
>    lib/Passes/GOTPass.cpp
>    lib/Passes/LayoutPass.cpp
>    lib/Passes/StubsPass.cpp
>    lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
>    lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
>    lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
>    lib/ReaderWriter/PECOFF/IdataPass.h
>
> Index: include/lld/Core/File.h
> ===================================================================
> --- include/lld/Core/File.h
> +++ include/lld/Core/File.h
> @@ -238,6 +238,8 @@
>   
>     virtual const LinkingContext &getLinkingContext() const { return _context; }
>   
> +  static bool classof(const File *) { return true; }
> +
>   protected:
>     /// \brief only subclasses of MutableFile can be instantiated
>     MutableFile(const LinkingContext &ctx, StringRef p)
> Index: include/lld/Core/Pass.h
> ===================================================================
> --- include/lld/Core/Pass.h
> +++ include/lld/Core/Pass.h
> @@ -36,7 +36,7 @@
>     virtual ~Pass() { }
>   
>     /// Do the actual work of the Pass.
> -  virtual void perform(MutableFile &mergedFile) = 0;
> +  virtual void perform(File &mergedFile) = 0;
>   
>   protected:
>     // Only subclassess can be instantiated.
> @@ -53,7 +53,7 @@
>     /// Scans all Atoms looking for call-site uses of SharedLibraryAtoms
>     /// and transfroms the call-site to call a stub instead using the
>     /// helper methods below.
> -  virtual void perform(MutableFile &mergedFile);
> +  virtual void perform(File &mergedFile);
>   
>     /// If true, the pass should use stubs for references
>     /// to shared library symbols. If false, the pass
> @@ -87,7 +87,7 @@
>     /// Scans all Atoms looking for pointer to SharedLibraryAtoms
>     /// and transfroms them to a pointer to a GOT entry using the
>     /// helper methods below.
> -  virtual void perform(MutableFile &mergedFile);
> +  virtual void perform(File &mergedFile);
>   
>     /// If true, the pass will use GOT entries for references
>     /// to shared library symbols. If false, the pass
> Index: include/lld/Core/PassManager.h
> ===================================================================
> --- include/lld/Core/PassManager.h
> +++ include/lld/Core/PassManager.h
> @@ -32,7 +32,7 @@
>       _passes.push_back(std::move(pass));
>     }
>   
> -  ErrorOr<void> runOnFile(MutableFile &);
> +  ErrorOr<void> runOnFile(File &);
>   
>   private:
>     /// \brief Passes in the order they should run.
> Index: include/lld/Passes/LayoutPass.h
> ===================================================================
> --- include/lld/Passes/LayoutPass.h
> +++ include/lld/Passes/LayoutPass.h
> @@ -48,7 +48,7 @@
>     LayoutPass() : Pass(), _compareAtoms(*this) {}
>   
>     /// Sorts atoms in mergedFile by content type then by command line order.
> -  virtual void perform(MutableFile &mergedFile);
> +  virtual void perform(File &mergedFile);
>   
>     virtual ~LayoutPass() {}
>   
> Index: lib/Core/PassManager.cpp
> ===================================================================
> --- lib/Core/PassManager.cpp
> +++ lib/Core/PassManager.cpp
> @@ -15,7 +15,7 @@
>   #include "llvm/Support/ErrorOr.h"
>   
>   namespace lld {
> -ErrorOr<void> PassManager::runOnFile(MutableFile &mf) {
> +ErrorOr<void> PassManager::runOnFile(File &mf) {
>     for (auto &pass : _passes) {
>       pass->perform(mf);
>     }
> Index: lib/Passes/GOTPass.cpp
> ===================================================================
> --- lib/Passes/GOTPass.cpp
> +++ lib/Passes/GOTPass.cpp
> @@ -67,7 +67,7 @@
>   }
>   } // end anonymous namespace
>   
> -void GOTPass::perform(MutableFile &mergedFile) {
> +void GOTPass::perform(File &mergedFile) {
>     // Use map so all pointers to same symbol use same GOT entry.
>     llvm::DenseMap<const Atom*, const DefinedAtom*> targetToGOT;
>   
> @@ -100,9 +100,10 @@
>       }
>     }
>   
> +  MutableFile &mf = *dyn_cast<MutableFile>(&mergedFile);
>     // add all created GOT Atoms to master file
>     for (auto &it : targetToGOT) {
> -    mergedFile.addAtom(*it.second);
> +    mf.addAtom(*it.second);
>     }
>   }
>   }
> Index: lib/Passes/LayoutPass.cpp
> ===================================================================
> --- lib/Passes/LayoutPass.cpp
> +++ lib/Passes/LayoutPass.cpp
> @@ -521,8 +521,11 @@
>   #endif  // #ifndef NDEBUG
>   
>   /// Perform the actual pass
> -void LayoutPass::perform(MutableFile &mergedFile) {
> +void LayoutPass::perform(File &mf) {
>     ScopedTask task(getDefaultDomain(), "LayoutPass");
> +
> +  MutableFile &mergedFile = *dyn_cast<MutableFile>(&mf);
> +
>     MutableFile::DefinedAtomRange atomRange = mergedFile.definedAtoms();
>   
>     // Build follow on tables
> Index: lib/Passes/StubsPass.cpp
> ===================================================================
> --- lib/Passes/StubsPass.cpp
> +++ lib/Passes/StubsPass.cpp
> @@ -23,7 +23,9 @@
>   
>   namespace lld {
>   
> -void StubsPass::perform(MutableFile &mergedFile) {
> +void StubsPass::perform(File &mf) {
> +
> +  MutableFile &mergedFile = *dyn_cast<MutableFile>(&mf);
>     // Skip this pass if output format uses text relocations instead of stubs.
>     if ( ! this->noTextRelocs() )
>       return;
> Index: lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
> ===================================================================
> --- lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
> +++ lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
> @@ -157,7 +157,8 @@
>     ///
>     /// After all references are handled, the atoms created during that are all
>     /// added to mf.
> -  virtual void perform(MutableFile &mf) {
> +  virtual void perform(File &mergedFile) {
> +    MutableFile &mf = *dyn_cast<MutableFile>(&mergedFile);
>       // Process all references.
>       for (const auto &atom : mf.defined())
>         for (const auto &ref : *atom)
> Index: lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
> ===================================================================
> --- lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
> +++ lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
> @@ -219,8 +219,9 @@
>     ///
>     /// After all references are handled, the atoms created during that are all
>     /// added to mf.
> -  virtual void perform(MutableFile &mf) {
> +  virtual void perform(File &mergedFile) {
>       ScopedTask task(getDefaultDomain(), "X86-64 GOT/PLT Pass");
> +    MutableFile &mf = *dyn_cast<MutableFile>(&mergedFile);
>       // Process all references.
>       for (const auto &atom : mf.defined())
>         for (const auto &ref : *atom)
> Index: lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
> ===================================================================
> --- lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
> +++ lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
> @@ -60,7 +60,8 @@
>   public:
>     GroupedSectionsPass() {}
>   
> -  virtual void perform(MutableFile &mergedFile) {
> +  virtual void perform(File &mf) {
> +    MutableFile &mergedFile = *dyn_cast<MutableFile>(&mf);
>       std::map<StringRef, std::vector<COFFDefinedAtom *>> sectionToHeadAtoms(
>           filterHeadAtoms(mergedFile));
>       std::vector<std::vector<COFFDefinedAtom *>> groupedAtomsList(
> Index: lib/ReaderWriter/PECOFF/IdataPass.h
> ===================================================================
> --- lib/ReaderWriter/PECOFF/IdataPass.h
> +++ lib/ReaderWriter/PECOFF/IdataPass.h
> @@ -252,7 +252,8 @@
>   public:
>     IdataPass(const LinkingContext &ctx) : _dummyFile(ctx) {}
>   
> -  virtual void perform(MutableFile &file) {
> +  virtual void perform(File &mf) {
> +    MutableFile &file = *dyn_cast<MutableFile>(&mf);
>       if (file.sharedLibrary().size() == 0)
>         return;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131018/b1ff1e7b/attachment.html>


More information about the llvm-commits mailing list