[llvm] [FunctionAttrs] Add the "initializes" attribute inference (PR #97373)
Haopeng Liu via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 10 10:01:09 PST 2024
================
@@ -580,6 +582,206 @@ struct ArgumentUsesTracker : public CaptureTracker {
const SCCNodeSet &SCCNodes;
};
+// A struct of argument use: a Use and the offset it accesses. This struct
+// is to track uses inside function via GEP. If GEP has a non-constant index,
+// the Offset field is nullopt.
+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 class AccessType : uint8_t { Write, Read, Unknown };
+ AccessType ArgAccessType;
+ bool IsClobber = false;
----------------
haopliu wrote:
Thanks for this comment. Cleaned up the code:
- Removed "IsClobber".
- Changed the AccessType enum to: Read/Write/WriteWithSideEffect/Unknown.
- Read: simple load/memcpy.
- Write: simple store/memstore/memcpy/call(write a parameter and the parameter is writeonly/readnone and nocapture).
- WriteWithSideEffect: call instructions write a parameter but the parameter is not writeonly/readnone or nocapture.
- Unknown: unrecognized accesses or non-simple load/store/memset/...
While inferring the `initializes` attribute in a block (from end inst to begin), we empty the `initializes` range list for WriteWithSideEffect/Unknown, union the range list of Write/WriteWithSideEffect, and subtract the range list of Read.
https://github.com/llvm/llvm-project/pull/97373
More information about the llvm-commits
mailing list