diff options
author | Vadim Curcă <80581374+VadimCurca@users.noreply.github.com> | 2025-09-01 12:39:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-01 12:39:58 +0200 |
commit | 4b226318cca1ed8c29168defbba4599b0caf8edd (patch) | |
tree | ef92239f1c7d3257d5e4b6894d5a1f1a8c3af213 /llvm/lib/IR/Attributes.cpp | |
parent | 2320529ff77338cd0cb9786b8f195d611edcae77 (diff) | |
download | llvm-4b226318cca1ed8c29168defbba4599b0caf8edd.zip llvm-4b226318cca1ed8c29168defbba4599b0caf8edd.tar.gz llvm-4b226318cca1ed8c29168defbba4599b0caf8edd.tar.bz2 |
[MLIR] Add target_specific_attrs attribute to mlir.global (#154706)
Adds a `target_specific_attrs` optional array attribute to
`mlir.global`, as well as conversions to and from LLVM attributes on
`llvm::GlobalVariable` objects. This is necessary to preserve unknown
attributes on global variables when converting to and from the LLVM
Dialect. Previously, any attributes on an `llvm::GlobalVariable` not
explicitly modeled by `mlir.global` were dropped during conversion.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index d1fbcb9..4ac2ebd 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -954,6 +954,19 @@ AttributeSet AttributeSet::addAttributes(LLVMContext &C, return get(C, B); } +AttributeSet AttributeSet::addAttributes(LLVMContext &C, + const AttrBuilder &B) const { + if (!hasAttributes()) + return get(C, B); + + if (!B.hasAttributes()) + return *this; + + AttrBuilder Merged(C, *this); + Merged.merge(B); + return get(C, Merged); +} + AttributeSet AttributeSet::removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const { if (!hasAttribute(Kind)) return *this; |