All of lore.kernel.org
 help / color / mirror / Atom feed
* sparse-llvm switch constants must all be same type as switch value
@ 2017-03-13 21:24 Dibyendu Majumdar
  2017-03-19  0:52 ` Luc Van Oostenryck
  0 siblings, 1 reply; 4+ messages in thread
From: Dibyendu Majumdar @ 2017-03-13 21:24 UTC (permalink / raw)
  To: Linux-Sparse

Hi,

While investigating errors that occurred when compiling 'minilua' I
found that the sparse-llvm output for switch statements is hard coded
to generate int32 values even when the switch is on a different
integer type. I believe following fix is needed in output_op_switch():

 FOR_EACH_PTR(insn->multijmp_list, jmp) {
  if (jmp->begin == jmp->end) {  /* case N */
   LLVMAddCase(target,
    LLVMConstInt(LLVMTypeOf(sw_val), jmp->begin, 0),
    jmp->target->priv);
  } else if (jmp->begin < jmp->end) { /* case M..N */
   assert(0);
  }
 } END_FOR_EACH_PTR(jmp);

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

* Re: sparse-llvm switch constants must all be same type as switch value
  2017-03-13 21:24 sparse-llvm switch constants must all be same type as switch value Dibyendu Majumdar
@ 2017-03-19  0:52 ` Luc Van Oostenryck
  2017-03-19 12:31   ` Dibyendu Majumdar
  0 siblings, 1 reply; 4+ messages in thread
From: Luc Van Oostenryck @ 2017-03-19  0:52 UTC (permalink / raw)
  To: Dibyendu Majumdar; +Cc: Linux-Sparse

On Mon, Mar 13, 2017 at 09:24:47PM +0000, Dibyendu Majumdar wrote:
> Hi,
> 
> While investigating errors that occurred when compiling 'minilua' I
> found that the sparse-llvm output for switch statements is hard coded
> to generate int32 values even when the switch is on a different
> integer type. I believe following fix is needed in output_op_switch():
> 
>  FOR_EACH_PTR(insn->multijmp_list, jmp) {
>   if (jmp->begin == jmp->end) {  /* case N */
>    LLVMAddCase(target,
>     LLVMConstInt(LLVMTypeOf(sw_val), jmp->begin, 0),
>     jmp->target->priv);
>   } else if (jmp->begin < jmp->end) { /* case M..N */
>    assert(0);
>   }
>  } END_FOR_EACH_PTR(jmp);

There is also a problem with signed/unsigned constants,
like everywhere else in the code.

Could you submit a test case for this?

-- Luc

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

* Re: sparse-llvm switch constants must all be same type as switch value
  2017-03-19  0:52 ` Luc Van Oostenryck
@ 2017-03-19 12:31   ` Dibyendu Majumdar
  2017-03-19 15:19     ` Luc Van Oostenryck
  0 siblings, 1 reply; 4+ messages in thread
From: Dibyendu Majumdar @ 2017-03-19 12:31 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: Linux-Sparse

On 19 March 2017 at 00:52, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> On Mon, Mar 13, 2017 at 09:24:47PM +0000, Dibyendu Majumdar wrote:
>>
>> While investigating errors that occurred when compiling 'minilua' I
>> found that the sparse-llvm output for switch statements is hard coded
>> to generate int32 values even when the switch is on a different
>> integer type.
>
> Could you submit a test case for this?
>

extern int printf(const char *, ...);
int main(int argc, const char *argv[])
{
 const char *cp = argv[0];
 switch (*cp) {
 case 's':
  printf("%c\n", *cp);
  break;
 default:
  if (*cp)
   printf("%c\n", *cp);
  break;
 }
 return 0;
}

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

* Re: sparse-llvm switch constants must all be same type as switch value
  2017-03-19 12:31   ` Dibyendu Majumdar
@ 2017-03-19 15:19     ` Luc Van Oostenryck
  0 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2017-03-19 15:19 UTC (permalink / raw)
  To: Dibyendu Majumdar; +Cc: Linux-Sparse

On Sun, Mar 19, 2017 at 12:31:27PM +0000, Dibyendu Majumdar wrote:
> On 19 March 2017 at 00:52, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> > On Mon, Mar 13, 2017 at 09:24:47PM +0000, Dibyendu Majumdar wrote:
> >>
> >> While investigating errors that occurred when compiling 'minilua' I
> >> found that the sparse-llvm output for switch statements is hard coded
> >> to generate int32 values even when the switch is on a different
> >> integer type.

This is fixed in the llvm-fixes-v3 serie I submitted yesterday.

-- Luc

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 21:24 sparse-llvm switch constants must all be same type as switch value Dibyendu Majumdar
2017-03-19  0:52 ` Luc Van Oostenryck
2017-03-19 12:31   ` Dibyendu Majumdar
2017-03-19 15:19     ` Luc Van Oostenryck

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.