summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2018-07-27 18:09:02 (GMT)
committerAndy Ayers <andya@microsoft.com>2018-07-31 22:29:00 (GMT)
commit760418ee6e569697a1c08b6f0296a74a3526c863 (patch)
treeba693030619e0942d144b06eed6c97d8c9d00ae3 /src
parentc93ca7f84a0986c0498ee2289902b3831b6467fd (diff)
downloadcoreclr-760418ee6e569697a1c08b6f0296a74a3526c863.zip
coreclr-760418ee6e569697a1c08b6f0296a74a3526c863.tar.gz
coreclr-760418ee6e569697a1c08b6f0296a74a3526c863.tar.bz2
JIT: port extra check to struct of struct of x promotion to relase/2.1
Port of #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')
-rw-r--r--src/jit/lclvars.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/jit/lclvars.cpp b/src/jit/lclvars.cpp
index 765a2ee..866b711 100644
--- a/src/jit/lclvars.cpp
+++ b/src/jit/lclvars.cpp
@@ -1626,6 +1626,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;
}