Add llvm.gcov metadata only if profiler is enabled
This commit is contained in:
parent
60524c55e9
commit
a1ca5f689f
1 changed files with 22 additions and 20 deletions
|
@ -806,28 +806,30 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext,
|
||||||
0,
|
0,
|
||||||
split_name.as_ptr() as *const _);
|
split_name.as_ptr() as *const _);
|
||||||
|
|
||||||
let cu_desc_metadata = llvm::LLVMRustMetadataAsValue(debug_context.llcontext,
|
if sess.opts.debugging_opts.profile {
|
||||||
unit_metadata);
|
let cu_desc_metadata = llvm::LLVMRustMetadataAsValue(debug_context.llcontext,
|
||||||
|
unit_metadata);
|
||||||
|
|
||||||
let gcov_cu_info = [
|
let gcov_cu_info = [
|
||||||
// Ideally we would be using the three-element form of !llvm.gcov metadata,
|
// Ideally we would be using the three-element form of !llvm.gcov metadata,
|
||||||
// which allows us to specify gcno/gcda files explicitly, but that's only
|
// which allows us to specify gcno/gcda files explicitly, but that's only
|
||||||
// available in LLVM 3.9+; so we rely on LLVM chopping off the extension
|
// available in LLVM 3.9+; so we rely on LLVM chopping off the extension
|
||||||
// and replacing it with gcno/gcda, instead.
|
// and replacing it with gcno/gcda, instead.
|
||||||
path_to_mdstring(debug_context.llcontext,
|
path_to_mdstring(debug_context.llcontext,
|
||||||
&scc.output_filenames().with_extension("gcno")),
|
&scc.output_filenames().with_extension("gcno")),
|
||||||
// path_to_mdstring(debug_context.llcontext,
|
// path_to_mdstring(debug_context.llcontext,
|
||||||
// &scc.output_filenames().with_extension("gcda")),
|
// &scc.output_filenames().with_extension("gcda")),
|
||||||
cu_desc_metadata,
|
cu_desc_metadata,
|
||||||
];
|
];
|
||||||
let gcov_metadata = llvm::LLVMMDNodeInContext(debug_context.llcontext,
|
let gcov_metadata = llvm::LLVMMDNodeInContext(debug_context.llcontext,
|
||||||
gcov_cu_info.as_ptr(),
|
gcov_cu_info.as_ptr(),
|
||||||
gcov_cu_info.len() as c_uint);
|
gcov_cu_info.len() as c_uint);
|
||||||
|
|
||||||
let llvm_gcov_ident = CString::new("llvm.gcov").unwrap();
|
let llvm_gcov_ident = CString::new("llvm.gcov").unwrap();
|
||||||
llvm::LLVMAddNamedMetadataOperand(debug_context.llmod,
|
llvm::LLVMAddNamedMetadataOperand(debug_context.llmod,
|
||||||
llvm_gcov_ident.as_ptr(),
|
llvm_gcov_ident.as_ptr(),
|
||||||
gcov_metadata);
|
gcov_metadata);
|
||||||
|
}
|
||||||
|
|
||||||
return unit_metadata;
|
return unit_metadata;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue