<div dir="ltr">Hans, can you pull this into the 3.6 branch? It is part of a series of commits that may significantly help compile times for some folks.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 8:57 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chandlerc<br>
Date: Tue Jan 27 22:57:56 2015<br>
New Revision: 227294<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227294&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227294&view=rev</a><br>
Log:<br>
[LPM] Stop using the string based preservation API. It is an<br>
abomination.<br>
<br>
For starters, this API is incredibly slow. In order to lookup the name<br>
of a pass it must take a memory fence to acquire a pointer to the<br>
managed static pass registry, and then potentially acquire locks while<br>
it consults this registry for information about what passes exist by<br>
that name. This stops the world of LLVMs in your process no matter<br>
how little they cared about the result.<br>
<br>
To make this more joyful, you'll note that we are preserving many passes<br>
which *do not exist* any more, or are not even analyses which one might<br>
wish to have be preserved. This means we do all the work only to say<br>
"nope" with no error to the user.<br>
<br>
String-based APIs are a *bad idea*. String-based APIs that cannot<br>
produce any meaningful error are an even worse idea. =/<br>
<br>
I have a patch that simply removes this API completely, but I'm hesitant<br>
to commit it as I don't really want to perniciously break out-of-tree<br>
users of the old pass manager. I'd rather they just have to migrate to<br>
the new one at some point. If others disagree and would like me to kill<br>
it with fire, just say the word. =]<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp<br>
    llvm/trunk/lib/Target/Hexagon/HexagonRemoveSZExtArgs.cpp<br>
    llvm/trunk/lib/Target/NVPTX/NVPTXAllocaHoisting.h<br>
    llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.h<br>
    llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp<br>
    llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp<br>
    llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=227294&r1=227293&r2=227294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=227294&r1=227293&r2=227294&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp Tue Jan 27 22:57:56 2015<br>
@@ -11,11 +11,19 @@<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
<br>
-#include "llvm/IR/Function.h"<br>
+#include "llvm/CodeGen/MachineFunctionPass.h"<br>
 #include "llvm/Analysis/AliasAnalysis.h"<br>
+#include "llvm/Analysis/DominanceFrontier.h"<br>
+#include "llvm/Analysis/IVUsers.h"<br>
+#include "llvm/Analysis/LoopInfo.h"<br>
+#include "llvm/Analysis/LoopInfo.h"<br>
+#include "llvm/Analysis/MemoryDependenceAnalysis.h"<br>
+#include "llvm/Analysis/ScalarEvolution.h"<br>
 #include "llvm/CodeGen/MachineFunctionAnalysis.h"<br>
-#include "llvm/CodeGen/MachineFunctionPass.h"<br>
 #include "llvm/CodeGen/Passes.h"<br>
+#include "llvm/CodeGen/StackProtector.h"<br>
+#include "llvm/IR/Dominators.h"<br>
+#include "llvm/IR/Function.h"<br>
 using namespace llvm;<br>
<br>
 Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,<br>
@@ -43,15 +51,13 @@ void MachineFunctionPass::getAnalysisUsa<br>
   // because CodeGen overloads that to mean preserving the MachineBasicBlock<br>
   // CFG in addition to the LLVM IR CFG.<br>
   AU.addPreserved<AliasAnalysis>();<br>
-  AU.addPreserved("scalar-evolution");<br>
-  AU.addPreserved("iv-users");<br>
-  AU.addPreserved("memdep");<br>
-  AU.addPreserved("live-values");<br>
-  AU.addPreserved("domtree");<br>
-  AU.addPreserved("domfrontier");<br>
-  AU.addPreserved("loops");<br>
-  AU.addPreserved("lda");<br>
-  AU.addPreserved("stack-protector");<br>
+  AU.addPreserved<DominanceFrontier>();<br>
+  AU.addPreserved<DominatorTreeWrapperPass>();<br>
+  AU.addPreserved<IVUsers>();<br>
+  AU.addPreserved<LoopInfoWrapperPass>();<br>
+  AU.addPreserved<MemoryDependenceAnalysis>();<br>
+  AU.addPreserved<ScalarEvolution>();<br>
+  AU.addPreserved<StackProtector>();<br>
<br>
   FunctionPass::getAnalysisUsage(AU);<br>
 }<br>
<br>
Modified: llvm/trunk/lib/Target/Hexagon/HexagonRemoveSZExtArgs.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonRemoveSZExtArgs.cpp?rev=227294&r1=227293&r2=227294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonRemoveSZExtArgs.cpp?rev=227294&r1=227293&r2=227294&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/Hexagon/HexagonRemoveSZExtArgs.cpp (original)<br>
+++ llvm/trunk/lib/Target/Hexagon/HexagonRemoveSZExtArgs.cpp Tue Jan 27 22:57:56 2015<br>
@@ -15,6 +15,7 @@<br>
 #include "Hexagon.h"<br>
 #include "HexagonTargetMachine.h"<br>
 #include "llvm/CodeGen/MachineFunctionAnalysis.h"<br>
+#include "llvm/CodeGen/StackProtector.h"<br>
 #include "llvm/IR/Function.h"<br>
 #include "llvm/IR/Instructions.h"<br>
 #include "llvm/Pass.h"<br>
@@ -42,7 +43,7 @@ namespace {<br>
     void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
       AU.addRequired<MachineFunctionAnalysis>();<br>
       AU.addPreserved<MachineFunctionAnalysis>();<br>
-      AU.addPreserved("stack-protector");<br>
+      AU.addPreserved<StackProtector>();<br>
       FunctionPass::getAnalysisUsage(AU);<br>
     }<br>
   };<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAllocaHoisting.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAllocaHoisting.h?rev=227294&r1=227293&r2=227294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAllocaHoisting.h?rev=227294&r1=227293&r2=227294&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/NVPTX/NVPTXAllocaHoisting.h (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAllocaHoisting.h Tue Jan 27 22:57:56 2015<br>
@@ -15,6 +15,7 @@<br>
 #define LLVM_LIB_TARGET_NVPTX_NVPTXALLOCAHOISTING_H<br>
<br>
 #include "llvm/CodeGen/MachineFunctionAnalysis.h"<br>
+#include "llvm/CodeGen/StackProtector.h"<br>
 #include "llvm/IR/DataLayout.h"<br>
 #include "llvm/Pass.h"<br>
<br>
@@ -32,8 +33,8 @@ public:<br>
<br>
   void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
     AU.addRequired<DataLayoutPass>();<br>
-    AU.addPreserved("stack-protector");<br>
     AU.addPreserved<MachineFunctionAnalysis>();<br>
+    AU.addPreserved<StackProtector>();<br>
   }<br>
<br>
   const char *getPassName() const override {<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.h?rev=227294&r1=227293&r2=227294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.h?rev=227294&r1=227293&r2=227294&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.h (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.h Tue Jan 27 22:57:56 2015<br>
@@ -16,6 +16,7 @@<br>
 #define LLVM_LIB_TARGET_NVPTX_NVPTXLOWERAGGRCOPIES_H<br>
<br>
 #include "llvm/CodeGen/MachineFunctionAnalysis.h"<br>
+#include "llvm/CodeGen/StackProtector.h"<br>
 #include "llvm/IR/DataLayout.h"<br>
 #include "llvm/Pass.h"<br>
<br>
@@ -29,8 +30,8 @@ struct NVPTXLowerAggrCopies : public Fun<br>
<br>
   void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
     AU.addRequired<DataLayoutPass>();<br>
-    AU.addPreserved("stack-protector");<br>
     AU.addPreserved<MachineFunctionAnalysis>();<br>
+    AU.addPreserved<StackProtector>();<br>
   }<br>
<br>
   bool runOnFunction(Function &F) override;<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp?rev=227294&r1=227293&r2=227294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp?rev=227294&r1=227293&r2=227294&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp Tue Jan 27 22:57:56 2015<br>
@@ -18,6 +18,7 @@<br>
 #include "llvm/Analysis/InstructionSimplify.h"<br>
 #include "llvm/Analysis/LoopInfo.h"<br>
 #include "llvm/Analysis/LoopPass.h"<br>
+#include "llvm/Analysis/ScalarEvolution.h"<br>
 #include "llvm/IR/DataLayout.h"<br>
 #include "llvm/IR/Dominators.h"<br>
 #include "llvm/IR/Instructions.h"<br>
@@ -47,7 +48,7 @@ namespace {<br>
       AU.addRequiredID(LoopSimplifyID);<br>
       AU.addPreservedID(LoopSimplifyID);<br>
       AU.addPreservedID(LCSSAID);<br>
-      AU.addPreserved("scalar-evolution");<br>
+      AU.addPreserved<ScalarEvolution>();<br>
       AU.addRequired<TargetLibraryInfoWrapperPass>();<br>
     }<br>
   };<br>
<br>
Modified: llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp?rev=227294&r1=227293&r2=227294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp?rev=227294&r1=227293&r2=227294&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp Tue Jan 27 22:57:56 2015<br>
@@ -63,7 +63,6 @@ namespace {<br>
     void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
       // This is a cluster of orthogonal Transforms<br>
       AU.addPreserved<UnifyFunctionExitNodes>();<br>
-      AU.addPreserved("mem2reg");<br>
       AU.addPreservedID(LowerInvokePassID);<br>
     }<br>
<br>
<br>
Modified: llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp?rev=227294&r1=227293&r2=227294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp?rev=227294&r1=227293&r2=227294&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Tue Jan 27 22:57:56 2015<br>
@@ -35,7 +35,6 @@ void UnifyFunctionExitNodes::getAnalysis<br>
   // We preserve the non-critical-edgeness property<br>
   AU.addPreservedID(BreakCriticalEdgesID);<br>
   // This is a cluster of orthogonal Transforms<br>
-  AU.addPreserved("mem2reg");<br>
   AU.addPreservedID(LowerSwitchID);<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>