#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Dominators.h"
#include "llvm/Support/Extension.def"
bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
- ToolOutputFile *Out, ToolOutputFile *ThinLTOLinkOut,
+ TargetLibraryInfoImpl *TLII, ToolOutputFile *Out,
+ ToolOutputFile *ThinLTOLinkOut,
ToolOutputFile *OptRemarkFile,
StringRef PassPipeline, ArrayRef<StringRef> Passes,
OutputKind OK, VerifierKind VK,
// Register the AA manager first so that our version is the one used.
FAM.registerPass([&] { return std::move(AA); });
+ // Register our TargetLibraryInfoImpl.
+ FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });
// Register all the basic analyses with the managers.
PB.registerModuleAnalyses(MAM);
class Module;
class TargetMachine;
class ToolOutputFile;
+class TargetLibraryInfoImpl;
namespace opt_tool {
enum OutputKind {
/// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be
/// nullptr.
bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
- ToolOutputFile *Out, ToolOutputFile *ThinLinkOut,
- ToolOutputFile *OptRemarkFile, StringRef PassPipeline,
- ArrayRef<StringRef> PassInfos, opt_tool::OutputKind OK,
- opt_tool::VerifierKind VK,
+ TargetLibraryInfoImpl *TLII, ToolOutputFile *Out,
+ ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile,
+ StringRef PassPipeline, ArrayRef<StringRef> PassInfos,
+ opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,
if (OutputThinLTOBC)
M->addModuleFlag(Module::Error, "EnableSplitLTOUnit", SplitLTOUnit);
+ // Add an appropriate TargetLibraryInfo pass for the module's triple.
+ TargetLibraryInfoImpl TLII(ModuleTriple);
+
+ // The -disable-simplify-libcalls flag actually disables all builtin optzns.
+ if (DisableSimplifyLibCalls)
+ TLII.disableAllFunctions();
+ else {
+ // Disable individual builtin functions in TargetLibraryInfo.
+ LibFunc F;
+ for (auto &FuncName : DisableBuiltins)
+ if (TLII.getLibFunc(FuncName, F))
+ TLII.setUnavailable(F);
+ else {
+ errs() << argv[0] << ": cannot disable nonexistent builtin function "
+ << FuncName << '\n';
+ return 1;
+ }
+ }
+
// If `-passes=` is specified, use NPM.
// If `-enable-new-pm` is specified and there are no codegen passes, use NPM.
// e.g. `-enable-new-pm -sroa` will use NPM.
// The user has asked to use the new pass manager and provided a pipeline
// string. Hand off the rest of the functionality to the new code for that
// layer.
- return runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(),
- RemarksFile.get(), PassPipeline, Passes, OK, VK,
- PreserveAssemblyUseListOrder,
+ return runPassPipeline(argv[0], *M, TM.get(), &TLII, Out.get(),
+ ThinLinkOut.get(), RemarksFile.get(), PassPipeline,
+ Passes, OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
EmitModuleHash, EnableDebugify, Coroutines)
? 0
bool AddOneTimeDebugifyPasses = EnableDebugify && !DebugifyEach;
- // Add an appropriate TargetLibraryInfo pass for the module's triple.
- TargetLibraryInfoImpl TLII(ModuleTriple);
-
- // The -disable-simplify-libcalls flag actually disables all builtin optzns.
- if (DisableSimplifyLibCalls)
- TLII.disableAllFunctions();
- else {
- // Disable individual builtin functions in TargetLibraryInfo.
- LibFunc F;
- for (auto &FuncName : DisableBuiltins)
- if (TLII.getLibFunc(FuncName, F))
- TLII.setUnavailable(F);
- else {
- errs() << argv[0] << ": cannot disable nonexistent builtin function "
- << FuncName << '\n';
- return 1;
- }
- }
-
Passes.add(new TargetLibraryInfoWrapperPass(TLII));
// Add internal analysis passes from the target machine.