Skip to content

Commit 4fd8311

Browse files
ovvengerigcbot
authored andcommitted
Relax func arg type check for inline
Do not enforce inline for functions with OCL event arg types
1 parent a0874ab commit 4fd8311

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

IGC/AdaptorCommon/ProcessFuncAttributes.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ static void getContainedStructType(Type *T, SmallPtrSetImpl<StructType *> &Tys)
133133
}
134134
}
135135

136-
// Check the existence of an opaque type.
137-
static bool containsOpaque(llvm::Type *T)
136+
// Check the existence of an image type.
137+
static bool containsImageType(llvm::Type *T)
138138
{
139139
// All (nested) struct types in T.
140140
SmallPtrSet<StructType *, 8> StructTys;
@@ -145,7 +145,10 @@ static bool containsOpaque(llvm::Type *T)
145145
StructType *ST = *I;
146146
if (ST->isOpaque())
147147
{
148-
return true;
148+
auto typeName = ST->getName();
149+
llvm::SmallVector<llvm::StringRef, 3> buf;
150+
typeName.split(buf, ".");
151+
return buf.size() >= 2 && buf[0].equals("opencl") && buf[1].startswith("image") && buf[1].endswith("_t");
149152
}
150153
}
151154

@@ -516,10 +519,11 @@ bool ProcessFuncAttributes::runOnModule(Module& M)
516519
}
517520
else
518521
{
519-
// Add always attribute if function has an argument with opaque type
522+
// Curently, ExtensionArgAnalysis assumes that all functions with image arguments
523+
// to be inlined. We add always inline for such cases.
520524
for (auto& arg : F->args())
521525
{
522-
if (containsOpaque(arg.getType()))
526+
if (containsImageType(arg.getType()))
523527
{
524528
mustAlwaysInline = true;
525529
break;

0 commit comments

Comments
 (0)