[llvm] r294205 - Fix the bug of samplepgo indirect call promption when type casting of the return value is needed.
Dehao Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 6 10:10:37 PST 2017
Author: dehao
Date: Mon Feb 6 12:10:36 2017
New Revision: 294205
URL: http://llvm.org/viewvc/llvm-project?rev=294205&view=rev
Log:
Fix the bug of samplepgo indirect call promption when type casting of the return value is needed.
Summary: When type casting of the return value is needed, promoteIndirectCall will return the type casting instruction instead of the direct call. This patch changed to return the direct call instruction instead.
Reviewers: davidxl
Reviewed By: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D29569
Modified:
llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
llvm/trunk/test/Transforms/SampleProfile/indirect-call.ll
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=294205&r1=294204&r2=294205&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Mon Feb 6 12:10:36 2017
@@ -643,7 +643,9 @@ bool SampleProfileLoader::inlineHotFunct
// result, we do not have profile info for the branch probability.
// We set the probability to 80% taken to indicate that the static
// call is likely taken.
- DI = promoteIndirectCall(I, CalledFunction, 80, 100);
+ DI = dyn_cast<Instruction>(
+ promoteIndirectCall(I, CalledFunction, 80, 100)
+ ->stripPointerCasts());
PromotedInsns.insert(I);
} else {
DEBUG(dbgs() << "\nFailed to promote indirect call to "
Modified: llvm/trunk/test/Transforms/SampleProfile/indirect-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/indirect-call.ll?rev=294205&r1=294204&r2=294205&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/indirect-call.ll (original)
+++ llvm/trunk/test/Transforms/SampleProfile/indirect-call.ll Mon Feb 6 12:10:36 2017
@@ -12,16 +12,16 @@ define void @test(void ()*) !dbg !3 {
; CHECK-LABEL: @test_inline
; If the indirect call is promoted and inlined in profile, we should promote and inline it.
-define void @test_inline(void ()*) !dbg !3 {
- %2 = alloca void ()*
- store void ()* %0, void ()** %2
- %3 = load void ()*, void ()** %2
+define void @test_inline(i64* (i32*)*, i32* %x) !dbg !3 {
+ %2 = alloca i64* (i32*)*
+ store i64* (i32*)* %0, i64* (i32*)** %2
+ %3 = load i64* (i32*)*, i64* (i32*)** %2
; CHECK: icmp {{.*}} @foo_inline
; CHECK: if.true.direct_targ:
; CHECK-NOT: call
; CHECK: if.false.orig_indirect:
; CHECK: call
- call void %3(), !dbg !5
+ call i64* %3(i32* %x), !dbg !5
ret void
}
@@ -37,8 +37,10 @@ define void @test_noinline(void ()*) !db
ret void
}
-define void @foo_inline() !dbg !3 {
- ret void
+ at x = global i32 0, align 4
+
+define i32* @foo_inline(i32* %x) !dbg !3 {
+ ret i32* %x
}
define i32 @foo_noinline(i32 %x) !dbg !3 {
More information about the llvm-commits
mailing list