You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/08/16 18:54:41 UTC

[GitHub] [tvm] kparzysz-quic commented on a diff in pull request #12200: [TOPI]fix scatterND large shape problem

kparzysz-quic commented on code in PR #12200:
URL: https://github.com/apache/tvm/pull/12200#discussion_r947138752


##########
src/target/llvm/codegen_cpu.cc:
##########
@@ -642,7 +642,16 @@ CodeGenLLVM::TypedPointer CodeGenCPU::PackClosureData(const Array<Var>& vfields,
   }
   llvm::StructType* ctype = struct_name.size() ? llvm::StructType::create(fields, struct_name)
                                                : llvm::StructType::create(fields);
-  llvm::Value* cvalue = builder_->CreateAlloca(ctype, ConstInt32(1));
+  // create ctype alloca at function entry
+  llvm::BasicBlock* cur_pt = builder_->GetInsertBlock();
+  llvm::BasicBlock* entry_block = &function_->getEntryBlock();
+  if (entry_block->getFirstInsertionPt() == entry_block->end()) {
+    builder_->SetInsertPoint(entry_block);
+  } else {
+    builder_->SetInsertPoint(&(*entry_block->getFirstInsertionPt()));
+  }
+  llvm::Value* cvalue = builder_->CreateAlloca(ctype, ConstInt32(1));  // alloca at function begin
+  builder_->SetInsertPoint(cur_pt);

Review Comment:
   You can replace all of this with
   ```
     llvm::AllocaInst* cvalue = WithFunctionEntry([&]() {
       return builder_->CreateAlloca(ctype, ConstInt32(1));
     });
   ```



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org