[PATCH] D113160: [stack-safety] Check SCEV constraints at memory instructions.

Florian Mayer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 11:45:16 PST 2021


fmayer marked 2 inline comments as done.
fmayer added inline comments.


================
Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:121
   ConstantRange Range;
-  std::map<const Instruction *, ConstantRange> Accesses;
+  std::set<const Instruction *> UnsafeAccesses;
 
----------------
kstoimenov wrote:
> I am not sure what is the ratio of unsafe to safe accesses is, but I would expect that more of them are unsafe, right? In that case it makes more sense to have a set of SafeAccesses to use less memory. 
That doesn't work though. What we want is 

any(instr is unsafe for alloca for all allocas reachable)

for that we need to keep track of the unsafe instructions for each alloca.


================
Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:951
   const auto &Info = getInfo();
-  auto It = Info.AccessIsUnsafe.find(&I);
-  if (It == Info.AccessIsUnsafe.end()) {
-    return true;
-  }
-  return !It->second;
+  return Info.UnsafeAccesses.find(&I) == Info.UnsafeAccesses.end();
 }
----------------
kstoimenov wrote:
> Nit: could be !Info.UnsafeAccesses.contains(&I). 
No, that doesn't work because it's too new for LLVM code.

> Unless otherwise documented, LLVM subprojects are written using standard C++14 code and avoid unnecessary vendor-specific extensions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113160



More information about the llvm-commits mailing list