[llvm] [FunctionAttrs] Add the "initializes" attribute inference (PR #97373)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 15:38:22 PDT 2024


================
@@ -866,9 +1070,124 @@ static bool addAccessAttr(Argument *A, Attribute::AttrKind R) {
   return true;
 }
 
+static bool inferInitializes(Argument &A, Function &F) {
+  SmallDenseMap<const BasicBlock *, UsesPerBlockInfo, 16> UsesPerBlock;
+  auto [HasAnyWrite, HasWriteOutsideEntryBB] =
+      CollectArgumentUsesPerBlock(A, F, UsesPerBlock);
+  // No write anywhere in the function, bail.
+  if (!HasAnyWrite)
+    return false;
+
+  BasicBlock &EntryBB = F.getEntryBlock();
+  DenseMap<const BasicBlock *, ConstantRangeList> Initialized;
+  auto VisitBlock = [&](const BasicBlock *BB) -> ConstantRangeList {
----------------
aeubanks wrote:

can you add a comment on what `VisitBlock` does

https://github.com/llvm/llvm-project/pull/97373


More information about the llvm-commits mailing list