[PATCH] D117503: [GlobalOpt] Generalize malloc-to-global for any allocation function
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 17 10:05:57 PST 2022
reames added a comment.
A couple of side notes:
With both the new and old code, we might be loosing some ability to prune loads from uninitialized state of the allocation. We could consider using lifetime markers at the point of the original allocation to preserve this. I'm a little leery of introducing them though as their semantics on globals are a bit vague. Thankfully, I think this is a minor opt quality issue at worst, and I don't have any motivating examples to justify exploring this further.
It would be interesting to explore whether we could prove the memory was allocated once. This might actually be easier for a nullable global than a non-null one. (e.g. for the idiomatic pattern if (!g) g = malloc()) I don't have a strong motivating example for this, but it seems like we're leaving something on the floor here. If we do the init once thing, we also need to be careful about data section size and profitability. What's profitable for undef and zero (e.g. effecting bss size), and what's profitably for other init constants (e.g. effecting .data sizes) might not be the same - i.e. we have to account for load time initialization costs.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117503/new/
https://reviews.llvm.org/D117503
More information about the llvm-commits
mailing list