Re: [PATCH 1/2] V2 Give the constant pseudo value a size

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

 



I am trying to test this change ... and work out the impact. It seems
interesting to create some weird examples:

struct A {
        long x,y;
};
struct B {
        char buf[100];
        union {
                int j;
                long long k;
        } u;
};

extern int printf(const char *, ...);
void bar(int j) {
        printf("got %d\n", j);
}

void foo()
{
        struct A a = { 0 };
        struct B b = { { 0 } };

        a.y == 0 ? bar(1) : bar(0);
        b.u.j == 0 ? bar(1) : bar(0);
        b.u.k == 0 ? bar(1) : bar(0);
}

int main(void)
{
        foo();
        return 0;
}

Now the output from Chris' version is:

bar:
.L0x7f0d5f810010:
        <entry-point>
        call.32     %r3 <- printf, "got %d\n", %arg1
        ret


foo:
.L0x7f0d5f8100b0:
        <entry-point>
        call        bar, $1
        call        bar, $1
        call        bar, $1
        ret


main:
.L0x7f0d5f810420:
        <entry-point>
        call        foo
        ret.32      $0

And the output from Sparse 0.5.1 is:

bar:
.L0:
        <entry-point>
        call.32     %r3 <- printf, "got %d\n", %arg1
        ret


foo:
.L2:
        <entry-point>
        store.128   $0 -> 0[a]
        store.64    $0 -> 0[a]
        store.896   $0 -> 0[b]
        store.8     $0 -> 0[b]
        load.64     %r4 <- 8[a]
        cbr         %r4, .L4, .L3

.L3:
        call        bar, $1
        br          .L5

.L4:
        call        bar, $0
        br          .L5

.L5:
        load.32     %r7 <- 104[b]
        cbr         %r7, .L7, .L6

.L6:
        call        bar, $1
        br          .L8

.L7:
        call        bar, $0
        br          .L8

.L8:
        load.64     %r10 <- 104[b]
        cbr         %r10, .L10, .L9

.L9:
        call        bar, $1
        br          .L12

.L10:
        call        bar, $0
        br          .L12

.L12:
        ret


main:
.L13:
        <entry-point>
        call        foo
        ret.32      $0
--
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