Karl Rehm via llvm-dev
2020-Jan-30 01:28 UTC
[llvm-dev] Question about ObjectSizeOffsetVisitor::visitGlobalVariable
Interesting, so I guess we can check for whether it's an array type and adjust accordingly instead? Blocking *all* global variables without definitive initializers feels a bit much to me, especially if they have primitive types (i.e. integers) that don't have the potential to be screwed around with like this. On Wed, Jan 29, 2020 at 8:14 PM George Burgess IV < george.burgess.iv at gmail.com> wrote:> Looks like the commit that added that was > https://github.com/llvm/llvm-project/commit/16e42128c24f5df8a61cfd2e6cdf3bd3966db0c5 > . A reduced example might look something like this: > https://godbolt.org/z/r4G_g- > > At the C source level, static object size detection has to be similarly > conservative in the face of 'variable-length' structs like `struct > my_string { size_t size; char data[0]; };`, though I don't know how > relevant that is here. > > On Tue, Jan 28, 2020 at 11:41 PM Karl Rehm via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> In this function (used to check the size of a global) there is an initial >> check for whether the initializer to this function is "definitive." My >> question is: why do we need this? How does the object's size change if a >> global's initializer is defined at link time? >> >> Thanks, >> Karl >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200129/93082068/attachment.html>
George Burgess IV via llvm-dev
2020-Jan-30 03:28 UTC
[llvm-dev] Question about ObjectSizeOffsetVisitor::visitGlobalVariable
Sounds reasonable to me if there're no other subtitles to worry about. On Wed, Jan 29, 2020 at 5:29 PM Karl Rehm <klrehm123 at gmail.com> wrote:> Interesting, so I guess we can check for whether it's an array type and > adjust accordingly instead? Blocking *all* global variables without > definitive initializers feels a bit much to me, especially if they have > primitive types (i.e. integers) that don't have the potential to be screwed > around with like this. > > On Wed, Jan 29, 2020 at 8:14 PM George Burgess IV < > george.burgess.iv at gmail.com> wrote: > >> Looks like the commit that added that was >> https://github.com/llvm/llvm-project/commit/16e42128c24f5df8a61cfd2e6cdf3bd3966db0c5 >> . A reduced example might look something like this: >> https://godbolt.org/z/r4G_g- >> >> At the C source level, static object size detection has to be similarly >> conservative in the face of 'variable-length' structs like `struct >> my_string { size_t size; char data[0]; };`, though I don't know how >> relevant that is here. >> >> On Tue, Jan 28, 2020 at 11:41 PM Karl Rehm via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >>> In this function (used to check the size of a global) there is an >>> initial check for whether the initializer to this function is "definitive." >>> My question is: why do we need this? How does the object's size change if a >>> global's initializer is defined at link time? >>> >>> Thanks, >>> Karl >>> _______________________________________________ >>> LLVM Developers mailing list >>> llvm-dev at lists.llvm.org >>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>> >>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200129/da65211e/attachment.html>
Doerfert, Johannes via llvm-dev
2020-Jan-30 04:40 UTC
[llvm-dev] Question about ObjectSizeOffsetVisitor::visitGlobalVariable
I tried to track down more of the reasons behind the strict definitive initializer requirement because of other IPO/global opts we do. Unfortunately, I failed. It seems clear we cannot allow any global, as we cannot do IPO depending on the linkage. I suspect exact definitions are the least we need to make sure we don't get something entirely different at link time. Then there is the variable-length/empty size issue that seems to me as if it is a "on-off" special case. Based on the above assumptions I tried out what happens if we relax the condition, here is what I came up with: https://reviews.llvm.org/D73679 On 01/29, Karl Rehm via llvm-dev wrote:> Interesting, so I guess we can check for whether it's an array type and > adjust accordingly instead? Blocking *all* global variables without > definitive initializers feels a bit much to me, especially if they have > primitive types (i.e. integers) that don't have the potential to be screwed > around with like this. > > On Wed, Jan 29, 2020 at 8:14 PM George Burgess IV < > george.burgess.iv at gmail.com> wrote: > > > Looks like the commit that added that was > > https://github.com/llvm/llvm-project/commit/16e42128c24f5df8a61cfd2e6cdf3bd3966db0c5 > > . A reduced example might look something like this: > > https://godbolt.org/z/r4G_g- > > > > At the C source level, static object size detection has to be similarly > > conservative in the face of 'variable-length' structs like `struct > > my_string { size_t size; char data[0]; };`, though I don't know how > > relevant that is here. > > > > On Tue, Jan 28, 2020 at 11:41 PM Karl Rehm via llvm-dev < > > llvm-dev at lists.llvm.org> wrote: > > > >> In this function (used to check the size of a global) there is an initial > >> check for whether the initializer to this function is "definitive." My > >> question is: why do we need this? How does the object's size change if a > >> global's initializer is defined at link time? > >> > >> Thanks, > >> Karl > >> _______________________________________________ > >> LLVM Developers mailing list > >> llvm-dev at lists.llvm.org > >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >> > >> _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- Johannes Doerfert Researcher Argonne National Laboratory Lemont, IL 60439, USA jdoerfert at anl.gov -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200130/23ddf615/attachment-0001.sig>
Karl Rehm via llvm-dev
2020-Jan-30 06:06 UTC
[llvm-dev] Question about ObjectSizeOffsetVisitor::visitGlobalVariable
Is the size == 0 check going to work for all cases? I don't know how flexible array types are represented but if we have an int[1] in a global would this fail? Maybe have a check instead for: if constructor is not definitive and we are an array type then return false - Karl On Wed, Jan 29, 2020, 11:40 PM Doerfert, Johannes <jdoerfert at anl.gov> wrote:> I tried to track down more of the reasons behind the strict definitive > initializer requirement because of other IPO/global opts we do. > Unfortunately, I failed. > > It seems clear we cannot allow any global, as we cannot do IPO depending > on the linkage. I suspect exact definitions are the least we need to > make sure we don't get something entirely different at link time. Then > there is the variable-length/empty size issue that seems to me as if it > is a "on-off" special case. > > Based on the above assumptions I tried out what happens if we relax the > condition, here is what I came up with: https://reviews.llvm.org/D73679 > > > On 01/29, Karl Rehm via llvm-dev wrote: > > Interesting, so I guess we can check for whether it's an array type and > > adjust accordingly instead? Blocking *all* global variables without > > definitive initializers feels a bit much to me, especially if they have > > primitive types (i.e. integers) that don't have the potential to be > screwed > > around with like this. > > > > On Wed, Jan 29, 2020 at 8:14 PM George Burgess IV < > > george.burgess.iv at gmail.com> wrote: > > > > > Looks like the commit that added that was > > > > https://github.com/llvm/llvm-project/commit/16e42128c24f5df8a61cfd2e6cdf3bd3966db0c5 > > > . A reduced example might look something like this: > > > https://godbolt.org/z/r4G_g- > > > > > > At the C source level, static object size detection has to be similarly > > > conservative in the face of 'variable-length' structs like `struct > > > my_string { size_t size; char data[0]; };`, though I don't know how > > > relevant that is here. > > > > > > On Tue, Jan 28, 2020 at 11:41 PM Karl Rehm via llvm-dev < > > > llvm-dev at lists.llvm.org> wrote: > > > > > >> In this function (used to check the size of a global) there is an > initial > > >> check for whether the initializer to this function is "definitive." My > > >> question is: why do we need this? How does the object's size change > if a > > >> global's initializer is defined at link time? > > >> > > >> Thanks, > > >> Karl > > >> _______________________________________________ > > >> LLVM Developers mailing list > > >> llvm-dev at lists.llvm.org > > >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > >> > > > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > -- > > Johannes Doerfert > Researcher > > Argonne National Laboratory > Lemont, IL 60439, USA > > jdoerfert at anl.gov >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200130/c89d9f73/attachment.html>