[llvm] d0584e2 - [CodeLayout] Update to resolve Wdangling warning.
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 25 11:32:01 PDT 2023
Author: Alina Sbirlea
Date: 2023-10-25T11:31:48-07:00
New Revision: d0584e248d2dc9e9f425caed5983282e2749159d
URL: https://github.com/llvm/llvm-project/commit/d0584e248d2dc9e9f425caed5983282e2749159d
DIFF: https://github.com/llvm/llvm-project/commit/d0584e248d2dc9e9f425caed5983282e2749159d.diff
LOG: [CodeLayout] Update to resolve Wdangling warning.
Change cc2fbc648d7babbfa612f4f5eda3160212ef6ca7 introduced -Wdangling
warning, use temporaries to resolve.
llvm/lib/Transforms/Utils/CodeLayout.cpp:764:27: error: temporary whose address is used as value of local variable '[minDensity, maxDensity]' will be destroyed at the end of the full-expression [-Werror,-Wdangling]
764 | std::minmax(ChainPred->density(), ChainSucc->density());
llvm/lib/Transforms/Utils/CodeLayout.cpp:764:49: error: temporary whose address is used as value of local variable '[minDensity, maxDensity]' will be destroyed at the end of the full-expression [-Werror,-Wdangling]
764 | std::minmax(ChainPred->density(), ChainSucc->density());
Added:
Modified:
llvm/lib/Transforms/Utils/CodeLayout.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp
index 9a5909c97b0fd13..a465e8914c1045b 100644
--- a/llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -760,8 +760,10 @@ class ExtTSPImpl {
// Skip the merge if the ratio between the densities exceeds
// MaxMergeDensityRatio. Smaller values of the option result in fewer
// merges, and hence, more chains.
+ auto ChainPredDensity = ChainPred->density();
+ auto ChainSuccDensity = ChainSucc->density();
auto [minDensity, maxDensity] =
- std::minmax(ChainPred->density(), ChainSucc->density());
+ std::minmax(ChainPredDensity, ChainSuccDensity);
assert(minDensity > 0.0 && maxDensity > 0.0 &&
"incorrectly computed chain densities");
const double Ratio = maxDensity / minDensity;
More information about the llvm-commits
mailing list