[llvm] [Attributor] Skip AS specialization for volatile memory instructions (PR #107250)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 11:52:02 PDT 2024


================
@@ -12509,6 +12509,34 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
 
 /// ------------------------ Address Space  ------------------------------------
 namespace {
+
+template <typename InstType>
+static bool makeChange(Attributor &A, InstType *MemInst, const Use &U,
+                       Value *OriginalValue, PointerType *NewPtrTy,
+                       bool UseOriginalValue) {
+  if (U.getOperandNo() != InstType::getPointerOperandIndex())
+    return false;
+
+  auto *TTI = A.getInfoCache().getAnalysisResultForFunction<TargetIRAnalysis>(
+      *MemInst->getFunction());
+  if (!TTI)
+    return false;
+
+  unsigned OldAS = MemInst->getPointerAddressSpace();
+  if (MemInst->isVolatile() && !TTI->hasVolatileVariant(MemInst, OldAS))
----------------
shiltian wrote:

I think `hasVolatileVariant` indeed needs to pass the new AS instead of the old one based on the comment. Also, it returns `false` by default, which prevents any AS inference.

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


More information about the llvm-commits mailing list