Skip to content

Commit

Permalink
Treat System.Runtime.CompilerServices.Unsafe as intrinsic (#68739)
Browse files Browse the repository at this point in the history
* Treat System.Runtime.CompilerServices.Unsafe as intrinsic

* Remove duplicated logic from Get_CORINFO_SIG_INFO

* Don't create a multiply node if the size is 1

* Remove unnecessary impBashVarAddrsToI calls over gtNewIconNode

* Use `#ifdef TARGET_64BIT` rather than `#if (REGSIZE_BYTES == 8)`

* Don't unnecessarily call `genActualType(TYP_U_IMPL)`, just use `TYP_I_IMPL` directly

* Only insert casts for `TYP_INT` to `TYP_I_IMPL` or `TYP_U_IMPL` on 64-bit

* Have Unsafe.SkipInit create a `GT_NO_OP` node

* Have Unsafe.Subtract and Unsafe.SubtractByteOffset be intrinsic

* Adding a couple `CLANG_FORMAT_COMMENT_ANCHOR;` to comments that precede an `#ifdef`

* Applying formatting patch

* Revert "Have Unsafe.Subtract and Unsafe.SubtractByteOffset be intrinsic"

This reverts commit 2301adc.

* Fixing the operand evaluation order for NI_SRCS_UNSAFE_Add

* Fixing the operand evaluation order for NI_SRCS_UNSAFE_ByteOffset

* Implement NI_SRCS_UNSAFE_SubtractByteOffset

* Fix the build failure

* Ensure impImplicitIorI4Cast is called on op2 for NI_SRCS_UNSAFE_Add

* Don't declare a `tmp` in NI_SRCS_UNSAFE_Add to make the logic clearer

* Have NI_SRCS_UNSAFE_SkipInit return gtNewNothingNode

* Handle side effects for NI_SRCS_UNSAFE_SkipInit

* Revert "Implement NI_SRCS_UNSAFE_SubtractByteOffset"

This reverts commit 7166b2e.

* Manually simplify some of the NI_SRCS_* import logic

* Ensure NI_SRCS_SkipInit returns the unused node when its side-effecting

* Remove unnecessary comment anchors

* Applying formatting patch

* Try to workaround the JIT issue by spilling op1/op2 for Unsafe.Add

* Apply formatting patch

* Revert "Try to workaround the JIT issue by spilling op1/op2 for Unsafe.Add"

* Have Unsafe.Subtract and Unsafe.SubtractByteOffset be intrinsic

This reverts commit 982660e.
  • Loading branch information
tannergooding authored May 12, 2022
1 parent 5975649 commit 3f4585c
Show file tree
Hide file tree
Showing 3 changed files with 577 additions and 22 deletions.
6 changes: 6 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3685,6 +3685,11 @@ class Compiler
CORINFO_SIG_INFO* sig,
bool mustExpand);

GenTree* impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
CORINFO_CLASS_HANDLE clsHnd,
CORINFO_METHOD_HANDLE method,
CORINFO_SIG_INFO* sig);

#ifdef FEATURE_HW_INTRINSICS
GenTree* impHWIntrinsic(NamedIntrinsic intrinsic,
CORINFO_CLASS_HANDLE clsHnd,
Expand Down Expand Up @@ -3968,6 +3973,7 @@ class Compiler
void impSpillStackEnsure(bool spillLeaves = false);
void impEvalSideEffects();
void impSpillSpecialSideEff();
void impSpillSideEffect(bool spillGlobEffects, unsigned chkLevel DEBUGARG(const char* reason));
void impSpillSideEffects(bool spillGlobEffects, unsigned chkLevel DEBUGARG(const char* reason));
void impSpillValueClasses();
void impSpillEvalStack();
Expand Down
Loading

0 comments on commit 3f4585c

Please sign in to comment.