[llvm] [Attributor] Change allocation size and load/store offsets using AAPointerInfo for Alloca instructions (PR #72029)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 17:22:05 PDT 2024


================
@@ -6285,12 +6341,38 @@ struct AAAllocationInfo : public StateWrapper<BooleanState, AbstractAttribute> {
     return AbstractAttribute::isValidIRPositionForInit(A, IRP);
   }
 
+  // A helper function to check is simplified values exists for the current
+  // instruction.
+  bool simplifiedValuesExists(Attributor &A, Instruction *LocalInst) {
+
+    // If there are potential values that replace the accessed instruction, we
+    // should use those instead
+    bool UsedAssumedInformation = false;
+    SmallVector<AA::ValueAndContext> Values;
+    if (A.getAssumedSimplifiedValues(IRPosition::inst(*LocalInst), *this,
+                                     Values, AA::AnyScope,
+                                     UsedAssumedInformation)) {
+
+      for (auto &ValAndContext : Values) {
+        // don't modify instruction if any simplified value exists
+        if (ValAndContext.getValue() && ValAndContext.getValue() != LocalInst) {
+          return true;
+        }
----------------
shiltian wrote:

```suggestion
        if (ValAndContext.getValue() && ValAndContext.getValue() != LocalInst)
          return true;
```

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


More information about the llvm-commits mailing list