-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MemProf] Avoid assertion checking loop under NDEBUG (NFC) #138985
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
Guard a loop that only exists to do assertion checking of stack ids on memprof metadata so that it isn't compiled and executed under NDEBUG. This is similar to how callsite metadata stack id verification is guarded further below.
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-llvm-transforms Author: Teresa Johnson (teresajohnson) ChangesGuard a loop that only exists to do assertion checking of stack ids on Full diff: https://github.com/llvm/llvm-project/pull/138985.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index ec158afb76519..567f0acadbd2d 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -5242,6 +5242,7 @@ bool MemProfContextDisambiguation::applyImport(Module &M) {
assert(AI != FS->allocs().end());
auto &AllocNode = *(AI++);
+#ifndef NDEBUG
// Sanity check that the MIB stack ids match between the summary and
// instruction metadata.
auto MIBIter = AllocNode.MIBs.begin();
@@ -5276,6 +5277,7 @@ bool MemProfContextDisambiguation::applyImport(Module &M) {
}
MIBIter++;
}
+#endif
// Perform cloning if not yet done.
CloneFuncIfNeeded(/*NumClones=*/AllocNode.Versions.size());
|
@@ -5242,6 +5242,7 @@ bool MemProfContextDisambiguation::applyImport(Module &M) { | |||
assert(AI != FS->allocs().end()); | |||
auto &AllocNode = *(AI++); | |||
|
|||
#ifndef NDEBUG | |||
// Sanity check that the MIB stack ids match between the summary and | |||
// instruction metadata. | |||
auto MIBIter = AllocNode.MIBs.begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor this out to a static helper? I think it should be straightforward since the only live ins for this region are AllocNode and MemProfMD as far as I can tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. There were a couple of other live in variables. I also updated one of the methods to take a const to enable using const for the new helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -5050,6 +5050,45 @@ bool MemProfContextDisambiguation::initializeIndirectCallPromotionInfo( | |||
return true; | |||
} | |||
|
|||
#ifndef NDEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop the ifndef around the function definition in favour of a LLVM_ATTRIBUTE_UNUSED function attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could, but then I need to put that attribute back on the StackIdIndexIter def in this code that I had removed it from. My sense is that the #ifdef
is simpler overall, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me
Guard a loop that only exists to do assertion checking of stack ids on memprof metadata so that it isn't compiled and executed under NDEBUG. This is similar to how callsite metadata stack id verification is guarded further below.
Guard a loop that only exists to do assertion checking of stack ids on
memprof metadata so that it isn't compiled and executed under NDEBUG.
This is similar to how callsite metadata stack id verification is
guarded further below.