[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-03-03 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment. See D145173 for a different tactic to solve this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143745/new/ https://reviews.llvm.org/D143745 ___ cfe-commits mailing list cfe-commi

[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-02-14 Thread Paul Robinson via Phabricator via cfe-commits
probinson abandoned this revision. probinson added a comment. Discussion on the GCC bug has persuaded me this is not a good idea. I'll solve my user's problem a different way. @MaskRay you can close the GCC bug, it looks like I can't do it myself. CHANGES SINCE LAST ACTION https://reviews.ll

[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-02-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. If one TU has more than one section of the same name, there is no guarantee they are adjacent after linking. Linker scripts and `--shuffle-sections` can adjust them. I don't mind a behavior change if GCC is willing to do the same. But without, it's safer to use an optio

[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-02-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment. I'm not sure I understand the linker's mechanics here. Let me say some things and you can describe my misunderstanding. - If the linker was going to discard all of section foo (in the current scheme), that means it had no reason to retain either f() or g(). In the new

[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-02-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. > [...] all functions with that attribute end up in a single section, defeating > the linker GC. This can be made preciser. Say we have __attribute__((section("foo"))) void f(i) {} __attribute__((section("foo"))) void g() {} `f` and `g` don't use COMDAT, therefore

[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-02-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment. This works in my simple test cases, but I'm not 100% sure it's (a) the best place to do this, or (b) the only place that needs to do this. Really we should guarantee that `comdat any` wins over `comdat nodeduplicate` in all cases. CHANGES SINCE LAST ACTION https://

[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-02-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision. probinson added reviewers: rjmccall, MaskRay. Herald added a project: All. probinson requested review of this revision. People use -ffunction-sections to put each function into its own object-file section; this makes linker garbage-collection simpler. However, if t