[clang] [llvm] [AMDGPU] Add alignment attr & propagate alignment through make.buffer.rsrc inst (PR #145278)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 6 19:47:51 PDT 2025


================
@@ -1432,6 +1442,26 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
       } else if (auto *CmpX = dyn_cast<AtomicCmpXchgInst>(&I)) {
         A.getOrCreateAAFor<AAAddressSpace>(
             IRPosition::value(*CmpX->getPointerOperand()));
+      } else if (auto *II = dyn_cast<IntrinsicInst>(&I)) {
+        if (II->getIntrinsicID() == Intrinsic::amdgcn_make_buffer_rsrc) {
+          IRPosition IRP = IRPosition::value(*II);
+
+          Attributor::AlignmentCallbackTy ACB =
+              [](const IRPosition &IRP, const AbstractAttribute *AA,
+                 SmallVectorImpl<AA::ValueAndContext> &Values) {
+                Instruction *I = IRP.getCtxI();
+                if (!I)
+                  return;
+                if (auto *II = dyn_cast<IntrinsicInst>(I))
+                  if (II->getIntrinsicID() ==
+                      Intrinsic::amdgcn_make_buffer_rsrc)
+                    Values.push_back(
+                        AA::ValueAndContext{*I->getOperand(0), nullptr});
----------------
shiltian wrote:

```suggestion
                if (auto *II = dyn_cast<IntrinsicInst>(I)) {
                  if (II->getIntrinsicID() ==
                      Intrinsic::amdgcn_make_buffer_rsrc)
                    Values.push_back(
                        AA::ValueAndContext{*I->getOperand(0), nullptr});
                }
```

https://github.com/llvm/llvm-project/pull/145278


More information about the llvm-commits mailing list