Possible incorrect linearization of code (master branch)

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

 



Hi,

I have this test program:

extern char *incr(char *p);
char *incr(char *p) {
 char *tmp = p;
 tmp += 5;
 return tmp;
}
int main(const char *argv[]) {
 char *text =  "abcde";
 char *p = incr(text);
 return (*p == 'e') ? 0 : 1;
}

The linearizer outputs following which I think is incorrect as it is
missing a load.

incr:
.L0:
        <entry-point>
        cast.64     %r3 <- (64) %arg1
        add.64      %r4 <- %r3, $5
        ptrcast.64  %r5 <- (64) %r4
        ret.64      %r5

main:
.L2:
        <entry-point>
        call.64     %r10 <- incr, "abcde"
        setne.32    %r15 <- %r13, $101
        ret.32      %r15

If I change the return in main to be a if else block then correct code
is generated.

int main(const char *argv[]) {
 char *text =  "abcde";
 char *p = incr(text);
 // return (*p == 'e') ? 0 : 1;
 if (*p == 'e')
  return 0;
 else
  return 1;
}

main:
.L2:
        <entry-point>
        call.64     %r10 <- incr, "abcde"
        load.8      %r12 <- 0[%r10]
        scast.32    %r13 <- (8) %r12
        setne.32    %r15 <- %r13, $101
        ret.32      %r15
--
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