Skip to content

Commit 4569b3a

Browse files
committed
Revert "Devirtualize a call on alloca without waiting for post inline cleanup and next"
This reverts commit 59fb9cd. The patch caused internal miscompilations.
1 parent 5900d3f commit 4569b3a

File tree

3 files changed

+8
-230
lines changed

3 files changed

+8
-230
lines changed

clang/test/CodeGenCXX/member-function-pointer-calls.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ int f(A* a, int (A::*fp)()) {
1111
}
1212

1313
// CHECK-LABEL: define i32 @_Z2g1v()
14-
// CHECK-NOT: }
15-
// CHECK: ret i32 1
14+
// CHECK-LEGACY: ret i32 1
15+
// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
16+
// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 0
17+
// 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
18+
// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2
19+
// CHECK-NEWPM: ret i32 [[RET]]
1620
// MINGW64-LABEL: define dso_local i32 @_Z2g1v()
1721
// MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
1822
int g1() {
@@ -21,7 +25,6 @@ int g1() {
2125
}
2226

2327
// CHECK-LABEL: define i32 @_Z2g2v()
24-
// CHECK-NOT: }
2528
// CHECK: ret i32 2
2629
// MINGW64-LABEL: define dso_local i32 @_Z2g2v()
2730
// MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})

llvm/lib/Transforms/IPO/Inliner.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "llvm/Analysis/TargetLibraryInfo.h"
3636
#include "llvm/Analysis/TargetTransformInfo.h"
3737
#include "llvm/Transforms/Utils/Local.h"
38-
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
3938
#include "llvm/IR/Attributes.h"
4039
#include "llvm/IR/BasicBlock.h"
4140
#include "llvm/IR/CallSite.h"
@@ -1101,20 +1100,10 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
11011100
if (!IFI.InlinedCallSites.empty()) {
11021101
int NewHistoryID = InlineHistory.size();
11031102
InlineHistory.push_back({&Callee, InlineHistoryID});
1104-
for (CallSite &CS : reverse(IFI.InlinedCallSites)) {
1105-
Function *NewCallee = CS.getCalledFunction();
1106-
if (!NewCallee) {
1107-
// Try to promote an indirect (virtual) call without waiting for the
1108-
// post-inline cleanup and the next DevirtSCCRepeatedPass iteration
1109-
// because the next iteration may not happen and we may miss
1110-
// inlining it.
1111-
if (tryPromoteCall(CS))
1112-
NewCallee = CS.getCalledFunction();
1113-
}
1114-
if (NewCallee)
1103+
for (CallSite &CS : reverse(IFI.InlinedCallSites))
1104+
if (Function *NewCallee = CS.getCalledFunction())
11151105
if (!NewCallee->isDeclaration())
11161106
Calls.push_back({CS, NewHistoryID});
1117-
}
11181107
}
11191108

11201109
if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)

llvm/test/Transforms/Inline/devirtualize-4.ll

Lines changed: 0 additions & 214 deletions
This file was deleted.

0 commit comments

Comments
 (0)