[PATCH] D109503: [stack-safety] Allow to determine safe accesses.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 11:57:47 PDT 2021


vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

LGTM if you agree with my changes



================
Comment at: llvm/include/llvm/Analysis/StackSafetyAnalysis.h:79
   bool isSafe(const AllocaInst &AI) const;
+  bool accessIsSafe(const Instruction *I) const;
   void print(raw_ostream &O) const;
----------------
"&I" for consistency


================
Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:137
+    std::map<const Instruction *, const ConstantRange>::iterator It;
+    std::tie(It, Inserted) = Accesses.emplace(I, R);
+    if (!Inserted) {
----------------
you missed my comment about auto vs tie.

this will work:

```
std::map<const Instruction *, /*remove const*/ ConstantRange> Accesses;
...
void addRange(const Instruction *I, const ConstantRange &R) {
    auto Ins = Accesses.emplace(I, R);
    if (!Ins.second)
      Ins.first->second = unionNoWrap(Ins.first->second, R);
    updateRange(R);
  }
```


================
Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:238
   GVToSSI Info;
   SmallPtrSet<const AllocaInst *, 8> SafeAllocas;
+  std::map<const Instruction *, bool> Accesses;
----------------
for consistency with line above
SmallPtrSet<const Instruction *, 8> SafeAccesses;


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109503/new/

https://reviews.llvm.org/D109503



More information about the llvm-commits mailing list