summaryrefslogtreecommitdiff
path: root/src/jit/flowgraph.cpp
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2018-12-03 10:46:52 -0800
committerGitHub <noreply@github.com>2018-12-03 10:46:52 -0800
commit562ae44982171945f85a1134a6ef9d24989e8882 (patch)
tree22001aa605a805f8044eea00e677ff7c4de8f7bf /src/jit/flowgraph.cpp
parentb285e42989730fc6c2a75478ede4348f18bc93b3 (diff)
downloadcoreclr-562ae44982171945f85a1134a6ef9d24989e8882.tar.gz
coreclr-562ae44982171945f85a1134a6ef9d24989e8882.tar.bz2
coreclr-562ae44982171945f85a1134a6ef9d24989e8882.zip
JIT: fix overly aggressive type propagation from returns (#21316)
For quite a while now the jit has been propagating return types from callees to the return spill temp. However this is only safe when the callee has a single return site (or all return sites return the same type). Because return spill temps often end up getting assigned to still more temps we haven't seen this overly aggressive type propgagation lead to bugs, but now that we're tracking single def temps and doing more type propagation during the late devirtualization callback, the fact that these types are wrong has been exposed and can lead to incorrect devirtualization. The fix is to only consider the return spill temp as single def if the callee has a single return site, and to check that the return spill temp is single def before trying to propagate the type. Fixes #21295.
Diffstat (limited to 'src/jit/flowgraph.cpp')
-rw-r--r--src/jit/flowgraph.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/jit/flowgraph.cpp b/src/jit/flowgraph.cpp
index 41a88d9ef9..dd184539fd 100644
--- a/src/jit/flowgraph.cpp
+++ b/src/jit/flowgraph.cpp
@@ -5904,8 +5904,12 @@ void Compiler::fgFindBasicBlocks()
// out we can prove the method returns a more specific type.
if (info.compRetType == TYP_REF)
{
- lvaTable[lvaInlineeReturnSpillTemp].lvSingleDef = 1;
- JITDUMP("Marked V%02u as a single def temp\n", lvaInlineeReturnSpillTemp);
+ // The return spill temp is single def only if the method has a single return block.
+ if (retBlocks == 1)
+ {
+ lvaTable[lvaInlineeReturnSpillTemp].lvSingleDef = 1;
+ JITDUMP("Marked return spill temp V%02u as a single def temp\n", lvaInlineeReturnSpillTemp);
+ }
CORINFO_CLASS_HANDLE retClassHnd = impInlineInfo->inlineCandidateInfo->methInfo.args.retTypeClass;
if (retClassHnd != nullptr)