Skip to content

Commit b95227e

Browse files
authored
Put memory(none) attribute instead of readnone (#1746)
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 <[email protected]> Signed-off-by: Sidorov, Dmitry <[email protected]>
1 parent e52f5d9 commit b95227e

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

lib/SPIRV/SPIRVReader.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4341,9 +4341,7 @@ Instruction *SPIRVToLLVM::transOCLBuiltinFromExtInst(SPIRVExtInst *BC,
43414341
if (isFuncNoUnwind())
43424342
F->addFnAttr(Attribute::NoUnwind);
43434343
if (isFuncReadNone(UnmangledName))
4344-
for (llvm::Argument &Arg : F->args())
4345-
if (Arg.getType()->isPointerTy())
4346-
Arg.addAttr(Attribute::ReadNone);
4344+
F->setDoesNotAccessMemory();
43474345
}
43484346
auto Args = transValue(BC->getArgValues(), F, BB);
43494347
SPIRVDBG(dbgs() << "[transOCLBuiltinFromExtInst] Function: " << *F

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,9 +1931,7 @@ bool lowerBuiltinVariableToCall(GlobalVariable *GV,
19311931
Func->setCallingConv(CallingConv::SPIR_FUNC);
19321932
Func->addFnAttr(Attribute::NoUnwind);
19331933
Func->addFnAttr(Attribute::WillReturn);
1934-
for (llvm::Argument &Arg : Func->args())
1935-
if (Arg.getType()->isPointerTy())
1936-
Arg.addAttr(Attribute::ReadNone);
1934+
Func->setDoesNotAccessMemory();
19371935
}
19381936

19391937
// Collect instructions in these containers to remove them later.

test/transcoding/builtin_vars_arithmetics.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ entry:
123123

124124
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" }
125125

126-
; CHECK-LLVM-OCL: attributes #1 = { nounwind willreturn }
126+
; CHECK-LLVM-OCL: attributes #1 = { nounwind willreturn memory(none) }
127127

128128
!llvm.module.flags = !{!0}
129129
!opencl.spir.version = !{!1}

0 commit comments

Comments
 (0)