Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3244072
Hide align behind a jmp
kunalspathak Oct 8, 2021
e7c0710
Fix a problem where curIG==0 and loop might be emitted in curIG, adju…
kunalspathak Oct 22, 2021
bd922aa
Add stress mode to emit int3 for xarch
kunalspathak Oct 22, 2021
4d0f912
Add stress mode to emit bkpt for arm64
kunalspathak Oct 22, 2021
8d64351
Add a loop align instruction placement phase
kunalspathak Oct 29, 2021
9b9b616
review comments
kunalspathak Oct 29, 2021
6302975
Change from unsigned short to unsigned
kunalspathak Oct 29, 2021
d20da6d
review comments around cleanup
kunalspathak Nov 10, 2021
c6a2d70
emitForceNewIG
kunalspathak Nov 10, 2021
e9c5eec
Remove emitPrevIG
kunalspathak Nov 10, 2021
c1c5db3
Revert change to forceNewIG for align instruction
kunalspathak Nov 10, 2021
b8a9742
Use loopAlignCandidates
kunalspathak Nov 11, 2021
db98ec2
Use loopHeadIG reference
kunalspathak Nov 11, 2021
5ab9edc
jit format
kunalspathak Nov 11, 2021
c8a9e01
Remove unneeded method
kunalspathak Nov 11, 2021
5bb1563
Misc changes
kunalspathak Nov 11, 2021
2c6e81d
Review feedback
kunalspathak Nov 12, 2021
bbc2ac5
Do not include align behind Jmp in PerfScore calculation
kunalspathak Nov 13, 2021
64bba41
jit format and fix a bug
kunalspathak Nov 15, 2021
1e24fcb
fix the loopCandidates == 0 scenario
kunalspathak Nov 15, 2021
b301fa5
Add unmarkLoopAlign(), add check for fgFirstBB
kunalspathak Nov 16, 2021
57759d0
merge conflict fix
kunalspathak Nov 16, 2021
ef0e859
Add missing }
kunalspathak Nov 16, 2021
976b253
Grammar nit
kunalspathak Nov 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
jit format
  • Loading branch information
kunalspathak committed Nov 16, 2021
commit 5ab9edcfcc197078d10ce8c2c845d0604ecf86a4
8 changes: 4 additions & 4 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6872,13 +6872,13 @@ class Compiler
bool fgHasLoops; // True if this method has any loops, set in fgComputeReachability

public:
LoopDsc* optLoopTable; // loop descriptor table
unsigned char optLoopCount; // number of tracked loops
LoopDsc* optLoopTable; // loop descriptor table
unsigned char optLoopCount; // number of tracked loops
unsigned char loopAlignCandidates; // number of loops identified for alignment

#ifdef DEBUG
unsigned char loopsAligned; // number of loops actually aligned
#endif // DEBUG
unsigned char loopsAligned; // number of loops actually aligned
#endif // DEBUG

bool optRecordLoop(BasicBlock* head,
BasicBlock* top,
Expand Down
11 changes: 6 additions & 5 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ void emitter::emitBegFN(bool hasFramePtr
/* We don't have any align instructions */

emitAlignList = emitAlignLastGroup = emitAlignLast = nullptr;
emitCurIGAlignList = nullptr;
emitCurIGAlignList = nullptr;
#endif

/* We have not recorded any live sets */
Expand Down Expand Up @@ -4867,7 +4867,7 @@ void emitter::emitLoopAlign(unsigned paddingBytes, bool isFirstAlign)
// For multiple align instructions, set the idaLoopHeadPredIG only for the
// first align instruction
id->idaLoopHeadPredIG = emitCurIG;
emitAlignLastGroup = id;
emitAlignLastGroup = id;
}
else
{
Expand Down Expand Up @@ -5275,7 +5275,7 @@ void emitter::emitLoopAlignAdjustments()

insGroup* loopHeadPredIG = alignInstr->idaLoopHeadPredIG;
insGroup* loopHeadIG = alignInstr->loopHeadIG();
insGroup* containingIG = alignInstr->idaIG;
insGroup* containingIG = alignInstr->idaIG;

JITDUMP(" Adjusting 'align' instruction in IG%02u that is targeted for IG%02u \n", containingIG->igNum,
loopHeadIG->igNum);
Expand Down Expand Up @@ -5430,7 +5430,8 @@ void emitter::emitLoopAlignAdjustments()
// 3b. If the loop already fits in minimum alignmentBoundary blocks, then return 0. // already best aligned
// 3c. return paddingNeeded.
//
unsigned emitter::emitCalculatePaddingForLoopAlignment(insGroup* loopHeadIG, size_t offset DEBUG_ARG(bool isAlignAdjusted))
unsigned emitter::emitCalculatePaddingForLoopAlignment(insGroup* loopHeadIG,
size_t offset DEBUG_ARG(bool isAlignAdjusted))
{
unsigned alignmentBoundary = emitComp->opts.compJitAlignLoopBoundary;

Expand Down Expand Up @@ -5578,7 +5579,7 @@ unsigned emitter::emitCalculatePaddingForLoopAlignment(insGroup* loopHeadIG, siz
// align instructions are emitted, this method will skip the 'align' instruction present
// in the same IG and return the first instruction that is present in next IG.
// Arguments:
// alignInstr - Current 'align' instruction for which next IG's first 'align' should be returned.
// alignInstr - Current 'align' instruction for which next IG's first 'align' should be returned.
//
emitter::instrDescAlign* emitter::emitAlignInNextIG(instrDescAlign* alignInstr)
{
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10050,7 +10050,8 @@ BYTE* emitter::emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst)
#ifdef DEBUG
if (validatePadding)
{
unsigned paddingNeeded = emitCalculatePaddingForLoopAlignment(((instrDescAlign*)id)->idaIG->igNext, (size_t)dst, true);
unsigned paddingNeeded =
emitCalculatePaddingForLoopAlignment(((instrDescAlign*)id)->idaIG->igNext, (size_t)dst, true);

// For non-adaptive, padding size is spread in multiple instructions, so don't bother checking
if (emitComp->opts.compJitAlignLoopAdaptive)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

void Compiler::optInit()
{
optLoopsMarked = false;
fgHasLoops = false;
optLoopsMarked = false;
fgHasLoops = false;
loopAlignCandidates = 0;

/* Initialize the # of tracked loops to 0 */
optLoopCount = 0;
optLoopTable = nullptr;

#ifdef DEBUG
loopsAligned = 0;
loopsAligned = 0;
#endif

/* Keep track of the number of calls and indirect calls made by this method */
Expand Down