Skip to content

Commit

Permalink
For arm32, kill REG_PROFILER_RET_SCRATCH for LSRA but not for GC (#40123
Browse files Browse the repository at this point in the history
)

Reworking of #37969. Block LSRA from using R2 around the profiler leave
callback, but don't kill GC refs in R2, since late codegen will use
R2 to temporarily hold return values around the callback.

Fixes #37223.

Co-authored-by: Carol Eidt <carol.eidt@microsoft.com>
  • Loading branch information
AndyAyersMS and CarolEidt authored Jul 30, 2020
1 parent e872afc commit 32ddcd3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/coreclr/src/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7692,7 +7692,12 @@ regMaskTP emitter::emitGetGCRegsKilledByNoGCCall(CorInfoHelpFunc helper)
break;

case CORINFO_HELP_PROF_FCN_LEAVE:
#if defined(TARGET_ARM)
// profiler scratch remains gc live
result = RBM_PROFILER_LEAVE_TRASH & ~RBM_PROFILER_RET_SCRATCH;
#else
result = RBM_PROFILER_LEAVE_TRASH;
#endif
break;

case CORINFO_HELP_PROF_FCN_TAILCALL:
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/src/jit/lsraarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ int LinearScan::BuildNode(GenTree* tree)

case GT_RETURN:
srcCount = BuildReturn(tree);
killMask = getKillSetForReturn();
BuildDefsWithKills(tree, 0, RBM_NONE, killMask);
break;

case GT_RETFILT:
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/src/jit/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,9 @@ typedef unsigned char regNumberSmall;
// The registers trashed by profiler enter/leave/tailcall hook
// See vm\arm\asmhelpers.asm for more details.
#define RBM_PROFILER_ENTER_TRASH RBM_NONE
#define RBM_PROFILER_LEAVE_TRASH RBM_NONE
// While REG_PROFILER_RET_SCRATCH is not trashed by the method, the register allocator must
// consider it killed by the return.
#define RBM_PROFILER_LEAVE_TRASH RBM_PROFILER_RET_SCRATCH
#define RBM_PROFILER_TAILCALL_TRASH RBM_NONE

// Which register are int and long values returned in ?
Expand Down

0 comments on commit 32ddcd3

Please sign in to comment.