[llvm] 48c74bb - [SampleProfileInference] Work around odr-use of const non-inline static data member to fix -O0 builds after D120508
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 8 14:34:59 PST 2022
Author: Fangrui Song
Date: 2022-03-08T14:34:53-08:00
New Revision: 48c74bb2e2a72830f1068823bfc2f6fd4b53d427
URL: https://github.com/llvm/llvm-project/commit/48c74bb2e2a72830f1068823bfc2f6fd4b53d427
DIFF: https://github.com/llvm/llvm-project/commit/48c74bb2e2a72830f1068823bfc2f6fd4b53d427.diff
LOG: [SampleProfileInference] Work around odr-use of const non-inline static data member to fix -O0 builds after D120508
MinBaseDistance may be odr-used by std::max, leading to an undefined symbol linker error:
```
ld.lld: error: undefined symbol: (anonymous namespace)::MinCostMaxFlow::MinBaseDistance
>>> referenced by SampleProfileInference.cpp:744 (/home/ray/llvm-project/llvm/lib/Transforms/Utils/SampleProfileInference.cpp:744)
>>> lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/SampleProfileInference.cpp.o:((anonymous namespace)::FlowAdjuster::jumpDistance(llvm::FlowJump*) const)
```
Since llvm-project is still using C++ 14, workaround it with a cast.
Added:
Modified:
llvm/lib/Transforms/Utils/SampleProfileInference.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SampleProfileInference.cpp b/llvm/lib/Transforms/Utils/SampleProfileInference.cpp
index 298c36b7ecd3d..6f56f1c432c2e 100644
--- a/llvm/lib/Transforms/Utils/SampleProfileInference.cpp
+++ b/llvm/lib/Transforms/Utils/SampleProfileInference.cpp
@@ -741,7 +741,7 @@ class FlowAdjuster {
/// parts to a multiple of 1 / BaseDistance.
int64_t jumpDistance(FlowJump *Jump) const {
uint64_t BaseDistance =
- std::max(MinCostMaxFlow::MinBaseDistance,
+ std::max(static_cast<uint64_t>(MinCostMaxFlow::MinBaseDistance),
std::min(Func.Blocks[Func.Entry].Flow,
MinCostMaxFlow::AuxCostUnlikely / NumBlocks()));
if (Jump->IsUnlikely)
More information about the llvm-commits
mailing list