-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: Remove BBJ_NONE #94239
JIT: Remove BBJ_NONE #94239
Changes from 15 commits
7d4cd5a
c5af52e
268d5ee
9e8d9a2
f3ae61f
e9184d9
596e9fe
7cdd02d
800777d
9a1ff5d
2e91bad
466b374
6f7d173
e6a04d5
43f50ae
4ea0dd0
0df9fdd
2c8c7a5
722f16a
10f82d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -603,6 +603,7 @@ void CodeGen::genCodeForBBlist() | |
noway_assert(genStackLevel == 0); | ||
|
||
#ifdef TARGET_AMD64 | ||
bool emitNop = false; | ||
// On AMD64, we need to generate a NOP after a call that is the last instruction of the block, in several | ||
// situations, to support proper exception handling semantics. This is mostly to ensure that when the stack | ||
// walker computes an instruction pointer for a frame, that instruction pointer is in the correct EH region. | ||
|
@@ -625,6 +626,11 @@ void CodeGen::genCodeForBBlist() | |
switch (block->GetJumpKind()) | ||
{ | ||
case BBJ_ALWAYS: | ||
// We might skip generating the jump via a peephole optimization. | ||
// If that happens, make sure a NOP is emitted as the last instruction in the block. | ||
emitNop = true; | ||
break; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we ever hit the case in the old code where we had There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added an |
||
case BBJ_THROW: | ||
case BBJ_CALLFINALLY: | ||
case BBJ_EHCATCHRET: | ||
|
@@ -635,20 +641,6 @@ void CodeGen::genCodeForBBlist() | |
case BBJ_EHFAULTRET: | ||
case BBJ_EHFILTERRET: | ||
// These are the "epilog follows" case, handled in the emitter. | ||
|
||
break; | ||
|
||
case BBJ_NONE: | ||
if (block->IsLast()) | ||
{ | ||
// Call immediately before the end of the code; we should never get here . | ||
instGen(INS_BREAKPOINT); // This should never get executed | ||
} | ||
else | ||
{ | ||
// We need the NOP | ||
instGen(INS_nop); | ||
} | ||
break; | ||
|
||
case BBJ_COND: | ||
|
@@ -738,13 +730,26 @@ void CodeGen::genCodeForBBlist() | |
|
||
#endif // !FEATURE_EH_FUNCLETS | ||
|
||
case BBJ_NONE: | ||
case BBJ_SWITCH: | ||
break; | ||
|
||
case BBJ_ALWAYS: | ||
#ifdef TARGET_XARCH | ||
{ | ||
// Peephole optimization: If this block jumps to the next one, skip emitting the jump | ||
// (unless we are jumping between hot/cold sections, or if we need the jump for EH reasons) | ||
// (Skip this if optimizations are disabled, unless the block shouldn't have a jump in the first place) | ||
if (block->CanRemoveJumpToNext(compiler)) | ||
{ | ||
#ifdef TARGET_AMD64 | ||
if (emitNop) | ||
{ | ||
instGen(INS_nop); | ||
} | ||
#endif // TARGET_AMD64 | ||
|
||
break; | ||
} | ||
#ifdef TARGET_XARCH | ||
// If a block was selected to place an alignment instruction because it ended | ||
// with a jump, do not remove jumps from such blocks. | ||
// Do not remove a jump between hot and cold regions. | ||
|
@@ -759,10 +764,10 @@ void CodeGen::genCodeForBBlist() | |
#endif // TARGET_AMD64 | ||
|
||
inst_JMP(EJ_jmp, block->GetJumpDest(), isRemovableJmpCandidate); | ||
} | ||
#else | ||
inst_JMP(EJ_jmp, block->GetJumpDest()); | ||
#endif // TARGET_XARCH | ||
} | ||
|
||
FALLTHROUGH; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5928,7 +5928,10 @@ class Compiler | |
|
||
bool fgIsThrow(GenTree* tree); | ||
|
||
public: | ||
bool fgInDifferentRegions(BasicBlock* blk1, BasicBlock* blk2); | ||
|
||
private: | ||
bool fgIsBlockCold(BasicBlock* block); | ||
|
||
GenTree* fgMorphCastIntoHelper(GenTree* tree, int helper, GenTree* oper); | ||
|
@@ -6508,7 +6511,7 @@ class Compiler | |
{ | ||
if (lpHead->NextIs(lpEntry)) | ||
{ | ||
assert(lpHead->bbFallsThrough()); | ||
assert(lpHead->bbFallsThrough() || lpHead->JumpsToNext()); | ||
assert(lpTop == lpEntry); | ||
return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to your PR, but it seems odd to me that we couldn't have a bottom-entered loop where |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, odd that the
DEBUG_ARG
shows up here since it was removed. I guess it will fix itself when you push a new merge commit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, those follow-up PRs I created caused a lot of merge conflicts that I plan to clean up today, so this should disappear.