cbalint13 commented on code in PR #15953:
URL: https://github.com/apache/tvm/pull/15953#discussion_r1368737298


##########
src/target/llvm/codegen_arm.cc:
##########
@@ -55,7 +55,13 @@ class CodeGenARM final : public CodeGenCPU {
 
 llvm::Value* CodeGenARM::CreateIntrinsic(const CallNode* op) {
   if (op->op.same_as(builtin_call_llvm_intrin_) || 
op->op.same_as(builtin_call_llvm_pure_intrin_)) {
-    llvm::Intrinsic::ID id = 
static_cast<llvm::Intrinsic::ID>(Downcast<IntImm>(op->args[0])->value);
+    llvm::Intrinsic::ID id = 0;
+    if (op->args[0]->IsInstance<StringImmNode>()) {
+      id = 
llvm::Function::lookupIntrinsicID(Downcast<StringImm>(op->args[0])->value.c_str());
+    } else if (op->args[0]->IsInstance<IntImmNode>()) {
+      id = 
static_cast<llvm::Intrinsic::ID>(Downcast<IntImm>(op->args[0])->value);
+    }
+    assert(id != 0);

Review Comment:
   Let's protect both: node type in falling ```else``` and the ```id !=0``` 
(via C api).
   Added a testcase to induce a invalid id=0.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to