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


##########
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:
   Removed the check instead.
   
   1. Actually ```id=0``` exists in LLVM internals.
     ```
     DBG [not_intrinsic] (0)
     DBG [llvm.abs] (1)
     DBG [llvm.addressofreturnaddress] (2)
     DBG [llvm.adjust.trampoline] (3)
     DBG [llvm.annotation] (4)
     ```
   2. From high level python `op.py` the 
```codegen.llvm_get_intrinsic_name(llvm_id)``` would fail on bad user input.
   



-- 
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