Skip to content

Commit 2e9f3f3

Browse files
authored
[AMDGPU][llvm-split] Fix another division by zero (#104421)
Somehow I missed this in #98888. It requires a log file, or the debug flag to be passed.
1 parent 57a19ac commit 2e9f3f3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,13 @@ doPartitioning(SplitModuleLogger &SML, Module &M, unsigned NumParts,
568568
}
569569

570570
if (SML) {
571+
CostType ModuleCostOr1 = ModuleCost ? ModuleCost : 1;
571572
for (const auto &[Idx, Part] : enumerate(Partitions)) {
572573
CostType Cost = 0;
573574
for (auto *Fn : Part)
574575
Cost += FnCosts.at(Fn);
575576
SML << "P" << Idx << " has a total cost of " << Cost << " ("
576-
<< format("%0.2f", (float(Cost) / ModuleCost) * 100)
577+
<< format("%0.2f", (float(Cost) / ModuleCostOr1) * 100)
577578
<< "% of source module)\n";
578579
}
579580

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: llvm-split -o %t %s -j 2 -mtriple amdgcn-amd-amdhsa --debug
2+
3+
; REQUIRES: asserts
4+
5+
; CHECK: --Partitioning Starts--
6+
; CHECK: P0 has a total cost of 0 (0.00% of source module)
7+
; CHECK: P1 has a total cost of 0 (0.00% of source module)
8+
; CHECK: --Partitioning Done--
9+
10+
declare void @A()
11+
12+
declare void @B()

0 commit comments

Comments
 (0)