@@ -8,7 +8,6 @@ use crate::llvm_util;
8
8
use crate :: type_:: Type ;
9
9
use crate :: value:: Value ;
10
10
11
- use cstr:: cstr;
12
11
use rustc_codegen_ssa:: base:: { wants_msvc_seh, wants_wasm_eh} ;
13
12
use rustc_codegen_ssa:: errors as ssa_errors;
14
13
use rustc_codegen_ssa:: traits:: * ;
@@ -214,13 +213,13 @@ pub unsafe fn create_module<'ll>(
214
213
// If skipping the PLT is enabled, we need to add some module metadata
215
214
// to ensure intrinsic calls don't use it.
216
215
if !sess. needs_plt ( ) {
217
- let avoid_plt = "RtLibUseGOT\0 " . as_ptr ( ) . cast ( ) ;
216
+ let avoid_plt = c "RtLibUseGOT". as_ptr ( ) . cast ( ) ;
218
217
llvm:: LLVMRustAddModuleFlag ( llmod, llvm:: LLVMModFlagBehavior :: Warning , avoid_plt, 1 ) ;
219
218
}
220
219
221
220
// Enable canonical jump tables if CFI is enabled. (See https://reviews.llvm.org/D65629.)
222
221
if sess. is_sanitizer_cfi_canonical_jump_tables_enabled ( ) && sess. is_sanitizer_cfi_enabled ( ) {
223
- let canonical_jump_tables = "CFI Canonical Jump Tables\0 " . as_ptr ( ) . cast ( ) ;
222
+ let canonical_jump_tables = c "CFI Canonical Jump Tables". as_ptr ( ) . cast ( ) ;
224
223
llvm:: LLVMRustAddModuleFlag (
225
224
llmod,
226
225
llvm:: LLVMModFlagBehavior :: Override ,
@@ -231,7 +230,7 @@ pub unsafe fn create_module<'ll>(
231
230
232
231
// Enable LTO unit splitting if specified or if CFI is enabled. (See https://reviews.llvm.org/D53891.)
233
232
if sess. is_split_lto_unit_enabled ( ) || sess. is_sanitizer_cfi_enabled ( ) {
234
- let enable_split_lto_unit = "EnableSplitLTOUnit\0 " . as_ptr ( ) . cast ( ) ;
233
+ let enable_split_lto_unit = c "EnableSplitLTOUnit". as_ptr ( ) . cast ( ) ;
235
234
llvm:: LLVMRustAddModuleFlag (
236
235
llmod,
237
236
llvm:: LLVMModFlagBehavior :: Override ,
@@ -242,7 +241,7 @@ pub unsafe fn create_module<'ll>(
242
241
243
242
// Add "kcfi" module flag if KCFI is enabled. (See https://reviews.llvm.org/D119296.)
244
243
if sess. is_sanitizer_kcfi_enabled ( ) {
245
- let kcfi = "kcfi\0 " . as_ptr ( ) . cast ( ) ;
244
+ let kcfi = c "kcfi". as_ptr ( ) . cast ( ) ;
246
245
llvm:: LLVMRustAddModuleFlag ( llmod, llvm:: LLVMModFlagBehavior :: Override , kcfi, 1 ) ;
247
246
}
248
247
@@ -255,7 +254,7 @@ pub unsafe fn create_module<'ll>(
255
254
llvm:: LLVMRustAddModuleFlag (
256
255
llmod,
257
256
llvm:: LLVMModFlagBehavior :: Warning ,
258
- "cfguard\0 " . as_ptr ( ) as * const _ ,
257
+ c "cfguard". as_ptr ( ) as * const _ ,
259
258
1 ,
260
259
)
261
260
}
@@ -264,7 +263,7 @@ pub unsafe fn create_module<'ll>(
264
263
llvm:: LLVMRustAddModuleFlag (
265
264
llmod,
266
265
llvm:: LLVMModFlagBehavior :: Warning ,
267
- "cfguard\0 " . as_ptr ( ) as * const _ ,
266
+ c "cfguard". as_ptr ( ) as * const _ ,
268
267
2 ,
269
268
)
270
269
}
@@ -282,26 +281,26 @@ pub unsafe fn create_module<'ll>(
282
281
llvm:: LLVMRustAddModuleFlag (
283
282
llmod,
284
283
behavior,
285
- "branch-target-enforcement\0 " . as_ptr ( ) . cast ( ) ,
284
+ c "branch-target-enforcement". as_ptr ( ) . cast ( ) ,
286
285
bti. into ( ) ,
287
286
) ;
288
287
llvm:: LLVMRustAddModuleFlag (
289
288
llmod,
290
289
behavior,
291
- "sign-return-address\0 " . as_ptr ( ) . cast ( ) ,
290
+ c "sign-return-address". as_ptr ( ) . cast ( ) ,
292
291
pac_ret. is_some ( ) . into ( ) ,
293
292
) ;
294
293
let pac_opts = pac_ret. unwrap_or ( PacRet { leaf : false , key : PAuthKey :: A } ) ;
295
294
llvm:: LLVMRustAddModuleFlag (
296
295
llmod,
297
296
behavior,
298
- "sign-return-address-all\0 " . as_ptr ( ) . cast ( ) ,
297
+ c "sign-return-address-all". as_ptr ( ) . cast ( ) ,
299
298
pac_opts. leaf . into ( ) ,
300
299
) ;
301
300
llvm:: LLVMRustAddModuleFlag (
302
301
llmod,
303
302
behavior,
304
- "sign-return-address-with-bkey\0 " . as_ptr ( ) . cast ( ) ,
303
+ c "sign-return-address-with-bkey". as_ptr ( ) . cast ( ) ,
305
304
u32:: from ( pac_opts. key == PAuthKey :: B ) ,
306
305
) ;
307
306
} else {
@@ -317,15 +316,15 @@ pub unsafe fn create_module<'ll>(
317
316
llvm:: LLVMRustAddModuleFlag (
318
317
llmod,
319
318
llvm:: LLVMModFlagBehavior :: Override ,
320
- "cf-protection-branch\0 " . as_ptr ( ) . cast ( ) ,
319
+ c "cf-protection-branch". as_ptr ( ) . cast ( ) ,
321
320
1 ,
322
321
)
323
322
}
324
323
if let CFProtection :: Return | CFProtection :: Full = sess. opts . unstable_opts . cf_protection {
325
324
llvm:: LLVMRustAddModuleFlag (
326
325
llmod,
327
326
llvm:: LLVMModFlagBehavior :: Override ,
328
- "cf-protection-return\0 " . as_ptr ( ) . cast ( ) ,
327
+ c "cf-protection-return". as_ptr ( ) . cast ( ) ,
329
328
1 ,
330
329
)
331
330
}
@@ -334,7 +333,7 @@ pub unsafe fn create_module<'ll>(
334
333
llvm:: LLVMRustAddModuleFlag (
335
334
llmod,
336
335
llvm:: LLVMModFlagBehavior :: Error ,
337
- "Virtual Function Elim\0 " . as_ptr ( ) . cast ( ) ,
336
+ c "Virtual Function Elim". as_ptr ( ) . cast ( ) ,
338
337
1 ,
339
338
) ;
340
339
}
@@ -344,7 +343,7 @@ pub unsafe fn create_module<'ll>(
344
343
llvm:: LLVMRustAddModuleFlag (
345
344
llmod,
346
345
llvm:: LLVMModFlagBehavior :: Warning ,
347
- "ehcontguard\0 " . as_ptr ( ) as * const _ ,
346
+ c "ehcontguard". as_ptr ( ) as * const _ ,
348
347
1 ,
349
348
)
350
349
}
@@ -362,7 +361,7 @@ pub unsafe fn create_module<'ll>(
362
361
) ;
363
362
llvm:: LLVMAddNamedMetadataOperand (
364
363
llmod,
365
- cstr ! ( "llvm.ident" ) . as_ptr ( ) ,
364
+ c "llvm.ident". as_ptr ( ) ,
366
365
llvm:: LLVMMDNodeInContext ( llcx, & name_metadata, 1 ) ,
367
366
) ;
368
367
@@ -510,14 +509,13 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
510
509
}
511
510
512
511
pub ( crate ) fn create_used_variable_impl ( & self , name : & ' static CStr , values : & [ & ' ll Value ] ) {
513
- let section = cstr ! ( "llvm.metadata" ) ;
514
512
let array = self . const_array ( self . type_ptr ( ) , values) ;
515
513
516
514
unsafe {
517
515
let g = llvm:: LLVMAddGlobal ( self . llmod , self . val_ty ( array) , name. as_ptr ( ) ) ;
518
516
llvm:: LLVMSetInitializer ( g, array) ;
519
517
llvm:: LLVMRustSetLinkage ( g, llvm:: Linkage :: AppendingLinkage ) ;
520
- llvm:: LLVMSetSection ( g, section . as_ptr ( ) ) ;
518
+ llvm:: LLVMSetSection ( g, c"llvm.metadata" . as_ptr ( ) ) ;
521
519
}
522
520
}
523
521
}
0 commit comments