summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2015-01-09 05:10:20 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2015-01-09 05:10:20 +0000
commit1928b9aa4147faf4c8dbe6ffe04e809f6dccef16 (patch)
treefcfb797c14e098c32b452109eb79669ac4d31445 /lib/CodeGen/BackendUtil.cpp
parent659e92bcfa578a0bf2cd1f9f50bcaa16c782a41b (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/BackendUtil.cpp')
-rw-r--r--lib/CodeGen/BackendUtil.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp
index 54215743f8..e1267192a7 100644
--- a/lib/CodeGen/BackendUtil.cpp
+++ b/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());