Mesa (master): microsoft/compiler: Misc fixes caught by GCC
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 1 17:19:59 UTC 2020
Module: Mesa
Branch: master
Commit: e593329b0c9fc1177e8d54ea15693a5a4368b802
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e593329b0c9fc1177e8d54ea15693a5a4368b802
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Tue Dec 1 08:44:40 2020 -0800
microsoft/compiler: Misc fixes caught by GCC
* Fix const-correctness on dxil_mdnode pointer arrays
* Fix warning for a missing scope in a case block
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>
---
src/microsoft/compiler/dxil_dump.c | 2 +-
src/microsoft/compiler/dxil_dump_decls.h | 2 +-
src/microsoft/compiler/dxil_internal.h | 4 ++--
src/microsoft/compiler/dxil_module.c | 16 ++++++++--------
src/microsoft/compiler/dxil_nir.c | 9 +++++----
5 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/microsoft/compiler/dxil_dump.c b/src/microsoft/compiler/dxil_dump.c
index 69faa2d2b81..2ba3196f89e 100644
--- a/src/microsoft/compiler/dxil_dump.c
+++ b/src/microsoft/compiler/dxil_dump.c
@@ -649,7 +649,7 @@ dump_mdnodes(struct dxil_dumper *d, struct list_head *list)
}
static void
-dump_mdnode(struct dxil_dumper *d, struct dxil_mdnode *node)
+dump_mdnode(struct dxil_dumper *d, const struct dxil_mdnode *node)
{
dxil_dump_indent(d);
switch (node->type) {
diff --git a/src/microsoft/compiler/dxil_dump_decls.h b/src/microsoft/compiler/dxil_dump_decls.h
index 889fe19756c..b651734b63f 100644
--- a/src/microsoft/compiler/dxil_dump_decls.h
+++ b/src/microsoft/compiler/dxil_dump_decls.h
@@ -50,7 +50,7 @@ dump_instrs(struct dxil_dumper *buf, struct list_head *list);
static void
dump_mdnodes(struct dxil_dumper *buf, struct list_head *list);
static void
-dump_mdnode(struct dxil_dumper *d, struct dxil_mdnode *node);
+dump_mdnode(struct dxil_dumper *d, const struct dxil_mdnode *node);
static void
dump_named_nodes(struct dxil_dumper *d, struct list_head *list);
static void
diff --git a/src/microsoft/compiler/dxil_internal.h b/src/microsoft/compiler/dxil_internal.h
index 1c10e4fca0b..391ba09a937 100644
--- a/src/microsoft/compiler/dxil_internal.h
+++ b/src/microsoft/compiler/dxil_internal.h
@@ -281,7 +281,7 @@ struct dxil_mdnode {
} value;
struct {
- struct dxil_mdnode **subnodes;
+ const struct dxil_mdnode **subnodes;
size_t num_subnodes;
} node;
};
@@ -292,7 +292,7 @@ struct dxil_mdnode {
struct dxil_named_node {
char *name;
- struct dxil_mdnode **subnodes;
+ const struct dxil_mdnode **subnodes;
size_t num_subnodes;
struct list_head head;
};
diff --git a/src/microsoft/compiler/dxil_module.c b/src/microsoft/compiler/dxil_module.c
index 8d856425da7..3fd5b1e2b12 100644
--- a/src/microsoft/compiler/dxil_module.c
+++ b/src/microsoft/compiler/dxil_module.c
@@ -2273,12 +2273,12 @@ dxil_get_metadata_node(struct dxil_module *m,
n = create_mdnode(m, MD_NODE);
if (n) {
- n->node.subnodes = ralloc_array(n, struct dxil_mdnode *, num_subnodes);
- if (!n->node.subnodes)
+ void *tmp = ralloc_array(n, struct dxil_mdnode *, num_subnodes);
+ if (!tmp)
return NULL;
- memcpy(n->node.subnodes, subnodes, sizeof(struct dxil_mdnode *) *
- num_subnodes);
+ memcpy(tmp, subnodes, sizeof(struct dxil_mdnode *) * num_subnodes);
+ n->node.subnodes = tmp;
n->node.num_subnodes = num_subnodes;
}
return n;
@@ -2354,12 +2354,12 @@ dxil_add_metadata_named_node(struct dxil_module *m, const char *name,
if (!n->name)
return false;
- n->subnodes = ralloc_array(n, struct dxil_mdnode *, num_subnodes);
- if (!n->subnodes)
+ void *tmp = ralloc_array(n, struct dxil_mdnode *, num_subnodes);
+ if (!tmp)
return false;
- memcpy(n->subnodes, subnodes, sizeof(struct dxil_mdnode *) *
- num_subnodes);
+ memcpy(tmp, subnodes, sizeof(struct dxil_mdnode *) * num_subnodes);
+ n->subnodes = tmp;
n->num_subnodes = num_subnodes;
list_addtail(&n->head, &m->md_named_node_list);
diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c
index a9a7b324a68..2e1b10d1f1c 100644
--- a/src/microsoft/compiler/dxil_nir.c
+++ b/src/microsoft/compiler/dxil_nir.c
@@ -88,17 +88,18 @@ load_comps_to_vec32(nir_builder *b, unsigned src_bit_size,
vec32comps[i] = src_comps[i];
break;
case 16:
- case 8:
+ case 8: {
unsigned src_offs = i * comps_per32b;
vec32comps[i] = nir_u2u32(b, src_comps[src_offs]);
for (unsigned j = 1; j < comps_per32b && src_offs + j < num_src_comps; j++) {
- nir_ssa_def *tmp = nir_ishl(b, nir_u2u32(b, src_comps[src_offs + j]),
- nir_imm_int(b, j * src_bit_size));
- vec32comps[i] = nir_ior(b, vec32comps[i], tmp);
+ nir_ssa_def *tmp = nir_ishl(b, nir_u2u32(b, src_comps[src_offs + j]),
+ nir_imm_int(b, j * src_bit_size));
+ vec32comps[i] = nir_ior(b, vec32comps[i], tmp);
}
break;
}
+ }
}
return nir_vec(b, vec32comps, num_vec32comps);
More information about the mesa-commit
mailing list