@@ -2835,6 +2835,22 @@ void LinearScan::buildInitialParamDef(const LclVarDsc* varDsc, regNumber paramRe
28352835 Interval* interval = getIntervalForLocalVar (varDsc->lvVarIndex );
28362836 const var_types regType = varDsc->GetRegisterType ();
28372837 SingleTypeRegSet mask = allRegs (regType);
2838+ #ifdef TARGET_AMD64
2839+ if (varTypeIsGC (regType))
2840+ {
2841+ #ifdef DEBUG
2842+ if (VERBOSE)
2843+ {
2844+ printf (" \n\n buildInitialParamDef : \n " );
2845+
2846+ // compiler->gtDispTree(tree, nullptr, nullptr, true);
2847+ printf (" (GC type)\n\n " );
2848+ }
2849+ #endif // DEBUG
2850+ assert ((mask & lowGprRegs) != RBM_NONE);
2851+ mask &= lowGprRegs;
2852+ }
2853+ #endif // TARGET_AMD64
28382854 if ((paramReg != REG_NA) && !stressInitialParamReg ())
28392855 {
28402856 // Set this interval as currently assigned to that register
@@ -3079,6 +3095,30 @@ RefPosition* LinearScan::BuildDef(GenTree* tree, SingleTypeRegSet dstCandidates,
30793095 interval->hasInterferingUses = true ;
30803096 // pendingDelayFree = false;
30813097 }
3098+ #ifdef TARGET_AMD64
3099+ if (varTypeIsGC (tree->TypeGet ()))
3100+ {
3101+ #ifdef DEBUG
3102+ if (VERBOSE)
3103+ {
3104+ printf (" \n\n BuildDef: tree : \n " );
3105+
3106+ compiler->gtDispTree (tree, nullptr , nullptr , true );
3107+ printf (" (GC type)\n\n " );
3108+ }
3109+ #endif // DEBUG
3110+ if (dstCandidates == RBM_NONE)
3111+ {
3112+ dstCandidates = lowGprRegs;
3113+ }
3114+ else
3115+ {
3116+ // If we have a candidate register, it must be a low GPR.
3117+ assert ((dstCandidates & lowGprRegs) != RBM_NONE);
3118+ dstCandidates &= lowGprRegs;
3119+ }
3120+ }
3121+ #endif // TARGET_AMD64
30823122 RefPosition* defRefPosition =
30833123 newRefPosition (interval, currentLoc + 1 , RefTypeDef, tree, dstCandidates, multiRegIdx);
30843124 if (tree->IsUnusedValue ())
@@ -4016,9 +4056,26 @@ void LinearScan::BuildStoreLocDef(GenTreeLclVarCommon* storeLoc,
40164056 {
40174057 defCandidates = allRegs (type);
40184058 }
4059+ #elif TARGET_AMD64
4060+ defCandidates = allRegs (type);
4061+ // if (varTypeIsGC(type))
4062+ if (varTypeUsesIntReg (type))
4063+ {
4064+ #ifdef DEBUG
4065+ if (VERBOSE)
4066+ {
4067+ printf (" \n\n BuildStoreLocDef : \n " );
4068+
4069+ // compiler->gtDispTree(tree, nullptr, nullptr, true);
4070+ printf (" (GC type)\n\n " );
4071+ }
4072+ #endif // DEBUG
4073+ assert ((defCandidates & lowGprRegs) != RBM_NONE);
4074+ defCandidates &= lowGprRegs;
4075+ }
40194076#else
40204077 defCandidates = allRegs (type);
4021- #endif // TARGET_X86
4078+ #endif
40224079
40234080 RefPosition* def = newRefPosition (varDefInterval, currentLoc + 1 , RefTypeDef, storeLoc, defCandidates, index);
40244081 if (varDefInterval->isWriteThru )
0 commit comments