aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2024-04-15 11:14:50 -0700
committerLeonard Chan <leonardchan@google.com>2024-04-15 11:14:50 -0700
commitc0b77e0a4a9bb090e5ad3a28adcd0aa98715cfe5 (patch)
tree679a440bd251b1154451f4d4aa9a97f9c16d59c7 /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
parent1c5d5478f7f35d7f212fcbf2af042fc3c720e9ed (diff)
downloadllvm-c0b77e0a4a9bb090e5ad3a28adcd0aa98715cfe5.zip
llvm-c0b77e0a4a9bb090e5ad3a28adcd0aa98715cfe5.tar.gz
llvm-c0b77e0a4a9bb090e5ad3a28adcd0aa98715cfe5.tar.bz2
Revert "Reapply "[llvm] Teach whole program devirtualization about relative vtables""
This reverts commit 09c3bfe9b3eb47a2af0c10531b25f90cfb5fa9f4.
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/ModuleSummaryAnalysis.cpp37
1 files changed, 4 insertions, 33 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index c3d15af..deda1ee 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -22,7 +22,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
-#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/IndirectCallPromotionAnalysis.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemoryProfileInfo.h"
@@ -669,8 +668,7 @@ static void computeFunctionSummary(
/// within the initializer.
static void findFuncPointers(const Constant *I, uint64_t StartingOffset,
const Module &M, ModuleSummaryIndex &Index,
- VTableFuncList &VTableFuncs,
- const GlobalVariable &OrigGV) {
+ VTableFuncList &VTableFuncs) {
// First check if this is a function pointer.
if (I->getType()->isPointerTy()) {
auto C = I->stripPointerCasts();
@@ -698,7 +696,7 @@ static void findFuncPointers(const Constant *I, uint64_t StartingOffset,
auto Offset = SL->getElementOffset(EI.index());
unsigned Op = SL->getElementContainingOffset(Offset);
findFuncPointers(cast<Constant>(I->getOperand(Op)),
- StartingOffset + Offset, M, Index, VTableFuncs, OrigGV);
+ StartingOffset + Offset, M, Index, VTableFuncs);
}
} else if (auto *C = dyn_cast<ConstantArray>(I)) {
ArrayType *ATy = C->getType();
@@ -706,34 +704,7 @@ static void findFuncPointers(const Constant *I, uint64_t StartingOffset,
uint64_t EltSize = DL.getTypeAllocSize(EltTy);
for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) {
findFuncPointers(cast<Constant>(I->getOperand(i)),
- StartingOffset + i * EltSize, M, Index, VTableFuncs,
- OrigGV);
- }
- } else if (const auto *CE = dyn_cast<ConstantExpr>(I)) {
- // For relative vtables, the next sub-component should be a trunc.
- if (CE->getOpcode() != Instruction::Trunc ||
- !(CE = dyn_cast<ConstantExpr>(CE->getOperand(0))))
- return;
-
- // If this constant can be reduced to the offset between a function and a
- // global, then we know this is a valid virtual function if the RHS is the
- // original vtable we're scanning through.
- if (CE->getOpcode() == Instruction::Sub) {
- GlobalValue *LHS, *RHS;
- APSInt LHSOffset, RHSOffset;
- if (IsConstantOffsetFromGlobal(CE->getOperand(0), LHS, LHSOffset, DL) &&
- IsConstantOffsetFromGlobal(CE->getOperand(1), RHS, RHSOffset, DL) &&
- RHS == &OrigGV &&
-
- // For relative vtables, this component should point to the callable
- // function without any offsets.
- LHSOffset == 0 &&
-
- // Also, the RHS should always point to somewhere within the vtable.
- RHSOffset <=
- static_cast<uint64_t>(DL.getTypeAllocSize(OrigGV.getInitializer()->getType()))) {
- findFuncPointers(LHS, StartingOffset, M, Index, VTableFuncs, OrigGV);
- }
+ StartingOffset + i * EltSize, M, Index, VTableFuncs);
}
}
}
@@ -746,7 +717,7 @@ static void computeVTableFuncs(ModuleSummaryIndex &Index,
return;
findFuncPointers(V.getInitializer(), /*StartingOffset=*/0, M, Index,
- VTableFuncs, V);
+ VTableFuncs);
#ifndef NDEBUG
// Validate that the VTableFuncs list is ordered by offset.