summaryrefslogtreecommitdiff
path: root/src/jit/importer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-06-18Implement instantiating and unboxing through portable stublinker code… (#106)JUNG DONG-HEON1-2/+2
* Implement instantiating and unboxing through portable stublinker code - Handle only the cases with register to register moves - Shares abi processing logic with delegate shuffle thunk creation - Architecture specific logic is relatively simple - Do not permit use of HELPERREG in computed instantiating stubs - Fix GetArgLoc such that it works on all architectures and OS combinations Add a JIT stress test case for testing all of the various combinations - Use the same calling convention test architecture that was used as part of tail call work Rename secure delegates to wrapper delegates - Secure delegates are no longer a feature of the runtime - But the wrapper delegate lives on as a workaround for a weird detail of the ARM32 abi
2020-01-14[release/3.1] Port fix for JIT silent bad code (#27972)Andy Ayers1-5/+16
* [release/3.1] Port fix for JIT silent bad code Release/3.1 port of https://github.com/dotnet/runtime/pull/797. Fixes https://github.com/dotnet/runtime/issues/764 The jit might incorrectly order a read from a struct field with an operation that modifies the field, so that the read returns the wrong value. Silent bad code; program behaves incorrectly. Yes, introduced in the 3.0 cycle. Verified the user's test case now passes; no diffs seen in any existing framework or test code. **Low**: the jit is now spilling the eval stack entries to temps in cases where it did not before; this should be conservatively safe. cc: @brucefo ____ If we're appending an assignment whose LHS is is a location within a local struct, we need to spill all references to that struct from the eval stack. Update the existing logic for this to handle the case where the LHS is a field of a local struct, and the field is updated by unusual means (here, `initobj`). Fixes dotnet/runtime#764. * Fix test
2019-06-11JIT: use stress mode tail call validation info for implicit tail calls (#25093)Andy Ayers1-17/+45
If a call site fails tail call stress validation, don't consider it for implicit tail calling either. In normal jitting we defer this level of validation until impImportCall to avoid duplicating work. This avoids an assert when we have invalid IL. Fixes #25027.
2019-06-06Marking Vector128<T>.Count and Vector256<T>.Count as [Intrinsic] (#24991)Tanner Gooding1-1/+1
* Marking Vector128<T>.Count and Vector256<T>.Count as [Intrinsic] * Fixing NI_Vector128_Count and NI_Vector256_Count to use clsHnd when getting the simdSize and baseType * Applying the formatting patch. * Changing some comments to just be "vector element count". * Fixing impBaseIntrinsic to set the baseType so Vector128_Count and Vector256_Count don't return nullptr
2019-05-09Mark local struct as having overlapping fields after struct reinterpretationEugene Rozenfeld1-1/+39
Methods like System.Runtime.CompilerServices.Unsafe.As<TFrom, TTo> may have struct reinterpretation when function signature specifies Struct1& and the method returns Struct2& where Struct1 and Struct2 are different structs. This may confuse jit optimizations (in particular, value numbering) because fields of a struct of type Struct1 may be accessed using handles of Struct2. This fix marks the source local involved in such struct reinterpretation as having overlapping fields. That prevents SSA builder from inserting the local into SSA. Fixes #24159. No diffs in framework assemblies and coreclr benchmarks.
2019-04-30Updating lookupNamedIntrinsic to no longer assert for an unexpected ↵Tanner Gooding1-2/+5
hwintrinsic method. (#24327)
2019-04-23Merge pull request #23932 from briansull/zero-offset-mapBrian Sullivan1-1/+2
Fixes for tracking struct field sequences
2019-04-19Fix `impGetStructAddr`.Sergey Andreenko1-11/+35
2019-04-19Fixes for Zero Offset field sequence trackingBrian Sullivan1-1/+2
- A GT_LCL_VAR may have a zeroOffset field - Add an assert to prevent building field sequences with duplicates - Fix fgMorphField when we have a zero offset field Improve fgAddFieldSeqForZeroOffset - Add JItDump info - Handle GT_LCL_FLD Changing the sign of an int constant also remove any field sequence information. Added method header comment for fgAddFieldSeqForZeroOffset Changed when we call fgAddFieldSeqForZeroOffset to be before the call to fgMorphSmpOp. Prefer calling fgAddFieldSeqForZeroOffset() to GetZeroOffsetFieldMap()->Set()
2019-04-17JIT: ignore pinning of non-gc types (#24010)Andy Ayers1-9/+15
We may see pin modifiers on locals that are not gc types. Ignore these modifiers. Closes #23950. Also added a missing copyright header on an unrelated test.
2019-04-17Add lvIsImplicitByRef information to lvaSetStruct (#19223)Jarret Shook1-5/+8
Before implicit byrefs were tracked by setting lvIsParam and lvIsTemp. This change explicitly adds a flag for implicitByRef instead of overloading. In addition, it fixes the decision to copy an implicitByRef for arm64 varargs. Temporarily bump weight on byref params to match old behavior and avoid codegen diffs. Re-enabled various tests and parts of tests. Closes #20046 Closes #19860
2019-04-16Arm64 vector ABI (#23675)Carol Eidt1-5/+5
* Support for Arm64 Vector ABI Extend HFA support to support vectors as well as floating point types. This requires that the JIT recognize vector types even during crossgen, so that the ABI is supported consistently. Also, fix and re-enable the disabled Arm64 Simd tests. Fix #16022
2019-04-05Update the JIT to recognize the IsSupported property for all HWIntrinsics ↵Tanner Gooding1-5/+61
(#23751) * Moving some JITDUMP calls into Compiler::lookupNamedIntrinsic * Marking the IsSupported methods as Intrinsic for all HWIntrinsic ISAs * Updating the hwintrinsic importation to more generally handle IsSupported and ThrowPNSE * Applying formatting patch. * Adding using System.Runtime.CompilerServices to the various x86 PlatformNotSupported HWIntrinsic files
2019-04-04Handle local struct pointer arithmetic (#23704)Carol Eidt1-13/+5
The assert introduced in #23570 was overly aggressive, and didn't account for the fact that pointer arithmetic can exist in the IL, not just introduced by morph. Fix #23693
2019-04-03Fix GitHub23672 (#23674)Fei Peng1-2/+0
2019-04-02Fix spill check for struct lclVars (#23570)Carol Eidt1-4/+29
* Fix spill check for struct lclVars With the 1st class struct changes, the `SPILL_APPEND` check for the case of an assignment to a lclVar needs to handle block ops as well as lclVar lhs. Fix #23545
2019-04-01Match BOX idioms early in the importer (#23550)Jan Kotas1-18/+122
2019-03-29Use GenTreeStmt* where it is implied. (#22963)Sergey Andreenko1-140/+133
* Extract `impAppendStmt` and `impExtractLastStmt`. * Delete `BEG_STMTS` fake stmt. Use new functions to keep the list updated. * Retype `impTreeList` and `impTreeLast` as statements. Rename `impTreeList` and `impTreeLast` to show that they are statements. * Fix fields that have to be stmt. * Start using GenTreeStmt. Change `optVNAssertionPropCurStmt` to use GenTreeStmt. Replace `GenTree* stmt = block->bbTreeList` with `GenTreeStmt* stmt = block->firstStmt()`. Save results of `FirstNonPhiDef` as `GenTreeStmt`. * Replace do-while with for loop. * Change type inside VNAssertionPropVisitorInfo. * Delete unused args fron `optVNConstantPropOnTree`. * Update fields to be stmt. Update optVNConstantPropCurStmt to use Stmt. Change `lvDefStmt` to stmt. Update LoopCloning structs. Update `optDebugLogLoopCloning`. Make `compCurStmt` a statement. Update declaration name in `BuildNode`. * Clean simple cpp files. Clean valuenum. Clean ssabuilder. Clean simd. Clean optcse. Clean loopcloning. Clean copyprop. Clean optimizer part1. * Start cleaning importer, morph, flowgraph, gentree. * Continue clean functons. Clean assertionprop. Clean morph. Clean gentree. Clean flowgraph. Clean compiler. Clean rangecheck. Clean indirectcalltransofrmer. Clean others. * Create some temp stmt. * Delete unnecessary noway_assert and casts. * Init `impStmtList` and `impLastStmt` in release. * Response review 1.
2019-03-29Simplify and unify Vector64/128/256 platform-agnostic intrinsic handling ↵Fei Peng1-258/+8
(#23028) * Simplify and unify Vector64/128/256 platform-agnostic intrinsic handling * Removed unsupported ISAs
2019-03-28Struct & SIMD improvements (#22255)Carol Eidt1-27/+3
* [WIP] Struct & SIMD improvements - Enable CSE of struct values when handle is available (and add code to get the handle of HW SIMD types) - Don't require block nodes for SIMD assignments - Don't set `GTF_GLOB_REF` on `GT_OBJ` if it is local - Set `lvRegStruct` on promoted SIMD fields - Add tests for #19910 (fixed with this PR) and #3539 & #19438 (fixed with #21314) - Additional cleanup Fix #19910
2019-03-18Fix explicit constructor calls and Remove multi-line comments (#23162)Sinan Kaya1-16/+16
* fix implicit constructor call * extern c format patch * muti-line * Remove direct constructor call * Conversion * Need paranthesis * Return value on resize * declspec(Thread) * Ignore warnings for GCC * Formatting issues * Move cast to constant
2019-03-16Fix typo (#23300)Nikita Potapenko1-1/+1
.Net -> .NET
2019-03-08Fix handling of struct setup assignmentsCarol Eidt1-4/+14
In #22791 I was creating struct assignments with COMMAs on the rhs, but that isn't handled downstream. Fix #23059
2019-02-26Fix condition for calling EvalArgsToTempsCarol Eidt1-4/+5
`fgArgInfo::ArgsComplete()` checks for additional conditions requiring temps that are not checked for in the body of `fgMorphArgs()`. However, if there are no register args, it won't be called. Fix #19256
2019-02-23fix BSWAP16 intrinsic handling of signed values (#22666)Clinton Ingram1-1/+2
2019-02-21Enable the HWIntrinsic extension methods and remove the instance ↵Tanner Gooding1-727/+31
implementations (#22705) * Removing various S.R.I.Vector instance method APIs, since they should now be exposed as extension methods * Updating the JIT to recognize the S.R.I.Vector extension methods. * Updating various S.R.I.Vector test templates * Regenerating the S.R.I tests that are created from a template. * Fixing the numArgs for Base_Vector256_GetLower * Fixing the handling for `Base_VectorXXX_As` to normalize the struct type. * Adding the Base_Vector128_As intrinsics back for arm64
2019-02-20Removed some dead codeAndrew Au1-18/+7
2019-02-19Optimize Vector128/256<T>.Get/WithElement (#22353)Fei Peng1-0/+421
2019-02-04Disable PInvoke inlining within try regions on ARM64.Aditya Mandaleeka1-4/+6
2019-01-30Remove GTF_ADDR_ONSTACK and IsVarAddr.Eugene Rozenfeld1-7/+7
IsVarAddr was checking GTF_ADDR_ONSTACK to determine if the GT_ADDR node is an address of a local. This change removes both GTF_ADDR_ONSTACK and IsVarAddr and uses IsLocalAdrExpr instead. IsLocalAddrExpr uses opcodes to determine if GT_ADDR node is a local address. GTF_ADDR_ONSTACK flag is ancient, added before 2002 so I couldn't find the checkin that introduced it. I changed the assert to a check and an assignment since simplifications inside fgMorphArgs between https://github.com/dotnet/coreclr/blob/1a1e4c4d5a8030cb8d82a2e5b06c2ab357b92534/src/jit/morph.cpp#L3709 (which causes https://github.com/dotnet/coreclr/blob/1a1e4c4d5a8030cb8d82a2e5b06c2ab357b92534/src/jit/morph.cpp#L3057) and https://github.com/dotnet/coreclr/blob/1a1e4c4d5a8030cb8d82a2e5b06c2ab357b92534/src/jit/morph.cpp#L3790 may result in more GT_ADDR nodes recognized by IsLocalAdrExpr. x86 and x64 pmi frameworks had no code diffs and some gcinfo reductions (15 methods with gcinfo diffs in x86). Fixes #22190.
2019-01-24Fix importer spilling in the presence of assignment side effectsMike Danes1-28/+49
Atomic ops like GT_CMPXCHG and some HW intrinsic nodes act like assignements so impAppendStmt has to account for them. They can be top level nodes or they can appear in the RHS of a GT_ASG node that perhaps is not considered to have an assignment side effect itself.
2019-01-10Code Review feedbackBrian Sullivan1-5/+5
Change test priority to 0
2019-01-09Added ifdef for FEATURE_TAILCALL_OPTBrian Sullivan1-0/+2
2019-01-09jit formatBrian Sullivan1-3/+3
2019-01-09When performing devirtualization we can not do both an unboxing optimization ↵Brian Sullivan1-3/+22
and a tail call optimization Explicit tail calls are now checked for and blocked from performing an unboxing operation in impDevirtualizeCall If late devirtualization calls impDevirtualizeCall with an IMPLICIT_TAILCALL we will clear this flag if we decide to perform the unboxing operation.
2019-01-09Merge pull request #20772 from mikedn/ir-cleanupBruce Forstall1-12/+8
Some IR cleanup
2019-01-08Copy address-taken SIMD intrinsic (#21884)Carol Eidt1-7/+4
* Copy address-taken SIMD intrinsic This occurs, for example, when boxing the result of a SIMD intrinsic. This was being handled for the HW intrinsic case, but not the SIMD Vector intrinsics. Also, eliminate `OperIsSimdHWIntrisic` since it redundantly checks for the case of a SIMD result, even though it was always called in a context where the result is known to be a struct type. Fix #21854
2019-01-04JIT: encapsulate general checks for optimizationAndy Ayers1-19/+13
Add methods that answer the general question of whether or not the jit is optimizing the code it produces. Use this to replace composite checks for minopts and debug codegen (the two modes where the jit is not optimizing).
2019-01-03Fix Vector128/256 As<U> intrinsic recognition and exceptionFei Peng1-4/+8
2018-12-21Ensure that the S.N.Vector methods are marked as [Intrinsic] and that the ↵Tanner Gooding1-1/+1
attribute is respected by the runtime (#21601) * Updating the SIMD intrinsics to check for the `[Intrinsic]` attribute * Ensure that the existing Vector/Vector<T> intrinsic methods are marked as such. * Fixing Vector<T>.DotProduct and Vector.AndNot to be treated as intrinsic * Fixing `SIMDIntrinsicBitwiseAndNot` to swap the operands for XARCH
2018-12-21 Updating `FusedMultiplyAdd` for `System.Math` and `System.MathF` to use ↵Tanner Gooding1-8/+59
intrinsics when available. (#21602) * Removing the explicit value assignment to NamedIntrinsic enum values * Renaming NI_Math_Round/NI_MathF_Round to NI_System_Math_Round/NI_System_MathF_Round * Updating `FusedMultiplyAdd` for `System.Math` and `System.MathF` to use intrinsics when available
2018-12-16Enable object stack allocation in R2R mode.Eugene Rozenfeld1-54/+8
This change modified the importer to create GenTreeAllocObj node for box and newobj instead of a helper call in R2R mode. ObjectAllocator phase decides whether the object can be allocated on the stack or has to be created on the heap via a helper call. To trigger object stack allocation COMPlus_JitObjectStackAllocation has to be set (it's not set by default).
2018-12-12Merge pull request #21304 from CarolEidt/NonObjSIMDCarol Eidt1-33/+48
Don't require BLK nodes for SIMD
2018-12-12JIT: optimize unbox/unbox.any when type is known (#21501)Andy Ayers1-0/+53
Optimize away the unbox type test when the jit knows the type of object being unboxed and can resolve the type comparison at jit time. Closes #14473.
2018-12-10Don't require BLK nodes for SIMDCarol Eidt1-33/+48
Eliminate most cases where an OBJ or BLK node is required for SIMD values. The exception is the case where a value produced by an intrinsic (SIMD or HWIntrinsic) is used as an argument but the argument is of a different SIMD type (e.g. a different baseType),
2018-12-07Moving various Vector128/256 helper method to be implemented using other ↵Tanner Gooding1-13/+23
intrinsics (#21432) * Updating Vector128.CreateScalar and Vector256.CreateScalar to be implemented using other intrinsics * Updating Vector128.Equals and Vector256.Equals to be implemented using other intrinsics * Updating Vector256.WithLower, Vector256.GetUpper, and Vector256.WithUpper to be implemented using other intrinsics * Updating Vector128.Create(T) and Vector256.Create(T) to be implemented using other intrinsics * Fixing the `NI_Base_Vector256_As` intrinsics to only fold the cast if AVX is supported and add a clarifying comment to the Vector128/256.Equals code * Changing the various `*Software()` local functions in Vector128/256 to be `SoftwareFallback()`
2018-12-06Moving CreateScalarUnsafe, ToScalar, Vector128.ToVector256Unsafe, and ↵Tanner Gooding1-10/+161
Vector256.GetLower to be intrinsics (#21351) * Moving CreateScalarUnsafe, ToScalar, Vector128.ToVector256Unsafe, and Vector256.GetLower to be intrinsics * Adding containment support to the helper intrinsics
2018-12-06Guarded devirtualization foundations (#21270)Andy Ayers1-64/+356
Lay the groundwork for guarded devirtualization of virtual and interface calls in the jit. Introduce the notion of a guarded devirtualization candidate and identify these if regular devirtualization fails. Use simple heuristics to produce a class to guess for. Require that the method that would be invoked if the class guess is correct be a plausible inline candidate. Generalize the calli transformer to become an indirect call transformer. This runs after importation because it needs to introduce control flow and runs before inlining so that the new direct calls it introduces can be inlined. Implement the transformation to duplicate the call site, devirtualize on the side where the class is now known exactly, and turn the resulting direct call into an inline candidate. Add a motivation and design document.
2018-11-30Implement 64-bit-only intrinsicFei Peng1-4/+6
2018-11-29Don't treat the Vector64/128/256<T> helper methods as intrinsic if ↵Tanner Gooding1-1/+7
featureSIMD is disabled (#21274)