@@ -3420,6 +3420,20 @@ Function *SPIRVToLLVM::transFunction(SPIRVFunction *BF, unsigned AS) {
34203420 {FT->getParamType (0 ), FT->getParamType (2 )})
34213421 ->getName ();
34223422 }
3423+
3424+ // Special handling for spirv.llvm_umul_with_overflow_* functions
3425+ // These were created during forward translation by lowering intrinsics.
3426+ // During reverse translation, we replace them with intrinsic calls.
3427+ if (FuncNameRef.starts_with (" spirv.llvm_umul_with_overflow_" )) {
3428+ Type *OverloadTy = FT->getParamType (0 );
3429+ Function *F = Intrinsic::getDeclaration (M, Intrinsic::umul_with_overflow,
3430+ {OverloadTy});
3431+ F = cast<Function>(mapValue (BF, F));
3432+ mapFunction (BF, F);
3433+ return F; // Skip body translation - intrinsic will be used instead
3434+ }
3435+
3436+ // Normal function handling.
34233437 if (FuncNameRef.consume_front (" spirv." )) {
34243438 FuncNameRef.consume_back (" .volatile" );
34253439 FuncName = FuncNameRef.str ();
@@ -3428,21 +3442,12 @@ Function *SPIRVToLLVM::transFunction(SPIRVFunction *BF, unsigned AS) {
34283442 Function *F = M->getFunction (FuncName);
34293443 if (!F)
34303444 F = Function::Create (FT, Linkage, AS, FuncName, M);
3445+
34313446 F = cast<Function>(mapValue (BF, F));
34323447 mapFunction (BF, F);
34333448
34343449 if (F->isIntrinsic ()) {
3435- if (F->getIntrinsicID () != Intrinsic::umul_with_overflow)
3436- return F;
3437- std::string Name = F->getName ().str ();
3438- auto *ST = cast<StructType>(F->getReturnType ());
3439- auto *FT = F->getFunctionType ();
3440- auto *NewST = StructType::get (ST->getContext (), ST->elements ());
3441- auto *NewFT = FunctionType::get (NewST, FT->params (), FT->isVarArg ());
3442- F->setName (" old_" + Name);
3443- auto *NewFn = Function::Create (NewFT, F->getLinkage (), F->getAddressSpace (),
3444- Name, F->getParent ());
3445- return NewFn;
3450+ return F;
34463451 }
34473452
34483453 F->setCallingConv (IsKernel ? CallingConv::SPIR_KERNEL
0 commit comments