@@ -8600,6 +8600,19 @@ void CodeGen::genFnEpilog(BasicBlock* block)
8600
8600
8601
8601
bool jmpEpilog = ((block->bbFlags & BBF_HAS_JMP) != 0 );
8602
8602
8603
+ GenTree* lastNode = block->lastNode ();
8604
+
8605
+ // Method handle and address info used in case of jump epilog
8606
+ CORINFO_METHOD_HANDLE methHnd = nullptr ;
8607
+ CORINFO_CONST_LOOKUP addrInfo;
8608
+ addrInfo.addr = nullptr ;
8609
+
8610
+ if (jmpEpilog && lastNode->gtOper == GT_JMP)
8611
+ {
8612
+ methHnd = (CORINFO_METHOD_HANDLE)lastNode->gtVal .gtVal1 ;
8613
+ compiler->info .compCompHnd ->getFunctionEntryPoint (methHnd, &addrInfo);
8614
+ }
8615
+
8603
8616
#ifdef _TARGET_ARM_
8604
8617
// We delay starting the unwind codes until we have an instruction which we know
8605
8618
// needs an unwind code. In particular, for large stack frames in methods without
@@ -8644,12 +8657,11 @@ void CodeGen::genFnEpilog(BasicBlock* block)
8644
8657
unwindStarted = true ;
8645
8658
}
8646
8659
8647
- #ifdef FEATURE_NGEN_RELOCS_OPTIMIZATIONS
8648
- #if !FEATURE_FASTTAILCALL
8649
- if (jmpEpilog)
8660
+ if (jmpEpilog && lastNode->gtOper == GT_JMP
8661
+ && addrInfo.accessType == IAT_RELPVALUE)
8650
8662
{
8651
- // In case of FEATURE_NGEN_RELOCS_OPTIMIZATIONS and IAT_RELPVALUE jump at the end is done using
8652
- // relative indirection, so, additional helper register is required.
8663
+ // IAT_RELPVALUE jump at the end is done using relative indirection, so,
8664
+ // additional helper register is required.
8653
8665
// We use LR just before it is going to be restored from stack, i.e.
8654
8666
//
8655
8667
// movw r12, laddr
@@ -8661,27 +8673,14 @@ void CodeGen::genFnEpilog(BasicBlock* block)
8661
8673
// ...
8662
8674
// bx r12
8663
8675
8664
- GenTree* jmpNode = block->lastNode ();
8665
-
8666
- noway_assert (jmpNode->gtOper == GT_JMP);
8676
+ regNumber indCallReg = REG_R12;
8677
+ regNumber vptrReg1 = REG_LR;
8667
8678
8668
- CORINFO_METHOD_HANDLE methHnd = (CORINFO_METHOD_HANDLE)jmpNode->gtVal .gtVal1 ;
8669
- CORINFO_CONST_LOOKUP addrInfo;
8670
- compiler->info .compCompHnd ->getFunctionEntryPoint (methHnd, &addrInfo);
8671
-
8672
- if (addrInfo.accessType == IAT_RELPVALUE)
8673
- {
8674
- regNumber indCallReg = REG_R12;
8675
- regNumber vptrReg1 = REG_LR;
8676
-
8677
- instGen_Set_Reg_To_Imm (EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t )addrInfo.addr );
8678
- getEmitter ()->emitIns_R_R (INS_mov, EA_PTRSIZE, vptrReg1, indCallReg);
8679
- getEmitter ()->emitIns_R_R_I (INS_ldr, EA_PTRSIZE, indCallReg, indCallReg, 0 );
8680
- getEmitter ()->emitIns_R_R (INS_add, EA_PTRSIZE, indCallReg, vptrReg1);
8681
- }
8679
+ instGen_Set_Reg_To_Imm (EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t )addrInfo.addr );
8680
+ getEmitter ()->emitIns_R_R (INS_mov, EA_PTRSIZE, vptrReg1, indCallReg);
8681
+ getEmitter ()->emitIns_R_R_I (INS_ldr, EA_PTRSIZE, indCallReg, indCallReg, 0 );
8682
+ getEmitter ()->emitIns_R_R (INS_add, EA_PTRSIZE, indCallReg, vptrReg1);
8682
8683
}
8683
- #endif // !FEATURE_FASTTAILCALL
8684
- #endif // FEATURE_NGEN_RELOCS_OPTIMIZATIONS
8685
8684
8686
8685
genPopCalleeSavedRegisters (jmpEpilog);
8687
8686
@@ -8709,15 +8708,13 @@ void CodeGen::genFnEpilog(BasicBlock* block)
8709
8708
8710
8709
if (jmpEpilog)
8711
8710
{
8712
- #ifdef _TARGET_ARMARCH_
8713
8711
hasTailCalls = true ;
8714
- #endif // _TARGET_ARMARCH_
8715
8712
8716
8713
noway_assert (block->bbJumpKind == BBJ_RETURN);
8717
8714
noway_assert (block->bbTreeList != nullptr );
8718
8715
8719
8716
/* figure out what jump we have */
8720
- GenTree* jmpNode = block-> lastNode () ;
8717
+ GenTree* jmpNode = lastNode;
8721
8718
#if !FEATURE_FASTTAILCALL
8722
8719
noway_assert (jmpNode->gtOper == GT_JMP);
8723
8720
#else // FEATURE_FASTTAILCALL
@@ -8736,10 +8733,8 @@ void CodeGen::genFnEpilog(BasicBlock* block)
8736
8733
{
8737
8734
// Simply emit a jump to the methodHnd. This is similar to a call so we can use
8738
8735
// the same descriptor with some minor adjustments.
8739
- CORINFO_METHOD_HANDLE methHnd = (CORINFO_METHOD_HANDLE)jmpNode->gtVal .gtVal1 ;
8740
-
8741
- CORINFO_CONST_LOOKUP addrInfo;
8742
- compiler->info .compCompHnd ->getFunctionEntryPoint (methHnd, &addrInfo);
8736
+ assert (methHnd != nullptr );
8737
+ assert (addrInfo.addr != nullptr )
8743
8738
8744
8739
#ifdef _TARGET_ARM_
8745
8740
emitter::EmitCallType callType;
0 commit comments