@@ -122,25 +122,6 @@ static SPIRVMemoryModelKind getMemoryModel(Module &M) {
122
122
return SPIRVMemoryModelKind::MemoryModelMax;
123
123
}
124
124
125
- static bool shouldTryToAddMemAliasingDecoration (Instruction *Inst) {
126
- // Limit translation of aliasing metadata with only this set of instructions
127
- // gracefully considering others as compilation mistakes and ignoring them
128
- if (!Inst->mayReadOrWriteMemory ())
129
- return false ;
130
- // Loads and Stores are handled during memory access mask addition
131
- if (isa<StoreInst>(Inst) || isa<LoadInst>(Inst))
132
- return false ;
133
- CallInst *CI = dyn_cast<CallInst>(Inst);
134
- if (!CI)
135
- return true ;
136
- // Calls to intrinsics are skipped. At some point lifetime start/end will be
137
- // handled separately, but specification isn't ready.
138
- if (Function *Fun = CI->getCalledFunction ())
139
- if (Fun->isIntrinsic ())
140
- return false ;
141
- return true ;
142
- }
143
-
144
125
LLVMToSPIRVBase::LLVMToSPIRVBase (SPIRVModule *SMod)
145
126
: M(nullptr ), Ctx(nullptr ), BM(SMod), SrcLang(0 ), SrcLangVer(0 ) {
146
127
DbgTran = std::make_unique<LLVMToSPIRVDbgTran>(nullptr , SMod, this );
@@ -1982,6 +1963,31 @@ SPIRVValue *LLVMToSPIRVBase::mapValue(Value *V, SPIRVValue *BV) {
1982
1963
return BV;
1983
1964
}
1984
1965
1966
+ bool LLVMToSPIRVBase::shouldTryToAddMemAliasingDecoration (Instruction *Inst) {
1967
+ // Limit translation of aliasing metadata with only this set of instructions
1968
+ // gracefully considering others as compilation mistakes and ignoring them
1969
+ if (!Inst->mayReadOrWriteMemory ())
1970
+ return false ;
1971
+ // Loads and Stores are handled during memory access mask addition
1972
+ if (isa<StoreInst>(Inst) || isa<LoadInst>(Inst))
1973
+ return false ;
1974
+ CallInst *CI = dyn_cast<CallInst>(Inst);
1975
+ if (!CI)
1976
+ return true ;
1977
+ if (Function *Fun = CI->getCalledFunction ()) {
1978
+ // Calls to intrinsics are skipped. At some point lifetime start/end will be
1979
+ // handled separately, but specification isn't ready.
1980
+ if (Fun->isIntrinsic ())
1981
+ return false ;
1982
+ // Also skip SPIR-V instructions that don't have result id to attach the
1983
+ // decorations
1984
+ if (isBuiltinTransToInst (Fun))
1985
+ if (Fun->getReturnType ()->isVoidTy ())
1986
+ return false ;
1987
+ }
1988
+ return true ;
1989
+ }
1990
+
1985
1991
bool LLVMToSPIRVBase::transDecoration (Value *V, SPIRVValue *BV) {
1986
1992
if (!transAlign (V, BV))
1987
1993
return false ;
0 commit comments