[llvm] [SandboxVec] Tag insts in a Region with metadata. (PR #109353)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 08:26:08 PDT 2024
================
@@ -13,13 +13,25 @@ namespace llvm::sandboxir {
Region::Region(Context &Ctx) : Ctx(Ctx) {
static unsigned StaticRegionID;
RegionID = StaticRegionID++;
+
+ LLVMContext &LLVMCtx = Ctx.LLVMCtx;
+ auto *RegionStrMD = MDString::get(LLVMCtx, RegionStr);
+ auto *RegionIDMD = llvm::ConstantAsMetadata::get(
+ llvm::ConstantInt::get(LLVMCtx, APInt(sizeof(RegionID) * 8, RegionID)));
+ RegionMDN = MDNode::get(LLVMCtx, {RegionStrMD, RegionIDMD});
}
Region::~Region() {}
-void Region::add(Instruction *I) { Insts.insert(I); }
+void Region::add(Instruction *I) {
+ Insts.insert(I);
+ cast<llvm::Instruction>(I->Val)->setMetadata(MDKind, RegionMDN);
----------------
vporpo wrote:
Let's also add a TODO about a potential redesign where we tag instructions lazily, perhaps at the end of the region pass manager, to save compile time. It might be worth exploring in the future.
https://github.com/llvm/llvm-project/pull/109353
More information about the llvm-commits
mailing list