@@ -669,11 +669,12 @@ void LegalizeMD::LegalizeLDIMM(IR::Instr * instr, IntConstType immed)
669669 // This is done by having the load be from a label operand, which is later
670670 // changed such that its offset is the correct value to ldimm
671671
672+ // InlineeCallInfo is encoded as ((offset into function) << 4) | (argCount & 0xF).
673+ // This will fit into 32 bits as long as the function has less than 2^26 instructions, which should be always.
674+
672675 // The assembly generated becomes something like
673676 // Label (offset:fake)
674677 // MOVZ DST, Label
675- // MOVK DST, Label
676- // MOVK DST, Label
677678 // MOVK DST, Label <- was the LDIMM
678679
679680 Assert (Security::DontEncode (instr->GetSrc1 ()));
@@ -689,15 +690,11 @@ void LegalizeMD::LegalizeLDIMM(IR::Instr * instr, IntConstType immed)
689690
690691 // We'll handle splitting this up to properly load the immediates now
691692 // Typically (and worst case) we'll need to load 64 bits.
692- IR::Instr* bits48_63 = IR::Instr::New (Js::OpCode::MOVZ, instr->GetDst (), target, IR::IntConstOpnd::New (48 , IRType::TyUint8, instr->m_func , true ), instr->m_func );
693- instr->InsertBefore (bits48_63);
694- IR::Instr* bits32_47 = IR::Instr::New (Js::OpCode::MOVK, instr->GetDst (), target, IR::IntConstOpnd::New (32 , IRType::TyUint8, instr->m_func , true ), instr->m_func );
695- instr->InsertBefore (bits32_47);
696- IR::Instr* bits16_31 = IR::Instr::New (Js::OpCode::MOVK, instr->GetDst (), target, IR::IntConstOpnd::New (16 , IRType::TyUint8, instr->m_func , true ), instr->m_func );
697- instr->InsertBefore (bits16_31);
693+ IR::Instr* bits0_15 = IR::Instr::New (Js::OpCode::MOVZ, instr->GetDst (), target, IR::IntConstOpnd::New (0 , IRType::TyUint8, instr->m_func , true ), instr->m_func );
694+ instr->InsertBefore (bits0_15);
698695
699696 instr->ReplaceSrc1 (target);
700- instr->SetSrc2 (IR::IntConstOpnd::New (0 , IRType::TyUint8, instr->m_func , true ));
697+ instr->SetSrc2 (IR::IntConstOpnd::New (16 , IRType::TyUint8, instr->m_func , true ));
701698 instr->m_opcode = Js::OpCode::MOVK;
702699
703700 instr->isInlineeEntryInstr = false ;
0 commit comments