[llvm] [Attributor] Improve debug string of `AAUnderlyingObjects` (PR #101861)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 3 20:34:19 PDT 2024
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/101861
None
>From a48752fd3c24eb21afa01e06558a6acc96c2eaa4 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Sat, 3 Aug 2024 20:56:06 -0400
Subject: [PATCH] [Attributor] Improve debug string of `AAUnderlyingObjects`
---
.../Transforms/IPO/AttributorAttributes.cpp | 26 +++++++++++++------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index cd31c4be1c1da..77026c6aa5b27 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -11874,14 +11874,24 @@ struct AAUnderlyingObjectsImpl
/// See AbstractAttribute::getAsStr().
const std::string getAsStr(Attributor *A) const override {
- return std::string("UnderlyingObjects ") +
- (isValidState()
- ? (std::string("inter #") +
- std::to_string(InterAssumedUnderlyingObjects.size()) +
- " objs" + std::string(", intra #") +
- std::to_string(IntraAssumedUnderlyingObjects.size()) +
- " objs")
- : "<invalid>");
+ if (!isValidState())
+ return "<invalid>";
+ std::string Str;
+ llvm::raw_string_ostream OS(Str);
+ OS << "underlying objects: inter " << InterAssumedUnderlyingObjects.size()
+ << " objects, intra " << IntraAssumedUnderlyingObjects.size()
+ << " objects.\n";
+ if (!InterAssumedUnderlyingObjects.empty()) {
+ OS << "inter objects:\n";
+ for (auto *Obj : InterAssumedUnderlyingObjects)
+ OS << *Obj << '\n';
+ }
+ if (!IntraAssumedUnderlyingObjects.empty()) {
+ OS << "intra objects:\n";
+ for (auto *Obj : IntraAssumedUnderlyingObjects)
+ OS << *Obj << '\n';
+ }
+ return Str;
}
/// See AbstractAttribute::trackStatistics()
More information about the llvm-commits
mailing list