Skip to content

Commit

Permalink
Merge branch 'main' into pr-wasm-plinq-wip
Browse files Browse the repository at this point in the history
  • Loading branch information
radekdoulik authored Jan 10, 2024
2 parents abf27e0 + 4d34799 commit 6d85a1e
Show file tree
Hide file tree
Showing 87 changed files with 1,503 additions and 1,774 deletions.
3 changes: 3 additions & 0 deletions eng/testing/RunnerTemplate.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ if %_exit_code%==1 (
)
)

if "%HELIX_CORRELATION_PAYLOAD%"=="" (
GOTO SKIP_XUNITLOGCHECKER
)
if NOT "%__IsXUnitLogCheckerSupported%"=="1" (
echo XUnitLogChecker not supported for this test case. Skipping.
GOTO SKIP_XUNITLOGCHECKER
Expand Down
4 changes: 3 additions & 1 deletion eng/testing/RunnerTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ if [ -n "$HELIX_WORKITEM_PAYLOAD" ]; then

fi

if [[ -z "$__IsXUnitLogCheckerSupported" ]]; then
if [[ -z "$HELIX_CORRELATION_PAYLOAD" ]]; then
: # Skip XUnitLogChecker execution
elif [[ -z "$__IsXUnitLogCheckerSupported" ]]; then
echo "The '__IsXUnitLogCheckerSupported' env var is not set."
elif [[ "$__IsXUnitLogCheckerSupported" != "1" ]]; then
echo "XUnitLogChecker not supported for this test case. Skipping."
Expand Down
3 changes: 2 additions & 1 deletion eng/testing/tests.ioslike.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
</PropertyGroup>

<PropertyGroup Condition="'$(BuildTestsOnHelix)' == 'true'">
<_AOTBuildCommand>export PATH=$HELIX_CORRELATION_PAYLOAD/build/cmake/cmake-3.16.4-Darwin-x86_64/CMake.app/Contents/bin:$PATH &amp;&amp; </_AOTBuildCommand>
<_AOTBuildCommand>export PATH=$HELIX_CORRELATION_PAYLOAD/build/cmake/cmake-3.28.0-macos-universal/CMake.app/Contents/bin:$PATH &amp;&amp; </_AOTBuildCommand>
<_AOTBuildCommand>$(_AOTBuildCommand) dotnet msbuild publish/ProxyProjectForAOTOnHelix.proj /bl:$XHARNESS_OUT/AOTBuild.binlog</_AOTBuildCommand>

<!-- running aot-helix tests locally, so we can test with the same project file as CI -->
<_AOTBuildCommand Condition="'$(ContinuousIntegrationBuild)' != 'true'">$(_AOTBuildCommand) /p:RuntimeSrcDir=$(RepoRoot) /p:RuntimeConfig=$(Configuration)</_AOTBuildCommand>
<!-- The command below sets default properties for runtime and library tests -->
<_AOTBuildCommand>$(_AOTBuildCommand) /p:XHARNESS_EXECUTION_DIR=&quot;$XHARNESS_EXECUTION_DIR&quot; /p:RunAOTCompilation=$(RunAOTCompilation) /p:UseNativeAOTRuntime=$(UseNativeAOTRuntime) /p:TargetOS=$(TargetOS) /p:TargetArchitecture=$(TargetArchitecture) /p:MonoForceInterpreter=$(MonoForceInterpreter) /p:MonoEnableLLVM=true /p:DevTeamProvisioning=$(DevTeamProvisioning) /p:UsePortableRuntimePack=true /p:Configuration=$(Configuration)</_AOTBuildCommand>
<_AOTBuildCommand Condition="'$(NativeLib)' != ''">$(_AOTBuildCommand) /p:NativeLib=$(NativeLib) /p:BundlesResources=$(BundlesResources) /p:ForceLibraryModeGenerateAppBundle=$(ForceLibraryModeGenerateAppBundle)</_AOTBuildCommand>
<_AOTBuildCommand>$(_AOTBuildCommand) </_AOTBuildCommand>

<_ResetSimulatorSwitch Condition="('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvossimulator') and '$(IncludesTestRunner)' == 'true'">--reset-simulator</_ResetSimulatorSwitch>
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5857,6 +5857,11 @@ void Compiler::RecomputeFlowGraphAnnotations()
m_dfsTree = fgComputeDfs();
optFindNewLoops();

if (fgHasLoops)
{
optFindAndScaleGeneralLoopBlocks();
}

m_domTree = FlowGraphDominatorTree::Build(m_dfsTree);

// Dominators and the loop table are computed above for old<->new loop
Expand Down
21 changes: 3 additions & 18 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5981,8 +5981,6 @@ class Compiler

PhaseStatus fgCanonicalizeFirstBB();

bool fgCreateLoopPreHeader(unsigned lnum);

void fgSetEHRegionForNewLoopHead(BasicBlock* newHead, BasicBlock* top);

void fgUnreachableBlock(BasicBlock* block);
Expand Down Expand Up @@ -6864,6 +6862,9 @@ class Compiler

void optFindLoops();
void optFindNewLoops();
bool optCanonicalizeLoops(FlowGraphNaturalLoops* loops);
bool optCreatePreheader(FlowGraphNaturalLoop* loop);
void optSetPreheaderWeight(FlowGraphNaturalLoop* loop, BasicBlock* preheader);

PhaseStatus optCloneLoops();
void optCloneLoop(FlowGraphNaturalLoop* loop, LoopCloneContext* context);
Expand Down Expand Up @@ -7165,22 +7166,6 @@ class Compiler

void optFindNaturalLoops();

// Ensures that all the loops in the loop nest rooted at "loopInd" (an index into the loop table) are 'canonical' --
// each loop has a unique "top." Returns "true" iff the flowgraph has been modified.
bool optCanonicalizeLoopNest(unsigned char loopInd);

// Ensures that the loop "loopInd" (an index into the loop table) is 'canonical' -- it has a unique "top,"
// unshared with any other loop. Returns "true" iff the flowgraph has been modified
bool optCanonicalizeLoop(unsigned char loopInd);

enum class LoopCanonicalizationOption
{
Outer,
Current
};

bool optCanonicalizeLoopCore(unsigned char loopInd, LoopCanonicalizationOption option);

// Requires "l1" to be a valid loop table index, and not "BasicBlock::NOT_IN_LOOP".
// Requires "l2" to be a valid loop table index, or else "BasicBlock::NOT_IN_LOOP".
// Returns true iff "l2" is not NOT_IN_LOOP, and "l1" contains "l2".
Expand Down
24 changes: 20 additions & 4 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ class emitter
// TODO-Cleanup: We should really add a DEBUG-only tag to this union so we can add asserts
// about reading what we think is here, to avoid unexpected corruption issues.

#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64)
#if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64)
emitLclVarAddr iiaLclVar;
#endif
BasicBlock* iiaBBlabel;
Expand Down Expand Up @@ -990,7 +990,7 @@ class emitter
regNumber _idReg3 : REGNUM_BITS;
regNumber _idReg4 : REGNUM_BITS;
};
#elif defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
#elif defined(TARGET_LOONGARCH64)
struct
{
unsigned int iiaEncodedInstr; // instruction's binary encoding.
Expand Down Expand Up @@ -1021,7 +1021,23 @@ class emitter
{
return iiaJmpOffset;
}
#endif // defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
#elif defined(TARGET_RISCV64)
struct
{
regNumber _idReg3 : REGNUM_BITS;
regNumber _idReg4 : REGNUM_BITS;
unsigned int iiaEncodedInstr; // instruction's binary encoding.
};

void iiaSetInstrEncode(unsigned int encode)
{
iiaEncodedInstr = encode;
}
unsigned int iiaGetInstrEncode() const
{
return iiaEncodedInstr;
}
#endif // defined(TARGET_RISCV64)

} _idAddrUnion;

Expand Down Expand Up @@ -1123,7 +1139,7 @@ class emitter
}

#elif defined(TARGET_LOONGARCH64)
unsigned idCodeSize() const
unsigned idCodeSize() const
{
return _idCodeSize;
}
Expand Down
31 changes: 20 additions & 11 deletions src/coreclr/jit/emitriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,9 @@ void emitter::emitIns_R_R(
void emitter::emitIns_R_R_I(
instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, ssize_t imm, insOpts opt /* = INS_OPTS_NONE */)
{
code_t code = emitInsCode(ins);
code_t code = emitInsCode(ins);
instrDesc* id = emitNewInstr(attr);

if ((INS_addi <= ins && INS_srai >= ins) || (INS_addiw <= ins && INS_sraiw >= ins) ||
(INS_lb <= ins && INS_lhu >= ins) || INS_ld == ins || INS_lw == ins || INS_jalr == ins || INS_fld == ins ||
INS_flw == ins)
Expand Down Expand Up @@ -688,6 +690,8 @@ void emitter::emitIns_R_R_I(
code |= ((imm >> 1) & 0xf) << 8;
code |= ((imm >> 5) & 0x3f) << 25;
code |= ((imm >> 12) & 0x1) << 31;
// TODO-RISCV64: Move jump logic to emitIns_J
id->idAddr()->iiaSetInstrCount(imm / sizeof(code_t));
}
else if (ins == INS_csrrs || ins == INS_csrrw || ins == INS_csrrc)
{
Expand All @@ -702,7 +706,6 @@ void emitter::emitIns_R_R_I(
{
NYI_RISCV64("illegal ins within emitIns_R_R_I!");
}
instrDesc* id = emitNewInstr(attr);

id->idIns(ins);
id->idReg1(reg1);
Expand Down Expand Up @@ -2124,8 +2127,8 @@ void emitter::emitOutputInstrJumpDistanceHelper(const insGroup* ig,
UNATIVE_OFFSET& dstOffs,
const BYTE*& dstAddr) const
{
// TODO-RISCV64-BUG: iiaEncodedInstrCount is not set by the riscv impl making distinguishing the jumps to label and
// an instruction-count based jumps impossible
// TODO-RISCV64-BUG: Currently the iiaEncodedInstrCount is not set by the riscv impl making distinguishing the jump
// to label and an instruction-count based jumps impossible
if (jmp->idAddr()->iiaHasInstrCount())
{
assert(ig != nullptr);
Expand All @@ -2136,7 +2139,7 @@ void emitter::emitOutputInstrJumpDistanceHelper(const insGroup* ig,
// Backward branches using instruction count must be within the same instruction group.
assert(insNum + 1 >= static_cast<unsigned>(-instrCount));
}
dstOffs = ig->igOffs + emitFindOffset(ig, (insNum + 1 + instrCount));
dstOffs = ig->igOffs + emitFindOffset(ig, insNum + 1 + instrCount);
dstAddr = emitOffsetToPtr(dstOffs);
return;
}
Expand Down Expand Up @@ -2989,19 +2992,25 @@ bool emitter::emitDispBranchInstrType(unsigned opcode2) const

void emitter::emitDispBranchOffset(const instrDesc* id, const insGroup* ig) const
{
static const auto signFn = [](int offset) { return offset >= 0 ? "+" : ""; };

int instrCount = id->idAddr()->iiaGetInstrCount();
if (ig == nullptr)
{
printf("pc%s%d instructions", signFn(instrCount), instrCount);
printf("pc%+d instructions", instrCount);
return;
}
unsigned insNum = emitFindInsNum(ig, id);
unsigned insNum = emitFindInsNum(ig, id);

if (ig->igInsCnt < insNum + 1 + instrCount)
{
// TODO-RISCV64-BUG: This should be a labeled offset but does not contain an iiaIGlabel
printf("pc%+d instructions", instrCount);
return;
}

UNATIVE_OFFSET srcOffs = ig->igOffs + emitFindOffset(ig, insNum + 1);
UNATIVE_OFFSET dstOffs = ig->igOffs + emitFindOffset(ig, insNum + 1 + instrCount);
ssize_t relOffs = static_cast<ssize_t>(emitOffsetToPtr(dstOffs) - emitOffsetToPtr(dstOffs));
printf("pc%s%d (%d instructions)", signFn(relOffs), static_cast<int>(relOffs), instrCount);
ssize_t relOffs = static_cast<ssize_t>(emitOffsetToPtr(dstOffs) - emitOffsetToPtr(srcOffs));
printf("pc%+d (%d instructions)", static_cast<int>(relOffs), instrCount);
}

void emitter::emitDispBranchLabel(const instrDesc* id) const
Expand Down
15 changes: 15 additions & 0 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4783,6 +4783,21 @@ void Compiler::fgDebugCheckSsa()
//
void Compiler::fgDebugCheckLoopTable()
{
if ((m_loops != nullptr) && optLoopsRequirePreHeaders)
{
for (FlowGraphNaturalLoop* loop : m_loops->InReversePostOrder())
{
// TODO-Quirk: Remove
if (!loop->GetHeader()->HasFlag(BBF_OLD_LOOP_HEADER_QUIRK))
{
continue;
}

assert(loop->EntryEdges().size() == 1);
assert(loop->EntryEdge(0)->getSourceBlock()->KindIs(BBJ_ALWAYS));
}
}

#ifdef DEBUG
if (!optLoopTableValid)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/loopcloning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3169,7 +3169,7 @@ PhaseStatus Compiler::optCloneLoops()
fgRenumberBlocks();

m_dfsTree = fgComputeDfs();
optFindNewLoops();
m_loops = FlowGraphNaturalLoops::Find(m_dfsTree);
}

#ifdef DEBUG
Expand Down
Loading

0 comments on commit 6d85a1e

Please sign in to comment.