From c7bc8149cd212b15fdd0987ac76f7909eab8a519 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 21 Aug 2014 17:58:42 +0000 Subject: [PATCH] Refactor TLI creation. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216198 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/BackendUtil.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 886c379839..36a6c638e6 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -218,6 +218,14 @@ static void addDataFlowSanitizerPass(const PassManagerBuilder &Builder, PM.add(createDataFlowSanitizerPass(CGOpts.SanitizerBlacklistFile)); } +static TargetLibraryInfo *createTLI(llvm::Triple &TargetTriple, + const CodeGenOptions &CodeGenOpts) { + TargetLibraryInfo *TLI = new TargetLibraryInfo(TargetTriple); + if (!CodeGenOpts.SimplifyLibCalls) + TLI->disableAllFunctions(); + return TLI; +} + void EmitAssemblyHelper::CreatePasses() { unsigned OptLevel = CodeGenOpts.OptimizationLevel; CodeGenOptions::InliningMethod Inlining = CodeGenOpts.getInlining(); @@ -295,9 +303,7 @@ void EmitAssemblyHelper::CreatePasses() { // Figure out TargetLibraryInfo. Triple TargetTriple(TheModule->getTargetTriple()); - PMBuilder.LibraryInfo = new TargetLibraryInfo(TargetTriple); - if (!CodeGenOpts.SimplifyLibCalls) - PMBuilder.LibraryInfo->disableAllFunctions(); + PMBuilder.LibraryInfo = createTLI(TargetTriple, CodeGenOpts); switch (Inlining) { case CodeGenOptions::NoInlining: break; @@ -494,10 +500,7 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action, // Add LibraryInfo. llvm::Triple TargetTriple(TheModule->getTargetTriple()); - TargetLibraryInfo *TLI = new TargetLibraryInfo(TargetTriple); - if (!CodeGenOpts.SimplifyLibCalls) - TLI->disableAllFunctions(); - PM->add(TLI); + PM->add(createTLI(TargetTriple, CodeGenOpts)); // Add Target specific analysis passes. TM->addAnalysisPasses(*PM); -- 2.40.0