summaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp b/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp
index baa57e2c6311..5683d1db473c 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp
@@ -156,8 +156,7 @@ bool StackProtector::ContainsProtectableArray(Type *Ty, bool &IsLarge,
return NeedsProtector;
}
-bool StackProtector::HasAddressTaken(const Instruction *AI,
- SmallPtrSetImpl<const PHINode *> &VisitedPHIs) {
+bool StackProtector::HasAddressTaken(const Instruction *AI) {
for (const User *U : AI->users()) {
const auto *I = cast<Instruction>(U);
switch (I->getOpcode()) {
@@ -189,7 +188,7 @@ bool StackProtector::HasAddressTaken(const Instruction *AI,
case Instruction::GetElementPtr:
case Instruction::Select:
case Instruction::AddrSpaceCast:
- if (HasAddressTaken(I, VisitedPHIs))
+ if (HasAddressTaken(I))
return true;
break;
case Instruction::PHI: {
@@ -197,7 +196,7 @@ bool StackProtector::HasAddressTaken(const Instruction *AI,
// they are only visited once.
const auto *PN = cast<PHINode>(I);
if (VisitedPHIs.insert(PN).second)
- if (HasAddressTaken(PN, VisitedPHIs))
+ if (HasAddressTaken(PN))
return true;
break;
}
@@ -273,12 +272,6 @@ bool StackProtector::RequiresStackProtector() {
else if (!F->hasFnAttribute(Attribute::StackProtect))
return false;
- /// VisitedPHIs - The set of PHI nodes visited when determining
- /// if a variable's reference has been taken. This set
- /// is maintained to ensure we don't visit the same PHI node multiple
- /// times.
- SmallPtrSet<const PHINode *, 16> VisitedPHIs;
-
for (const BasicBlock &BB : *F) {
for (const Instruction &I : BB) {
if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
@@ -332,7 +325,7 @@ bool StackProtector::RequiresStackProtector() {
continue;
}
- if (Strong && HasAddressTaken(AI, VisitedPHIs)) {
+ if (Strong && HasAddressTaken(AI)) {
++NumAddrTaken;
Layout.insert(std::make_pair(AI, MachineFrameInfo::SSPLK_AddrOf));
ORE.emit([&]() {