[Mlir-commits] [mlir] [mlir][XeGPU] Fix crash in getUArch for unsupported architectures (PR #179173)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Feb 1 22:53:24 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-gpu
Author: puneeth_aditya_5656 (mugiwaraluffy56)
<details>
<summary>Changes</summary>
## Summary
- Return nullptr from getUArch() instead of crashing with llvm_unreachable when the architecture name is not recognized
- Callers already check for nullptr and handle it gracefully (e.g., returning match failure)
Fixes #<!-- -->179167
## Test plan
- Added test case that runs xegpu subgroup distribute without a target attribute
---
Full diff: https://github.com/llvm/llvm-project/pull/179173.diff
2 Files Affected:
- (modified) mlir/include/mlir/Dialect/XeGPU/uArch/IntelGpuXe2.h (+1-4)
- (added) mlir/test/Dialect/XeGPU/subgroup-distribute-no-target.mlir (+14)
``````````diff
diff --git a/mlir/include/mlir/Dialect/XeGPU/uArch/IntelGpuXe2.h b/mlir/include/mlir/Dialect/XeGPU/uArch/IntelGpuXe2.h
index 29e75b57f4a5f..5a1fcb42b53ee 100644
--- a/mlir/include/mlir/Dialect/XeGPU/uArch/IntelGpuXe2.h
+++ b/mlir/include/mlir/Dialect/XeGPU/uArch/IntelGpuXe2.h
@@ -296,11 +296,8 @@ struct BMGuArch : public Xe2Plus {
inline const uArch *getUArch(llvm::StringRef archName) {
if (archName.equals_insensitive("pvc"))
return PVCuArch::getInstance();
- else if (archName.equals_insensitive("bmg"))
+ if (archName.equals_insensitive("bmg"))
return BMGuArch::getInstance();
- else
- llvm_unreachable("No matching uArch found");
-
return nullptr;
}
diff --git a/mlir/test/Dialect/XeGPU/subgroup-distribute-no-target.mlir b/mlir/test/Dialect/XeGPU/subgroup-distribute-no-target.mlir
new file mode 100644
index 0000000000000..0df69a14d44f5
--- /dev/null
+++ b/mlir/test/Dialect/XeGPU/subgroup-distribute-no-target.mlir
@@ -0,0 +1,14 @@
+// RUN: mlir-opt -xegpu-subgroup-distribute -split-input-file %s 2>&1 | FileCheck %s
+
+// Test that the pass gracefully handles a GPU module without a target attribute
+// instead of crashing with "UNREACHABLE executed".
+
+// CHECK-LABEL: gpu.module @no_target_module
+// The function body should remain unchanged since no target is attached.
+// CHECK: gpu.func @simple_func
+// CHECK: gpu.return
+gpu.module @no_target_module {
+ gpu.func @simple_func(%arg0: memref<8x16xf16>) {
+ gpu.return
+ }
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/179173
More information about the Mlir-commits
mailing list