Skip to content

Commit

Permalink
Revert "Devirtualize a call on alloca without waiting for post inline…
Browse files Browse the repository at this point in the history
… cleanup and next"

This reverts commit 59fb9cd.

The patch caused internal miscompilations.
  • Loading branch information
kirillbobyrev committed Feb 27, 2020
1 parent 5900d3f commit 4569b3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 230 deletions.
9 changes: 6 additions & 3 deletions clang/test/CodeGenCXX/member-function-pointer-calls.cpp
Expand Up @@ -11,8 +11,12 @@ int f(A* a, int (A::*fp)()) {
}

// CHECK-LABEL: define i32 @_Z2g1v()
// CHECK-NOT: }
// CHECK: ret i32 1
// CHECK-LEGACY: ret i32 1
// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 0
// CHECK-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** [[TMP]], align 8
// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2
// CHECK-NEWPM: ret i32 [[RET]]
// MINGW64-LABEL: define dso_local i32 @_Z2g1v()
// MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
int g1() {
Expand All @@ -21,7 +25,6 @@ int g1() {
}

// CHECK-LABEL: define i32 @_Z2g2v()
// CHECK-NOT: }
// CHECK: ret i32 2
// MINGW64-LABEL: define dso_local i32 @_Z2g2v()
// MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
Expand Down
15 changes: 2 additions & 13 deletions llvm/lib/Transforms/IPO/Inliner.cpp
Expand Up @@ -35,7 +35,6 @@
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
Expand Down Expand Up @@ -1101,20 +1100,10 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
if (!IFI.InlinedCallSites.empty()) {
int NewHistoryID = InlineHistory.size();
InlineHistory.push_back({&Callee, InlineHistoryID});
for (CallSite &CS : reverse(IFI.InlinedCallSites)) {
Function *NewCallee = CS.getCalledFunction();
if (!NewCallee) {
// Try to promote an indirect (virtual) call without waiting for the
// post-inline cleanup and the next DevirtSCCRepeatedPass iteration
// because the next iteration may not happen and we may miss
// inlining it.
if (tryPromoteCall(CS))
NewCallee = CS.getCalledFunction();
}
if (NewCallee)
for (CallSite &CS : reverse(IFI.InlinedCallSites))
if (Function *NewCallee = CS.getCalledFunction())
if (!NewCallee->isDeclaration())
Calls.push_back({CS, NewHistoryID});
}
}

if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)
Expand Down
214 changes: 0 additions & 214 deletions llvm/test/Transforms/Inline/devirtualize-4.ll

This file was deleted.

0 comments on commit 4569b3a

Please sign in to comment.