A few quick-and-dirty edits got Polly working during ThinLTO codegen via lld-link.exe on Windows.
D:\src_builds\llvm-monorepo\llvm\lld\COFF\CMakeLists.txt
Add IPO to LINK_COMPONENTS. Add Polly to LINK_LIBS. File attached.
D:\src_builds\llvm-monorepo\llvm\lld\COFF\Driver.cpp
Add namespace for Polly. Line 57 in attached file.
Initialize Polly for LTO. Line 1113 in attached file.
lld-link.exe will now accept, initialize, and pass arguments to Polly.
-mllvm:-polly -mllvm:-pass-remarks-analysis=polly
Example of analysis remarks generated by lld-link.exe for some code I compiled with both Polly and ThinLTO enabled.
....
<unknown>:0:0: SCoP begins here.
<unknown>:0:0: Inbounds assumption: [p_0, p_1, p_2, p_3] -> { : p_3 >= p_0 }
<unknown>:0:0: Inbounds assumption: [p_0, p_1, p_2, p_3] -> { : p_2 >= 2p_0 }
<unknown>:0:0: Inbounds assumption: [p_0, p_1, p_2, p_3] -> { : p_2 >= 2p_0 }
<unknown>:0:0: Inbounds assumption: [p_0, p_1, p_2, p_3] -> { : p_2 >= -1 + 2p_0 }
<unknown>:0:0: Inbounds assumption: [p_0, p_1, p_2, p_3] -> { : p_2 >= -1 + 2p_0 }
<unknown>:0:0: No-overflows restriction: [p_0, p_1, p_2, p_3] -> { : p_0 >= 4611686018427387905 and p_1 > 0 }
<unknown>:0:0: No-overflows restriction: [p_0, p_1, p_2, p_3] -> { : p_0 >= 4611686018427387905 and p_1 > 0 }
<unknown>:0:0: No-overflows restriction: [p_0, p_1, p_2, p_3] -> { : p_0 >= 4611686018427387905 and p_1 > 0 }
<unknown>:0:0: No-overflows restriction: [p_0, p_1, p_2, p_3] -> { : p_0 > 0 and p_1 >= 4611686018427387905 }
<unknown>:0:0: No-overflows restriction: [p_0, p_1, p_2, p_3] -> { : p_0 > 0 and p_1 >= 4611686018427387905 }
<unknown>:0:0: No-overflows restriction: [p_0, p_1, p_2, p_3] -> { : p_0 > 0 and p_1 >= 4611686018427387905 }
<unknown>:0:0: Finite loop restriction: [p_0, p_1, p_2, p_3] -> { : p_0 < 0 and p_1 > 0 }
<unknown>:0:0: Finite loop restriction: [p_0, p_1, p_2, p_3] -> { : p_1 < 0 and (p_0 < 0 or p_0 > 0) }
<unknown>:0:0: Possibly aliasing pointer, use restrict keyword.
<unknown>:0:0: Possibly aliasing pointer, use restrict keyword.
<unknown>:0:0: Possibly aliasing pointer, use restrict keyword.
<unknown>:0:0: Possibly aliasing pointer, use restrict keyword.
<unknown>:0:0: Possibly aliasing pointer, use restrict keyword.
<unknown>:0:0: SCoP ends here.
....
I would suspect similar can be done for ELF and whatever else. Assuming someone wants to add some build conditionals and submit the needed patch(es).