This is an automated email from the ASF dual-hosted git repository.
mshr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new f2930d5bb1 [LLVM][Codegen] Avoid segfault when
`arith::GetVScaleValues` returns empty vector (#18586)
f2930d5bb1 is described below
commit f2930d5bb14eac4c3984c413da5a069eab98fd20
Author: Masahiro Hiramori <[email protected]>
AuthorDate: Tue Dec 16 13:10:54 2025 +0900
[LLVM][Codegen] Avoid segfault when `arith::GetVScaleValues` returns empty
vector (#18586)
As per title.
---
src/target/llvm/codegen_aarch64.cc | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/target/llvm/codegen_aarch64.cc
b/src/target/llvm/codegen_aarch64.cc
index adac659144..872e4f4cd1 100644
--- a/src/target/llvm/codegen_aarch64.cc
+++ b/src/target/llvm/codegen_aarch64.cc
@@ -59,9 +59,11 @@ void CodeGenAArch64::SetTargetAttributes(llvm::Function*
func) {
// Add vscale_range() function attribute when appropriate.
if (llvm_target_->TargetHasCPUFeature("sve") ||
llvm_target_->TargetHasCPUFeature("sme")) {
auto kVScaleValues = arith::GetVScaleValues(Target::Current());
- unsigned int max_val = *std::max_element(kVScaleValues.begin(),
kVScaleValues.end());
- func->addFnAttr(
- llvm::Attribute::getWithVScaleRangeArgs(*llvm_target_->GetContext(),
1, max_val));
+ if (!kVScaleValues.empty()) {
+ unsigned int max_val = *std::max_element(kVScaleValues.begin(),
kVScaleValues.end());
+ func->addFnAttr(
+ llvm::Attribute::getWithVScaleRangeArgs(*llvm_target_->GetContext(),
1, max_val));
+ }
}
#endif
CodeGenCPU::SetTargetAttributes(func);