[llvm] 20cb6c7 - [AA] Add option for tracing AA queries (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 12 12:44:09 PST 2021
Author: Nikita Popov
Date: 2021-02-12T21:42:49+01:00
New Revision: 20cb6c7cebb5a3566640a9bf0da4729993ce6020
URL: https://github.com/llvm/llvm-project/commit/20cb6c7cebb5a3566640a9bf0da4729993ce6020
DIFF: https://github.com/llvm/llvm-project/commit/20cb6c7cebb5a3566640a9bf0da4729993ce6020.diff
LOG: [AA] Add option for tracing AA queries (NFC)
Add an -aa-trace debug option that can be used to print AA queries,
including any recursive queries and their results.
Added:
Modified:
llvm/lib/Analysis/AliasAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index ebf7070c5aa1..6af69e823d40 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -67,6 +67,13 @@ STATISTIC(NumMustAlias, "Number of MustAlias results");
/// when testing to isolate a single AA implementation.
cl::opt<bool> DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false));
+#ifndef NDEBUG
+/// Print a trace of alias analysis queries and their results.
+static cl::opt<bool> EnableAATrace("aa-trace", cl::Hidden, cl::init(false));
+#else
+static const bool EnableAATrace = false;
+#endif
+
AAResults::AAResults(AAResults &&Arg)
: TLI(Arg.TLI), AAs(std::move(Arg.AAs)), AADeps(std::move(Arg.AADeps)) {
for (auto &AA : AAs)
@@ -118,6 +125,13 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB, AAQueryInfo &AAQI) {
AliasResult Result = MayAlias;
+ if (EnableAATrace) {
+ for (unsigned I = 0; I < AAQI.Depth; ++I)
+ dbgs() << " ";
+ dbgs() << "Start " << *LocA.Ptr << " @ " << LocA.Size << ", "
+ << *LocB.Ptr << " @ " << LocB.Size << "\n";
+ }
+
AAQI.Depth++;
for (const auto &AA : AAs) {
Result = AA->alias(LocA, LocB, AAQI);
@@ -126,6 +140,13 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
}
AAQI.Depth--;
+ if (EnableAATrace) {
+ for (unsigned I = 0; I < AAQI.Depth; ++I)
+ dbgs() << " ";
+ dbgs() << "End " << *LocA.Ptr << " @ " << LocA.Size << ", "
+ << *LocB.Ptr << " @ " << LocB.Size << " = " << Result << "\n";
+ }
+
if (AAQI.Depth == 0) {
if (Result == NoAlias)
++NumNoAlias;
More information about the llvm-commits
mailing list