@@ -665,11 +665,23 @@ bool InstExpander::visitInstruction(Instruction& I) {
665665}
666666
667667bool InstExpander::visitRet (ReturnInst& RI) {
668- if (Value * V = RI.getReturnValue ())
668+ if (Value* V = RI.getReturnValue ())
669669 {
670- // TODO: Add 64-bit return value support when function/subroutine call is supported.
671670 IGC_ASSERT (nullptr != Emu);
672- IGC_ASSERT_MESSAGE (false == Emu->isInt64 (V), " TODO: NOT IMPLEMENTED YET!" );
671+ if (Emu->isInt64 (V))
672+ {
673+ Value* Lo = nullptr , *Hi = nullptr ;
674+ std::tie (Lo, Hi) = Emu->getExpandedValues (V);
675+ Type* V2I32Ty = Emu->getV2Int32Ty ();
676+ Value* NewVal = UndefValue::get (V2I32Ty);
677+ NewVal = IRB->CreateInsertElement (NewVal, Lo, IRB->getInt32 (0 ));
678+ NewVal = IRB->CreateInsertElement (NewVal, Hi, IRB->getInt32 (1 ));
679+ NewVal = IRB->CreateBitCast (NewVal, IRB->getInt64Ty ());
680+
681+ IRB->SetInsertPoint (&RI);
682+ (void ) IRB->CreateRet (NewVal);
683+ return true ;
684+ }
673685 }
674686 return false ;
675687}
@@ -1969,7 +1981,9 @@ bool InstExpander::visitCall(CallInst& Call) {
19691981 }
19701982 }
19711983 // Support for stack/indirect/subroutine calls
1972- else if (!F || F->hasFnAttribute (" visaStackCall" ) || F->hasFnAttribute (" UserSubroutine" ))
1984+ // Note: should use enableFunctionCall() without using attr checking.
1985+ else if ( !F || F->hasFnAttribute (" visaStackCall" ) || F->hasFnAttribute (" UserSubroutine" )
1986+ || Emu->CGC ->enableFunctionCall ())
19731987 {
19741988 auto * CallCopy = Call.clone ();
19751989 IGC_ASSERT (nullptr != CallCopy);
0 commit comments