#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;
"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('_') +
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();
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);
// 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.