diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-01-09 05:10:20 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-01-09 05:10:20 +0000 |
commit | 76a4b95ad84a0fd23e34982cfb1b40b39ca2fb4d (patch) | |
tree | e8a835776bcfe4c3678cd88271c70ec38c02c0aa /clang/lib/CodeGen/BackendUtil.cpp | |
parent | 7e87384592c45532d794ebf252fd5afe506427db (diff) | |
download | bcm5719-llvm-76a4b95ad84a0fd23e34982cfb1b40b39ca2fb4d.tar.gz bcm5719-llvm-76a4b95ad84a0fd23e34982cfb1b40b39ca2fb4d.zip |
Driver: begin threading frontend support for SymbolRewriter
Allow blessed access to the symbol rewriter from the driver. Although the
symbol rewriter could be invoked through tools like opt and llc, it would not
accessible from the frontend. This allows us to read the rewrite map files in
the frontend rather than the backend and enable symbol rewriting for actually
performing the symbol interpositioning.
llvm-svn: 225504
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 54215743f8a..e1267192a74 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -39,6 +39,7 @@ #include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/SymbolRewriter.h" #include <memory> using namespace clang; using namespace llvm; @@ -234,6 +235,17 @@ static TargetLibraryInfo *createTLI(llvm::Triple &TargetTriple, return TLI; } +static void addSymbolRewriterPass(const CodeGenOptions &Opts, + PassManager *MPM) { + llvm::SymbolRewriter::RewriteDescriptorList DL; + + llvm::SymbolRewriter::RewriteMapParser MapParser; + for (const auto &MapFile : Opts.RewriteMapFiles) + MapParser.parse(MapFile, &DL); + + MPM->add(createRewriteSymbolsPass(DL)); +} + void EmitAssemblyHelper::CreatePasses() { unsigned OptLevel = CodeGenOpts.OptimizationLevel; CodeGenOptions::InliningMethod Inlining = CodeGenOpts.getInlining(); @@ -346,6 +358,8 @@ void EmitAssemblyHelper::CreatePasses() { // Set up the per-module pass manager. PassManager *MPM = getPerModulePasses(); + if (!CodeGenOpts.RewriteMapFiles.empty()) + addSymbolRewriterPass(CodeGenOpts, MPM); if (CodeGenOpts.VerifyModule) MPM->add(createDebugInfoVerifierPass()); |