Re: [PATCH] fix casts when linearizing compound assignments

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

 



On Fri, Jun 8, 2012 at 6:45 PM, Xi Wang <xi.wang@xxxxxxxxx> wrote:
> On Jun 8, 2012, at 6:47 AM, Xi Wang wrote:
>> -             oldvalue = cast_pseudo(ep, oldvalue, src->ctype, expr->ctype);
>> -             opcode = opcode_sign(op_trans[expr->op - SPECIAL_BASE], src->ctype);
>> -             dst = add_binary_op(ep, src->ctype, opcode, oldvalue, value);
>> -             value = cast_pseudo(ep, dst, expr->ctype, src->ctype);
>> +             opcode = opcode_sign(op_trans[expr->op - SPECIAL_BASE], expr->ctype);
>> +             value = cast_pseudo(ep, value, src->ctype, expr->ctype);
>> +             value = add_binary_op(ep, expr->ctype, opcode, oldvalue, value);
>
> For sparse-llvm, is it better to get rid of the cast_pseudo()
> at all?
>
> For example, what to emit for p += 1:
>
> 1) pointer p + integer 1,
>
> 2) pointer + pointer [cast from integer], or
>
> 3) (pointer)(integer [cast from pointer] + integer)?

Dunno.

This:

void *foo(void *p)
{
  p += 1;

  return p;
}

is converted as follows by clang:

define i8* @foo(i8* %p) nounwind uwtable readnone {
  %1 = getelementptr i8* %p, i64 1
  ret i8* %1
}

[ You can try it out yourself here: http://llvm.org/demo/index.cgi ]

So it seems that LLVM really wants to use the "getelementptr" thingy
for these. I have no idea what makes the most sense from sparse IR
point of view.

Jeff, Linus, Chris, hmm?

                        Pekka
--
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