Set fgOptimizedFinally flag correctly (#44268)
authorDavid Wrighton <davidwr@microsoft.com>
Thu, 5 Nov 2020 22:55:36 +0000 (14:55 -0800)
committerGitHub <noreply@github.com>
Thu, 5 Nov 2020 22:55:36 +0000 (14:55 -0800)
- Initialize to 0 at compiler startup
- Set flag when finally cloning optimization kicks in

Fixes non-deterministic generation of nop opcodes into ARM32 code

src/coreclr/src/jit/flowgraph.cpp

index f2ca85c..8ee9e69 100644 (file)
@@ -122,6 +122,9 @@ void Compiler::fgInit()
     /* This global flag is set whenever we add a throw block for a RngChk */
     fgRngChkThrowAdded = false; /* reset flag for fgIsCodeAdded() */
 
+    /* Keep track of whether or not EH statements have been optimized */
+    fgOptimizedFinally = false;
+
     /* We will record a list of all BBJ_RETURN blocks here */
     fgReturnBlocks = nullptr;
 
@@ -25436,6 +25439,7 @@ PhaseStatus Compiler::fgCloneFinally()
     if (cloneCount > 0)
     {
         JITDUMP("fgCloneFinally() cloned %u finally handlers\n", cloneCount);
+        fgOptimizedFinally = true;
 
 #ifdef DEBUG
         if (verbose)