Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#126242 - yaahc:simplify-provider, r=jhpratt
Simplify provider api to improve llvm ir This PR seeks to resolve the last concern in rust-lang#99301 (comment) We resolve the issue by moving the type_id to be stored in the `Request` itself rather than being accessed through the `Erased` trait, letting the compiler infer that the value of the type id will not change between lookups. ### LLVM Codegen **Before** ``` ; <provider_test::MyError as core::error::Error>::provide ; Function Attrs: nonlazybind uwtable define void `@"_ZN61_$LT$provider_test..MyError$u20$as$u20$core..error..Error$GT$7provide17hd9c9de412063aa73E"(ptr` noalias nocapture noundef nonnull readonly align 1 %self, ptr noundef nonnull align 1 %request.0, ptr noalias nocapture noundef readonly align 8 dereferenceable(32) %request.1) unnamed_addr #0 personality ptr `@rust_eh_personality` { start: %0 = getelementptr inbounds i8, ptr %request.1, i64 24 %self.1.val.i = load ptr, ptr %0, align 8 %1 = tail call { i64, i64 } %self.1.val.i(ptr noundef nonnull align 1 %request.0), !noalias !15 %2 = extractvalue { i64, i64 } %1, 0 %3 = extractvalue { i64, i64 } %1, 1 %_18.i.i = icmp ne i64 %2, 1101338453689927725 %_2.i.i = icmp ne i64 %3, 472224167662714873 %or.cond.i.not.i = select i1 %_18.i.i, i1 true, i1 %_2.i.i br i1 %or.cond.i.not.i, label %_ZN4core5error7Request7provide17h8f8125d2543333e0E.exit, label %bb2.i ``` **After** ``` ; <provider_test::MyError as provider_test::Error>::provide ; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: readwrite) uwtable define void `@"_ZN63_$LT$provider_test..MyError$u20$as$u20$provider_test..Error$GT$7provide17h5bbf091795a6d359E"(ptr` noalias nocapture noundef nonnull readonly align 1 %self, ptr nocapture noundef nonnull align 8 %request.0, ptr noalias nocapture noundef readonly align 8 dereferenceable(24) %request.1) unnamed_addr rust-lang#2 personality ptr `@rust_eh_personality` { start: %_19.i = load i64, ptr %request.0, align 8, !noalias !3, !noundef !3 switch i64 %_19.i, label %_ZN13provider_test7Request7provide17heb3ee140962e3b2fE.exit [ i64 7665305208997882008, label %bb12.i i64 7050211241160863540, label %bb12.i3 i64 9112786072622981063, label %bb12.i11 ] ```
- Loading branch information