Skip to content

Commit 9e866a5

Browse files
committed
Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2 parents e62b34b + 3a0aae4 commit 9e866a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/pass/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737
let mut saw_false = false;
3838

3939
for _ in 0..50 {
40-
if unsafe { intrinsics::is_val_statically_known(0) } {
40+
if intrinsics::is_val_statically_known(0) {
4141
saw_true = true;
4242
} else {
4343
saw_false = true;

0 commit comments

Comments
 (0)