Skip to content

Commit a0e2b34

Browse files
committed
revert constrained. call part
1 parent cc37cdd commit a0e2b34

File tree

3 files changed

+13
-48
lines changed

3 files changed

+13
-48
lines changed

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4516,7 +4516,7 @@ class Compiler
45164516
};
45174517

45184518
bool impIsPrimitive(CorInfoType type);
4519-
bool impILConsumesAddr(const BYTE* codeAddr);
4519+
bool impILConsumesAddr(var_types typ, const BYTE* codeAddr, const BYTE* codeEndp);
45204520

45214521
void impResolveToken(const BYTE* addr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CorInfoTokenKind kind);
45224522

src/coreclr/jit/fgbasic.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
11351135
if (resolveTokens)
11361136
{
11371137
impResolveToken(codeAddr, &resolvedToken, CORINFO_TOKENKIND_Method);
1138-
methodHnd = resolvedToken.hMethod;
1138+
methodHnd = resolvedToken.hMethod;
1139+
11391140
isIntrinsic = eeIsIntrinsic(methodHnd);
11401141
}
11411142

@@ -2261,10 +2262,10 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
22612262
{
22622263
noway_assert(opcode == CEE_LDARGA || opcode == CEE_LDARGA_S);
22632264

2264-
varType = impInlineInfo->lclVarInfo[varNum].lclTypeInfo;
2265-
22662265
impInlineInfo->inlArgInfo[varNum].argHasLdargaOp = true;
22672266

2267+
varType = impInlineInfo->lclVarInfo[varNum].lclTypeInfo;
2268+
22682269
pushedStack.PushArgument(varNum);
22692270
handled = true;
22702271
}
@@ -2310,11 +2311,11 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
23102311
// generate for this ldfld, and we require that we
23112312
// won't need the address of this local at all
23122313

2313-
const bool notStruct = !varTypeIsStruct(lvaGetDesc(varNum));
23142314
const bool notLastInstr = (codeAddr < codeEndp - sz);
23152315
const bool notDebugCode = !opts.compDbgCode;
23162316

2317-
if (notStruct && notLastInstr && notDebugCode && impILConsumesAddr(codeAddr + sz))
2317+
if (notLastInstr && notDebugCode &&
2318+
impILConsumesAddr(lvaGetDesc(varNum)->TypeGet(), codeAddr + sz, codeEndp))
23182319
{
23192320
// We can skip the addrtaken, as next IL instruction consumes
23202321
// the address.

src/coreclr/jit/importer.cpp

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,51 +50,17 @@ void Compiler::impPushOnStack(GenTree* tree, typeInfo ti)
5050
// helper function that will tell us if the IL instruction at the addr passed
5151
// by param consumes an address at the top of the stack. We use it to save
5252
// us lvAddrTaken
53-
bool Compiler::impILConsumesAddr(const BYTE* codeAddr)
53+
bool Compiler::impILConsumesAddr(var_types typ, const BYTE* codeAddr, const BYTE* codeEndp)
5454
{
55-
assert(!compIsForInlining());
56-
57-
OPCODE opcode;
58-
59-
opcode = (OPCODE)getU1LittleEndian(codeAddr);
60-
55+
OPCODE opcode = impGetNonPrefixOpcode(codeAddr, codeEndp);
6156
switch (opcode)
6257
{
63-
// case CEE_LDFLDA: We're taking this one out as if you have a sequence
64-
// like
65-
//
66-
// ldloca.0
67-
// ldflda whatever
68-
//
69-
// of a primitivelike struct, you end up after morphing with addr of a local
70-
// that's not marked as addrtaken, which is wrong. Also ldflda is usually used
71-
// for structs that contain other structs, which isnt a case we handle very
72-
// well now for other reasons.
73-
7458
case CEE_LDFLD:
7559
{
76-
// We won't collapse small fields. This is probably not the right place to have this
77-
// check, but we're only using the function for this purpose, and is easy to factor
78-
// out if we need to do so.
79-
80-
CORINFO_RESOLVED_TOKEN resolvedToken;
81-
impResolveToken(codeAddr + sizeof(int8_t), &resolvedToken, CORINFO_TOKENKIND_Field);
82-
83-
var_types lclTyp = JITtype2varType(info.compCompHnd->getFieldType(resolvedToken.hField));
84-
85-
// Preserve 'small' int types
86-
if (!varTypeIsSmall(lclTyp))
87-
{
88-
lclTyp = genActualType(lclTyp);
89-
}
90-
91-
if (varTypeIsSmall(lclTyp))
92-
{
93-
return false;
94-
}
95-
96-
return true;
60+
// addr followed by LDFLD for non-struct types
61+
return !varTypeIsStruct(typ);
9762
}
63+
9864
default:
9965
break;
10066
}
@@ -7062,9 +7028,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
70627028
return;
70637029
}
70647030

7065-
op1->ChangeType(TYP_BYREF);
7066-
op1->SetOper(GT_LCL_ADDR);
7067-
op1->AsLclFld()->SetLclOffs(0);
7031+
op1 = gtNewLclAddrNode(op1->AsLclVar()->GetLclNum(), 0, TYP_BYREF);
70687032
goto _PUSH_ADRVAR;
70697033
}
70707034

0 commit comments

Comments
 (0)