Re: [Mesa-dev] [PATCH 4/9] nir: Use nir_src_is_const and nir_src_as_* in core code

2018-10-23 Thread Michel Dänzer

Hi Jason,


this change caused an assertion failure for me during make check, in the
nir/tests/vars_tests test under src/compiler. See the attached backtrace.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
Core was generated by `./nir/tests/vars_tests'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x7fa17a3a62f1 in __GI_abort () at abort.c:79
#2  0x7fa17a39da8a in __assert_fail_base (fmt=0x7fa17a4f1ec8 "%s%s%s:%u: 
%s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x559a19a47c08 
"nir_src_num_components(src) == 1", file=file@entry=0x559a19a477e0 
"../../../src/compiler/nir/nir.c", 
line=line@entry=1275, function=function@entry=0x559a19a48490 
<__PRETTY_FUNCTION__.25988> "nir_src_as_uint") at assert.c:92
#3  0x7fa17a39db02 in __GI___assert_fail 
(assertion=assertion@entry=0x559a19a47c08 "nir_src_num_components(src) == 1", 
file=file@entry=0x559a19a477e0 "../../../src/compiler/nir/nir.c", 
line=line@entry=1275, 
function=function@entry=0x559a19a48490 <__PRETTY_FUNCTION__.25988> 
"nir_src_as_uint") at assert.c:101
#4  0x559a19a0ee64 in nir_src_as_uint (src=...) at 
../../../src/compiler/nir/nir.c:1276
#5  0x559a199e3244 in 
nir_copy_prop_vars_test_store_store_load_different_components_Test::TestBody() 
() at ../../../src/compiler/nir/tests/vars_tests.cpp:378
#6  0x559a19a0be1e in 
testing::internal::HandleSehExceptionsInMethodIfSupported 
(location=0x559a19a4468f "the test body", method=, 
object=0x559a19f20b60) at ../../../src/gtest/src/gtest.cc:2383
#7  testing::internal::HandleExceptionsInMethodIfSupported 
(object=object@entry=0x559a19f20b60, method=, 
location=location@entry=0x559a19a4468f "the test body") at 
../../../src/gtest/src/gtest.cc:2438
#8  0x559a19a023ba in testing::Test::Run (this=0x559a19f20b60) at 
../../../src/gtest/src/gtest.cc:2474
#9  0x559a19a02508 in testing::TestInfo::Run (this=0x559a19f1f350) at 
../../../src/gtest/src/gtest.cc:2656
#10 0x559a19a025e4 in testing::TestCase::Run (this=0x559a19f1ee90) at 
../../../src/gtest/src/gtest.cc:2774
#11 0x559a19a02ad4 in testing::internal::UnitTestImpl::RunAllTests() () at 
/usr/include/c++/8/bits/stl_vector.h:930
#12 0x559a19a0c2fe in 
testing::internal::HandleSehExceptionsInMethodIfSupported (location=0x559a19a45830 "auxiliary test code (environments or event 
listeners)", method=, object=0x559a19f1e100)
at ../../../src/gtest/src/gtest.cc:2383
#13 
testing::internal::HandleExceptionsInMethodIfSupported (object=0x559a19f1e100, method=, 
location=location@entry=0x559a19a45830 "auxiliary test code (environments or 
event listeners)")
at ../../../src/gtest/src/gtest.cc:2438
#14 0x559a19a02bc2 in testing::UnitTest::Run() () at 
../../../src/gtest/include/gtest/gtest.h:1287
#15 0x559a199db934 in RUN_ALL_TESTS () at 
../../../src/gtest/include/gtest/gtest.h:2233
#16 main (argc=, argv=0x7fffc3ee3048) at 
../../../src/gtest/src/gtest_main.cc:37
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/9] nir: Use nir_src_is_const and nir_src_as_* in core code

2018-10-20 Thread Jason Ekstrand
---
 src/compiler/glsl/gl_nir_lower_samplers.c   |  7 ++-
 src/compiler/nir/nir_deref.c| 14 ++
 src/compiler/nir/nir_gather_info.c  |  6 ++
 src/compiler/nir/nir_gs_count_vertices.c|  7 +++
 src/compiler/nir/nir_lower_clip.c   |  2 +-
 src/compiler/nir/nir_lower_indirect_derefs.c|  4 ++--
 src/compiler/nir/nir_lower_io.c |  6 ++
 .../nir/nir_lower_io_arrays_to_elements.c   | 11 +--
 src/compiler/nir/nir_lower_locals_to_regs.c |  6 +++---
 src/compiler/nir/nir_lower_two_sided_color.c|  2 +-
 src/compiler/nir/nir_lower_vars_to_ssa.c| 14 +-
 src/compiler/nir/nir_opt_dead_cf.c  |  7 ++-
 src/compiler/nir/nir_opt_find_array_copies.c| 13 +++--
 src/compiler/nir/nir_opt_intrinsics.c   |  4 ++--
 src/compiler/nir/nir_opt_large_constants.c  |  2 +-
 src/compiler/nir/nir_split_vars.c   | 17 -
 src/compiler/nir/tests/vars_tests.cpp   | 10 --
 17 files changed, 56 insertions(+), 76 deletions(-)

diff --git a/src/compiler/glsl/gl_nir_lower_samplers.c 
b/src/compiler/glsl/gl_nir_lower_samplers.c
index 593967b7108..1ee075cfd14 100644
--- a/src/compiler/glsl/gl_nir_lower_samplers.c
+++ b/src/compiler/glsl/gl_nir_lower_samplers.c
@@ -57,12 +57,9 @@ lower_tex_src_to_offset(nir_builder *b,
  break;
 
   case nir_deref_type_array: {
- nir_const_value *const_deref_index =
-nir_src_as_const_value(deref->arr.index);
-
- if (const_deref_index && index == NULL) {
+ if (nir_src_is_const(deref->arr.index) && index == NULL) {
 /* We're still building a direct index */
-base_index += const_deref_index->u32[0] * array_elements;
+base_index += nir_src_as_uint(deref->arr.index) * array_elements;
  } else {
 if (index == NULL) {
/* We used to be direct but not anymore */
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index 4a87ee84d8a..4a2e81956d1 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -112,7 +112,7 @@ nir_deref_instr_has_indirect(nir_deref_instr *instr)
  return true;
 
   if (instr->deref_type == nir_deref_type_array &&
-  !nir_src_as_const_value(instr->arr.index))
+  !nir_src_is_const(instr->arr.index))
  return true;
 
   instr = nir_deref_instr_parent(instr);
@@ -160,7 +160,7 @@ nir_deref_instr_get_const_offset(nir_deref_instr *deref,
unsigned offset = 0;
for (nir_deref_instr **p = [1]; *p; p++) {
   if ((*p)->deref_type == nir_deref_type_array) {
- offset += nir_src_as_const_value((*p)->arr.index)->u32[0] *
+ offset += nir_src_as_uint((*p)->arr.index) *
type_get_array_stride((*p)->type, size_align);
   } else if ((*p)->deref_type == nir_deref_type_struct) {
  /* p starts at path[1], so this is safe */
@@ -312,15 +312,13 @@ nir_compare_deref_paths(nir_deref_path *a_path,
b_tail->deref_type == nir_deref_type_array);
 assert(a_tail->arr.index.is_ssa && b_tail->arr.index.is_ssa);
 
-nir_const_value *a_index_const =
-   nir_src_as_const_value(a_tail->arr.index);
-nir_const_value *b_index_const =
-   nir_src_as_const_value(b_tail->arr.index);
-if (a_index_const && b_index_const) {
+if (nir_src_is_const(a_tail->arr.index) &&
+nir_src_is_const(b_tail->arr.index)) {
/* If they're both direct and have different offsets, they
 * don't even alias much less anything else.
 */
-   if (a_index_const->u32[0] != b_index_const->u32[0])
+   if (nir_src_as_uint(a_tail->arr.index) !=
+   nir_src_as_uint(b_tail->arr.index))
   return 0;
 } else if (a_tail->arr.index.ssa == b_tail->arr.index.ssa) {
/* They're the same indirect, continue on */
diff --git a/src/compiler/nir/nir_gather_info.c 
b/src/compiler/nir/nir_gather_info.c
index 30f0bc721d4..15d38f036b5 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -108,13 +108,11 @@ get_io_offset(nir_deref_instr *deref, bool 
is_vertex_input)
 
for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
   if (d->deref_type == nir_deref_type_array) {
- nir_const_value *const_index = nir_src_as_const_value(d->arr.index);
-
- if (!const_index)
+ if (!nir_src_is_const(d->arr.index))
 return -1;
 
  offset += glsl_count_attribute_slots(d->type, is_vertex_input) *
-const_index->u32[0];
+   nir_src_as_uint(d->arr.index);
   }
   /* TODO: we can get the offset for structs here see nir_lower_io() */
}
diff --git