Skip to content
Merged
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/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4516,7 +4516,7 @@ class Compiler
};

bool impIsPrimitive(CorInfoType type);
bool impILConsumesAddr(const BYTE* codeAddr);
bool impILConsumesAddr(const BYTE* codeAddr, const BYTE* codeEndp);

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

Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,11 +2310,10 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
// generate for this ldfld, and we require that we
// won't need the address of this local at all

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

if (notStruct && notLastInstr && notDebugCode && impILConsumesAddr(codeAddr + sz))
if (notLastInstr && notDebugCode && impILConsumesAddr(codeAddr + sz, codeEndp))
{
// We can skip the addrtaken, as next IL instruction consumes
// the address.
Expand Down
45 changes: 4 additions & 41 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,51 +50,16 @@ void Compiler::impPushOnStack(GenTree* tree, typeInfo ti)
// helper function that will tell us if the IL instruction at the addr passed
// by param consumes an address at the top of the stack. We use it to save
// us lvAddrTaken
bool Compiler::impILConsumesAddr(const BYTE* codeAddr)
bool Compiler::impILConsumesAddr(const BYTE* codeAddr, const BYTE* codeEndp)
{
assert(!compIsForInlining());

OPCODE opcode;

opcode = (OPCODE)getU1LittleEndian(codeAddr);

OPCODE opcode = impGetNonPrefixOpcode(codeAddr, codeEndp);
switch (opcode)
{
// case CEE_LDFLDA: We're taking this one out as if you have a sequence
// like
//
// ldloca.0
// ldflda whatever
//
// of a primitivelike struct, you end up after morphing with addr of a local
// that's not marked as addrtaken, which is wrong. Also ldflda is usually used
// for structs that contain other structs, which isnt a case we handle very
// well now for other reasons.

case CEE_LDFLD:
{
// We won't collapse small fields. This is probably not the right place to have this
// check, but we're only using the function for this purpose, and is easy to factor
// out if we need to do so.

CORINFO_RESOLVED_TOKEN resolvedToken;
impResolveToken(codeAddr + sizeof(int8_t), &resolvedToken, CORINFO_TOKENKIND_Field);

var_types lclTyp = JITtype2varType(info.compCompHnd->getFieldType(resolvedToken.hField));

// Preserve 'small' int types
if (!varTypeIsSmall(lclTyp))
{
lclTyp = genActualType(lclTyp);
}

if (varTypeIsSmall(lclTyp))
{
return false;
}

return true;
}

default:
break;
}
Expand Down Expand Up @@ -7062,9 +7027,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
return;
}

op1->ChangeType(TYP_BYREF);
op1->SetOper(GT_LCL_ADDR);
op1->AsLclFld()->SetLclOffs(0);
op1 = gtNewLclAddrNode(op1->AsLclVar()->GetLclNum(), 0, TYP_BYREF);
goto _PUSH_ADRVAR;
}

Expand Down
Loading