add a way to disable all builtins, wire it up to opt's -disable-simplifylibcalls flag.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125978 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 8ccd8e8..e55b4b3 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -532,8 +532,12 @@
   PassManager Passes;
 
   // Add an appropriate TargetLibraryInfo pass for the module's triple.
-  if (!M->getTargetTriple().empty())
-    Passes.add(new TargetLibraryInfo(Triple(M->getTargetTriple())));
+  TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple()));
+  
+  // The -disable-simplify-libcalls flag actually disables all builtin optzns.
+  if (DisableSimplifyLibCalls)
+    TLI->disableAllFunctions();
+  Passes.add(TLI);
   
   // Add an appropriate TargetData instance for this module.
   TargetData *TD = 0;