[Mesa-dev] [PATCH] nir/spirv: Make unhandled decorations a warning rather than unreachable()
Jason Ekstrand
jason at jlekstrand.net
Tue May 24 01:43:41 UTC 2016
This prevents SPIR-V -> NIR from dying if we get a decoration we don't know
about. Compiling incorrect code is probably a better failure mode than
dying horribly.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95573
---
src/compiler/spirv/spirv_to_nir.c | 6 ++++--
src/compiler/spirv/vtn_private.h | 13 +++++++++++++
src/compiler/spirv/vtn_variables.c | 3 ++-
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 359fa5c..fd003ee 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -491,7 +491,8 @@ struct_member_decoration_cb(struct vtn_builder *b,
mutable_matrix_member(b, ctx->type, member)->row_major = true;
break;
default:
- unreachable("Unhandled member decoration");
+ vtn_warn("Unhandled member decoration");
+ break;
}
}
@@ -525,7 +526,8 @@ type_decoration_cb(struct vtn_builder *b,
break;
default:
- unreachable("Unhandled type decoration");
+ vtn_warn("Unhandled type decoration");
+ break;
}
}
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 3ecffad..3351dcd 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -417,6 +417,19 @@ vtn_value(struct vtn_builder *b, uint32_t value_id,
return val;
}
+#ifndef NDEBUG
+static inline void
+__vtn_warn(const char *fname, int line, const char *msg)
+{
+ fprintf(stderr, "WARNING %s:%d:%s", fname, line, msg);
+}
+
+#define vtn_warn(msg) __vtn_warn(__FILE__, __LINE__, msg)
+
+#else
+#define vtn_warn(msg)
+#endif
+
struct vtn_ssa_value *vtn_ssa_value(struct vtn_builder *b, uint32_t value_id);
struct vtn_ssa_value *vtn_create_ssa_value(struct vtn_builder *b,
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 0c7f0f7..5f5dd50 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1044,7 +1044,8 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
case SpvDecorationSpecId:
break;
default:
- unreachable("Unhandled variable decoration");
+ vtn_warn("Unhandled variable decoration");
+ break;
}
}
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list