Moving gen stack level to code gen interface (#23328)
authorBrian Bohe <brianbohe@gmail.com>
Thu, 21 Mar 2019 18:19:03 +0000 (11:19 -0700)
committerSergey Andreenko <seandree@microsoft.com>
Thu, 21 Mar 2019 18:19:03 +0000 (11:19 -0700)
* Make genStackLevel accessible from CodeGenInterface

* Initializing stackLevel before fist BasicBlock's code is generated

* Typo

* Removing extra line on comments

src/jit/codegen.h
src/jit/codegencommon.cpp
src/jit/codegeninterface.h
src/jit/codegenlinear.cpp

index 11c81c4..046addf 100644 (file)
@@ -126,10 +126,6 @@ private:
     bool     genUseBlockInit;  // true if we plan to block-initialize the local stack frame
     unsigned genInitStkLclCnt; // The count of local variables that we need to zero init
 
-    //  Keeps track of how many bytes we've pushed on the processor's stack.
-    //
-    unsigned genStackLevel;
-
     void SubtractStackLevel(unsigned adjustment)
     {
         assert(genStackLevel >= adjustment);
index 2b5236b..2e15383 100644 (file)
@@ -11578,3 +11578,8 @@ void CodeGen::genStackPointerCheck(bool doStackPointerCheck, unsigned lvaStackPo
 }
 
 #endif // defined(DEBUG) && defined(_TARGET_XARCH_)
+
+unsigned CodeGenInterface::getCurrentStackLevel() const
+{
+    return genStackLevel;
+}
index 9a67649..6935a77 100644 (file)
@@ -542,6 +542,13 @@ public:
             const LclVarDsc* varDsc, var_types type, regNumber baseReg, int offset, bool isFramePointerUsed);
     };
 
+public:
+    unsigned getCurrentStackLevel() const;
+
+protected:
+    //  Keeps track of how many bytes we've pushed on the processor's stack.
+    unsigned genStackLevel;
+
 #ifdef LATE_DISASM
 public:
     virtual const char* siRegVarName(size_t offs, size_t size, unsigned reg) = 0;
index c0a2034..595f860 100644 (file)
@@ -114,6 +114,10 @@ void CodeGen::genInitialize()
     // Make sure a set is allocated for compiler->compCurLife (in the long case), so we can set it to empty without
     // allocation at the start of each basic block.
     VarSetOps::AssignNoCopy(compiler, compiler->compCurLife, VarSetOps::MakeEmpty(compiler));
+
+    // We initialize the stack level before first "BasicBlock" code is generated in case we need to report stack
+    // variable needs home and so its stack offset.
+    SetStackLevel(0);
 }
 
 //------------------------------------------------------------------------