[PATCH] D139133: [SPIR-V] Support memory(...) function attributes
Michal Paszkowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 1 11:54:30 PST 2022
mpaszkowski created this revision.
mpaszkowski added reviewers: iliya-diyachkov, konrad.trifunovic, zuban32, andreytr, arsenm, MaskRay, rengolin.
Herald added subscribers: StephenFan, ThomasRaoux, hiraditya.
Herald added a project: All.
mpaszkowski requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Adds support for //memory(...)// function attributes in SPIR-V function control info lowering. More about the memory effects attributes changes can be found here: https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579 <https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139133
Files:
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
Index: llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
===================================================================
--- llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
+++ llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
@@ -21,6 +21,7 @@
#include "SPIRVSubtarget.h"
#include "SPIRVUtils.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h"
+#include "llvm/Support/ModRef.h"
using namespace llvm;
@@ -49,19 +50,23 @@
// Based on the LLVM function attributes, get a SPIR-V FunctionControl.
static uint32_t getFunctionControl(const Function &F) {
+ MemoryEffects MemEffects = F.getMemoryEffects();
+
uint32_t FuncControl = static_cast<uint32_t>(SPIRV::FunctionControl::None);
- if (F.hasFnAttribute(Attribute::AttrKind::AlwaysInline)) {
+
+ if (F.hasFnAttribute(Attribute::AttrKind::AlwaysInline))
FuncControl |= static_cast<uint32_t>(SPIRV::FunctionControl::Inline);
- }
- if (F.hasFnAttribute(Attribute::AttrKind::ReadNone)) {
+
+ if (F.hasFnAttribute(Attribute::AttrKind::ReadNone) ||
+ MemEffects.doesNotAccessMemory())
FuncControl |= static_cast<uint32_t>(SPIRV::FunctionControl::Pure);
- }
- if (F.hasFnAttribute(Attribute::AttrKind::ReadOnly)) {
+ else if (F.hasFnAttribute(Attribute::AttrKind::ReadOnly) ||
+ MemEffects.onlyReadsMemory())
FuncControl |= static_cast<uint32_t>(SPIRV::FunctionControl::Const);
- }
- if (F.hasFnAttribute(Attribute::AttrKind::NoInline)) {
+
+ if (F.hasFnAttribute(Attribute::AttrKind::NoInline))
FuncControl |= static_cast<uint32_t>(SPIRV::FunctionControl::DontInline);
- }
+
return FuncControl;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139133.479375.patch
Type: text/x-patch
Size: 1594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221201/e82c3fca/attachment.bin>
More information about the llvm-commits
mailing list