[llvm] [FunctionAttrs] Add the "initializes" attribute inference (PR #97373)
Haopeng Liu via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 12:58:51 PDT 2024
================
@@ -580,6 +582,205 @@ struct ArgumentUsesTracker : public CaptureTracker {
const SCCNodeSet &SCCNodes;
};
+struct ArgumentUse {
+ Use *U;
+ std::optional<int64_t> Offset;
+};
+
+// A struct of argument access info. "Unknown" accesses are the cases like
+// unrecognized instructions, instructions that have more than one use of
+// the argument, or volatile memory accesses. "Unknown" implies "IsClobber"
+// and an empty access range.
+// Write or Read accesses can be clobbers as well for example, a Load with
+// scalable type.
+struct ArgumentAccessInfo {
+ enum AccessType { Write, Read, Unknown };
+ AccessType ArgAccessType;
+ ConstantRangeList AccessRanges;
+ bool IsClobber = false;
+};
+
+struct UsesPerBlockInfo {
+ DenseMap<Instruction *, ArgumentAccessInfo> Insts;
----------------
haopliu wrote:
Oh, good point! Changed the SmallDenseMap size here to 4 and the size of `UsesPerBlock` to 16.
With 4\*3/4 (<=3) and 16\*3/4 (<=12), they covers 96% and 94% cases in an internal large benchmark. Thanks!
BTW, the size must be a power of 2 so choose 4 and 16. https://github.com/llvm/llvm-project/blob/8f159096e097dde5a95d14984623c51d58ed8e69/llvm/include/llvm/ADT/DenseMap.h#L933
https://github.com/llvm/llvm-project/pull/97373
More information about the llvm-commits
mailing list