Skip to content

Commit 4b0e51e

Browse files
committed
Diagnostic change only, to confirm whether a theory is correct or
not when chasing an error.
1 parent ed4d070 commit 4b0e51e

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

src/coreclr/jit/emit.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9122,11 +9122,22 @@ void emitter::emitNxtIG(bool extend)
91229122
// NOTE: It is expected that the GC effect of the removed instruction will be handled by the newly
91239123
// generated replacement(s).
91249124
//
9125-
void emitter::emitRemoveLastInstruction()
9125+
bool emitter::emitRemoveLastInstruction()
91269126
{
91279127
assert(emitLastIns != nullptr);
91289128
assert(emitLastInsIG != nullptr);
91299129

9130+
#ifdef TARGET_ARM64
9131+
// AJG - This is a temporary change, to prevent the first
9132+
// instruction in a group to be optimised away.
9133+
// This is for diagnostic and test purposes only.
9134+
9135+
if (emitCurIGinsCnt == 1)
9136+
{
9137+
return false;
9138+
}
9139+
#endif
9140+
91309141
JITDUMP("Removing saved instruction in %s:\n> ", emitLabelString(emitLastInsIG));
91319142
JITDUMPEXEC(dispIns(emitLastIns))
91329143

@@ -9175,6 +9186,8 @@ void emitter::emitRemoveLastInstruction()
91759186

91769187
emitLastIns = nullptr;
91779188
emitLastInsIG = nullptr;
9189+
9190+
return true;
91789191
}
91799192

91809193
/*****************************************************************************

src/coreclr/jit/emit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ class emitter
21812181
insGroup* emitSavIG(bool emitAdd = false);
21822182
void emitNxtIG(bool extend = false);
21832183

2184-
void emitRemoveLastInstruction();
2184+
bool emitRemoveLastInstruction();
21852185

21862186
bool emitCurIGnonEmpty()
21872187
{

src/coreclr/jit/emitarm64.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16219,24 +16219,32 @@ bool emitter::TryReplaceLdrStrWithPairInstr(
1621916219
}
1622016220

1622116221
// Remove the last instruction written.
16222-
emitRemoveLastInstruction();
16223-
16224-
// We need to scale the immediate value by the operand size.
16225-
// This is either the "old" immediate (for ascending) or the
16226-
// "current" immediate (for descending) register order.
16227-
if (optimizationOrder == eRO_ascending)
16228-
{
16229-
// The FIRST register is at the lower offset
16230-
emitIns_R_R_R_I(optIns, oldReg1Attr, oldReg1, reg1, reg2, oldImm * size, INS_OPTS_NONE, reg1Attr);
16231-
}
16232-
else
16222+
// This has been temporarily changed to allow the function
16223+
// to "refuse" to remove an instruction for diagnostic purposes only.
16224+
if (emitRemoveLastInstruction())
1623316225
{
16234-
// The SECOND register is at the lower offset
16235-
emitIns_R_R_R_I(optIns, reg1Attr, reg1, oldReg1, reg2, imm * size, INS_OPTS_NONE, oldReg1Attr);
16236-
}
16226+
// The above function can refuse to remove an emitted
16227+
// instruction, for diagnostic purposes only.
1623716228

16238-
// And now return true, to indicate that the second instruction descriptor is no longer to be emitted.
16239-
return true;
16229+
// It HAS removed an instruction this time.
16230+
16231+
// We need to scale the immediate value by the operand size.
16232+
// This is either the "old" immediate (for ascending) or the
16233+
// "current" immediate (for descending) register order.
16234+
if (optimizationOrder == eRO_ascending)
16235+
{
16236+
// The FIRST register is at the lower offset
16237+
emitIns_R_R_R_I(optIns, oldReg1Attr, oldReg1, reg1, reg2, oldImm * size, INS_OPTS_NONE, reg1Attr);
16238+
}
16239+
else
16240+
{
16241+
// The SECOND register is at the lower offset
16242+
emitIns_R_R_R_I(optIns, reg1Attr, reg1, oldReg1, reg2, imm * size, INS_OPTS_NONE, oldReg1Attr);
16243+
}
16244+
16245+
// And now return true, to indicate that the second instruction descriptor is no longer to be emitted.
16246+
return true;
16247+
}
1624016248
}
1624116249

1624216250
return false;

0 commit comments

Comments
 (0)