Re: sparse-llvm issue with counter in a loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 11, 2017 at 11:38 PM, Dibyendu Majumdar
<mobile@xxxxxxxxxxxxxxx> wrote:
> On 11 March 2017 at 22:04, Dibyendu Majumdar <mobile@xxxxxxxxxxxxxxx> wrote:
>> I am not sure what is happening here. The test program is:
>>
>> extern int printf(const char *fmt, ...);
>> int main(void) {
>>     int Count;
>>     for (Count = 0; Count < 4; Count++)
>>     {
>>         printf("%d\n", Count);
>>         switch (Count)
>>         {
>>         case 1:
>>             printf("%d\n", 1);
>>             break;
>>         case 2:
>>             printf("%d\n", 2);
>>             break;
>>         default:
>>             printf("%d\n", 0);
>>             break;
>>         }
>>     }
>>     return 0;
>> }
>>
>> The linearized output I get:
>>
>> main:
>> .L0:
>>         <entry-point>
>>         phisrc.32   %phi4(Count) <- $0
>>         br          .L4
>> .L4:
>>         phi.32      %r1(Count) <- %phi4(Count), %phi5(Count)
>>         setlt.32    %r2 <- %r1(Count), $4
>>         br          %r2, .L1, .L9
>> .L1:
>>         symaddr.64  %r3 <- <anon symbol:000001A5682A1E38>
>>         call.32     %r5 <- printf, %r3, %r1(Count)
>>         switch      %r1(Count), 1 -> .L6, 2 -> .L7, default -> .L8
>> .L6:
>>         symaddr.64  %r7 <- <anon symbol:000001A5682A21B8>
>>         call.32     %r8 <- printf, %r7, $1
>>         br          .L2
>> .L7:
>>         symaddr.64  %r9 <- <anon symbol:000001A5682A2538>
>>         call.32     %r10 <- printf, %r9, $2
>>         br          .L2
>> .L8:
>>         symaddr.64  %r11 <- <anon symbol:000001A5682A28B8>
>>         call.32     %r12 <- printf, %r11, $0
>>         br          .L2
>> .L2:
>>         add.32      %r14 <- %r1(Count), $1
>>         phisrc.32   %phi5(Count) <- %r14
>>         br          .L4
>> .L9:
>>         ret.32      $0
>>
>>
>> In sparse-llvm the instruction:
>> add.32      %r14 <- %r1(Count), $1
>>
>> fails because the type of %r1(Count) is void. I am not sure why the
>> type is void here.
>>
>
> Looks like the 'void' is coming from this in output_op_switch() in
> sparse-llvm.c:
>
>  target = LLVMBuildSwitch(fn->builder, sw_val,
>      def ? def->priv : NULL, n_jmp);
> ...
>  insn->target->priv = target;
>
>
> So this is probably incorrect. Looks like we should not set
> insn->target->priv  here as it is already set. Removing the assignment
> resolves the issue.

Yes, it looks the same as there was in output_op_store().
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux