aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-01-29 16:56:47 +0100
committerGitHub <noreply@github.com>2025-01-29 16:56:47 +0100
commit29441e4f5fa5f5c7709f7cf180815ba97f611297 (patch)
treeec6e52b957d314139f9cc548f26068f3432fb6d8 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent3c3c850a45c8f1ea1e9d6aa514e2b6076d1a4534 (diff)
downloadllvm-29441e4f5fa5f5c7709f7cf180815ba97f611297.zip
llvm-29441e4f5fa5f5c7709f7cf180815ba97f611297.tar.gz
llvm-29441e4f5fa5f5c7709f7cf180815ba97f611297.tar.bz2
[IR] Convert from nocapture to captures(none) (#123181)
This PR removes the old `nocapture` attribute, replacing it with the new `captures` attribute introduced in #116990. This change is intended to be essentially NFC, replacing existing uses of `nocapture` with `captures(none)` without adding any new analysis capabilities. Making use of non-`none` values is left for a followup. Some notes: * `nocapture` will be upgraded to `captures(none)` by the bitcode reader. * `nocapture` will also be upgraded by the textual IR reader. This is to make it easier to use old IR files and somewhat reduce the test churn in this PR. * Helper APIs like `doesNotCapture()` will check for `captures(none)`. * MLIR import will convert `captures(none)` into an `llvm.nocapture` attribute. The representation in the LLVM IR dialect should be updated separately.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 551dfd4..e16e8a0 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1865,7 +1865,7 @@ static uint64_t getRawAttributeMask(Attribute::AttrKind Val) {
case Attribute::StackProtect: return 1 << 14;
case Attribute::StackProtectReq: return 1 << 15;
case Attribute::Alignment: return 31 << 16;
- case Attribute::NoCapture: return 1 << 21;
+ // 1ULL << 21 is NoCapture, which is upgraded separately.
case Attribute::NoRedZone: return 1 << 22;
case Attribute::NoImplicitFloat: return 1 << 23;
case Attribute::Naked: return 1 << 24;
@@ -1986,6 +1986,12 @@ static void decodeLLVMAttributesForBitcode(AttrBuilder &B,
B.addMemoryAttr(ME);
}
+ // Upgrade nocapture to captures(none).
+ if (Attrs & (1ULL << 21)) {
+ Attrs &= ~(1ULL << 21);
+ B.addCapturesAttr(CaptureInfo::none());
+ }
+
addRawAttributeValue(B, Attrs);
}
@@ -2098,8 +2104,6 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
return Attribute::NoBuiltin;
case bitc::ATTR_KIND_NO_CALLBACK:
return Attribute::NoCallback;
- case bitc::ATTR_KIND_NO_CAPTURE:
- return Attribute::NoCapture;
case bitc::ATTR_KIND_NO_DIVERGENCE_SOURCE:
return Attribute::NoDivergenceSource;
case bitc::ATTR_KIND_NO_DUPLICATE:
@@ -2349,6 +2353,11 @@ Error BitcodeReader::parseAttributeGroupBlock() {
upgradeOldMemoryAttribute(ME, EncodedKind))
continue;
+ if (EncodedKind == bitc::ATTR_KIND_NO_CAPTURE) {
+ B.addCapturesAttr(CaptureInfo::none());
+ continue;
+ }
+
if (Error Err = parseAttrKind(EncodedKind, &Kind))
return Err;