[ISSUE] Instruction does not dominate all uses

" Instruction does not dominate all uses" is not a new issue since in unity branch, more strict check has merged in codegen_llvm.cc(see following this->Verify()): tvm/src/target/llvm/codegen_llvm.cc at main · apache/tvm (github.com)

  std::unique_ptr<llvm::Module> CodeGenLLVM::Finish() {
  this->AddStartupFunction();
  for (size_t i = 0; i < link_modules_.size(); ++i) {
    ICHECK(!llvm::Linker::linkModules(*module_, std::move(link_modules_[i])))
        << "Failed to link modules";
  }
  link_modules_.clear();
  this->Verify();
  this->Optimize();
  this->Verify();
  return std::move(module_);
}

not only RoCM target, but alse other amd-likes target may occur same kind of issue. part of compile error may likes:

TVMError: LLVM module verification failed with the following errors: 
Instruction does not dominate all uses!
  %27 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
  %47 = and i32 %27, 15
Instruction does not dominate all uses!
  %27 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
  %49 = ashr i32 %27, 4
Instruction does not dominate all uses!
  %27 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
  %60 = add nsw i32 %59, %27
Instruction does not dominate all uses!
  %27 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
  %202 = add nsw i32 %201, %27
Instruction does not dominate all uses!
  %27 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
  %206 = and i32 %27, 15
Instruction does not dominate all uses!
  %27 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
  %209 = ashr i32 %27, 4
1 Like

I collected relevant docs to this issue:

LLVM: Instruction does not dominate all uses - Stack Overflow

Error when compiling model with rocm - Troubleshooting - Apache TVM Discuss

[LLVM] Codegen subroutine call when CallNode::op is GlobalVar by Lunderberg · Pull Request #14901 · apache/tvm (github.com)

tvm/tests/python/unittest/test_tir_schedule_tensorize_hip_mfma.py at lei/feat-hip · LeiWang1999/tvm (github.com)

[Bug] [ROCm] dense op error when compiling model with rocm · Issue #16160 · apache/tvm (github.com)

if one want to quickly workaround this issue, only to quate off this->Verify() in codegen_llvm.cc,compile error won’t happen, and program may runs good, coredump may happen since your llvm ir may indeed illegal.

1 Like