Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
JIT: tolerate nonzero constant byrefs in impCheckForNullPointer (#17042)
Browse files Browse the repository at this point in the history
With the advent of #16966 we may now see constant nonzero byrefs from
things like RVA statics. Tolerate these in `impCheckForNullPointer`.

Note previously we'd type these as ints/longs and so bail out of
`impCheckForNullPointer` after the first check.

Closes #17008.
  • Loading branch information
AndyAyersMS authored Mar 20, 2018
1 parent 20f7c21 commit 58f8744
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4355,7 +4355,13 @@ inline GenTree* Compiler::impCheckForNullPointer(GenTree* obj)
if (obj->gtOper == GT_CNS_INT)
{
assert(obj->gtType == TYP_REF || obj->gtType == TYP_BYREF);
assert(obj->gtIntCon.gtIconVal == 0);

// We can see non-zero byrefs for RVA statics.
if (obj->gtIntCon.gtIconVal != 0)
{
assert(obj->gtType == TYP_BYREF);
return obj;
}

unsigned tmp = lvaGrabTemp(true DEBUGARG("CheckForNullPointer"));

Expand Down
1 change: 0 additions & 1 deletion tests/src/JIT/Directed/RVAInit/oddsize.ilproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<OutputType>Exe</OutputType>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
Expand Down

0 comments on commit 58f8744

Please sign in to comment.