about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-01-31 00:25:37 -0500
committerGitHub <noreply@github.com>2025-01-31 00:25:37 -0500
commitb87df231c565bd2f05e39d201a49a96f96ae4930 (patch)
tree4c697db59f6f1624b5c6d6c7bb164f87003613bd /compiler/rustc_llvm/llvm-wrapper
parent8b409e44dae2ff56682641f31907f9f2841794ea (diff)
parent6e457b88eb6058267794ab6dbf595cf8f183368c (diff)
downloadrust-b87df231c565bd2f05e39d201a49a96f96ae4930.tar.gz
rust-b87df231c565bd2f05e39d201a49a96f96ae4930.zip
Rollup merge of #136287 - zmodem:nocapture, r=nikic
LLVM changed the nocapture attribute to captures(none)

This updates RustWrapper.cpp and tests after
https://github.com/llvm/llvm-project/pull/123181
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 35186778671..545422682f0 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -319,7 +319,11 @@ static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) {
   case LLVMRustAttributeKind::NoAlias:
     return Attribute::NoAlias;
   case LLVMRustAttributeKind::NoCapture:
+#if LLVM_VERSION_GE(21, 0)
+    report_fatal_error("NoCapture doesn't exist in LLVM 21");
+#else
     return Attribute::NoCapture;
+#endif
   case LLVMRustAttributeKind::NoCfCheck:
     return Attribute::NoCfCheck;
   case LLVMRustAttributeKind::NoInline:
@@ -431,6 +435,12 @@ extern "C" void LLVMRustEraseInstFromParent(LLVMValueRef Instr) {
 
 extern "C" LLVMAttributeRef
 LLVMRustCreateAttrNoValue(LLVMContextRef C, LLVMRustAttributeKind RustAttr) {
+#if LLVM_VERSION_GE(21, 0)
+  // LLVM 21 replaced the NoCapture attribute with Captures(none).
+  if (RustAttr == LLVMRustAttributeKind::NoCapture) {
+    return wrap(Attribute::getWithCaptureInfo(*unwrap(C), CaptureInfo::none()));
+  }
+#endif
   return wrap(Attribute::get(*unwrap(C), fromRust(RustAttr)));
 }