[PATCH 14/79] [Backport to 15] Put memory(none) attribute instead of readnone (#1746)
authorDmitry Sidorov <dmitry.sidorov@intel.com>
Tue, 29 Nov 2022 11:55:12 +0000 (12:55 +0100)
committerAndreas Beckmann <anbe@debian.org>
Thu, 8 Feb 2024 21:48:18 +0000 (22:48 +0100)
Instead of creating readnone attributes on each parameter of
a function it's better to put just memory(none) which was recently
introduced.

See https://reviews.llvm.org/D135780

Co-authored by: Zou, Feng <feng.zou@intel.com>

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Gbp-Pq: Name 0014-Backport-to-15-Put-memory-none-attribute-instead-of-.patch

lib/SPIRV/SPIRVReader.cpp
lib/SPIRV/SPIRVUtil.cpp
test/transcoding/builtin_vars_arithmetics.ll

index c75d0e6d009c41f9a2845628323aa3da6a30c6a8..6a84d54d52560e6423e5e8fadb71238e7ba05f69 100644 (file)
@@ -4413,9 +4413,7 @@ Instruction *SPIRVToLLVM::transOCLBuiltinFromExtInst(SPIRVExtInst *BC,
     if (isFuncNoUnwind())
       F->addFnAttr(Attribute::NoUnwind);
     if (isFuncReadNone(UnmangledName))
-      for (llvm::Argument &Arg : F->args())
-        if (Arg.getType()->isPointerTy())
-          Arg.addAttr(Attribute::ReadNone);
+      F->setDoesNotAccessMemory();
   }
   auto Args = transValue(BC->getArgValues(), F, BB);
   SPIRVDBG(dbgs() << "[transOCLBuiltinFromExtInst] Function: " << *F
index 98a905165eb7945a7999400f7595520903508f9c..4889d7b5b44d93b6d07672ce293e2dc2182ee079 100644 (file)
@@ -1947,9 +1947,7 @@ bool lowerBuiltinVariableToCall(GlobalVariable *GV,
     Func->setCallingConv(CallingConv::SPIR_FUNC);
     Func->addFnAttr(Attribute::NoUnwind);
     Func->addFnAttr(Attribute::WillReturn);
-    for (llvm::Argument &Arg : Func->args())
-      if (Arg.getType()->isPointerTy())
-        Arg.addAttr(Attribute::ReadNone);
+    Func->setDoesNotAccessMemory();
   }
 
   // Collect instructions in these containers to remove them later.
index 0fa2f04b4df6dadcbd9bdba95f42d67c29315f22..4ecbbb4977245f43155aa58e1ebd5e5710b3bdaa 100644 (file)
@@ -123,7 +123,7 @@ entry:
 
 attributes #0 = { norecurse "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="test.cpp" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" }
 
-; CHECK-LLVM-OCL: attributes #1 = { nounwind willreturn }
+; CHECK-LLVM-OCL: attributes #1 = { nounwind readnone willreturn }
 
 !llvm.module.flags = !{!0}
 !opencl.spir.version = !{!1}