* [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type
@ 2022-06-02 2:13 Antoni Boucher
2022-06-02 2:45 ` Antoni Boucher
2022-06-28 22:39 ` David Malcolm
0 siblings, 2 replies; 7+ messages in thread
From: Antoni Boucher @ 2022-06-02 2:13 UTC (permalink / raw)
To: gcc-patches, jit
[-- Attachment #1: Type: text/plain, Size: 298 bytes --]
Hi.
The attached patch fix bug 105812:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105812
I'm having an issue where contrib/check_GNU_style.sh doesn't seem to
work, i.e. it doesn't seem to do any checking.
Is there a new way to do that or am I missing something?
Thanks for the review.
[-- Attachment #2: 0001-libgccjit-Fix-bug-where-unary_op-will-return-an-inte.patch --]
[-- Type: text/x-patch, Size: 4683 bytes --]
From ef20b0a18e4978aac9eb77b91898356c67f6a0e4 Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Wed, 1 Jun 2022 22:07:07 -0400
Subject: [PATCH] libgccjit: Fix bug where unary_op will return an integer type
instead of the correct type
2022-06-01 Antoni Boucher <bouanto@zoho.com>
gcc/jit/
PR target/105812
* jit-playback.cc: Use the correct return when folding in
as_truth_value.
gcc/testsuite/
PR target/105812
* jit.dg/test-pr105812-bool-operations.c: New test.
---
gcc/jit/jit-playback.cc | 3 +-
.../jit.dg/test-pr105812-bool-operations.c | 89 +++++++++++++++++++
2 files changed, 91 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/jit.dg/test-pr105812-bool-operations.c
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 6be6bdf8dea..c08cba58743 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -1025,8 +1025,9 @@ as_truth_value (tree expr, location *loc)
if (loc)
set_tree_location (typed_zero, loc);
+ tree type = TREE_TYPE (expr);
expr = fold_build2_loc (UNKNOWN_LOCATION,
- NE_EXPR, integer_type_node, expr, typed_zero);
+ NE_EXPR, type, expr, typed_zero);
if (loc)
set_tree_location (expr, loc);
diff --git a/gcc/testsuite/jit.dg/test-pr105812-bool-operations.c b/gcc/testsuite/jit.dg/test-pr105812-bool-operations.c
new file mode 100644
index 00000000000..1daa1c3c35a
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-pr105812-bool-operations.c
@@ -0,0 +1,89 @@
+#include "libgccjit.h"
+
+#include "harness.h"
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{
+ gcc_jit_type* bool_type =
+ gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_BOOL);
+ gcc_jit_type* bool_ptr_type =
+ gcc_jit_type_get_pointer (gcc_jit_type_get_aligned (bool_type, 1));
+
+ /* Function 1 */
+
+ gcc_jit_param* param1 = gcc_jit_context_new_param (ctxt, NULL, bool_type,
+ "param1");
+ gcc_jit_function* function1 =
+ gcc_jit_context_new_function (ctxt, NULL,
+ GCC_JIT_FUNCTION_EXPORTED, bool_type,
+ "function1", 1, ¶m1, 0);
+ gcc_jit_block* block1 = gcc_jit_function_new_block (function1, "start1");
+
+ gcc_jit_lvalue* var1 =
+ gcc_jit_function_new_local (function1, NULL, bool_type, "var1");
+ gcc_jit_rvalue* addr1 =
+ gcc_jit_lvalue_get_address (var1, NULL);
+ gcc_jit_rvalue* ptr1 =
+ gcc_jit_context_new_cast (ctxt, NULL, addr1, bool_ptr_type);
+ gcc_jit_lvalue* deref1 =
+ gcc_jit_rvalue_dereference (ptr1, NULL);
+ gcc_jit_rvalue* param1_rvalue =
+ gcc_jit_param_as_rvalue (param1);
+ gcc_jit_block_add_assignment (block1, NULL, deref1, param1_rvalue);
+
+ gcc_jit_rvalue* one = gcc_jit_context_one (ctxt, bool_type);
+ gcc_jit_block_end_with_return (block1, NULL, one);
+
+ /* Function 2 */
+
+ gcc_jit_param* param2 = gcc_jit_context_new_param (ctxt, NULL, bool_type,
+ "param2");
+ gcc_jit_function* function2 =
+ gcc_jit_context_new_function (ctxt, NULL,
+ GCC_JIT_FUNCTION_EXPORTED, bool_type,
+ "function2", 1, ¶m2, 0);
+ gcc_jit_block* block2 = gcc_jit_function_new_block (function2, "start2");
+
+ gcc_jit_lvalue* var2 =
+ gcc_jit_function_new_local (function2, NULL, bool_type, "var2");
+ gcc_jit_rvalue* addr2 =
+ gcc_jit_lvalue_get_address (var2, NULL);
+ gcc_jit_rvalue* ptr2 =
+ gcc_jit_context_new_cast (ctxt, NULL, addr2, bool_ptr_type);
+ gcc_jit_lvalue* deref2 =
+ gcc_jit_rvalue_dereference (ptr2, NULL);
+ gcc_jit_rvalue* param2_rvalue =
+ gcc_jit_param_as_rvalue (param2);
+ gcc_jit_block_add_assignment (block2, NULL, deref2, param2_rvalue);
+
+ gcc_jit_lvalue* return_value =
+ gcc_jit_function_new_local (function2, NULL, bool_type, "return_value");
+ gcc_jit_rvalue* call =
+ gcc_jit_context_new_call (ctxt, NULL, function1, 1, ¶m2_rvalue);
+ gcc_jit_block_add_assignment (block2, NULL, return_value, call);
+
+ gcc_jit_block* block2_1 =
+ gcc_jit_function_new_block (function2, "end2");
+ gcc_jit_block_end_with_jump (block2, NULL, block2_1);
+
+ gcc_jit_rvalue* value =
+ gcc_jit_context_new_unary_op (ctxt, NULL,
+ GCC_JIT_UNARY_OP_LOGICAL_NEGATE, bool_type,
+ param2_rvalue);
+ gcc_jit_rvalue* return_rvalue =
+ gcc_jit_lvalue_as_rvalue (return_value);
+ gcc_jit_rvalue* and =
+ gcc_jit_context_new_binary_op (ctxt, NULL,
+ GCC_JIT_BINARY_OP_BITWISE_AND, bool_type,
+ return_rvalue, value);
+
+ gcc_jit_block_end_with_return (block2_1, NULL, and);
+}
+
+extern void
+verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
+{
+ /* Verify that no errors were emitted. */
+ CHECK_NON_NULL (result);
+}
--
2.26.2.7.g19db9cfb68.dirty
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type
2022-06-02 2:13 [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type Antoni Boucher
@ 2022-06-02 2:45 ` Antoni Boucher
2022-06-25 15:01 ` Antoni Boucher
2022-06-28 22:40 ` David Malcolm
2022-06-28 22:39 ` David Malcolm
1 sibling, 2 replies; 7+ messages in thread
From: Antoni Boucher @ 2022-06-02 2:45 UTC (permalink / raw)
To: gcc-patches, jit
Also, the test gcc/testsuite/jit.dg/test-asm.cc fails and would need
this line:
#include <stdint.h>
Is this okay if I add it in this patch?
On Wed, 2022-06-01 at 22:13 -0400, Antoni Boucher wrote:
> Hi.
> The attached patch fix bug 105812:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105812
>
> I'm having an issue where contrib/check_GNU_style.sh doesn't seem to
> work, i.e. it doesn't seem to do any checking.
> Is there a new way to do that or am I missing something?
>
> Thanks for the review.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type
2022-06-02 2:45 ` Antoni Boucher
@ 2022-06-25 15:01 ` Antoni Boucher
2022-06-28 22:40 ` David Malcolm
1 sibling, 0 replies; 7+ messages in thread
From: Antoni Boucher @ 2022-06-25 15:01 UTC (permalink / raw)
To: David Malcolm, gcc-patches, jit
David: PING
On Wed, 2022-06-01 at 22:45 -0400, Antoni Boucher wrote:
> Also, the test gcc/testsuite/jit.dg/test-asm.cc fails and would need
> this line:
>
> #include <stdint.h>
>
> Is this okay if I add it in this patch?
>
> On Wed, 2022-06-01 at 22:13 -0400, Antoni Boucher wrote:
> > Hi.
> > The attached patch fix bug 105812:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105812
> >
> > I'm having an issue where contrib/check_GNU_style.sh doesn't seem
> > to
> > work, i.e. it doesn't seem to do any checking.
> > Is there a new way to do that or am I missing something?
> >
> > Thanks for the review.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type
2022-06-02 2:13 [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type Antoni Boucher
2022-06-02 2:45 ` Antoni Boucher
@ 2022-06-28 22:39 ` David Malcolm
1 sibling, 0 replies; 7+ messages in thread
From: David Malcolm @ 2022-06-28 22:39 UTC (permalink / raw)
To: Antoni Boucher, gcc-patches, jit
On Wed, 2022-06-01 at 22:13 -0400, Antoni Boucher via Gcc-patches
wrote:
> Hi.
> The attached patch fix bug 105812:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105812
Thanks; the patch looks good to me, assuming it's been tested in the
usual way, with one nit: the "PR target/105812" in the ChangeLog should
presuambly be "PR jit/105812".
>
> I'm having an issue where contrib/check_GNU_style.sh doesn't seem to
> work, i.e. it doesn't seem to do any checking.
> Is there a new way to do that or am I missing something?
I confess I've never actually used that script.
Dave
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type
2022-06-02 2:45 ` Antoni Boucher
2022-06-25 15:01 ` Antoni Boucher
@ 2022-06-28 22:40 ` David Malcolm
2022-06-29 13:44 ` Antoni Boucher
1 sibling, 1 reply; 7+ messages in thread
From: David Malcolm @ 2022-06-28 22:40 UTC (permalink / raw)
To: Antoni Boucher, gcc-patches, jit
On Wed, 2022-06-01 at 22:45 -0400, Antoni Boucher via Gcc-patches
wrote:
> Also, the test gcc/testsuite/jit.dg/test-asm.cc fails and would need
> this line:
>
> #include <stdint.h>
I'm curious; how is it failing?
>
> Is this okay if I add it in this patch?
>
> On Wed, 2022-06-01 at 22:13 -0400, Antoni Boucher wrote:
> > Hi.
> > The attached patch fix bug 105812:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105812
> >
> > I'm having an issue where contrib/check_GNU_style.sh doesn't seem
> > to
> > work, i.e. it doesn't seem to do any checking.
> > Is there a new way to do that or am I missing something?
> >
> > Thanks for the review.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type
2022-06-28 22:40 ` David Malcolm
@ 2022-06-29 13:44 ` Antoni Boucher
2022-06-29 13:51 ` David Malcolm
0 siblings, 1 reply; 7+ messages in thread
From: Antoni Boucher @ 2022-06-29 13:44 UTC (permalink / raw)
To: David Malcolm, gcc-patches, jit
It fails with the following error:
gcc/gcc/testsuite/jit.dg/test-asm.cc: In function 'void
verify_code_2(gcc_jit_context*, gcc_jit_result*)':
gcc/gcc/testsuite/jit.dg/test-asm.cc:160:11: error: ISO C++ forbids
declaration of 'uint32_t' with no type [-fpermissive]
gcc/gcc/testsuite/jit.dg/test-asm.cc:160:11: error: typedef 'uint32_t'
is initialized (use 'decltype' instead)
Are you OK with me adding the stdint.h header?
On Tue, 2022-06-28 at 18:40 -0400, David Malcolm wrote:
> On Wed, 2022-06-01 at 22:45 -0400, Antoni Boucher via Gcc-patches
> wrote:
> > Also, the test gcc/testsuite/jit.dg/test-asm.cc fails and would
> > need
> > this line:
> >
> > #include <stdint.h>
>
> I'm curious; how is it failing?
>
> >
> > Is this okay if I add it in this patch?
> >
> > On Wed, 2022-06-01 at 22:13 -0400, Antoni Boucher wrote:
> > > Hi.
> > > The attached patch fix bug 105812:
> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105812
> > >
> > > I'm having an issue where contrib/check_GNU_style.sh doesn't seem
> > > to
> > > work, i.e. it doesn't seem to do any checking.
> > > Is there a new way to do that or am I missing something?
> > >
> > > Thanks for the review.
> >
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type
2022-06-29 13:44 ` Antoni Boucher
@ 2022-06-29 13:51 ` David Malcolm
0 siblings, 0 replies; 7+ messages in thread
From: David Malcolm @ 2022-06-29 13:51 UTC (permalink / raw)
To: Antoni Boucher, gcc-patches, jit
On Wed, 2022-06-29 at 09:44 -0400, Antoni Boucher wrote:
> It fails with the following error:
>
> gcc/gcc/testsuite/jit.dg/test-asm.cc: In function 'void
> verify_code_2(gcc_jit_context*, gcc_jit_result*)':
> gcc/gcc/testsuite/jit.dg/test-asm.cc:160:11: error: ISO C++ forbids
> declaration of 'uint32_t' with no type [-fpermissive]
> gcc/gcc/testsuite/jit.dg/test-asm.cc:160:11: error: typedef
> 'uint32_t'
> is initialized (use 'decltype' instead)
Aha - I didn't notice the use of uint32_t there.
>
> Are you OK with me adding the stdint.h header?
Yes, thanks.
Dave
>
> On Tue, 2022-06-28 at 18:40 -0400, David Malcolm wrote:
> > On Wed, 2022-06-01 at 22:45 -0400, Antoni Boucher via Gcc-patches
> > wrote:
> > > Also, the test gcc/testsuite/jit.dg/test-asm.cc fails and would
> > > need
> > > this line:
> > >
> > > #include <stdint.h>
> >
> > I'm curious; how is it failing?
> >
> > >
> > > Is this okay if I add it in this patch?
> > >
> > > On Wed, 2022-06-01 at 22:13 -0400, Antoni Boucher wrote:
> > > > Hi.
> > > > The attached patch fix bug 105812:
> > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105812
> > > >
> > > > I'm having an issue where contrib/check_GNU_style.sh doesn't
> > > > seem
> > > > to
> > > > work, i.e. it doesn't seem to do any checking.
> > > > Is there a new way to do that or am I missing something?
> > > >
> > > > Thanks for the review.
> > >
> >
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-06-29 13:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 2:13 [PATCH] libgccjit: Fix bug where unary_op will return an integer type instead of the correct type Antoni Boucher
2022-06-02 2:45 ` Antoni Boucher
2022-06-25 15:01 ` Antoni Boucher
2022-06-28 22:40 ` David Malcolm
2022-06-29 13:44 ` Antoni Boucher
2022-06-29 13:51 ` David Malcolm
2022-06-28 22:39 ` David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).