Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Add nullptr checking for AttrStmt with coproc_uop_scope attr key #9123

Merged
merged 3 commits into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/target/llvm/codegen_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,11 @@ void CodeGenCPU::CreateComputeScope(const AttrStmtNode* op) {
// $xxx_compute_ functions are not global. They should be marked as static (via InternalLinkage)
// to call them correctly on MIPS platform (CALL16 issue)
// Linkage ld Error: CALL16 reloc at 0x290 not against global symbol
llvm::Function* fcompute = llvm::Function::Create(
ftype, llvm::Function::InternalLinkage,
op->value.as<StringImmNode>()->value.operator llvm::StringRef(), module_.get());
const StringImmNode* value = op->value.as<StringImmNode>();
ICHECK(value != nullptr);
llvm::Function* fcompute =
llvm::Function::Create(ftype, llvm::Function::InternalLinkage,
value->value.operator llvm::StringRef(), module_.get());
BasicBlock* compute_call_end = CheckCallSuccess(builder_->CreateCall(fcompute, arg_values));
// setup compute function.
std::unordered_map<const VarNode*, llvm::Value*> new_vmap;
Expand Down Expand Up @@ -941,7 +943,9 @@ void CodeGenCPU::VisitStmt_(const AssertStmtNode* op) {

void CodeGenCPU::VisitStmt_(const AttrStmtNode* op) {
if (op->attr_key == tir::attr::coproc_uop_scope) {
this->CreateStaticInit(op->value.as<StringImmNode>()->value, op->body);
const StringImmNode* value = op->value.as<StringImmNode>();
ICHECK(value != nullptr);
this->CreateStaticInit(value->value, op->body);
} else if (op->attr_key == tir::attr::compute_scope) {
this->CreateComputeScope(op);
} else if (tir::attr::IsPragmaKey(op->attr_key)) {
Expand Down