Skip to content

Commit d102c7f

Browse files
dlei6gigcbot
authored andcommitted
Bug fixes to enable function pointers directly passed by FE (Commit attempt #3)
1 parent df3ff27 commit d102c7f

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

IGC/AdaptorCommon/ProcessFuncAttributes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,10 @@ bool ProcessFuncAttributes::runOnModule(Module& M)
322322
for (auto I : F->users()) {
323323
if (CallInst* callInst = dyn_cast<CallInst>(&*I)) {
324324
// Go through call sites and remove NoInline atrributes.
325+
// Verifier fails if a call has optnone but not noinline, so if we remove noinline, we must also remove optnone
325326
if (callInst->hasFnAttr(llvm::Attribute::NoInline)) {
326327
callInst->removeAttribute(AttributeList::FunctionIndex, llvm::Attribute::NoInline);
328+
callInst->removeAttribute(AttributeList::FunctionIndex, llvm::Attribute::OptimizeNone);
327329
}
328330
// Remove AlwaysInline at callsites
329331
if (isOptDisable && callInst->hasFnAttr(llvm::Attribute::AlwaysInline)) {

IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,10 @@ namespace //Anonymous
16351635
}
16361636
}
16371637

1638-
// remove function pointers
1638+
// Remove function pointer from instructions
1639+
// FIXME: Allowing function pointer calls directly passed by FE will cause regressions due to implicit args
1640+
// not being supported by indirect calls. When runtime turns on support, we should remove the following code
1641+
// to allow function pointer usage in all cases.
16391642
auto nullPtrConst = llvm::ConstantPointerNull::get(Type::getInt8PtrTy(M.getContext()));
16401643
for (auto& func : M.functions())
16411644
{
@@ -1645,11 +1648,8 @@ namespace //Anonymous
16451648
{
16461649
if (!isa<llvm::Constant>(user)) {
16471650
user->replaceUsesOfWith(&func, nullPtrConst);
1651+
changed = true;
16481652
}
1649-
else {
1650-
user->replaceAllUsesWith(llvm::Constant::getNullValue(user->getType()));
1651-
}
1652-
changed = true;
16531653
}
16541654
}
16551655
}
@@ -2153,7 +2153,7 @@ namespace //Anonymous
21532153
{
21542154
return std::unique_ptr<StructValue>(new NullStructValue(sourceValue));
21552155
}
2156-
IGC_ASSERT_MESSAGE(0, "should not be here");
2156+
// Not a block description struct
21572157
return nullptr;
21582158
}
21592159

IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ void ProgramScopeConstantAnalysis::addData(Constant* initializer,
485485
if (Constant * C = dyn_cast<Constant>(&Op))
486486
addData(C, inlineProgramScopeBuffer, pointerOffsetInfoList, inlineProgramScopeOffsets, addressSpace);
487487
}
488-
else if (ce->getOpcode() == Instruction::AddrSpaceCast)
488+
else if (ce->getOpcode() == Instruction::AddrSpaceCast ||
489+
ce->getOpcode() == Instruction::BitCast)
489490
{
490491
if (Constant * C = dyn_cast<Constant>(ce->getOperand(0)))
491492
addData(C, inlineProgramScopeBuffer, pointerOffsetInfoList, inlineProgramScopeOffsets, addressSpace);

0 commit comments

Comments
 (0)