[llvm] 05590a9 - [SafeStack, NFC] Move unconditional code into constructor

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 14 23:14:58 PDT 2020


Author: Vitaly Buka
Date: 2020-06-14T23:05:41-07:00
New Revision: 05590a9cb8717e2db0aa274047f1b00c5ab51a8d

URL: https://github.com/llvm/llvm-project/commit/05590a9cb8717e2db0aa274047f1b00c5ab51a8d
DIFF: https://github.com/llvm/llvm-project/commit/05590a9cb8717e2db0aa274047f1b00c5ab51a8d.diff

LOG: [SafeStack,NFC] Move unconditional code into constructor

Prepare to move ClColoring from SafeStackCode to SafeStackLayout.
This will allow to reuse the code in other components.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SafeStackColoring.cpp b/llvm/lib/CodeGen/SafeStackColoring.cpp
index 27600f2d6eac..564df8a8ce46 100644
--- a/llvm/lib/CodeGen/SafeStackColoring.cpp
+++ b/llvm/lib/CodeGen/SafeStackColoring.cpp
@@ -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);

diff  --git a/llvm/lib/CodeGen/SafeStackColoring.h b/llvm/lib/CodeGen/SafeStackColoring.h
index d917d02099bc..05de021038dd 100644
--- a/llvm/lib/CodeGen/SafeStackColoring.h
+++ b/llvm/lib/CodeGen/SafeStackColoring.h
@@ -115,8 +115,7 @@ class StackColoring {
   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();


        


More information about the llvm-commits mailing list