[llvm] 6e12c73 - [NFC] [stack-safety] add placeholder addRange.
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 9 05:13:37 PDT 2021
Author: Florian Mayer
Date: 2021-09-09T13:13:18+01:00
New Revision: 6e12c73316b765e8a9bc814579352ab3bf50ee75
URL: https://github.com/llvm/llvm-project/commit/6e12c73316b765e8a9bc814579352ab3bf50ee75
DIFF: https://github.com/llvm/llvm-project/commit/6e12c73316b765e8a9bc814579352ab3bf50ee75.diff
LOG: [NFC] [stack-safety] add placeholder addRange.
This is in preparataion of D108457.
Added:
Modified:
llvm/lib/Analysis/StackSafetyAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index a157fec65bb8..431d1af0b949 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -129,6 +129,9 @@ template <typename CalleeTy> struct UseInfo {
UseInfo(unsigned PointerSize) : Range{PointerSize, false} {}
void updateRange(const ConstantRange &R) { Range = unionNoWrap(Range, R); }
+ void addRange(const Instruction *I, const ConstantRange &R) {
+ updateRange(R);
+ }
};
template <typename CalleeTy>
@@ -348,11 +351,11 @@ void StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
switch (I->getOpcode()) {
case Instruction::Load: {
if (AI && !SL.isAliveAfter(AI, I)) {
- US.updateRange(UnknownRange);
+ US.addRange(I, UnknownRange);
return;
}
- US.updateRange(
- getAccessRange(UI, Ptr, DL.getTypeStoreSize(I->getType())));
+ US.addRange(I,
+ getAccessRange(UI, Ptr, DL.getTypeStoreSize(I->getType())));
break;
}
@@ -362,15 +365,16 @@ void StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
case Instruction::Store: {
if (V == I->getOperand(0)) {
// Stored the pointer - conservatively assume it may be unsafe.
- US.updateRange(UnknownRange);
+ US.addRange(I, UnknownRange);
return;
}
if (AI && !SL.isAliveAfter(AI, I)) {
- US.updateRange(UnknownRange);
+ US.addRange(I, UnknownRange);
return;
}
- US.updateRange(getAccessRange(
- UI, Ptr, DL.getTypeStoreSize(I->getOperand(0)->getType())));
+ US.addRange(
+ I, getAccessRange(
+ UI, Ptr, DL.getTypeStoreSize(I->getOperand(0)->getType())));
break;
}
@@ -378,7 +382,7 @@ void StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
// Information leak.
// FIXME: Process parameters correctly. This is a leak only if we return
// alloca.
- US.updateRange(UnknownRange);
+ US.addRange(I, UnknownRange);
return;
case Instruction::Call:
@@ -387,25 +391,26 @@ void StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
break;
if (AI && !SL.isAliveAfter(AI, I)) {
- US.updateRange(UnknownRange);
+ US.addRange(I, UnknownRange);
return;
}
if (const MemIntrinsic *MI = dyn_cast<MemIntrinsic>(I)) {
- US.updateRange(getMemIntrinsicAccessRange(MI, UI, Ptr));
+ US.addRange(I, getMemIntrinsicAccessRange(MI, UI, Ptr));
break;
}
const auto &CB = cast<CallBase>(*I);
if (!CB.isArgOperand(&UI)) {
- US.updateRange(UnknownRange);
+ US.addRange(I, UnknownRange);
return;
}
unsigned ArgNo = CB.getArgOperandNo(&UI);
if (CB.isByValArgument(ArgNo)) {
- US.updateRange(getAccessRange(
- UI, Ptr, DL.getTypeStoreSize(CB.getParamByValType(ArgNo))));
+ US.addRange(I, getAccessRange(
+ UI, Ptr,
+ DL.getTypeStoreSize(CB.getParamByValType(ArgNo))));
break;
}
@@ -415,7 +420,7 @@ void StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
const GlobalValue *Callee =
dyn_cast<GlobalValue>(CB.getCalledOperand()->stripPointerCasts());
if (!Callee) {
- US.updateRange(UnknownRange);
+ US.addRange(I, UnknownRange);
return;
}
More information about the llvm-commits
mailing list