Skip to content

Commit 40448c7

Browse files
sarnexjsji
authored andcommitted
Handle entry point wrappers in reverse translation
Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
1 parent 95589cf commit 40448c7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,6 +3448,24 @@ Function *SPIRVToLLVM::transFunction(SPIRVFunction *BF, unsigned AS) {
34483448
return Loc->second;
34493449

34503450
auto IsKernel = isKernel(BF);
3451+
if (IsKernel) {
3452+
// search for a previous function with the same name
3453+
// upgrade it to a kernel and drop this if it's found
3454+
for (auto &I : FuncMap) {
3455+
const auto &BFName = I.getFirst()->getName();
3456+
if (BF->getName() == BFName) {
3457+
auto *F = I.getSecond();
3458+
F->setCallingConv(CallingConv::SPIR_KERNEL);
3459+
F->setLinkage(GlobalValue::ExternalLinkage);
3460+
F->setDSOLocal(false);
3461+
F = cast<Function>(mapValue(BF, F));
3462+
mapFunction(BF, F);
3463+
transFunctionAttrs(BF, F);
3464+
return F;
3465+
}
3466+
}
3467+
}
3468+
34513469
auto Linkage = IsKernel ? GlobalValue::ExternalLinkage : transLinkageType(BF);
34523470
FunctionType *FT = cast<FunctionType>(transType(BF->getFunctionType()));
34533471
std::string FuncName = BF->getName();

0 commit comments

Comments
 (0)