Skip to content

Commit 994fe47

Browse files
aratajewsys_zuul
authored andcommitted
Add assert in case getOrInsertFunction returns unexpected type
Change-Id: I93bcd2e6fc543f4a3eee7cb63929c17e7e81d9c7
1 parent a45b048 commit 994fe47

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

IGC/GenISAIntrinsics/GenIntrinsics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ Function *GenISAIntrinsic::getDeclaration(
521521
IGCLLVM::Module* M = (IGCLLVM::Module*)Module;
522522

523523
Function *F =
524-
cast<Function>(
524+
dyn_cast<Function>(
525525
M->getOrInsertFunction(
526526
getName((GenISAIntrinsic::ID)(id-Intrinsic::num_intrinsics), Tys),
527527
getType(
@@ -530,6 +530,7 @@ Function *GenISAIntrinsic::getDeclaration(
530530
Tys),
531531
getAttributes(M->getContext(),(GenISAIntrinsic::ID)(id - 1))));
532532

533+
IGC_ASSERT_MESSAGE(F, "getOrInsertFunction probably returned constant expression!");
533534
// Since Function::isIntrinsic() will return true due to llvm.* prefix,
534535
// Module::getOrInsertFunction fails to add the attributes.
535536
// explicitly adding the attribute to handle this problem.

0 commit comments

Comments
 (0)