[SafeStack,NFC] Move unconditional code into constructor
authorVitaly Buka <vitalybuka@google.com>
Sun, 14 Jun 2020 21:35:34 +0000 (14:35 -0700)
committerVitaly Buka <vitalybuka@google.com>
Mon, 15 Jun 2020 06:05:41 +0000 (23:05 -0700)
Prepare to move ClColoring from SafeStackCode to SafeStackLayout.
This will allow to reuse the code in other components.

llvm/lib/CodeGen/SafeStackColoring.cpp
llvm/lib/CodeGen/SafeStackColoring.h

index 27600f2..564df8a 100644 (file)
@@ -273,7 +273,8 @@ LLVM_DUMP_METHOD void StackColoring::dumpLiveRanges() {
 }
 #endif
 
-void StackColoring::run() {
+StackColoring::StackColoring(Function &F, ArrayRef<AllocaInst *> Allocas)
+    : F(F), Allocas(Allocas), NumAllocas(Allocas.size()) {
   LLVM_DEBUG(dumpAllocas());
 
   for (unsigned I = 0; I < NumAllocas; ++I)
@@ -281,7 +282,9 @@ void StackColoring::run() {
   LiveRanges.resize(NumAllocas);
 
   collectMarkers();
+}
 
+void StackColoring::run() {
   if (!ClColoring) {
     for (auto &R : LiveRanges) {
       R.SetMaximum(1);
index d917d02..05de021 100644 (file)
@@ -115,8 +115,7 @@ private:
   void calculateLiveIntervals();
 
 public:
-  StackColoring(Function &F, ArrayRef<AllocaInst *> Allocas)
-      : F(F), Allocas(Allocas), NumAllocas(Allocas.size()) {}
+  StackColoring(Function &F, ArrayRef<AllocaInst *> Allocas);
 
   void run();
   void removeAllMarkers();