@@ -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 );
@@ -1963,6 +1944,31 @@ SPIRVValue *LLVMToSPIRVBase::mapValue(Value *V, SPIRVValue *BV) {
1963
1944
return BV;
1964
1945
}
1965
1946
1947
+ bool LLVMToSPIRVBase::shouldTryToAddMemAliasingDecoration (Instruction *Inst) {
1948
+ // Limit translation of aliasing metadata with only this set of instructions
1949
+ // gracefully considering others as compilation mistakes and ignoring them
1950
+ if (!Inst->mayReadOrWriteMemory ())
1951
+ return false ;
1952
+ // Loads and Stores are handled during memory access mask addition
1953
+ if (isa<StoreInst>(Inst) || isa<LoadInst>(Inst))
1954
+ return false ;
1955
+ CallInst *CI = dyn_cast<CallInst>(Inst);
1956
+ if (!CI)
1957
+ return true ;
1958
+ if (Function *Fun = CI->getCalledFunction ()) {
1959
+ // Calls to intrinsics are skipped. At some point lifetime start/end will be
1960
+ // handled separately, but specification isn't ready.
1961
+ if (Fun->isIntrinsic ())
1962
+ return false ;
1963
+ // Also skip SPIR-V instructions that don't have result id to attach the
1964
+ // decorations
1965
+ if (isBuiltinTransToInst (Fun))
1966
+ if (Fun->getReturnType ()->isVoidTy ())
1967
+ return false ;
1968
+ }
1969
+ return true ;
1970
+ }
1971
+
1966
1972
bool LLVMToSPIRVBase::transDecoration (Value *V, SPIRVValue *BV) {
1967
1973
if (!transAlign (V, BV))
1968
1974
return false ;
0 commit comments