nikic wrote:
I believe this is a representative example of the issue:
```
@g = external global ptr
define i32 @test(ptr dereferenceable(16) %this) {
%_length.i = getelementptr inbounds nuw i8, ptr %this, i64 8
store i32 0, ptr %_length.i
%call.i = call noalias ptr @_Znam(i64 8) #14
store ptr %call.i, ptr @g
%res = load i32, ptr %_length.i, !tbaa !20
ret i32 %res
}
declare ptr @_Znam(i64)
attributes #14 = { builtin allocsize(0) memory(inaccessiblemem: readwrite,
errnomem: write) }
!llvm.errno.tbaa = !{!4}
!4 = !{!5, !5, i64 0}
!5 = !{!"int", !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!9 = !{!"_ZTS11CStringBaseIwE", !10, i64 0, !5, i64 8, !5, i64 12}
!10 = !{!"p1 wchar_t", !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!20 = !{!9, !5, i64 8}
```
We no longer perform store to load forwarding.
The issue is the `errnomem: write`. We consider the load here to alias errno.
Previously this worked because we fell through to the special allocator
handling (that I'm trying to remove).
GCC considers these to not alias: https://gcc.godbolt.org/z/ejT6doxv8
I think it would make sense to say that anything using struct TBAA cannot alias
errno? Even if the member happens to be an int. (As usual, this may be slightly
iffy when it comes to libc LTO, where errno might be part of a struct.)
https://github.com/llvm/llvm-project/pull/197199
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits