[llvm-dev] Help with SROA throwing away no-alias information
Neil Henning via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 17 08:22:22 PST 2020
I'm having an issue where SROA will throw away no-alias information on some
loads after inlining, because the loads are derived from a store to an
alloca which can be removed after inlining.
The pointers that were originally stored into the alloca do *not *have any
aliasing information - the only context that allowed me to assert aliasing
was that the inlined-function guaranteed it to be so.
I know why SROA has done this - its just removing a store -> load on an
alloca by forwarding the store, but is there anyway I can preserve the
information that these pointers must no-alias?
Here is the pre/post from when SROA is run and you can see the now missing
information of no-alias:
define dllexport void
@"Burst.Compiler.IL.Tests.Aliasing.CheckInlinedFunctionPreservesAliasing(ref
Burst.Compiler.IL.Tests.Aliasing.NoAliasWithContentsStruct
s)_862A52BC559AC318"(%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"*
nocapture nonnull readonly %s) local_unnamed_addr #0 !ubaa. !1 {
entry:
%var.0 = alloca %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField", align 8
%0 = bitcast
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s to i64*
%1 = load i64, i64* %0, align 1
%2 = getelementptr
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct",
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s, i64 0,
i32 1
%3 = bitcast i8** %2 to i64*
%4 = load i64, i64* %3, align 1
%5 = bitcast %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0 to
i64*
store i64 %1, i64* %5, align 8
%.fca.1.gep = getelementptr inbounds
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasField",
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0, i64 0, i32 1
%6 = bitcast i32** %.fca.1.gep to i64*
store i64 %4, i64* %6, align 8
%7 = bitcast %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0 to
i8**
%8 = load i8*, i8** %7, align 1, !alias.scope !2, !noalias !5
%9 = getelementptr %"Burst.Compiler.IL.Tests.Aliasing/NoAliasField",
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasField"* %var.0, i64 0, i32 1
%10 = bitcast i32** %9 to i8**
%11 = load i8*, i8** %10, align 1, !alias.scope !5, !noalias !2
call void @llvm.ubaa.expect.no.alias(i8* %8, i64 -1, i8* %11, i64 -1,
metadata
!"C:\\Users\\NeilHenning\\Home\\burst\\src\\Burst.Compiler.IL.Tests\\Shared\\083-Aliasing.cs(229,9):
") #0
ret void
}
*** IR Dump After SROA ***
; Function Attrs: nounwind
define dllexport void
@"Burst.Compiler.IL.Tests.Aliasing.CheckInlinedFunctionPreservesAliasing(ref
Burst.Compiler.IL.Tests.Aliasing.NoAliasWithContentsStruct
s)_862A52BC559AC318"(%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"*
nocapture nonnull readonly %s) local_unnamed_addr #0 !ubaa. !1 {
entry:
%0 = bitcast
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s to i64*
%1 = load i64, i64* %0, align 1
%2 = getelementptr
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct",
%"Burst.Compiler.IL.Tests.Aliasing/NoAliasWithContentsStruct"* %s, i64 0,
i32 1
%3 = bitcast i8** %2 to i64*
%4 = load i64, i64* %3, align 1
%5 = inttoptr i64 %1 to i8*
%6 = inttoptr i64 %4 to i8*
call void @llvm.ubaa.expect.no.alias(i8* %5, i64 -1, i8* %6, i64 -1,
metadata
!"C:\\Users\\NeilHenning\\Home\\burst\\src\\Burst.Compiler.IL.Tests\\Shared\\083-Aliasing.cs(229,9):
") #0
ret void
}
My only workaround I can dream up locally is to run a pass before SROA to
do the alias.scope and noalias forwarding myself by looking back through
the store...
Cheers,
-Neil.
--
Neil Henning
Senior Software Engineer Compiler
unity.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200117/d52c58da/attachment-0001.html>
More information about the llvm-dev
mailing list