@@ -228,94 +228,140 @@ extern "C" LLVMValueRef LLVMRustInsertPrivateGlobal(LLVMModuleRef M,
228228 GlobalValue::PrivateLinkage, nullptr ));
229229}
230230
231- static Attribute::AttrKind fromRust (LLVMRustAttribute Kind) {
231+ // Must match the layout of `rustc_codegen_llvm::llvm::ffi::AttributeKind`.
232+ enum class LLVMRustAttributeKind {
233+ AlwaysInline = 0 ,
234+ ByVal = 1 ,
235+ Cold = 2 ,
236+ InlineHint = 3 ,
237+ MinSize = 4 ,
238+ Naked = 5 ,
239+ NoAlias = 6 ,
240+ NoCapture = 7 ,
241+ NoInline = 8 ,
242+ NonNull = 9 ,
243+ NoRedZone = 10 ,
244+ NoReturn = 11 ,
245+ NoUnwind = 12 ,
246+ OptimizeForSize = 13 ,
247+ ReadOnly = 14 ,
248+ SExt = 15 ,
249+ StructRet = 16 ,
250+ UWTable = 17 ,
251+ ZExt = 18 ,
252+ InReg = 19 ,
253+ SanitizeThread = 20 ,
254+ SanitizeAddress = 21 ,
255+ SanitizeMemory = 22 ,
256+ NonLazyBind = 23 ,
257+ OptimizeNone = 24 ,
258+ ReadNone = 26 ,
259+ SanitizeHWAddress = 28 ,
260+ WillReturn = 29 ,
261+ StackProtectReq = 30 ,
262+ StackProtectStrong = 31 ,
263+ StackProtect = 32 ,
264+ NoUndef = 33 ,
265+ SanitizeMemTag = 34 ,
266+ NoCfCheck = 35 ,
267+ ShadowCallStack = 36 ,
268+ AllocSize = 37 ,
269+ AllocatedPointer = 38 ,
270+ AllocAlign = 39 ,
271+ SanitizeSafeStack = 40 ,
272+ FnRetThunkExtern = 41 ,
273+ Writable = 42 ,
274+ DeadOnUnwind = 43 ,
275+ };
276+
277+ static Attribute::AttrKind fromRust (LLVMRustAttributeKind Kind) {
232278 switch (Kind) {
233- case AlwaysInline:
279+ case LLVMRustAttributeKind:: AlwaysInline:
234280 return Attribute::AlwaysInline;
235- case ByVal:
281+ case LLVMRustAttributeKind:: ByVal:
236282 return Attribute::ByVal;
237- case Cold:
283+ case LLVMRustAttributeKind:: Cold:
238284 return Attribute::Cold;
239- case InlineHint:
285+ case LLVMRustAttributeKind:: InlineHint:
240286 return Attribute::InlineHint;
241- case MinSize:
287+ case LLVMRustAttributeKind:: MinSize:
242288 return Attribute::MinSize;
243- case Naked:
289+ case LLVMRustAttributeKind:: Naked:
244290 return Attribute::Naked;
245- case NoAlias:
291+ case LLVMRustAttributeKind:: NoAlias:
246292 return Attribute::NoAlias;
247- case NoCapture:
293+ case LLVMRustAttributeKind:: NoCapture:
248294 return Attribute::NoCapture;
249- case NoCfCheck:
295+ case LLVMRustAttributeKind:: NoCfCheck:
250296 return Attribute::NoCfCheck;
251- case NoInline:
297+ case LLVMRustAttributeKind:: NoInline:
252298 return Attribute::NoInline;
253- case NonNull:
299+ case LLVMRustAttributeKind:: NonNull:
254300 return Attribute::NonNull;
255- case NoRedZone:
301+ case LLVMRustAttributeKind:: NoRedZone:
256302 return Attribute::NoRedZone;
257- case NoReturn:
303+ case LLVMRustAttributeKind:: NoReturn:
258304 return Attribute::NoReturn;
259- case NoUnwind:
305+ case LLVMRustAttributeKind:: NoUnwind:
260306 return Attribute::NoUnwind;
261- case OptimizeForSize:
307+ case LLVMRustAttributeKind:: OptimizeForSize:
262308 return Attribute::OptimizeForSize;
263- case ReadOnly:
309+ case LLVMRustAttributeKind:: ReadOnly:
264310 return Attribute::ReadOnly;
265- case SExt:
311+ case LLVMRustAttributeKind:: SExt:
266312 return Attribute::SExt;
267- case StructRet:
313+ case LLVMRustAttributeKind:: StructRet:
268314 return Attribute::StructRet;
269- case UWTable:
315+ case LLVMRustAttributeKind:: UWTable:
270316 return Attribute::UWTable;
271- case ZExt:
317+ case LLVMRustAttributeKind:: ZExt:
272318 return Attribute::ZExt;
273- case InReg:
319+ case LLVMRustAttributeKind:: InReg:
274320 return Attribute::InReg;
275- case SanitizeThread:
321+ case LLVMRustAttributeKind:: SanitizeThread:
276322 return Attribute::SanitizeThread;
277- case SanitizeAddress:
323+ case LLVMRustAttributeKind:: SanitizeAddress:
278324 return Attribute::SanitizeAddress;
279- case SanitizeMemory:
325+ case LLVMRustAttributeKind:: SanitizeMemory:
280326 return Attribute::SanitizeMemory;
281- case NonLazyBind:
327+ case LLVMRustAttributeKind:: NonLazyBind:
282328 return Attribute::NonLazyBind;
283- case OptimizeNone:
329+ case LLVMRustAttributeKind:: OptimizeNone:
284330 return Attribute::OptimizeNone;
285- case ReadNone:
331+ case LLVMRustAttributeKind:: ReadNone:
286332 return Attribute::ReadNone;
287- case SanitizeHWAddress:
333+ case LLVMRustAttributeKind:: SanitizeHWAddress:
288334 return Attribute::SanitizeHWAddress;
289- case WillReturn:
335+ case LLVMRustAttributeKind:: WillReturn:
290336 return Attribute::WillReturn;
291- case StackProtectReq:
337+ case LLVMRustAttributeKind:: StackProtectReq:
292338 return Attribute::StackProtectReq;
293- case StackProtectStrong:
339+ case LLVMRustAttributeKind:: StackProtectStrong:
294340 return Attribute::StackProtectStrong;
295- case StackProtect:
341+ case LLVMRustAttributeKind:: StackProtect:
296342 return Attribute::StackProtect;
297- case NoUndef:
343+ case LLVMRustAttributeKind:: NoUndef:
298344 return Attribute::NoUndef;
299- case SanitizeMemTag:
345+ case LLVMRustAttributeKind:: SanitizeMemTag:
300346 return Attribute::SanitizeMemTag;
301- case ShadowCallStack:
347+ case LLVMRustAttributeKind:: ShadowCallStack:
302348 return Attribute::ShadowCallStack;
303- case AllocSize:
349+ case LLVMRustAttributeKind:: AllocSize:
304350 return Attribute::AllocSize;
305- case AllocatedPointer:
351+ case LLVMRustAttributeKind:: AllocatedPointer:
306352 return Attribute::AllocatedPointer;
307- case AllocAlign:
353+ case LLVMRustAttributeKind:: AllocAlign:
308354 return Attribute::AllocAlign;
309- case SanitizeSafeStack:
355+ case LLVMRustAttributeKind:: SanitizeSafeStack:
310356 return Attribute::SafeStack;
311- case FnRetThunkExtern:
357+ case LLVMRustAttributeKind:: FnRetThunkExtern:
312358 return Attribute::FnRetThunkExtern;
313- case Writable:
359+ case LLVMRustAttributeKind:: Writable:
314360 return Attribute::Writable;
315- case DeadOnUnwind:
361+ case LLVMRustAttributeKind:: DeadOnUnwind:
316362 return Attribute::DeadOnUnwind;
317363 }
318- report_fatal_error (" bad AttributeKind " );
364+ report_fatal_error (" bad LLVMRustAttributeKind " );
319365}
320366
321367template <typename T>
@@ -345,7 +391,7 @@ extern "C" void LLVMRustAddCallSiteAttributes(LLVMValueRef Instr,
345391}
346392
347393extern " C" LLVMAttributeRef
348- LLVMRustCreateAttrNoValue (LLVMContextRef C, LLVMRustAttribute RustAttr) {
394+ LLVMRustCreateAttrNoValue (LLVMContextRef C, LLVMRustAttributeKind RustAttr) {
349395 return wrap (Attribute::get (*unwrap (C), fromRust (RustAttr)));
350396}
351397
0 commit comments