diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-02-07 17:00:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-07 17:00:16 +0100 |
| commit | 2f1eaeea772c2800cd45d263a6927db366f5bdc5 (patch) | |
| tree | 1f9f6d8e4553a4a0cee6a539eb2767bcf9259d09 /src/librustc_codegen_ssa | |
| parent | b5e21dbb5cabdaaadc47a4d8e3f59979dcad2871 (diff) | |
| parent | 80adde2e337f4e0d784da401b2db37c5d4d3468b (diff) | |
| download | rust-2f1eaeea772c2800cd45d263a6927db366f5bdc5.tar.gz rust-2f1eaeea772c2800cd45d263a6927db366f5bdc5.zip | |
Rollup merge of #68164 - tmiasko:no-sanitize, r=nikomatsakis
Selectively disable sanitizer instrumentation Add `no_sanitize` attribute that allows to opt out from sanitizer instrumentation in an annotated function.
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/base.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 1f43a4027c5..90015091384 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -391,10 +391,12 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( /// Creates the `main` function which will initialize the rust runtime and call /// users main function. -pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'a Bx::CodegenCx) { +pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( + cx: &'a Bx::CodegenCx, +) -> Option<Bx::Function> { let (main_def_id, span) = match cx.tcx().entry_fn(LOCAL_CRATE) { Some((def_id, _)) => (def_id, cx.tcx().def_span(def_id)), - None => return, + None => return None, }; let instance = Instance::mono(cx.tcx(), main_def_id); @@ -402,17 +404,15 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &' if !cx.codegen_unit().contains_item(&MonoItem::Fn(instance)) { // We want to create the wrapper in the same codegen unit as Rust's main // function. - return; + return None; } let main_llfn = cx.get_fn_addr(instance); - let et = cx.tcx().entry_fn(LOCAL_CRATE).map(|e| e.1); - match et { - Some(EntryFnType::Main) => create_entry_fn::<Bx>(cx, span, main_llfn, main_def_id, true), - Some(EntryFnType::Start) => create_entry_fn::<Bx>(cx, span, main_llfn, main_def_id, false), - None => {} // Do nothing. - } + return cx.tcx().entry_fn(LOCAL_CRATE).map(|(_, et)| { + let use_start_lang_item = EntryFnType::Start != et; + create_entry_fn::<Bx>(cx, span, main_llfn, main_def_id, use_start_lang_item) + }); fn create_entry_fn<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx, @@ -420,7 +420,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &' rust_main: Bx::Value, rust_main_def_id: DefId, use_start_lang_item: bool, - ) { + ) -> Bx::Function { // The entry function is either `int main(void)` or `int main(int argc, char **argv)`, // depending on whether the target needs `argc` and `argv` to be passed in. let llfty = if cx.sess().target.target.options.main_needs_argc_argv { @@ -481,6 +481,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &' let result = bx.call(start_fn, &args, None); let cast = bx.intcast(result, cx.type_int(), true); bx.ret(cast); + + llfn } } |
