Issue |
99887
|
Summary |
WRONG code. FE:@llvm.lifetime.end? DeadStoreElim?
|
Labels |
new issue
|
Assignees |
|
Reporter |
JonPsson1
|
This program:
```
int printf(const char *, ...);
long RES;
unsigned ****c;
unsigned *****volatile P5 = &c;
static unsigned ****P4;
unsigned **P2a, **P2b;
int main() {
{
unsigned ***P3 = &P2a;
for (unsigned IV = -8; IV; IV = IV + 4) {
unsigned ***i = &P2b;
long *P = &RES;
*P5 = &i;
*P = ( (P4 = &P3) == *P5 );
}
}
printf("%d\n", RES);
}
```
should print '0', which it does, except if compiled with -Os on SystemZ:
clang -march=z15 -Os wrong0.i -o a.out -w; ./a.out
1
If I remove the extra curly braces around the loop, 0 is printed also with -Os. I see from the front-end only one slight difference with the braces in a block:
```
for.end: ; pred for.end: ; pred
> call void @llvm.lifetime.end.p0(i64 8, ptr %P3) #3
%6 = load i64, ptr @RES, align 8, !tbaa !10 %6 = load i64, ptr @RES, align 8, !tbaa !10
%call = call signext i32 (ptr, ...) @printf(ptr nounde %call = call signext i32 (ptr, ...) @printf(ptr nounde
call void @llvm.lifetime.end.p0(i64 8, ptr %P3) #3 <
%7 = load i32, ptr %retval, align 4 %7 = load i32, ptr %retval, align 4
ret i32 %7 ret i32 %7
}
```
Many passes later, the next change then is after DSE where a store now has been removed:
```
; *** IR Dump After DSEPass on main *** ; *** IR Dump After DSEPass on main ***
; Function Attrs: nounwind optsize ; Function Attrs: nounwind optsize
define dso_local signext i32 @main() local_unnamed_addr define dso_local signext i32 @main() local_unnamed_addr
entry: entry:
%P3 = alloca ptr, align 8 %P3 = alloca ptr, align 8
%i = alloca ptr, align 8 %i = alloca ptr, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull % call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %
store ptr @P2a, ptr %P3, align 8, !tbaa !4 <
br label %for.body br label %for.body
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs