[IROutliner] Refactoring errors in the cost model from past patches.

There were was the reuse of a variable that should not have been
occurred due to confusion during committing patches.
This commit is contained in:
Andrew Litteken 2021-01-03 23:44:20 -06:00
parent 05e6ac4eb8
commit 5c951623bc
3 changed files with 116 additions and 68 deletions

View File

@ -1405,7 +1405,7 @@ void IROutliner::findCostBenefit(Module &M, OutlinableGroup &CurrentGroup) {
<< " instructions to cost for each argument in the new"
<< " function.\n");
CurrentGroup.Cost +=
NumRegions * OverallArgumentNum * TargetTransformInfo::TCC_Basic;
OverallArgumentNum * TargetTransformInfo::TCC_Basic;
LLVM_DEBUG(dbgs() << "Current Cost: " << CurrentGroup.Cost << "\n");
// Each argument needs to either be loaded into a register or onto the stack.
@ -1416,7 +1416,7 @@ void IROutliner::findCostBenefit(Module &M, OutlinableGroup &CurrentGroup) {
<< " function " << NumRegions << " times for the "
<< "needed argument handling at the call site.\n");
CurrentGroup.Cost +=
OverallArgumentNum * TargetTransformInfo::TCC_Basic * NumRegions;
2 * OverallArgumentNum * TargetTransformInfo::TCC_Basic * NumRegions;
LLVM_DEBUG(dbgs() << "Current Cost: " << CurrentGroup.Cost << "\n");
CurrentGroup.Cost += findCostForOutputBlocks(M, CurrentGroup, TTI);

View File

@ -5,18 +5,48 @@
; RUN: -pass-remarks-output=%t < %s
; RUN: cat %t | FileCheck -check-prefix=YAML %s
; CHECK: remark: <unknown>:0:0: outlined 2 regions with decrease of 2 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 6 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 7 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 8 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 9 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 12 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 5 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: outlined 2 regions with decrease of 2 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 10 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 7 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 8 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 11 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 12 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 13 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 14 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 10 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 11 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 17 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; CHECK-NEXT: remark: <unknown>:0:0: did not outline 2 regions due to estimated increase of 13 instructions at locations <UNKNOWN LOCATION> <UNKNOWN LOCATION>
; YAML: --- !Passed
; YAML: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function3
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '12'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function3
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '5'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Passed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: Outlined
; YAML-NEXT: Function: function3.outlined
@ -38,62 +68,6 @@
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '6'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '7'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '8'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '9'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '10'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
@ -108,7 +82,7 @@
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '7'
; YAML-NEXT: - InstructionIncrease: '11'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
@ -122,7 +96,7 @@
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '8'
; YAML-NEXT: - InstructionIncrease: '12'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
@ -150,12 +124,68 @@
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '14'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '10'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '11'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '17'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
; YAML-NEXT: --- !Missed
; YAML-NEXT: Pass: iroutliner
; YAML-NEXT: Name: WouldNotDecreaseSize
; YAML-NEXT: Function: function1
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'did not outline '
; YAML-NEXT: - String: '2'
; YAML-NEXT: - String: ' regions due to estimated increase of '
; YAML-NEXT: - InstructionIncrease: '13'
; YAML-NEXT: - String: ' instructions at locations '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ' '
; YAML-NEXT: - DebugLoc: '<UNKNOWN LOCATION>'
; YAML-NEXT: ...
define void @function1() #0 {
entry:
@ -205,10 +235,15 @@ entry:
%mul = mul i32 %0, %1
%sub = sub i32 %0, %1
%div = sdiv i32 %0, %1
%add1 = add i32 %0, %1
%mul1 = mul i32 %0, %1
%sub1 = sub i32 %0, %1
%div1 = sdiv i32 %0, %1
%add2 = add i32 %0, %1
%mul2 = mul i32 %0, %1
%sub2 = sub i32 %0, %1
%div2 = sdiv i32 %0, %1
%mul3 = mul i32 %0, %1
ret void
}
@ -222,9 +257,14 @@ entry:
%mul = mul i32 %0, %1
%sub = sub i32 %0, %1
%div = sdiv i32 %0, %1
%add1 = add i32 %0, %1
%mul1 = mul i32 %0, %1
%sub1 = sub i32 %0, %1
%div1 = sdiv i32 %0, %1
%add2 = add i32 %0, %1
%mul2 = mul i32 %0, %1
%sub2 = sub i32 %0, %1
%div2 = sdiv i32 %0, %1
%div3 = sdiv i32 %0, %1
ret void
}

View File

@ -31,6 +31,10 @@ entry:
%mul = mul i32 %0, %1
%sub = sub i32 %0, %1
%div = sdiv i32 %0, %1
%add1 = add i32 %0, %1
%mul1 = mul i32 %0, %1
%sub1 = sub i32 %0, %1
%div1 = sdiv i32 %0, %1
%add2 = add i32 %0, %1
%mul2 = mul i32 %0, %1
%sub2 = sub i32 %0, %1
@ -62,6 +66,10 @@ entry:
%mul = mul i32 %0, %1
%sub = sub i32 %0, %1
%div = sdiv i32 %0, %1
%add1 = add i32 %0, %1
%mul1 = mul i32 %0, %1
%sub1 = sub i32 %0, %1
%div1 = sdiv i32 %0, %1
%add2 = add i32 %0, %1
%mul2 = mul i32 %0, %1
%sub2 = sub i32 %0, %1