Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
Use LateNodeRef or EarlyNodeRef
Always SetExpandedEarly even in Optimised builds
Some formatting that keeps getting applied on save so presume it is wanted.
Remove TestDynamicInterfaceCastable as it uses a thunk pool and uses RhGetCommonStubAddress which we haven't implemented.
  • Loading branch information
yowl committed Oct 21, 2024
1 parent 6ad4423 commit 8e581c4
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 403 deletions.
8 changes: 0 additions & 8 deletions eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@
<CoreCLRAotSdkDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'aotsdk'))</CoreCLRAotSdkDir>
<CoreCLRBuildIntegrationDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'build'))</CoreCLRBuildIntegrationDir>

<<<<<<< HEAD
<!-- NativeAOT-LLVM: we set up cross-compilation for WASM differently from upstream. The upstream cross-compilation scheme
does not scale for local development because it requires you to build the same host tools for each target configuration.
E. g. you need to build the same Debug compiler 3 times if you want to compile code in Debug, Checked and Release. -->
<IlcConfig Condition="'$(IlcConfig)' == ''">$(CoreCLRConfiguration)</IlcConfig>
<CoreCLRCrossILCompilerDir Condition="'$(CoreCLRCrossILCompilerDir)' != '' and '$(TargetsWasm)' == 'true'">$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(HostOS).$(BuildArchitecture).$(IlcConfig)', 'ilc'))</CoreCLRCrossILCompilerDir>

<Crossgen2Dir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'crossgen2'))</Crossgen2Dir>
=======
<Crossgen2Dir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'crossgen2-published'))</Crossgen2Dir>
<Crossgen2InBuildDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'crossgen2'))</Crossgen2InBuildDir>
>>>>>>> runtime/main

<ToolsILLinkDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'ILLink.Tasks', '$(ToolsConfiguration)'))</ToolsILLinkDir>

Expand Down Expand Up @@ -71,7 +67,6 @@
<SingleFileHostSourcePath>$([MSBuild]::NormalizePath('$(CoreCLRArtifactsPath)', 'corehost', 'singlefilehost$(ExeSuffix)'))</SingleFileHostSourcePath>
</PropertyGroup>

<<<<<<< HEAD
<!-- Not a live build, but allow overriding the LKG ILCompiler package with a specific version. -->
<PropertyGroup Condition="'$(UseNativeAotForComponents)' == 'true' and '$(PublishAot)' == 'true' and '$(MicrosoftDotNetILCompilerVersion)' != ''">
<SuppressGenerateILCompilerExplicitPackageReferenceWarning>true</SuppressGenerateILCompilerExplicitPackageReferenceWarning>
Expand All @@ -82,9 +77,6 @@
</ItemGroup>

<Target Name="ResolveRuntimeFilesFromLocalBuild" Condition="$(TestBuildMode) != 'nativeaot'">
=======
<Target Name="ResolveRuntimeFilesFromLocalBuild">
>>>>>>> runtime/main
<Error Condition="!Exists('$(CoreCLRArtifactsPath)') and '$(RuntimeFlavor)' == 'CoreCLR'"
Text="The CoreCLR artifacts path does not exist '$(CoreCLRArtifactsPath)'. The 'clr' subset must be built before building this project. Configuration: '$(CoreCLRConfiguration)'. To use a different configuration, specify the 'RuntimeConfiguration' property." />
<Error Condition="!Exists('$(MonoArtifactsPath)') and '$(RuntimeFlavor)' == 'Mono'"
Expand Down
40 changes: 0 additions & 40 deletions eng/pipelines/runtimelab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,12 @@ extends:
platforms:
- windows_x64
jobParameters:
<<<<<<< HEAD
timeoutInMinutes: 300
buildArgs: -s clr.aot+libs -c debug -rc $(_BuildConfig)
=======
timeoutInMinutes: 200
buildArgs: -s clr+libs+clr.hosts+packs -c debug -rc $(_BuildConfig)
>>>>>>> runtime/main
postBuildSteps:
- template: /eng/pipelines/runtimelab/runtimelab-post-build-steps.yml
parameters:
<<<<<<< HEAD
librariesConfiguration: Debug
=======
creator: dotnet-bot
testRunNamePrefixSuffix: CoreCLR_$(_BuildConfig)
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
>>>>>>> runtime/main

#
# Build and test with Release libraries and Release runtime
Expand All @@ -118,37 +106,9 @@ extends:
- wasi_wasm_linux_x64_naot_llvm
- Browser_wasm_linux_x64_naot_llvm
jobParameters:
<<<<<<< HEAD
timeoutInMinutes: 300
buildArgs: -s clr.aot+libs -c $(_BuildConfig)
=======
timeoutInMinutes: 180
buildArgs: -s clr+libs+libs.tests+clr.hosts+packs -c $(_BuildConfig) /p:ArchiveTests=true
>>>>>>> runtime/main
postBuildSteps:
- template: /eng/pipelines/runtimelab/runtimelab-post-build-steps.yml
parameters:
<<<<<<< HEAD
librariesConfiguration: Release
=======
creator: dotnet-bot
testRunNamePrefixSuffix: Libraries_$(_BuildConfig)
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml

#
# Build and test libraries AllConfigurations
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: ${{ variables.debugOnPrReleaseOnRolling }}
platforms:
- windows_x64
jobParameters:
buildArgs: -test -s tools+libs+libs.tests -allConfigurations -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
nameSuffix: Libraries_AllConfigurations
timeoutInMinutes: 150
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
>>>>>>> runtime/main
13 changes: 9 additions & 4 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2643,7 +2643,7 @@ GenTree* Compiler::optVNBasedFoldExpr_Call_Memmove(GenTreeCall* call)

// if dstArg is not simple, we replace the arg directly with a temp assignment and
// continue using that temp - it allows us reliably extract all side effects.
GenTree* dst = fgMakeMultiUse(&dstArg->LateNodeRef());
GenTree* dst = fgMakeMultiUse(dstArg->GetLateNode() != nullptr ? &dstArg->LateNodeRef() : &dstArg->EarlyNodeRef());

// Now we're going to emit a chain of STOREIND via COMMA nodes.
// the very first tree is expected to be side-effects from the original call (including all args)
Expand Down Expand Up @@ -2714,7 +2714,8 @@ GenTree* Compiler::optVNBasedFoldExpr_Call(BasicBlock* block, GenTree* parent, G
{
// if castObjArg is not simple, we replace the arg with a temp assignment and
// continue using that temp - it allows us reliably extract all side effects
castObjArg = fgMakeMultiUse(&castObjCallArg->LateNodeRef());
castObjArg = fgMakeMultiUse(castObjCallArg->GetLateNode() != nullptr ? &castObjCallArg->LateNodeRef()
: &castObjCallArg->EarlyNodeRef());
return gtWrapWithSideEffects(castObjArg, call, GTF_ALL_EFFECT, true);
}

Expand All @@ -2731,7 +2732,10 @@ GenTree* Compiler::optVNBasedFoldExpr_Call(BasicBlock* block, GenTree* parent, G
{
// if castObjArg is not simple, we replace the arg with a temp assignment and
// continue using that temp - it allows us reliably extract all side effects
castObjArg = fgMakeMultiUse(&castObjCallArg->LateNodeRef());
castObjArg =
fgMakeMultiUse(castObjCallArg->GetLateNode() != nullptr ? &castObjCallArg->LateNodeRef()
: &castObjCallArg->EarlyNodeRef());
;
return gtWrapWithSideEffects(castObjArg, call, GTF_ALL_EFFECT, true);
}
}
Expand Down Expand Up @@ -5228,7 +5232,8 @@ GenTree* Compiler::optAssertionProp_Call(ASSERT_VALARG_TP assertions, GenTreeCal

// if castObjArg is not simple, we replace the arg with a temp assignment and
// continue using that temp - it allows us reliably extract all side effects
objArg = fgMakeMultiUse(&objCallArg->LateNodeRef());
objArg = fgMakeMultiUse(objCallArg->GetLateNode() != nullptr ? &objCallArg->LateNodeRef()
: &objCallArg->EarlyNodeRef());
objArg = gtWrapWithSideEffects(objArg, call, GTF_SIDE_EFFECT, true);
return optAssertionProp_Update(objArg, call, stmt);
}
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6892,15 +6892,10 @@ class Compiler
PhaseStatus fgCreateThrowHelperBlocks();

public:
<<<<<<< HEAD
#if defined(TARGET_WASM) // Accessed in llvmcodegen.cpp
static unsigned acdHelper(SpecialCodeKind codeKind);
#endif

AddCodeDsc* fgFindExcptnTarget(SpecialCodeKind kind, unsigned refData);
=======
>>>>>>> runtime/main

bool fgHasAddCodeDscMap() const { return fgAddCodeDscMap != nullptr; }
AddCodeDsc* fgFindExcptnTarget(SpecialCodeKind kind, BasicBlock* fromBlock);
bool fgUseThrowHelperBlocks();
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,16 @@ var_types Compiler::impImportCall(OPCODE opcode,
call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, di);
call->gtFlags |= GTF_CALL_VIRT_VTABLE;

// In consumeCallTarget we assume virtual vtable calls are expanded into gtControlExpr
#if !defined(TARGET_WASM)
if (opts.OptimizationEnabled())
{
#endif
// Mark this method to expand the virtual call target early in fgMorphCall
call->AsCall()->SetExpandedEarly();
#if !defined(TARGET_WASM)
}
#endif
break;
}

Expand Down
71 changes: 42 additions & 29 deletions src/coreclr/jit/llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

// TODO-LLVM-Upstream: figure out how to fix these warnings in LLVM headers.
#pragma warning(push)
#pragma warning (disable : 4242)
#pragma warning (disable : 4244)
#pragma warning (disable : 4459)
#pragma warning (disable : 4267)
#pragma warning(disable : 4242)
#pragma warning(disable : 4244)
#pragma warning(disable : 4459)
#pragma warning(disable : 4267)
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/Support/Signals.h"
#pragma warning(pop)
Expand Down Expand Up @@ -65,12 +65,22 @@ size_t HelperFuncInfo::GetSigArgCount(unsigned* callArgCount) const
return count;
}

bool Compiler::IsHfa(CORINFO_CLASS_HANDLE hClass) { return false; }
var_types Compiler::GetHfaType(CORINFO_CLASS_HANDLE hClass) { return TYP_UNDEF; }
unsigned Compiler::GetHfaCount(CORINFO_CLASS_HANDLE hClass) { return 0; }
bool Compiler::IsHfa(CORINFO_CLASS_HANDLE hClass)
{
return false;
}
var_types Compiler::GetHfaType(CORINFO_CLASS_HANDLE hClass)
{
return TYP_UNDEF;
}
unsigned Compiler::GetHfaCount(CORINFO_CLASS_HANDLE hClass)
{
return 0;
}

Llvm::Llvm(Compiler* compiler)
: m_pEECorInfo(*((void**)compiler->info.compCompHnd + 1)) // TODO-LLVM: hack. CorInfoImpl* is the first field of JitInterfaceWrapper.
: m_pEECorInfo(*((void**)compiler->info.compCompHnd + 1)) // TODO-LLVM: hack. CorInfoImpl* is the first field of
// JitInterfaceWrapper.
, m_context(GetSingleThreadedCompilationContext())
, _compiler(compiler)
, m_info(&compiler->info)
Expand Down Expand Up @@ -112,7 +122,7 @@ var_types Llvm::GetArgTypeForStructWasm(CORINFO_CLASS_HANDLE structHnd, structPa
{
// Note the managed and unmanaged ABIs are the same in terms of values, but do differ w.r.t by-ref
// parameter aliasing guarantees (native assumes no aliasing, we do not).
bool isPassedByRef;
bool isPassedByRef;
CorInfoType argType = getLlvmArgTypeForArg(CORINFO_TYPE_VALUECLASS, structHnd, &isPassedByRef);

*pPassKind = isPassedByRef ? Compiler::SPK_ByReference : Compiler::SPK_ByValue;
Expand All @@ -121,7 +131,7 @@ var_types Llvm::GetArgTypeForStructWasm(CORINFO_CLASS_HANDLE structHnd, structPa

var_types Llvm::GetReturnTypeForStructWasm(CORINFO_CLASS_HANDLE structHnd, structPassingKind* pPassKind)
{
bool isReturnByRef;
bool isReturnByRef;
CorInfoType retType = getLlvmReturnType(CORINFO_TYPE_VALUECLASS, structHnd, &isReturnByRef);
if (isReturnByRef)
{
Expand Down Expand Up @@ -354,8 +364,6 @@ bool Llvm::helperCallMayVirtuallyUnwind(CorInfoHelpFunc helperFunc) const
// Implemented in "CoreLib\src\Internal\Runtime\CompilerHelpers\SynchronizedMethodHelpers.cs".
{ FUNC(CORINFO_HELP_MON_ENTER) CORINFO_TYPE_VOID, { CORINFO_TYPE_CLASS, CORINFO_TYPE_BYREF }, HFIF_SS_ARG },
{ FUNC(CORINFO_HELP_MON_EXIT) CORINFO_TYPE_VOID, { CORINFO_TYPE_CLASS, CORINFO_TYPE_BYREF }, HFIF_SS_ARG },
{ FUNC(CORINFO_HELP_MON_ENTER_STATIC) CORINFO_TYPE_VOID, { CORINFO_TYPE_PTR, CORINFO_TYPE_BYREF }, HFIF_SS_ARG },
{ FUNC(CORINFO_HELP_MON_EXIT_STATIC) CORINFO_TYPE_VOID, { CORINFO_TYPE_PTR, CORINFO_TYPE_BYREF }, HFIF_SS_ARG },
{ FUNC(CORINFO_HELP_GETCLASSFROMMETHODPARAM) CORINFO_TYPE_PTR, { CORINFO_TYPE_NATIVEINT }, HFIF_SS_ARG },
{ FUNC(CORINFO_HELP_GETSYNCFROMCLASSHANDLE) CORINFO_TYPE_PTR, { CORINFO_TYPE_PTR }, HFIF_SS_ARG },

Expand Down Expand Up @@ -583,7 +591,7 @@ CorInfoType Llvm::getLlvmArgTypeForArg(CorInfoType argSigType, CORINFO_CLASS_HAN
// In essence, structs are passed by reference except if they are trivial wrappers of a primitive (scalar).
// We follow this rule for the native calling convention as well as the managed one.
//
bool isByRef = false;
bool isByRef = false;
CorInfoType argType = argSigType;
if (argSigType == CORINFO_TYPE_VALUECLASS)
{
Expand Down Expand Up @@ -624,8 +632,8 @@ CorInfoType Llvm::getLlvmReturnType(CorInfoType sigRetType, CORINFO_CLASS_HANDLE
return isByRef ? CORINFO_TYPE_VOID : returnType;
}

// When looking at a sigInfo from eeGetMethodSig we have CorInfoType(s) but when looking at lclVars we have LclVarDsc or var_type(s),
// This method exists to allow both to map to LLVM types.
// When looking at a sigInfo from eeGetMethodSig we have CorInfoType(s) but when looking at lclVars we have LclVarDsc or
// var_type(s), This method exists to allow both to map to LLVM types.
/* static */ CorInfoType Llvm::toCorInfoType(var_types type)
{
switch (type)
Expand Down Expand Up @@ -713,7 +721,7 @@ TargetAbiType Llvm::getAbiTypeForType(var_types type)
CORINFO_GENERIC_HANDLE Llvm::getSymbolHandleForHelperFunc(CorInfoHelpFunc helperFunc)
{
void* pIndirection = nullptr;
void* handle = _compiler->compGetHelperFtn(static_cast<CorInfoHelpFunc>(helperFunc), &pIndirection);
void* handle = _compiler->compGetHelperFtn(static_cast<CorInfoHelpFunc>(helperFunc), &pIndirection);
assert(pIndirection == nullptr);

return CORINFO_GENERIC_HANDLE(handle);
Expand All @@ -725,7 +733,7 @@ CORINFO_GENERIC_HANDLE Llvm::getSymbolHandleForClassToken(mdToken token)
CORINFO_RESOLVED_TOKEN resolvedToken;
_compiler->impResolveToken((BYTE*)&token, &resolvedToken, CORINFO_TOKENKIND_Class);

void* pIndirection = nullptr;
void* pIndirection = nullptr;
CORINFO_CLASS_HANDLE typeSymbolHandle = m_info->compCompHnd->embedClassHandle(resolvedToken.hClass, &pIndirection);
assert(pIndirection == nullptr);

Expand Down Expand Up @@ -778,11 +786,12 @@ const char* Llvm::GetAlternativeFunctionName()
return CallEEApi<EEAI_GetAlternativeFunctionName, const char*>(m_pEECorInfo);
}

CORINFO_GENERIC_HANDLE Llvm::GetExternalMethodAccessor(
CORINFO_METHOD_HANDLE methodHandle, const TargetAbiType* sig, int sigLength)
CORINFO_GENERIC_HANDLE Llvm::GetExternalMethodAccessor(CORINFO_METHOD_HANDLE methodHandle,
const TargetAbiType* sig,
int sigLength)
{
return CallEEApi<EEAI_GetExternalMethodAccessor, CORINFO_GENERIC_HANDLE>(
m_pEECorInfo, methodHandle, sig, sigLength);
return CallEEApi<EEAI_GetExternalMethodAccessor, CORINFO_GENERIC_HANDLE>(m_pEECorInfo, methodHandle, sig,
sigLength);
}

CORINFO_LLVM_DEBUG_TYPE_HANDLE Llvm::GetDebugTypeForType(CORINFO_CLASS_HANDLE typeHandle)
Expand Down Expand Up @@ -825,10 +834,13 @@ CORINFO_GENERIC_HANDLE Llvm::GetSparseVirtualUnwindInfo(CORINFO_LLVM_EH_CLAUSE*
return CallEEApi<EEAI_GetSparseVirtualUnwindInfo, CORINFO_GENERIC_HANDLE>(m_pEECorInfo, pClauses, count);
}

CORINFO_GENERIC_HANDLE Llvm::GetPreciseVirtualUnwindInfo(
unsigned* pAbsoluteValue, unsigned shadowFrameSize, CORINFO_LLVM_EH_CLAUSE* pClauses, int clauseCount)
CORINFO_GENERIC_HANDLE Llvm::GetPreciseVirtualUnwindInfo(unsigned* pAbsoluteValue,
unsigned shadowFrameSize,
CORINFO_LLVM_EH_CLAUSE* pClauses,
int clauseCount)
{
return CallEEApi<EEAI_GetPreciseVirtualUnwindInfo, CORINFO_GENERIC_HANDLE>(m_pEECorInfo, pAbsoluteValue, shadowFrameSize, pClauses, clauseCount);
return CallEEApi<EEAI_GetPreciseVirtualUnwindInfo, CORINFO_GENERIC_HANDLE>(m_pEECorInfo, pAbsoluteValue,
shadowFrameSize, pClauses, clauseCount);
}

bool Llvm::IsVirtualUnwindFrameVisible()
Expand All @@ -848,9 +860,9 @@ extern "C" DLLEXPORT int registerLlvmCallbacks(void** jitImports, void** jitExpo

memcpy(g_callbacks, jitImports, static_cast<int>(EEAI_Count) * sizeof(void*));

jitExports[CJAI_StartSingleThreadedCompilation] = (void*)&Llvm::StartSingleThreadedCompilation;
jitExports[CJAI_StartSingleThreadedCompilation] = (void*)&Llvm::StartSingleThreadedCompilation;
jitExports[CJAI_FinishSingleThreadedCompilation] = (void*)&Llvm::FinishSingleThreadedCompilation;
jitExports[CJAI_Count] = (void*)0x1234;
jitExports[CJAI_Count] = (void*)0x1234;

for (int i = 0; i < CJAI_Count; i++)
{
Expand All @@ -860,8 +872,9 @@ extern "C" DLLEXPORT int registerLlvmCallbacks(void** jitImports, void** jitExpo
return 1;
}

/* static */ SingleThreadedCompilationContext* Llvm::StartSingleThreadedCompilation(
const char* path, const char* triple, const char* dataLayout)
/* static */ SingleThreadedCompilationContext* Llvm::StartSingleThreadedCompilation(const char* path,
const char* triple,
const char* dataLayout)
{
SingleThreadedCompilationContext* context = new SingleThreadedCompilationContext(path);
context->Module.setTargetTriple(triple);
Expand All @@ -882,7 +895,7 @@ extern "C" DLLEXPORT int registerLlvmCallbacks(void** jitImports, void** jitExpo
}

std::error_code code;
StringRef outputFilePath = module.getName();
StringRef outputFilePath = module.getName();
if (JitConfig.JitCheckLlvmIR())
{
StringRef outputFilePathWithoutExtension = outputFilePath.take_front(outputFilePath.find_last_of('.'));
Expand Down
Loading

0 comments on commit 8e581c4

Please sign in to comment.