[clang] [llvm] [mlir] [LLVM] Improve IR parsing and printing for target memory locations (PR #176968)
Antonio Frighetto via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 21 03:37:53 PST 2026
================
@@ -2546,18 +2546,30 @@ bool LLParser::parseAllocKind(AllocFnKind &Kind) {
return false;
}
-static std::optional<MemoryEffects::Location> keywordToLoc(lltok::Kind Tok) {
+static std::optional<SmallVector<MemoryEffects::Location, 2>>
----------------
antoniofrighetto wrote:
We shouldn't need a std::optional anymore now, may as well return an empty vector on default and check for emptiness in the caller. However, I'd avoid stack allocations that come with SmallVector here, and favour static storage instead:
```cpp
static ArrayRef<IRMemLocation> keywordToLoc(lltok::Kind Tok) {
using Loc = IRMemLocation;
static constexpr Loc ArgMem[] = {Loc::ArgMem};
static constexpr Loc InaccessibleMem[] = {Loc::InaccessibleMem};
// ...
switch (Tok) {
case lltok::kw_argmem:
return ArgMem;
// ...
}
```
https://github.com/llvm/llvm-project/pull/176968
More information about the cfe-commits
mailing list