diff options
author | Mehdi Amini <joker.eph@gmail.com> | 2020-06-03 03:02:28 +0000 |
---|---|---|
committer | Mehdi Amini <joker.eph@gmail.com> | 2020-06-03 03:02:28 +0000 |
commit | f9bb101d394d62027ba33e132691540f1e63cea8 (patch) | |
tree | 0c66d585345f43bf6d7643c7b57ee8c365e82877 /llvm/lib/Analysis/StackSafetyAnalysis.cpp | |
parent | 8b96703652ade915eb444b8dae91ae6a16d32d75 (diff) | |
download | llvm-f9bb101d394d62027ba33e132691540f1e63cea8.zip llvm-f9bb101d394d62027ba33e132691540f1e63cea8.tar.gz llvm-f9bb101d394d62027ba33e132691540f1e63cea8.tar.bz2 |
Revert "[NFC, StackSafety] Change type of internal container"
This reverts commit f62813e7eae148a6175de28bfa384524a9f2bf94.
GCC 5.3 build is broken.
Diffstat (limited to 'llvm/lib/Analysis/StackSafetyAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/StackSafetyAnalysis.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp index dafa069..60ed0ed 100644 --- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp +++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp @@ -140,7 +140,7 @@ ConstantRange getStaticAllocaSizeRange(const AllocaInst &AI) { } struct FunctionInfo { - std::map<const AllocaInst *, UseInfo> Allocas; + SmallVector<UseInfo, 4> Allocas; SmallVector<UseInfo, 4> Params; // TODO: describe return value as depending on one or more of its arguments. @@ -165,11 +165,13 @@ struct FunctionInfo { O << " allocas uses:\n"; if (F) { + size_t Pos = 0; for (auto &I : instructions(F)) { if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) { - auto &AS = Allocas.find(AI)->second; + auto &AS = Allocas[Pos]; O << " " << AI->getName() << "[" << getStaticAllocaSizeRange(*AI).getUpper() << "]: " << AS << "\n"; + ++Pos; } } } else { @@ -389,7 +391,8 @@ FunctionInfo StackSafetyLocalAnalysis::run() { for (auto &I : instructions(F)) { if (auto *AI = dyn_cast<AllocaInst>(&I)) { - UseInfo &AS = Info.Allocas.emplace(AI, PointerSize).first->second; + Info.Allocas.emplace_back(PointerSize); + UseInfo &AS = Info.Allocas.back(); analyzeAllUses(AI, AS); } } @@ -599,18 +602,19 @@ GVToSSI createGlobalStackSafetyInfo( for (auto &F : SSDFA.run()) { auto FI = F.second; + size_t Pos = 0; auto &SrcF = Functions[F.first]; - for (auto &KV : FI.Allocas) { - auto &A = KV.second; + for (auto &A : FI.Allocas) { resolveAllCalls(A); for (auto &C : A.Calls) { A.updateRange( SSDFA.getArgumentAccessRange(C.Callee, C.ParamNo, C.Offset)); } // FIXME: This is needed only to preserve calls in print() results. - A.Calls = SrcF.Allocas.find(KV.first)->second.Calls; + A.Calls = SrcF.Allocas[Pos].Calls; + ++Pos; } - size_t Pos = 0; + Pos = 0; for (auto &P : FI.Params) { P.Calls = SrcF.Params[Pos].Calls; ++Pos; @@ -658,11 +662,20 @@ const StackSafetyGlobalInfo::InfoTy &StackSafetyGlobalInfo::getInfo() const { } Info.reset( new InfoTy{createGlobalStackSafetyInfo(std::move(Functions)), {}}); - for (auto &FnKV : Info->Info) { - for (auto &KV : FnKV.second.Allocas) { - const AllocaInst *AI = KV.first; - if (getStaticAllocaSizeRange(*AI).contains(KV.second.Range)) - Info->SafeAllocas.insert(AI); + for (auto &KV : Info->Info) { + if (!KV.first->isDeclaration()) { + size_t Pos = 0; + // FIXME: Convert FunctionInfo::Allocas into map<AllocaInst*, UseInfo> + // and do not rely on alloca index. + for (auto &I : instructions(*cast<Function>(KV.first))) { + if (const auto &AI = dyn_cast<AllocaInst>(&I)) { + if (getStaticAllocaSizeRange(*AI).contains( + KV.second.Allocas[Pos].Range)) { + Info->SafeAllocas.insert(AI); + } + ++Pos; + } + } } } if (StackSafetyPrint) |