diff options
author | Eugene Rozenfeld <erozen@microsoft.com> | 2018-11-01 17:19:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-01 17:19:34 -0700 |
commit | dc028d9893915c4c1bd62daf5e12325c15334154 (patch) | |
tree | 83ae47b768233b76b0e859496c53777d7b652683 | |
parent | 82ebf52e680a2c8c43aa63b0ff5d541d005cffa1 (diff) | |
download | coreclr-dc028d9893915c4c1bd62daf5e12325c15334154.tar.gz coreclr-dc028d9893915c4c1bd62daf5e12325c15334154.tar.bz2 coreclr-dc028d9893915c4c1bd62daf5e12325c15334154.zip |
Remove redundant zero-initializations for long-lifetime structs. (#20753)
When compInitMem is true long-lifetime structs (i.e., the ones with lvIsTemp set to false)
are zero-initialized in the prolog: https://github.com/dotnet/coreclr/blob/c8a63947382b0db428db602238199ca81badbe8e/src/jit/codegencommon.cpp#L4765
Therefore, these structs don't need an explicit zero-initialization in blocks that are not in a loop.
-rw-r--r-- | src/jit/compiler.hpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/jit/compiler.hpp b/src/jit/compiler.hpp index f8fc9421e4..20fda04e1c 100644 --- a/src/jit/compiler.hpp +++ b/src/jit/compiler.hpp @@ -4201,13 +4201,14 @@ inline void Compiler::CLR_API_Leave(API_ICorJitInfo_Names ename) // false otherwise // // Notes: -// Structs with GC pointer fields are fully zero-initialized in the prolog if compInitMem is true. -// Therefore, we don't need to insert zero-initialization if this block is not in a loop. +// If compInitMem is true, structs with GC pointer fields and long-lifetime structs +// are fully zero-initialized in the prologue. Therefore, we don't need to insert +// zero-initialization in this block if it is not in a loop. bool Compiler::fgStructTempNeedsExplicitZeroInit(LclVarDsc* varDsc, BasicBlock* block) { bool containsGCPtr = (varDsc->lvStructGcCount > 0); - return (!containsGCPtr || !info.compInitMem || ((block->bbFlags & BBF_BACKWARD_JUMP) != 0)); + return (!info.compInitMem || ((block->bbFlags & BBF_BACKWARD_JUMP) != 0) || (!containsGCPtr && varDsc->lvIsTemp)); } /*****************************************************************************/ |