[llvm] 4b6e3e3 - [Attributor] Improve debug string of `AAUnderlyingObjects` (#101861)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 12:31:38 PDT 2024
Author: Shilei Tian
Date: 2024-08-06T12:31:35-07:00
New Revision: 4b6e3e38c46f8fedb92a30b29cc9654450244e2d
URL: https://github.com/llvm/llvm-project/commit/4b6e3e38c46f8fedb92a30b29cc9654450244e2d
DIFF: https://github.com/llvm/llvm-project/commit/4b6e3e38c46f8fedb92a30b29cc9654450244e2d.diff
LOG: [Attributor] Improve debug string of `AAUnderlyingObjects` (#101861)
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
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