On 08/08/2014 15:11, Roman Gareev wrote:
I think this is fine. On the other side, I think the test case itself
>is unnecessarily large. I would assume the majority of the code could
>be deleted while still triggering the bug. Could you give it a shot.
I've attached an improved version of the patch.

LGTM.

>Is there anything else you still would like to do?
I wanted to make the current code available to be able to fix all new
possible bugs before 'pencils down'. If I have free time, I'll try to
improve the performance of the generation.

Good, though before let's try to get the correctness right.

>Otherwise, I believe fixing the last remaining bugs is of high importance, as 
we want to enable
>this code as soon as possible to avoid future bitrot.
>
>I understand that reducing this may require some work, but I don't think it
>is that hard. Specifically, you could first compile the individual *.cpp
>files to .o files once using once graphite once not.
I've found out that btCollisionWorld.cpp, btCollisionDispatcher.cpp
and btDiscreteDynamicsWorld.llvm.cpp cause “Segmentation fault”. All
of them produce similar ASTs:

Is this segmentation fault at compile time or at run-time? I believe it was a segfault at run-time due to a miscompile.

btCollisionWorld.cpp:

CLAST generated by CLooG:

if (8*T_45 >= -T_44+9) {
   for (scat_1=0;scat_1<=T_45-1;scat_1++) {
     if ((8*scat_1+T_44+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
       (scat_1);
     }
   }
}

isl_codegen:

[P_45, P_44] -> { S_12[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_45)/4294967296), e1 = floor((P_44 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_45 and 4294967296e0 >= -4294967296 +
P_45 and 4294967296e0 <= -1 + P_45 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_44 + 8i0 and
18446744073709551616e1 <= -1 + P_44 + 8i0) }

[P_45, P_44] -> {  : exists (e0 = floor((-1 + P_45)/4294967296):
4294967296e0 <= -1 + P_45 and 4294967296e0 >= -2147483647 + P_45 and
P_45 >= -2147483648 and P_45 <= 2147483647 and P_44 >= 0 and P_44 <=
18446744073709551615) }

[P_45, P_44] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_45; c1 += 1)
   if ((P_44 + 8 * c1) % 18446744073709551616 >= 1)
     S_12(c1);

btCollisionDispatcher.cpp:

CLAST generated by CLooG:

if (8*T_81 >= -T_80+9) {
   for (scat_1=0;scat_1<=T_81-1;scat_1++) {
     if ((8*scat_1+T_80+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
       (scat_1);
     }
   }
}

isl_codegen:

[P_81, P_80] -> { S_22[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_81)/4294967296), e1 = floor((P_80 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_81 and 4294967296e0 >= -4294967296 +
P_81 and 4294967296e0 <= -1 + P_81 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_80 + 8i0 and
18446744073709551616e1 <= -1 + P_80 + 8i0) }

[P_81, P_80] -> {  : exists (e0 = floor((-1 + P_81)/4294967296):
4294967296e0 <= -1 + P_81 and 4294967296e0 >= -2147483647 + P_81 and
P_81 >= -2147483648 and P_81 <= 2147483647 and P_80 >= 0 and P_80 <=
18446744073709551615) }

[P_81, P_80] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_81; c1 += 1)
   if ((P_80 + 8 * c1) % 18446744073709551616 >= 1)
     S_22(c1);

btDiscreteDynamicsWorld.llvm.cpp:

CLAST generated by CLooG:

if (8*T_24 >= -T_23+9) {
   for (scat_1=0;scat_1<=T_24-1;scat_1++) {
     if ((8*scat_1+T_23+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
       (scat_1);
     }
   }
}

isl_codegen:

[P_24, P_23] -> { S_13[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_24)/4294967296), e1 = floor((P_23 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_24 and 4294967296e0 >= -4294967296 +
P_24 and 4294967296e0 <= -1 + P_24 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_23 + 8i0 and
18446744073709551616e1 <= -1 + P_23 + 8i0) }

[P_24, P_23] -> {  : exists (e0 = floor((-1 + P_24)/4294967296):
4294967296e0 <= -1 + P_24 and 4294967296e0 >= -2147483647 + P_24 and
P_24 >= -2147483648 and P_24 <= 2147483647 and P_23 >= 0 and P_23 <=
18446744073709551615) }

[P_24, P_23] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_24; c1 += 1)
   if ((P_23 + 8 * c1) % 18446744073709551616 >= 1)
     S_13(c1);

CLAST generated by CLooG:

if (8*T_46 >= -T_45+9) {
   for (scat_1=0;scat_1<=T_46-1;scat_1++) {
     if ((8*scat_1+T_45+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
       (scat_1);
     }
   }
}

isl_codegen:

[P_46, P_45] -> { S_16[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_46)/4294967296), e1 = floor((P_45 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_46 and 4294967296e0 >= -4294967296 +
P_46 and 4294967296e0 <= -1 + P_46 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_45 + 8i0 and
18446744073709551616e1 <= -1 + P_45 + 8i0) }

[P_46, P_45] -> {  : exists (e0 = floor((-1 + P_46)/4294967296):
4294967296e0 <= -1 + P_46 and 4294967296e0 >= -2147483647 + P_46 and
P_46 >= -2147483648 and P_46 <= 2147483647 and P_45 >= 0 and P_45 <=
18446744073709551615) }

[P_46, P_45] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_46; c1 += 1)
   if ((P_45 + 8 * c1) % 18446744073709551616 >= 1)
     S_16(c1);

CLAST generated by CLooG:

if (8*T_18 >= -T_17+9) {
   for (scat_1=0;scat_1<=T_18-1;scat_1++) {
     if ((8*scat_1+T_17+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
       (scat_1);
     }
   }
}

isl_codegen:

[P_18, P_17] -> { S_12[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_18)/4294967296), e1 = floor((P_17 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_18 and 4294967296e0 >= -4294967296 +
P_18 and 4294967296e0 <= -1 + P_18 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_17 + 8i0 and
18446744073709551616e1 <= -1 + P_17 + 8i0) }

[P_18, P_17] -> {  : exists (e0 = floor((-1 + P_18)/4294967296):
4294967296e0 <= -1 + P_18 and 4294967296e0 >= -2147483647 + P_18 and
P_18 >= -2147483648 and P_18 <= 2147483647 and P_17 >= 0 and P_17 <=
18446744073709551615) }

[P_18, P_17] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_18; c1 += 1)
   if ((P_17 + 8 * c1) % 18446744073709551616 >= 1)
     S_12(c1);

I think that, for example, the following code

if (8*T_45 >= -T_44+9) {
   for (scat_1=0;scat_1<=T_45-1;scat_1++) {
     if ((8*scat_1+T_44+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
       (scat_1);
     }
   }
}

is equivalent to

if (8*T_45 >= -T_44+9) {
   for (scat_1=0;scat_1<=T_45-1;scat_1++) {
     if ((8*scat_1+T_44)%18446744073709551616 <= -1) {
       (scat_1);
     }
   }
}

If I'm not mistaken it's not equivalent to

for (int c1 = 0; c1 < P_45; c1 += 1)
   if ((P_44 + 8 * c1) % 18446744073709551616 >= 1)
     S_12(c1);

Maybe the ISL generator generates wrong code. What do you think about this?

Possibly. Can you split the .cpp files such that you only compile a single function with graphite and that compiling this function causes the miscompile. This allows us to look at less code.

Cheers,
Tobias

Reply via email to