@@ -39,17 +39,18 @@ using namespace llvm;
39
39
using namespace IGC ;
40
40
using namespace IGC ::IGCMD;
41
41
42
- void CCommand::execute (CallInst* Inst)
42
+ void CCommand::execute (CallInst* Inst, CodeGenContext* CodeGenContext )
43
43
{
44
- init (Inst);
44
+ init (Inst, CodeGenContext );
45
45
createIntrinsic ();
46
46
}
47
47
48
- void CCommand::init (CallInst* Inst)
48
+ void CCommand::init (CallInst* Inst, CodeGenContext* CodeGenContext )
49
49
{
50
50
m_pCallInst = Inst;
51
51
m_pFunc = m_pCallInst->getParent ()->getParent ();
52
52
m_pCtx = &(m_pFunc->getContext ());
53
+ m_pCodeGenContext = CodeGenContext;
53
54
m_pFloatType = Type::getFloatTy (*m_pCtx);
54
55
m_pIntType = Type::getInt32Ty (*m_pCtx);
55
56
m_pFloatZero = Constant::getNullValue (m_pFloatType);
@@ -191,11 +192,11 @@ void CImagesBI::prepareImageBTI()
191
192
}
192
193
}
193
194
194
- void CImagesBI::verifiyCommand (CodeGenContext* context )
195
+ void CImagesBI::verifyCommand ( )
195
196
{
196
197
if (m_IncorrectBti)
197
198
{
198
- context ->EmitError (" Inconsistent use of image!" );
199
+ m_pCodeGenContext ->EmitError (" Inconsistent use of image!" );
199
200
}
200
201
}
201
202
@@ -767,6 +768,11 @@ class COCL_sample : public CImagesBI
767
768
{
768
769
ConstantInt* samplerIndex = nullptr ;
769
770
Value* samplerParam = CImagesBI::CImagesUtils::traceImageOrSamplerArgument (m_pCallInst, 1 , m_pMdUtils, m_modMD);
771
+ if (!samplerParam) {
772
+ m_pCodeGenContext->EmitError (" There are instructions that use a sampler, but no sampler found in the kernel!" );
773
+ return nullptr ;
774
+ }
775
+
770
776
// Argument samplers are looked up in the parameter map
771
777
if (isa<Argument>(samplerParam))
772
778
{
@@ -961,12 +967,14 @@ class COCL_sample : public CImagesBI
961
967
}
962
968
}
963
969
964
- void prepareSamplerIndex ()
970
+ bool prepareSamplerIndex ()
965
971
{
966
972
ConstantInt* samplerIndex = getSamplerIndex ();
973
+ if (!samplerIndex) return false ;
967
974
unsigned int addrSpace = EncodeAS4GFXResource (*samplerIndex, SAMPLER, 0 );
968
975
Value* sampler = ConstantPointerNull::get (PointerType::get (samplerIndex->getType (), addrSpace));
969
976
m_args.push_back (sampler);
977
+ return true ;
970
978
}
971
979
972
980
void prepareGradients (Dimension Dim, Value* gradX, Value* gradY)
@@ -1057,7 +1065,9 @@ class COCL_sample_l : public COCL_sample
1057
1065
m_args.push_back (CoordZ);
1058
1066
m_args.push_back (m_pFloatZero); // ai (?)
1059
1067
createGetBufferPtr ();
1060
- prepareSamplerIndex ();
1068
+ bool samplerIndexFound = prepareSamplerIndex ();
1069
+ if (!samplerIndexFound) return ;
1070
+
1061
1071
prepareZeroOffsets ();
1062
1072
Type* types[] = { m_pCallInst->getType (), m_pFloatType, m_args[5 ]->getType (), m_args[6 ]->getType () };
1063
1073
replaceGenISACallInst (GenISAIntrinsic::GenISA_sampleLptr, types);
@@ -1936,8 +1946,8 @@ bool CBuiltinsResolver::resolveBI(CallInst* Inst)
1936
1946
{
1937
1947
return false ;
1938
1948
}
1939
- m_CommandMap[calleeName]->execute (Inst);
1940
- m_CommandMap[calleeName]->verifiyCommand (m_CodeGenContext );
1949
+ m_CommandMap[calleeName]->execute (Inst, m_CodeGenContext );
1950
+ m_CommandMap[calleeName]->verifyCommand ( );
1941
1951
1942
- return true ;
1952
+ return !m_CodeGenContext-> HasError () ;
1943
1953
}
0 commit comments