Skip to content

Instantly share code, notes, and snippets.

@Voultapher
Last active July 16, 2018 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Voultapher/ebc3abb55994ea90f3ac604c5ffccc19 to your computer and use it in GitHub Desktop.
Save Voultapher/ebc3abb55994ea90f3ac604c5ffccc19 to your computer and use it in GitHub Desktop.
rustc vs clang | llvm production | app
#include <cstdint>
auto foo(int64_t a, int64_t b) -> int64_t
{
return (a % 239082) % b;
}
auto bar(int64_t a) -> int64_t
{
return foo(a, 77);
}
int main(int argc, const char* argv[])
{
return bar(argc);
}
fn foo(a: i64, b: i64) -> i64 {
(a % 239082) % b
}
fn bar(a: i64) -> i64 {
foo(a, 77)
}
fn main() {
std::process::exit(bar(std::env::args().len() as i64) as i32);
}

compiler | version

command

  • name | instruction count | time

clang++ | 6.0.1

perf stat clang -O3 main.cpp -o cpp-app-full

  • full | 266m | 110ms

perf stat clang -O3 main.cpp -emit-llvm -S -o cpp.ll

  • emit | 219m | 95ms

perf stat llc -O3 -filetype=obj cpp.ll -o cpp.o

  • llvm compile | 56m | 45ms

couldn't figure this one out

  • llvm link

rustc | 1.27.1

perf stat rustc -O main.rs -o rust-app-full

  • full | 1870m | 575ms

perf stat rustc -O main.rs --emit=llvm-ir -o rust.ll

  • emit | 520m | 200ms

perf stat llc -O3 -filetype=obj rust.ll -o rust.o

  • llvm compile | 55m | 50ms

rustc | 1.29.0-nightly

perf stat rustc -O main.rs -o rust-app-full

  • full | 1340m | 405ms

perf stat rustc -O main.rs --emit=llvm-ir -o rust.ll

  • emit | 422m | 145ms

perf stat llc -O3 -filetype=obj rust.ll -o rust.o

  • llvm compile | 66m | 50ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment