-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MemProf] Display backedges with dotted line in dot graphs #128235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add checking of this behavior in the postbuild dot graphs, facilitated by PR128226 which marked these edges at the end of the graph building.
@llvm/pr-subscribers-lto Author: Teresa Johnson (teresajohnson) ChangesAdd checking of this behavior in the postbuild dot graphs, facilitated Full diff: https://github.com/llvm/llvm-project/pull/128235.diff 3 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 705806b98f8da..85fb0b770f1ed 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -3067,11 +3067,15 @@ struct DOTGraphTraits<const CallsiteContextGraph<DerivedCCG, FuncTy, CallTy> *>
GraphType) {
auto &Edge = *(ChildIter.getCurrent());
auto Color = getColor(Edge->AllocTypes);
- return (Twine("tooltip=\"") + getContextIds(Edge->ContextIds) + "\"" +
- // fillcolor is the arrow head and color is the line
- Twine(",fillcolor=\"") + Color + "\"" + Twine(",color=\"") + Color +
- "\"")
- .str();
+ std::string AttributeString =
+ (Twine("tooltip=\"") + getContextIds(Edge->ContextIds) + "\"" +
+ // fillcolor is the arrow head and color is the line
+ Twine(",fillcolor=\"") + Color + "\"" + Twine(",color=\"") + Color +
+ "\"")
+ .str();
+ if (Edge->IsBackedge)
+ AttributeString += ",style=\"dotted\"";
+ return AttributeString;
}
// Since the NodeOwners list includes nodes that are no longer connected to
diff --git a/llvm/test/ThinLTO/X86/memprof-recursive.ll b/llvm/test/ThinLTO/X86/memprof-recursive.ll
index e1a9084b583b9..a39f9216e8ab4 100644
--- a/llvm/test/ThinLTO/X86/memprof-recursive.ll
+++ b/llvm/test/ThinLTO/X86/memprof-recursive.ll
@@ -52,11 +52,20 @@
; RUN: -r=%t.o,main,plx \
; RUN: -r=%t.o,_Znam, \
; RUN: -memprof-verify-ccg -memprof-verify-nodes -stats \
+; RUN: -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
; RUN: -pass-remarks=memprof-context-disambiguation \
; RUN: -o %t.out 2>&1 | FileCheck %s \
; RUN: --check-prefix=ALLOW-RECUR-CALLSITES --check-prefix=ALLOW-RECUR-CONTEXTS \
; RUN: --check-prefix=CLONE-RECUR-CALLSITES
+;; Check that the backedge was correctly detected and emitted to the dot file
+;; as a dotted edge.
+; RUN: cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOT
+; DOT-DAG: Node[[B:0x[a-f0-9]+]] {{.*}}_Z1Bi -\> _Z1Ci
+; DOT-DAG: Node[[C:0x[a-f0-9]+]] {{.*}}_Z1Ci -\> _Z1Bi
+; DOT-DAG: Node[[B]] -> Node[[C]]{{.*}}style="solid"
+; DOT-DAG: Node[[C]] -> Node[[B]]{{.*}}style="dotted"
+
;; Skipping recursive contexts should prevent spurious call to cloned version of
;; B from the context starting at memprof_recursive.cc:19:13, which is actually
;; recursive (until that support is added).
diff --git a/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll b/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll
index 1d09b1c1a0cb3..ed5c43ceaf375 100644
--- a/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll
+++ b/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll
@@ -64,11 +64,20 @@
;; Check the default behavior (clone recursive callsites).
; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
; RUN: -memprof-verify-ccg -memprof-verify-nodes -stats \
+; RUN: -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
; RUN: -pass-remarks=memprof-context-disambiguation \
; RUN: %s -S 2>&1 | FileCheck %s \
; RUN: --check-prefix=ALL --check-prefix=ALLOW-RECUR-CALLSITES --check-prefix=ALLOW-RECUR-CONTEXTS \
; RUN: --check-prefix=CLONE-RECUR-CALLSITES
+;; Check that the backedge was correctly detected and emitted to the dot file
+;; as a dotted edge.
+; RUN: cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOT
+; DOT-DAG: Node[[B:0x[a-f0-9]+]] {{.*}}_Z1Bi -\> _Z1Ci
+; DOT-DAG: Node[[C:0x[a-f0-9]+]] {{.*}}_Z1Ci -\> _Z1Bi
+; DOT-DAG: Node[[B]] -> Node[[C]]{{.*}}style="solid"
+; DOT-DAG: Node[[C]] -> Node[[B]]{{.*}}style="dotted"
+
;; Skipping recursive contexts should prevent spurious call to cloned version of
;; B from the context starting at memprof_recursive.cc:19:13, which is actually
;; recursive (until that support is added).
|
@llvm/pr-subscribers-llvm-transforms Author: Teresa Johnson (teresajohnson) ChangesAdd checking of this behavior in the postbuild dot graphs, facilitated Full diff: https://github.com/llvm/llvm-project/pull/128235.diff 3 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 705806b98f8da..85fb0b770f1ed 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -3067,11 +3067,15 @@ struct DOTGraphTraits<const CallsiteContextGraph<DerivedCCG, FuncTy, CallTy> *>
GraphType) {
auto &Edge = *(ChildIter.getCurrent());
auto Color = getColor(Edge->AllocTypes);
- return (Twine("tooltip=\"") + getContextIds(Edge->ContextIds) + "\"" +
- // fillcolor is the arrow head and color is the line
- Twine(",fillcolor=\"") + Color + "\"" + Twine(",color=\"") + Color +
- "\"")
- .str();
+ std::string AttributeString =
+ (Twine("tooltip=\"") + getContextIds(Edge->ContextIds) + "\"" +
+ // fillcolor is the arrow head and color is the line
+ Twine(",fillcolor=\"") + Color + "\"" + Twine(",color=\"") + Color +
+ "\"")
+ .str();
+ if (Edge->IsBackedge)
+ AttributeString += ",style=\"dotted\"";
+ return AttributeString;
}
// Since the NodeOwners list includes nodes that are no longer connected to
diff --git a/llvm/test/ThinLTO/X86/memprof-recursive.ll b/llvm/test/ThinLTO/X86/memprof-recursive.ll
index e1a9084b583b9..a39f9216e8ab4 100644
--- a/llvm/test/ThinLTO/X86/memprof-recursive.ll
+++ b/llvm/test/ThinLTO/X86/memprof-recursive.ll
@@ -52,11 +52,20 @@
; RUN: -r=%t.o,main,plx \
; RUN: -r=%t.o,_Znam, \
; RUN: -memprof-verify-ccg -memprof-verify-nodes -stats \
+; RUN: -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
; RUN: -pass-remarks=memprof-context-disambiguation \
; RUN: -o %t.out 2>&1 | FileCheck %s \
; RUN: --check-prefix=ALLOW-RECUR-CALLSITES --check-prefix=ALLOW-RECUR-CONTEXTS \
; RUN: --check-prefix=CLONE-RECUR-CALLSITES
+;; Check that the backedge was correctly detected and emitted to the dot file
+;; as a dotted edge.
+; RUN: cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOT
+; DOT-DAG: Node[[B:0x[a-f0-9]+]] {{.*}}_Z1Bi -\> _Z1Ci
+; DOT-DAG: Node[[C:0x[a-f0-9]+]] {{.*}}_Z1Ci -\> _Z1Bi
+; DOT-DAG: Node[[B]] -> Node[[C]]{{.*}}style="solid"
+; DOT-DAG: Node[[C]] -> Node[[B]]{{.*}}style="dotted"
+
;; Skipping recursive contexts should prevent spurious call to cloned version of
;; B from the context starting at memprof_recursive.cc:19:13, which is actually
;; recursive (until that support is added).
diff --git a/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll b/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll
index 1d09b1c1a0cb3..ed5c43ceaf375 100644
--- a/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll
+++ b/llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll
@@ -64,11 +64,20 @@
;; Check the default behavior (clone recursive callsites).
; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
; RUN: -memprof-verify-ccg -memprof-verify-nodes -stats \
+; RUN: -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
; RUN: -pass-remarks=memprof-context-disambiguation \
; RUN: %s -S 2>&1 | FileCheck %s \
; RUN: --check-prefix=ALL --check-prefix=ALLOW-RECUR-CALLSITES --check-prefix=ALLOW-RECUR-CONTEXTS \
; RUN: --check-prefix=CLONE-RECUR-CALLSITES
+;; Check that the backedge was correctly detected and emitted to the dot file
+;; as a dotted edge.
+; RUN: cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOT
+; DOT-DAG: Node[[B:0x[a-f0-9]+]] {{.*}}_Z1Bi -\> _Z1Ci
+; DOT-DAG: Node[[C:0x[a-f0-9]+]] {{.*}}_Z1Ci -\> _Z1Bi
+; DOT-DAG: Node[[B]] -> Node[[C]]{{.*}}style="solid"
+; DOT-DAG: Node[[C]] -> Node[[B]]{{.*}}style="dotted"
+
;; Skipping recursive contexts should prevent spurious call to cloned version of
;; B from the context starting at memprof_recursive.cc:19:13, which is actually
;; recursive (until that support is added).
|
Add checking of this behavior in the postbuild dot graphs, facilitated
by PR128226 which marked these edges at the end of the graph building.