Properly update block flags during branch opt.
authorPat Gavlin <pagavlin@microsoft.com>
Wed, 2 Nov 2016 19:39:40 +0000 (12:39 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Wed, 2 Nov 2016 19:39:40 +0000 (12:39 -0700)
`fgOptimizeBranch` was updating the flags for the predecessor block
using the flags from the wrong destination block. This was causing an
assert in `AllocateObjects` when verifying that all blocks that contain
`allocObj` nodes are properly marked with `BBF_HAS_NEWOBJ`.

Commit migrated from https://github.com/dotnet/coreclr/commit/b0e3c23069a73943f52014b3cba52c56a6839439

src/coreclr/src/jit/flowgraph.cpp

index 7122869..c02bd50 100644 (file)
@@ -14163,16 +14163,16 @@ bool Compiler::fgOptimizeBranch(BasicBlock* bJump)
     //
     gtReverseCond(condTree);
 
+    // We need to update the following flags of the bJump block if they were set in the bbJumpDest block
+    bJump->bbFlags |= (bDest->bbFlags &
+                       (BBF_HAS_NEWOBJ | BBF_HAS_NEWARRAY | BBF_HAS_NULLCHECK | BBF_HAS_IDX_LEN | BBF_HAS_VTABREF));
+
     bJump->bbJumpKind = BBJ_COND;
     bJump->bbJumpDest = bDest->bbNext;
 
     /* Mark the jump dest block as being a jump target */
     bJump->bbJumpDest->bbFlags |= BBF_JMP_TARGET | BBF_HAS_LABEL;
 
-    // We need to update the following flags of the bJump block if they were set in the bbJumpDest block
-    bJump->bbFlags |= (bJump->bbJumpDest->bbFlags &
-                       (BBF_HAS_NEWOBJ | BBF_HAS_NEWARRAY | BBF_HAS_NULLCHECK | BBF_HAS_IDX_LEN | BBF_HAS_VTABREF));
-
     /* Update bbRefs and bbPreds */
 
     // bJump now falls through into the next block