rust/compiler
Matthias Krüger 324b4bcb3c
Rollup merge of #91169 - RDambrosio016:master, r=bjorn3
Change cg_ssa's get_param to borrow the builder mutably

This is a small change to make `get_param` more flexible for codegens that may need to modify things when retrieving function parameters.

This will currently only be used by [rustc_codegen_nvvm](https://github.com/Rust-GPU/Rust-CUDA) (my own project), but may be useful to more codegens in the future.

This is needed because cg_nvvm needs to remap certain types to libnvvm-friendly types, such as `i128` -> `<2 x i64>`. Because cg_ssa does not give mutable access to the builder, i resorted to using a mutex:
```rs
    fn get_param(&self, index: usize) -> Self::Value {
        let val = llvm::get_param(self.llfn(), index as c_uint);
        trace!("Get param `{:?}`", val);
        unsafe {
            let llfnty = LLVMRustGetFunctionType(self.llfn());
            let map = self.remapped_integer_args.borrow();
            if let Some((_, key)) = map.get(llfnty) {
                if let Some((_, new_ty)) = key.iter().find(|t| t.0 == index) {
                    trace!("Casting irregular param {:?} to {:?}", val, new_ty);
                    return transmute_llval(
                        *self.llbuilder.lock().unwrap(),
                        &self.cx,
                        val,
                        *new_ty,
                    );
                }
            }
            val
        }
    }
```
However, i predict this is pretty bad for performance, considering how much builders are called during codegen, so i would greatly appreciate having a more flexible API for this.
2021-11-26 16:02:23 +01:00
..
rustc
rustc_apfloat
rustc_arena Add some comments. 2021-11-19 07:52:59 +11:00
rustc_ast Account for incorrect impl Foo<const N: ty> {} syntax 2021-11-24 20:02:09 +00:00
rustc_ast_lowering Auto merge of #85102 - estebank:point-at-assignment, r=oli-obk 2021-11-26 03:57:55 +00:00
rustc_ast_passes Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid 2021-11-24 22:56:37 +01:00
rustc_ast_pretty Add support for specifying multiple clobber_abi in asm! 2021-11-10 01:06:03 -05:00
rustc_attr
rustc_borrowck Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper 2021-11-24 15:51:46 +00:00
rustc_builtin_macros Stabilize format_args_capture 2021-11-15 10:14:29 +01:00
rustc_codegen_cranelift
rustc_codegen_gcc Feat: make cg_ssa get_param borrow the builder mutable 2021-11-23 22:30:20 -05:00
rustc_codegen_llvm Feat: make cg_ssa get_param borrow the builder mutable 2021-11-23 22:30:20 -05:00
rustc_codegen_ssa Feat: make cg_ssa get_param borrow the builder mutable 2021-11-23 22:30:20 -05:00
rustc_const_eval Rollup merge of #91162 - RalfJung:miri-shift-truncation, r=oli-obk 2021-11-25 15:05:39 +01:00
rustc_data_structures Add #[inline]s to SortedIndexMultiMap 2021-11-11 08:35:59 +09:00
rustc_driver add rustc option for using LLVM stack smash protection 2021-11-22 20:06:22 +01:00
rustc_error_codes Update Copy/Clone documentation WRT arrays 2021-11-08 13:11:59 -05:00
rustc_errors replace_tabs -> normalize_whitespace 2021-11-23 20:37:21 +00:00
rustc_expand Stabilize format_args_capture 2021-11-15 10:14:29 +01:00
rustc_feature Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid 2021-11-24 22:56:37 +01:00
rustc_fs_util
rustc_graphviz
rustc_hir Add generator lang-item 2021-11-23 10:34:16 -08:00
rustc_hir_pretty
rustc_incremental Add -Zassert-incr-state to assert state of incremental cache 2021-11-12 13:41:46 -06:00
rustc_index Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper 2021-11-24 15:51:46 +00:00
rustc_infer Visit param_env field in Obligation's TypeFoldable impl 2021-11-25 15:33:37 -06:00
rustc_interface Rollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiser 2021-11-25 15:05:40 +01:00
rustc_lexer udpate comment to be more accurate 2021-11-23 20:37:23 +00:00
rustc_lint Stabilize format_args_capture 2021-11-15 10:14:29 +01:00
rustc_lint_defs Properly register text_direction_codepoint_in_comment lint. 2021-11-05 20:12:40 +01:00
rustc_llvm add rustc option for using LLVM stack smash protection 2021-11-22 20:06:22 +01:00
rustc_macros Avoid generating empty closures for fieldless enums 2021-11-22 21:22:35 -05:00
rustc_metadata Add ty::Visibility::is_public() 2021-11-09 18:35:00 -08:00
rustc_middle Auto merge of #90580 - cjgillot:no-ee-upvar, r=Aaron1011 2021-11-25 19:43:56 +00:00
rustc_mir_build Simplify for loop desugar 2021-11-21 08:15:21 -06:00
rustc_mir_dataflow Auto merge of #90788 - ecstatic-morse:issue-90752, r=wesleywiser 2021-11-23 17:44:33 +00:00
rustc_mir_transform impl Copy/Clone for arrays in std, not in compiler 2021-11-08 13:11:58 -05:00
rustc_monomorphize Rollup merge of #90701 - michaelwoerister:more-artifact-sizes, r=davidtwco 2021-11-09 19:00:45 +01:00
rustc_parse Auto merge of #88781 - estebank:emoji-idents, r=oli-obk 2021-11-25 08:16:08 +00:00
rustc_parse_format
rustc_passes Rollup merge of #89359 - fee1-dead:const-it, r=oli-obk 2021-11-25 15:05:35 +01:00
rustc_plugin_impl
rustc_privacy Add ty::Visibility::is_public() 2021-11-09 18:35:00 -08:00
rustc_query_impl Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
rustc_query_system Manually outline error on incremental_verify_ich 2021-11-22 21:32:20 -05:00
rustc_resolve Rollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoerister 2021-11-25 15:05:38 +01:00
rustc_save_analysis Give inline const separate DefKind 2021-11-07 03:59:06 +00:00
rustc_serialize Avoid generating empty closures for fieldless enums 2021-11-22 21:22:35 -05:00
rustc_session Rollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiser 2021-11-25 15:05:40 +01:00
rustc_span Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebank 2021-11-25 15:05:37 +01:00
rustc_symbol_mangling Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
rustc_target Rollup merge of #90499 - rusticstuff:macos-target-fixes, r=petrochenkov 2021-11-25 15:05:36 +01:00
rustc_trait_selection Add impl polarity to fields 2021-11-24 16:31:47 +08:00
rustc_traits Make select_* methods return Vec for TraitEngine 2021-11-08 23:35:23 +08:00
rustc_ty_utils Recurse through query system when checking ADT drop types, hopefully improving perf 2021-11-13 14:47:17 -05:00
rustc_type_ir
rustc_typeck Account for type obligation coming from const and static 2021-11-25 18:04:33 +00:00