[Local] preserve MD_prof in hoistAllInstructionsInto
This commit is contained in:
parent
961489a611
commit
18cf46f5b8
@ -498,6 +498,7 @@ LLVM_ABI void dropDebugUsers(Instruction &I);
|
||||
///
|
||||
/// The moved instructions receive the insertion point debug location values
|
||||
/// (DILocations) and their debug intrinsic instructions are removed.
|
||||
/// Selects and indirect calls keep their MD_prof metadata.
|
||||
LLVM_ABI void hoistAllInstructionsInto(BasicBlock *DomBlock,
|
||||
Instruction *InsertPt, BasicBlock *BB);
|
||||
|
||||
|
||||
@ -116,6 +116,8 @@ static cl::opt<unsigned> MaxPhiEntriesIncreaseAfterRemovingEmptyBlock(
|
||||
cl::desc("Stop removing an empty block if removing it will introduce more "
|
||||
"than this number of phi entries in its successor"));
|
||||
|
||||
extern cl::opt<bool> ProfcheckDisableMetadataFixes;
|
||||
|
||||
// Max recursion depth for collectBitParts used when detecting bswap and
|
||||
// bitreverse idioms.
|
||||
static const unsigned BitPartRecursionMaxDepth = 48;
|
||||
@ -3342,8 +3344,11 @@ void llvm::hoistAllInstructionsInto(BasicBlock *DomBlock, Instruction *InsertPt,
|
||||
// retain their original debug locations (DILocations) and debug intrinsic
|
||||
// instructions.
|
||||
//
|
||||
// Doing so would degrade the debugging experience and adversely affect the
|
||||
// accuracy of profiling information.
|
||||
// Doing so would degrade the debugging experience.
|
||||
//
|
||||
// FIXME: Issue #152767: debug info should also be the same as the
|
||||
// original branch, **if** the user explicitly indicated that (for sampling
|
||||
// PGO)
|
||||
//
|
||||
// Currently, when hoisting the instructions, we take the following actions:
|
||||
// - Remove their debug intrinsic instructions.
|
||||
@ -3362,7 +3367,10 @@ void llvm::hoistAllInstructionsInto(BasicBlock *DomBlock, Instruction *InsertPt,
|
||||
|
||||
for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;) {
|
||||
Instruction *I = &*II;
|
||||
I->dropUBImplyingAttrsAndMetadata();
|
||||
if (ProfcheckDisableMetadataFixes)
|
||||
I->dropUBImplyingAttrsAndMetadata();
|
||||
else
|
||||
I->dropUBImplyingAttrsAndMetadata({LLVMContext::MD_prof});
|
||||
if (I->isUsedByMetadata())
|
||||
dropDebugUsers(*I);
|
||||
// RemoveDIs: drop debug-info too as the following code does.
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
; NOTE: Assertions have been autogenerated by update_test_checks.py
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5
|
||||
; Test merging of blocks that only have PHI nodes in them
|
||||
;
|
||||
; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
|
||||
;
|
||||
|
||||
define i32 @test(i1 %a, i1 %b) {
|
||||
; CHECK-LABEL: @test(
|
||||
; CHECK: M:
|
||||
; CHECK-NEXT: [[DOT:%.*]] = select i1 %b, i32 0, i32 1
|
||||
; CHECK-NEXT: [[W:%.*]] = select i1 %a, i32 2, i32 [[DOT]]
|
||||
; CHECK-LABEL: define i32 @test(
|
||||
; CHECK-SAME: i1 [[A:%.*]], i1 [[B:%.*]]) {
|
||||
; CHECK-NEXT: [[M:.*:]]
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[B]], i32 0, i32 1, !prof [[PROF0:![0-9]+]]
|
||||
; CHECK-NEXT: [[W:%.*]] = select i1 [[A]], i32 2, i32 [[SPEC_SELECT]], !prof [[PROF1:![0-9]+]]
|
||||
; CHECK-NEXT: [[R:%.*]] = add i32 [[W]], 1
|
||||
; CHECK-NEXT: ret i32 [[R]]
|
||||
;
|
||||
br i1 %a, label %M, label %O
|
||||
br i1 %a, label %M, label %O, !prof !0
|
||||
O: ; preds = %0
|
||||
br i1 %b, label %N, label %Q
|
||||
br i1 %b, label %N, label %Q, !prof !1
|
||||
Q: ; preds = %O
|
||||
br label %N
|
||||
N: ; preds = %Q, %O
|
||||
@ -27,3 +28,9 @@ M: ; preds = %N, %0
|
||||
ret i32 %R
|
||||
}
|
||||
|
||||
!0 = !{!"branch_weights", i32 11, i32 7}
|
||||
!1 = !{!"branch_weights", i32 3, i32 5}
|
||||
;.
|
||||
; CHECK: [[PROF0]] = !{!"branch_weights", i32 3, i32 5}
|
||||
; CHECK: [[PROF1]] = !{!"branch_weights", i32 11, i32 7}
|
||||
;.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user