about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper
diff options
context:
space:
mode:
authorHans Wennborg <hans@chromium.org>2025-01-30 11:18:36 +0100
committerHans Wennborg <hans@chromium.org>2025-01-30 11:22:46 +0100
commit23fb08bb532ed8a9b4947c213ae3fc0862b2b254 (patch)
tree8535fdcbf0adda669c8778bd08f30cda0615e4b5 /compiler/rustc_llvm/llvm-wrapper
parente6f12c8b7d8d5c821c32fb2739ea01d1d874c58a (diff)
downloadrust-23fb08bb532ed8a9b4947c213ae3fc0862b2b254.tar.gz
rust-23fb08bb532ed8a9b4947c213ae3fc0862b2b254.zip
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.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 35186778671..858251ff9c8 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,13 @@ 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::get(*unwrap(C), Attribute::Captures,
+                               CaptureInfo::none().toIntValue()));
+  }
+#endif
   return wrap(Attribute::get(*unwrap(C), fromRust(RustAttr)));
 }