Skip to content

Commit 0a9d382

Browse files
Andres Madrid Uchayuri91
authored andcommitted
PartialExecuter: Handle cheerp_typed_ptrcast
cheerp_typed_ptrcast cannot be treated as a normal function call and cannot be skipped in visitOuter. Instead we need to track the pointer base and bit mask information for any instruction that rely on it.
1 parent b9b8890 commit 0a9d382

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

llvm/lib/CheerpWriter/PartialExecuter.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ class PartialInterpreter : public llvm::Interpreter {
485485
if (!calledFunc)
486486
return true;
487487

488+
if (calledFunc->getIntrinsicID() == Intrinsic::cheerp_typed_ptrcast)
489+
return false;
490+
488491
if (isAlreadyInCallStack(calledFunc))
489492
return true;
490493

@@ -1744,7 +1747,24 @@ void PartialInterpreter::visitOuter(FunctionData& data, llvm::Instruction& I)
17441747

17451748
//Iff it's a call, set up the next stack frame
17461749
if (CallInst* CI = dyn_cast<CallInst>(&I))
1750+
{
1751+
const Function* calledFunc = dyn_cast_or_null<Function>(cast<CallInst>(I).getCalledFunction());
1752+
if (calledFunc->getIntrinsicID() == Intrinsic::cheerp_typed_ptrcast)
1753+
{
1754+
Value* srcPtr = CI->getArgOperand(0);
1755+
BitMask strongBits = getBitMask(srcPtr);
1756+
GlobalVariable* ptrBase = getPointerBase(srcPtr);
1757+
if (isValueComputed(srcPtr))
1758+
{
1759+
GenericValue GV = getOperandValue(srcPtr);
1760+
assignToMaps(&I, strongBits, GV, ptrBase);
1761+
}
1762+
else
1763+
assignToMaps(&I, strongBits, ptrBase);
1764+
return;
1765+
}
17471766
forwardArgumentsToNextFrame(*CI);
1767+
}
17481768

17491769
//Dispatch to the Interpreter's visitor for the given Instructon
17501770
Interpreter::visit(I);

0 commit comments

Comments
 (0)