@@ -228,94 +228,140 @@ extern "C" LLVMValueRef LLVMRustInsertPrivateGlobal(LLVMModuleRef M,
228
228
GlobalValue::PrivateLinkage, nullptr ));
229
229
}
230
230
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) {
232
278
switch (Kind) {
233
- case AlwaysInline:
279
+ case LLVMRustAttributeKind:: AlwaysInline:
234
280
return Attribute::AlwaysInline;
235
- case ByVal:
281
+ case LLVMRustAttributeKind:: ByVal:
236
282
return Attribute::ByVal;
237
- case Cold:
283
+ case LLVMRustAttributeKind:: Cold:
238
284
return Attribute::Cold;
239
- case InlineHint:
285
+ case LLVMRustAttributeKind:: InlineHint:
240
286
return Attribute::InlineHint;
241
- case MinSize:
287
+ case LLVMRustAttributeKind:: MinSize:
242
288
return Attribute::MinSize;
243
- case Naked:
289
+ case LLVMRustAttributeKind:: Naked:
244
290
return Attribute::Naked;
245
- case NoAlias:
291
+ case LLVMRustAttributeKind:: NoAlias:
246
292
return Attribute::NoAlias;
247
- case NoCapture:
293
+ case LLVMRustAttributeKind:: NoCapture:
248
294
return Attribute::NoCapture;
249
- case NoCfCheck:
295
+ case LLVMRustAttributeKind:: NoCfCheck:
250
296
return Attribute::NoCfCheck;
251
- case NoInline:
297
+ case LLVMRustAttributeKind:: NoInline:
252
298
return Attribute::NoInline;
253
- case NonNull:
299
+ case LLVMRustAttributeKind:: NonNull:
254
300
return Attribute::NonNull;
255
- case NoRedZone:
301
+ case LLVMRustAttributeKind:: NoRedZone:
256
302
return Attribute::NoRedZone;
257
- case NoReturn:
303
+ case LLVMRustAttributeKind:: NoReturn:
258
304
return Attribute::NoReturn;
259
- case NoUnwind:
305
+ case LLVMRustAttributeKind:: NoUnwind:
260
306
return Attribute::NoUnwind;
261
- case OptimizeForSize:
307
+ case LLVMRustAttributeKind:: OptimizeForSize:
262
308
return Attribute::OptimizeForSize;
263
- case ReadOnly:
309
+ case LLVMRustAttributeKind:: ReadOnly:
264
310
return Attribute::ReadOnly;
265
- case SExt:
311
+ case LLVMRustAttributeKind:: SExt:
266
312
return Attribute::SExt;
267
- case StructRet:
313
+ case LLVMRustAttributeKind:: StructRet:
268
314
return Attribute::StructRet;
269
- case UWTable:
315
+ case LLVMRustAttributeKind:: UWTable:
270
316
return Attribute::UWTable;
271
- case ZExt:
317
+ case LLVMRustAttributeKind:: ZExt:
272
318
return Attribute::ZExt;
273
- case InReg:
319
+ case LLVMRustAttributeKind:: InReg:
274
320
return Attribute::InReg;
275
- case SanitizeThread:
321
+ case LLVMRustAttributeKind:: SanitizeThread:
276
322
return Attribute::SanitizeThread;
277
- case SanitizeAddress:
323
+ case LLVMRustAttributeKind:: SanitizeAddress:
278
324
return Attribute::SanitizeAddress;
279
- case SanitizeMemory:
325
+ case LLVMRustAttributeKind:: SanitizeMemory:
280
326
return Attribute::SanitizeMemory;
281
- case NonLazyBind:
327
+ case LLVMRustAttributeKind:: NonLazyBind:
282
328
return Attribute::NonLazyBind;
283
- case OptimizeNone:
329
+ case LLVMRustAttributeKind:: OptimizeNone:
284
330
return Attribute::OptimizeNone;
285
- case ReadNone:
331
+ case LLVMRustAttributeKind:: ReadNone:
286
332
return Attribute::ReadNone;
287
- case SanitizeHWAddress:
333
+ case LLVMRustAttributeKind:: SanitizeHWAddress:
288
334
return Attribute::SanitizeHWAddress;
289
- case WillReturn:
335
+ case LLVMRustAttributeKind:: WillReturn:
290
336
return Attribute::WillReturn;
291
- case StackProtectReq:
337
+ case LLVMRustAttributeKind:: StackProtectReq:
292
338
return Attribute::StackProtectReq;
293
- case StackProtectStrong:
339
+ case LLVMRustAttributeKind:: StackProtectStrong:
294
340
return Attribute::StackProtectStrong;
295
- case StackProtect:
341
+ case LLVMRustAttributeKind:: StackProtect:
296
342
return Attribute::StackProtect;
297
- case NoUndef:
343
+ case LLVMRustAttributeKind:: NoUndef:
298
344
return Attribute::NoUndef;
299
- case SanitizeMemTag:
345
+ case LLVMRustAttributeKind:: SanitizeMemTag:
300
346
return Attribute::SanitizeMemTag;
301
- case ShadowCallStack:
347
+ case LLVMRustAttributeKind:: ShadowCallStack:
302
348
return Attribute::ShadowCallStack;
303
- case AllocSize:
349
+ case LLVMRustAttributeKind:: AllocSize:
304
350
return Attribute::AllocSize;
305
- case AllocatedPointer:
351
+ case LLVMRustAttributeKind:: AllocatedPointer:
306
352
return Attribute::AllocatedPointer;
307
- case AllocAlign:
353
+ case LLVMRustAttributeKind:: AllocAlign:
308
354
return Attribute::AllocAlign;
309
- case SanitizeSafeStack:
355
+ case LLVMRustAttributeKind:: SanitizeSafeStack:
310
356
return Attribute::SafeStack;
311
- case FnRetThunkExtern:
357
+ case LLVMRustAttributeKind:: FnRetThunkExtern:
312
358
return Attribute::FnRetThunkExtern;
313
- case Writable:
359
+ case LLVMRustAttributeKind:: Writable:
314
360
return Attribute::Writable;
315
- case DeadOnUnwind:
361
+ case LLVMRustAttributeKind:: DeadOnUnwind:
316
362
return Attribute::DeadOnUnwind;
317
363
}
318
- report_fatal_error (" bad AttributeKind " );
364
+ report_fatal_error (" bad LLVMRustAttributeKind " );
319
365
}
320
366
321
367
template <typename T>
@@ -345,7 +391,7 @@ extern "C" void LLVMRustAddCallSiteAttributes(LLVMValueRef Instr,
345
391
}
346
392
347
393
extern " C" LLVMAttributeRef
348
- LLVMRustCreateAttrNoValue (LLVMContextRef C, LLVMRustAttribute RustAttr) {
394
+ LLVMRustCreateAttrNoValue (LLVMContextRef C, LLVMRustAttributeKind RustAttr) {
349
395
return wrap (Attribute::get (*unwrap (C), fromRust (RustAttr)));
350
396
}
351
397
0 commit comments