@@ -957,8 +957,15 @@ static Type* getIntrinsicParamType(
957957 case AMDGPULibFunc::EVENT:
958958 T = PointerType::getUnqual (C);
959959 break ;
960- default :
961- llvm_unreachable (" Unhandled param type" );
960+ case AMDGPULibFunc::B8:
961+ case AMDGPULibFunc::B16:
962+ case AMDGPULibFunc::B32:
963+ case AMDGPULibFunc::B64:
964+ case AMDGPULibFunc::SIZE_MASK:
965+ case AMDGPULibFunc::FLOAT:
966+ case AMDGPULibFunc::INT:
967+ case AMDGPULibFunc::UINT:
968+ case AMDGPULibFunc::DUMMY:
962969 return nullptr ;
963970 }
964971 if (P.VectorSize > 1 )
@@ -974,8 +981,13 @@ FunctionType *AMDGPUMangledLibFunc::getFunctionType(const Module &M) const {
974981 std::vector<Type*> Args;
975982 ParamIterator I (Leads, manglingRules[FuncId]);
976983 Param P;
977- while ((P=I.getNextParam ()).ArgType != 0 )
978- Args.push_back (getIntrinsicParamType (C, P, true ));
984+ while ((P = I.getNextParam ()).ArgType != 0 ) {
985+ Type *ParamTy = getIntrinsicParamType (C, P, true );
986+ if (!ParamTy)
987+ return nullptr ;
988+
989+ Args.push_back (ParamTy);
990+ }
979991
980992 return FunctionType::get (
981993 getIntrinsicParamType (C, getRetType (FuncId, Leads), true ),
@@ -1001,10 +1013,15 @@ bool AMDGPULibFunc::isCompatibleSignature(const Module &M,
10011013 const FunctionType *CallTy) const {
10021014 const FunctionType *FuncTy = getFunctionType (M);
10031015
1004- // FIXME: UnmangledFuncInfo does not have any type information other than the
1005- // number of arguments.
1006- if (!FuncTy)
1016+ if (!FuncTy) {
1017+ // Give up on mangled functions with unexpected types.
1018+ if (AMDGPULibFuncBase::isMangled (getId ()))
1019+ return false ;
1020+
1021+ // FIXME: UnmangledFuncInfo does not have any type information other than
1022+ // the number of arguments.
10071023 return getNumArgs () == CallTy->getNumParams ();
1024+ }
10081025
10091026 // Normally the types should exactly match.
10101027 if (FuncTy == CallTy)
0 commit comments