Skip to content
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

Introduce OptLevel() in jit #77465

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3285,7 +3285,7 @@ void CodeGen::genCall(GenTreeCall* call)

// If there is nothing next, that means the result is thrown away, so this value is not live.
// However, for minopts or debuggable code, we keep it live to support managed return value debugging.
if ((call->gtNext == nullptr) && !compiler->opts.MinOpts() && !compiler->opts.compDbgCode)
if ((call->gtNext == nullptr) && !compiler->opts.OptimizationDisabled() && !compiler->opts.compDbgCode)
Copy link
Contributor

@SingleAccretion SingleAccretion Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!compiler->opts.OptimizationDisabled()

Nit: the double negation is hard to read. Can these (there are a number of instances) be switched to OptimizationEnabled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but I didn't want to distract code reviewers with that. I think we'd better do it separately, for now it's easier to review because I simply replaced MinOpts with the same OptimizationDisabled so no need to validate it 🙂

{
gcInfo.gcMarkRegSetNpt(RBM_INTRET);
}
Expand Down
45 changes: 19 additions & 26 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,17 +1715,22 @@ void CodeGen::genGenerateMachineCode()

printf("; Emitting ");

if (compiler->compCodeOpt() == Compiler::SMALL_CODE)
switch (compiler->opts.OptLevel())
{
printf("SMALL_CODE");
}
else if (compiler->compCodeOpt() == Compiler::FAST_CODE)
{
printf("FAST_CODE");
}
else
{
printf("BLENDED_CODE");
case Compiler::OPT_MinOpts:
printf("MinOpts code");
break;
case Compiler::OPT_Quick:
printf("quick and small code");
break;
case Compiler::OPT_Blended:
printf("blended code");
break;
case Compiler::OPT_Speed:
printf("fast code");
break;
default:
unreached();
}

printf(" for ");
Expand Down Expand Up @@ -1799,26 +1804,14 @@ void CodeGen::genGenerateMachineCode()
printf("; OSR variant for entry point 0x%x\n", compiler->info.compILEntry);
}

if ((compiler->opts.compFlags & CLFLG_MAXOPT) == CLFLG_MAXOPT)
{
printf("; optimized code\n");
}
else if (compiler->opts.compDbgEnC)
if (compiler->opts.compDbgEnC)
{
printf("; EnC code\n");
}
else if (compiler->opts.compDbgCode)
{
printf("; debuggable code\n");
}
else if (compiler->opts.MinOpts())
{
printf("; MinOpts code\n");
}
else
{
printf("; unknown optimization flags\n");
}

if (compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_BBINSTR))
{
Expand Down Expand Up @@ -1880,12 +1873,12 @@ void CodeGen::genGenerateMachineCode()
// layout. This helps us generate smaller code, and allocate, after code generation, a smaller amount of
// memory from the VM.

genFinalizeFrame();
genFinalizeFrame(); //

GetEmitter()->emitBegFN(isFramePointerUsed()
#if defined(DEBUG)
,
(compiler->compCodeOpt() != Compiler::SMALL_CODE) &&
!compiler->opts.OptLevelIs(Compiler::OPT_Quick) &&
!compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT)
#endif
);
Expand Down Expand Up @@ -5312,7 +5305,7 @@ void CodeGen::genFinalizeFrame()
regMaskTP maskPushRegsInt = maskCalleeRegsPushed & ~maskPushRegsFloat;

if ((maskPushRegsFloat != RBM_NONE) ||
(compiler->opts.MinOpts() && (regSet.rsMaskResvd & maskCalleeRegsPushed & RBM_OPT_RSVD)))
(compiler->opts.OptimizationDisabled() && (regSet.rsMaskResvd & maskCalleeRegsPushed & RBM_OPT_RSVD)))
{
// Here we try to keep stack double-aligned before the vpush
if ((genCountBits(regSet.rsMaskPreSpillRegs(true) | maskPushRegsInt) % 2) != 0)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7084,7 +7084,7 @@ void CodeGen::genCall(GenTreeCall* call)

// If there is nothing next, that means the result is thrown away, so this value is not live.
// However, for minopts or debuggable code, we keep it live to support managed return value debugging.
if ((call->gtNext == nullptr) && !compiler->opts.MinOpts() && !compiler->opts.compDbgCode)
if ((call->gtNext == nullptr) && !compiler->opts.OptimizationDisabled() && !compiler->opts.compDbgCode)
{
gcInfo.gcMarkRegSetNpt(RBM_INTRET);
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9698,7 +9698,7 @@ void CodeGen::genFnEpilog(BasicBlock* block)
gcInfo.gcRegGCrefSetCur = GetEmitter()->emitInitGCrefRegs;
gcInfo.gcRegByrefSetCur = GetEmitter()->emitInitByrefRegs;

noway_assert(!compiler->opts.MinOpts() || isFramePointerUsed()); // FPO not allowed with minOpts
noway_assert(!compiler->opts.OptimizationDisabled() || isFramePointerUsed()); // FPO not allowed with minOpts

#ifdef DEBUG
genInterruptibleUsed = true;
Expand Down
Loading