[PATCH] D63444: [ThinLTO] Optimize write-only globals out
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 00:17:54 PDT 2019
evgeny777 marked an inline comment as done.
evgeny777 added a comment.
> Is the global storage (from the other module) also eliminated in this case? If so, can you add a testcase for that?
Yes, optimized variable is internalized in both source and destination module. I'll add test case for that
================
Comment at: include/llvm/IR/ModuleSummaryIndex.h:165
struct ValueInfo {
- PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 2, int>
+ enum Flags { HaveGV = 1, ReadOnly = 2, WriteOnly = 4 };
+ PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 3, int>
----------------
steven_wu wrote:
> Would it be cleaner if you create a new enum bitfield for access specifier?
> ```
> enum Access { ReadWrite = 0, ReadOnly = 1, WriteOnly =2, Invalid =3 };
> ```
> This should make all the method below a bit cleaner.
I'm not sure if this would make it cleaner. There is also a HaveGV flag in `PointerIntPair`, so to manipulate access bits as suggested you'll have to do something like this:
```
bool isValidAccessSpecifier() const {
return (RefAndFlags.getInt() & (Invalid << 1)) != (Invalid << 1);
}
void setWriteOnly() {
assert(isValidAccessSpecifier());
RefAndFlags.setInt(RefAndFlags.getInt() | (WriteOnly << 1));
}
```
so technically almost the same as before
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63444/new/
https://reviews.llvm.org/D63444
More information about the llvm-commits
mailing list