[PM] Separate the TargetLibraryInfo object from the immutable pass.
[oota-llvm.git] / tools / llc / llc.cpp
index 35f965b2a300f7ff71ea4c6708f0c76587af1cbf..671f82b120e116fab2b514ccf481bb8aa8dc1246 100644 (file)
@@ -15,6 +15,7 @@
 
 
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
@@ -39,7 +40,6 @@
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/ToolOutputFile.h"
-#include "llvm/Target/TargetLibraryInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetSubtargetInfo.h"
 #include <memory>
@@ -296,10 +296,12 @@ static int compileModule(char **argv, LLVMContext &Context) {
   PassManager PM;
 
   // Add an appropriate TargetLibraryInfo pass for the module's triple.
-  TargetLibraryInfo *TLI = new TargetLibraryInfo(TheTriple);
+  TargetLibraryInfo TLI(Triple(M->getTargetTriple()));
+
+  // The -disable-simplify-libcalls flag actually disables all builtin optzns.
   if (DisableSimplifyLibCalls)
-    TLI->disableAllFunctions();
-  PM.add(TLI);
+    TLI.disableAllFunctions();
+  PM.add(new TargetLibraryInfoWrapperPass(TLI));
 
   // Add the target data from the target machine, if it exists, or the module.
   if (const DataLayout *DL = Target->getSubtargetImpl()->getDataLayout())