summaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-01-22 20:31:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-01-22 20:31:01 +0000
commit8bcb0991864975618c09697b1aca10683346d9f0 (patch)
tree0afab28faa50e5f27698f8dd6c1921fff8d25e39 /contrib/llvm-project/llvm/lib/CodeGen/StackProtector.cpp
parentb14637d118e110006a149a79b649c5695e7f419a (diff)
parent1d5ae1026e831016fc29fd927877c86af904481f (diff)
Notes
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([&]() {