14
14
#include " JitEEApi.Shared.cspp"
15
15
#include < new>
16
16
17
- // this breaks StringMap.h
18
- #undef NumItems
19
-
20
17
// TODO-LLVM-Upstream: figure out how to fix these warnings in LLVM headers.
21
18
#pragma warning(push)
22
19
#pragma warning(disable : 4146)
@@ -215,6 +212,27 @@ inline CallSiteFacts& operator |=(CallSiteFacts& a, CallSiteFacts b)
215
212
return a = static_cast <CallSiteFacts>(static_cast <int >(a) | static_cast <int >(b));
216
213
}
217
214
215
+ enum NodeOptimizationRequirement
216
+ {
217
+ NOR_NONE = 0 ,
218
+ NOR_SHADOW_TAILCALL = 1
219
+ };
220
+
221
+ inline NodeOptimizationRequirement& operator |=(NodeOptimizationRequirement& a, NodeOptimizationRequirement b)
222
+ {
223
+ return a = static_cast <NodeOptimizationRequirement>(static_cast <int >(a) | static_cast <int >(b));
224
+ }
225
+
226
+ inline NodeOptimizationRequirement& operator &=(NodeOptimizationRequirement& a, NodeOptimizationRequirement b)
227
+ {
228
+ return a = static_cast <NodeOptimizationRequirement>(static_cast <int >(a) & static_cast <int >(b));
229
+ }
230
+
231
+ inline NodeOptimizationRequirement operator ~(NodeOptimizationRequirement a)
232
+ {
233
+ return static_cast <NodeOptimizationRequirement>(~static_cast <int >(a));
234
+ }
235
+
218
236
struct ThrowHelperKey
219
237
{
220
238
unsigned ThrowIndex;
@@ -231,6 +249,14 @@ struct ThrowHelperKey
231
249
}
232
250
};
233
251
252
+ struct ThrowHelperCode
253
+ {
254
+ llvm::BasicBlock* LlvmBlock;
255
+ #ifdef DEBUG
256
+ bool ShadowTailCalledThrowHelper;
257
+ #endif // DEBUG
258
+ };
259
+
234
260
struct PhiPair
235
261
{
236
262
GenTreeLclVar* StoreNode;
@@ -330,7 +356,7 @@ class Llvm
330
356
llvm::IRBuilder<> _builder;
331
357
JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, Value*> _sdsuMap;
332
358
JitHashTable<SSAName, SSAName, Value*> _localsMap;
333
- JitHashTable<ThrowHelperKey, ThrowHelperKey, llvm::BasicBlock* > m_throwHelperBlocksMap;
359
+ JitHashTable<ThrowHelperKey, ThrowHelperKey, ThrowHelperCode > m_throwHelperBlocksMap;
334
360
jitstd::vector<PhiPair> m_phiPairs;
335
361
FunctionInfo* m_functions;
336
362
@@ -361,6 +387,10 @@ class Llvm
361
387
unsigned m_preciseVirtualUnwindFrameLclNum = BAD_VAR_NUM;
362
388
unsigned _llvmArgCount = 0 ;
363
389
390
+ #ifdef DEBUG
391
+ JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, NodeOptimizationRequirement> m_optimizationRequirements;
392
+ #endif // DEBUG
393
+
364
394
// ================================================================================================================
365
395
// | General |
366
396
// ================================================================================================================
@@ -369,6 +399,7 @@ class Llvm
369
399
Llvm (Compiler* compiler);
370
400
371
401
static void ConfigureDiagnosticOutput ();
402
+ bool EnableVerboseDump ();
372
403
373
404
var_types GetArgTypeForStructWasm (CORINFO_CLASS_HANDLE structHnd, structPassingKind* pPassKind);
374
405
var_types GetReturnTypeForStructWasm (CORINFO_CLASS_HANDLE structHnd, structPassingKind* pPassKind);
@@ -425,6 +456,10 @@ class Llvm
425
456
bool IsVirtualUnwindFrameVisible ();
426
457
void GetJitTestInfo (CorInfoLlvmJitTestKind kind, CORINFO_LLVM_JIT_TEST_INFO* pInfo);
427
458
459
+ void ImposeOptimizationRequirement (GenTree* node, NodeOptimizationRequirement requirement);
460
+ void SatisfyOptimizationRequirement (GenTree* node, NodeOptimizationRequirement requirement);
461
+ void VerifyAllOptimizationRequirementsSatisfied ();
462
+
428
463
// ================================================================================================================
429
464
// | Type system |
430
465
// ================================================================================================================
@@ -495,9 +530,8 @@ class Llvm
495
530
void lowerDissolveDependentlyPromotedLocals ();
496
531
void dissolvePromotedLocal (unsigned lclNum);
497
532
498
- void lowerCanonicalizeFirstBlock ();
499
533
bool isFirstBlockCanonical ();
500
- void lowerAndInsertIntoFirstBlock (LIR::Range& range, GenTree* insertAfter = nullptr );
534
+ GenTree* lowerAndInsertIntoFirstBlock (LIR::Range& range, GenTree* insertAfter = nullptr );
501
535
502
536
public:
503
537
PhaseStatus AddVirtualUnwindFrame ();
@@ -543,7 +577,8 @@ class Llvm
543
577
544
578
unsigned getShadowFrameSize (unsigned funcIdx) const ;
545
579
unsigned getCalleeShadowStackOffset (unsigned funcIdx, bool isTailCall) const ;
546
- bool canEmitCallAsShadowTailCall (bool callIsInTry, bool callIsInFilter DEBUGARG (const char ** pReasonWhyNot)) const ;
580
+ bool canEmitCallAsShadowTailCall (
581
+ bool callIsInTry, bool callIsInFilter DEBUGARG (const char ** pReasonWhyNot = nullptr )) const ;
547
582
bool isPotentialGcSafePoint (GenTree* node) const ;
548
583
bool isShadowFrameLocal (LclVarDsc* varDsc) const ;
549
584
bool isShadowStackLocal (unsigned lclNum) const ;
@@ -621,19 +656,21 @@ class Llvm
621
656
void buildCallFinally (BasicBlock* block);
622
657
623
658
Value* consumeAddressAndEmitNullCheck (GenTreeIndir* indir);
624
- void emitNullCheckForAddress (GenTree* addr, Value* addrValue);
625
- void emitAlignmentCheckForAddress (GenTree* addr, Value* addrValue, unsigned alignment);
659
+ void emitNullCheckForAddress (GenTree* addr, Value* addrValue DEBUGARG (GenTree* indir) );
660
+ void emitAlignmentCheckForAddress (GenTree* addr, Value* addrValue, unsigned alignment DEBUGARG (GenTree* indir) );
626
661
bool isAddressAligned (GenTree* addr, unsigned alignment);
627
662
628
663
Value* consumeInitVal (GenTree* initVal);
629
664
void storeObjAtAddress (Value* baseAddress, Value* data, StructDesc* structDesc);
630
665
unsigned buildMemCpy (Value* baseAddress, unsigned startOffset, unsigned endOffset, Value* srcAddress);
631
666
632
- void emitJumpToThrowHelper (Value* jumpCondValue, CorInfoHelpFunc helperFunc);
633
- Value* emitCheckedArithmeticOperation (llvm::Intrinsic::ID intrinsicId, Value* op1Value, Value* op2Value);
667
+ void emitJumpToThrowHelper (Value* jumpCondValue, CorInfoHelpFunc helperFunc DEBUGARG (GenTree* nodeThrowing));
668
+ Value* emitCheckedArithmeticOperation (
669
+ llvm::Intrinsic::ID intrinsicId, Value* op1Value, Value* op2Value DEBUGARG (GenTree* opNode));
634
670
635
671
llvm::CallBase* emitGcStressCall (GenTreeCall* call, llvm::CallBase* callValue);
636
- llvm::CallBase* emitHelperCall (CorInfoHelpFunc helperFunc, ArrayRef<Value*> sigArgs = {});
672
+ llvm::CallBase* emitHelperCall (
673
+ CorInfoHelpFunc helperFunc, ArrayRef<Value*> sigArgs = {} DEBUGARG(bool * pIsShadowTailCall = nullptr ));
637
674
bool canEmitHelperCallAsShadowTailCall (CorInfoHelpFunc helperFunc);
638
675
llvm::CallBase* emitCallOrInvoke (llvm::FunctionCallee callee, ArrayRef<Value*> args, CallSiteFacts facts);
639
676
0 commit comments