[flang-commits] [flang] b147636 - [NFC][flang] Added debug option to bisect TBAA tag attachments.
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Thu Jan 19 09:28:06 PST 2023
Author: Slava Zakharin
Date: 2023-01-19T09:27:50-08:00
New Revision: b14763652f8519e9ec6b10667a17e32bc3dce913
URL: https://github.com/llvm/llvm-project/commit/b14763652f8519e9ec6b10667a17e32bc3dce913
DIFF: https://github.com/llvm/llvm-project/commit/b14763652f8519e9ec6b10667a17e32bc3dce913.diff
LOG: [NFC][flang] Added debug option to bisect TBAA tag attachments.
Reviewed By: jeanPerier, PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D142070
Added:
Modified:
flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
flang/lib/Optimizer/CodeGen/TBAABuilder.h
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp b/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
index 1bee674f748fe..2d206ed2dcbf5 100644
--- a/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
+++ b/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
@@ -13,6 +13,9 @@
#include "TBAABuilder.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "flang-tbaa-builder"
using namespace mlir;
using namespace mlir::LLVM;
@@ -23,6 +26,15 @@ static llvm::cl::opt<bool> disableTBAA(
"to override default Flang behavior"),
llvm::cl::init(false));
+// tagAttachmentLimit is a debugging option that allows limiting
+// the number of TBAA access tag attributes attached to operations.
+// It is set to kTagAttachmentUnlimited by default denoting "no limit".
+static constexpr unsigned kTagAttachmentUnlimited =
+ std::numeric_limits<unsigned>::max();
+static llvm::cl::opt<unsigned>
+ tagAttachmentLimit("tbaa-attach-tag-max", llvm::cl::desc(""),
+ llvm::cl::init(kTagAttachmentUnlimited));
+
namespace fir {
std::string TBAABuilder::getNewTBAANodeName(llvm::StringRef basename) {
return (llvm::Twine(basename) + llvm::Twine('_') +
@@ -50,6 +62,9 @@ TBAABuilder::TBAABuilder(mlir::ModuleOp module, bool applyTBAA)
return;
}
+ LLVM_DEBUG(llvm::dbgs() << "Creating TBAA MetadataOp for module '"
+ << module.getName().value_or("<unknown>") << "'\n");
+
// Create TBAA MetadataOp with the root and basic type descriptors.
Location loc = module.getLoc();
MLIRContext *context = module.getContext();
@@ -130,6 +145,14 @@ void TBAABuilder::attachTBAATag(Operation *op, Type baseFIRType,
if (!enableTBAA)
return;
+ ++tagAttachmentCounter;
+ if (tagAttachmentLimit != kTagAttachmentUnlimited &&
+ tagAttachmentCounter > tagAttachmentLimit)
+ return;
+
+ LLVM_DEBUG(llvm::dbgs() << "Attaching TBAA tag #" << tagAttachmentCounter
+ << "\n");
+
SymbolRefAttr tbaaTagSym;
if (baseFIRType.isa<fir::BaseBoxType>())
tbaaTagSym = getBoxAccessTag(baseFIRType, accessFIRType, gep);
diff --git a/flang/lib/Optimizer/CodeGen/TBAABuilder.h b/flang/lib/Optimizer/CodeGen/TBAABuilder.h
index dff924bb2a202..f0dfc0ea48b92 100644
--- a/flang/lib/Optimizer/CodeGen/TBAABuilder.h
+++ b/flang/lib/Optimizer/CodeGen/TBAABuilder.h
@@ -251,6 +251,9 @@ class TBAABuilder {
// Counter for unique naming of TBAA operations' symbols.
unsigned tbaaNodeCounter = 0;
+ // Number of attached TBAA tags (used for debugging).
+ unsigned tagAttachmentCounter = 0;
+
// Mapping from a FIR type to the symbol defined by the corresponding
// TBAATypeDescriptorOp. It must be populated during the type conversion.
// Currently unused.
More information about the flang-commits
mailing list