All of lore.kernel.org
 help / color / mirror / Atom feed
* sparse-llvm incorrect type when ealing with union type
@ 2017-03-13 22:54 Dibyendu Majumdar
  2017-03-13 23:44 ` Dibyendu Majumdar
  2017-03-19 15:36 ` Luc Van Oostenryck
  0 siblings, 2 replies; 9+ messages in thread
From: Dibyendu Majumdar @ 2017-03-13 22:54 UTC (permalink / raw)
  To: Linux-Sparse

Hi,

I am investigating a type error in LLVM. Here is the snippet of code:

typedef union GCObject GCObject;
typedef unsigned char lu_byte;
typedef double lua_Number;
typedef union {
 GCObject *gc;
 void *p;
 lua_Number n;
 int b;
} Value;
typedef struct lua_TValue {
 Value value;
 int tt;
} TValue;
typedef struct UpVal {
 GCObject *next;
 lu_byte tt;
 lu_byte marked;
 TValue *v;
 union {
  TValue value;
  struct {
   struct UpVal *prev;
   struct UpVal *next;
  } l;
 } u;
} UpVal;
static void close(UpVal *uv)
{
 uv->v = &uv->u.value;
}

The linearized output is:

close:
.L0:
        <entry-point>
        add.64      %r2 <- %arg1, $24
        store.64    %r2 -> 16[%arg1]
        ret

The result of the add operation ends up the same type as arg1 which is
UpVal*. But this is then assigned to uv->v which is expected to be
TValue*. So LLVM doesn't like it.

While in this case we could cast to the expected value before the
store - I am worried that in other cases where the value is read and
used somewhere it will have the wrong type.

I see that the add instruction's type is 'void *'.

Any suggestions on how to solve this issue?

Thanks and Regards
Dibyendu

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-03-19 21:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 22:54 sparse-llvm incorrect type when ealing with union type Dibyendu Majumdar
2017-03-13 23:44 ` Dibyendu Majumdar
2017-03-14  1:29   ` Dibyendu Majumdar
2017-03-19 15:36 ` Luc Van Oostenryck
2017-03-19 15:54   ` Dibyendu Majumdar
2017-03-19 16:37   ` Dibyendu Majumdar
2017-03-19 17:15     ` Luc Van Oostenryck
2017-03-19 17:55       ` Dibyendu Majumdar
2017-03-19 20:48         ` Dibyendu Majumdar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.