diff options
author | Andy Ayers <andya@microsoft.com> | 2018-07-27 11:09:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-27 11:09:02 -0700 |
commit | d38774d80e07436eadc28f7255a8c9f8edb1e570 (patch) | |
tree | 23e68235af36561bc241339ec451ee083aca6a8b /src/jit | |
parent | 826c55f9a24926d64b042c083e09dfdf78ffe4ae (diff) | |
download | coreclr-d38774d80e07436eadc28f7255a8c9f8edb1e570.tar.gz coreclr-d38774d80e07436eadc28f7255a8c9f8edb1e570.tar.bz2 coreclr-d38774d80e07436eadc28f7255a8c9f8edb1e570.zip |
JIT: add extra check to struct of struct of x promotion (#19156)
Avoid promoting structs that contain struct fields that themselves
wrap single simple fields, if those single simple fields are smaller
than their enclosing struct.
Otherwise we run the risk of losing track of the "extra" bytes in the
innner struct.
Addresses #19149.
Diffstat (limited to 'src/jit')
-rw-r--r-- | src/jit/lclvars.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/jit/lclvars.cpp b/src/jit/lclvars.cpp index 9e83d11776..96aa090213 100644 --- a/src/jit/lclvars.cpp +++ b/src/jit/lclvars.cpp @@ -1656,6 +1656,18 @@ void Compiler::lvaCanPromoteStructType(CORINFO_CLASS_HANDLE typeHnd, // natural boundary. if (fieldSize == 0 || fieldSize != TARGET_POINTER_SIZE || varTypeIsFloating(fieldVarType)) { + JITDUMP("Promotion blocked: struct contains struct field with one field," + " but that field has invalid size or type"); + return; + } + + // Insist this wrapped field occupy all of its parent storage. + unsigned innerStructSize = info.compCompHnd->getClassSize(pFieldInfo->fldTypeHnd); + + if (fieldSize != innerStructSize) + { + JITDUMP("Promotion blocked: struct contains struct field with one field," + " but that field is not the same size as its parent."); return; } |