From b9d52e8ac8f3de0656ebf17e8d741c0421f6b5ea Mon Sep 17 00:00:00 2001 From: Eric Schweitz Date: Tue, 4 Feb 2025 08:40:41 -0800 Subject: [PATCH] Workaround overly excitable warnings in GCC 12. Signed-off-by: Eric Schweitz --- lib/Optimizer/CodeGen/ReturnToOutputLog.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/Optimizer/CodeGen/ReturnToOutputLog.cpp b/lib/Optimizer/CodeGen/ReturnToOutputLog.cpp index e478f4f412..9c6c73eaf5 100644 --- a/lib/Optimizer/CodeGen/ReturnToOutputLog.cpp +++ b/lib/Optimizer/CodeGen/ReturnToOutputLog.cpp @@ -86,7 +86,8 @@ class ReturnRewrite : public OpRewritePattern { Type valTy = val.getType(); TypeSwitch(valTy) .Case([&](IntegerType intTy) { - std::string labelStr{"i" + std::to_string(intTy.getWidth())}; + int width = intTy.getWidth(); + std::string labelStr{"i" + std::to_string(width)}; if (prefix) labelStr = prefix->str(); Value label = makeLabel(loc, rewriter, labelStr); @@ -111,7 +112,8 @@ class ReturnRewrite : public OpRewritePattern { ArrayRef{castVal, label}); }) .Case([&](FloatType fltTy) { - std::string labelStr{"f" + std::to_string(fltTy.getWidth())}; + int width = fltTy.getWidth(); + std::string labelStr{"f" + std::to_string(width)}; if (prefix) labelStr = prefix->str(); Value label = makeLabel(loc, rewriter, labelStr); @@ -197,10 +199,14 @@ class ReturnRewrite : public OpRewritePattern { static std::string translateType(Type ty, std::optional vecSz = std::nullopt) { - if (auto intTy = dyn_cast(ty)) - return "i" + std::to_string(intTy.getWidth()); - if (auto fltTy = dyn_cast(ty)) - return "f" + std::to_string(fltTy.getWidth()); + if (auto intTy = dyn_cast(ty)) { + int width = intTy.getWidth(); + return "i" + std::to_string(width); + } + if (auto fltTy = dyn_cast(ty)) { + int width = fltTy.getWidth(); + return "f" + std::to_string(width); + } if (auto strTy = dyn_cast(ty)) { if (strTy.getMembers().empty()) return "{}"; @@ -210,7 +216,8 @@ class ReturnRewrite : public OpRewritePattern { return result + "}"; } if (auto arrTy = dyn_cast(ty)) { - return "[" + std::to_string(arrTy.getSize()) + " x " + + std::int32_t size = arrTy.getSize(); + return "[" + std::to_string(size) + " x " + translateType(arrTy.getElementType()) + "]"; } if (auto arrTy = dyn_cast(ty)) {