[llvm] [SandboxIR][Region] Implement an auxiliary vector in Region (PR #126376)
Jorge Gorbe Moya via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 13 11:45:48 PST 2025
================
@@ -93,16 +135,34 @@ Region::createRegionsFromMD(Function &F, TargetTransformInfo &TTI) {
auto &Ctx = F.getContext();
for (BasicBlock &BB : F) {
for (Instruction &Inst : BB) {
- if (auto *MDN = cast<llvm::Instruction>(Inst.Val)->getMetadata(MDKind)) {
+ auto *LLVMI = cast<llvm::Instruction>(Inst.Val);
+ if (auto *MDN = LLVMI->getMetadata(MDKind)) {
+ Region *R = nullptr;
auto [It, Inserted] = MDNToRegion.try_emplace(MDN);
if (Inserted) {
Regions.push_back(std::make_unique<Region>(Ctx, TTI));
- It->second = Regions.back().get();
+ R = Regions.back().get();
+ It->second = R;
+ } else {
+ R = It->second;
+ }
+ R->add(&Inst);
+
+ if (auto *AuxMDN = LLVMI->getMetadata(AuxMDKind)) {
+ llvm::Constant *IdxC =
+ dyn_cast<ConstantAsMetadata>(AuxMDN->getOperand(0))->getValue();
+ auto Idx = cast<llvm::ConstantInt>(IdxC)->getSExtValue();
+ R->setAux(Idx, &Inst);
----------------
slackito wrote:
Here we could have a check that we don't have two different values whose metadata claims the same index in the aux vector.
https://github.com/llvm/llvm-project/pull/126376
More information about the llvm-commits
mailing list