Closed
Description
Given a program such as:
#![feature(wasm_target_feature)]
#[target_feature(enable = "simd128")]
#[no_mangle]
pub unsafe extern "C" fn bar() {
inline_me();
}
fn inline_me() {
unsafe { foo() } // or anything else that's "side effectful"
}
extern "C" {
fn foo();
}
LLVM generates this IR:
$ rustc +nightly foo.rs --target wasm32-unknown-unknown --crate-type cdylib --emit llvm-ir -O
$ cat foo.ll
; ModuleID = 'foo.3a1fbbbh-cgu.0'
source_filename = "foo.3a1fbbbh-cgu.0"
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
; Function Attrs: nounwind
define void @bar() unnamed_addr #0 {
start:
; call foo::inline_me
tail call fastcc void @_ZN3foo9inline_me17h0a001429f3373a4bE()
ret void
}
; foo::inline_me
; Function Attrs: nounwind
define internal fastcc void @_ZN3foo9inline_me17h0a001429f3373a4bE() unnamed_addr #1 {
start:
tail call void @foo()
ret void
}
; Function Attrs: nounwind
declare void @foo() unnamed_addr #1
attributes #0 = { nounwind "target-cpu"="generic" "target-features"="+simd128" }
attributes #1 = { nounwind "target-cpu"="generic" }
Here the inline_me
function is not inlined in to bar
, even though it should be a candidate for doing so. This is a bug in LLVM rather than rustc, but I wanted to file an issue here since I'm about to write documentation referencing this issue. I also figured it's good for us to track this at least!