[llvm] [Attributor] Improve debug string of `AAUnderlyingObjects` (PR #101861)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 3 20:34:54 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Shilei Tian (shiltian)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/101861.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+18-8)
``````````diff
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()
``````````
</details>
https://github.com/llvm/llvm-project/pull/101861
More information about the llvm-commits
mailing list