Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
WASM
Zig
Javascript
GIMPLE
Ygen
llvm source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
clang (assertions trunk)
clang (trunk)
clang 10.0.0
clang 10.0.1
clang 11.0.0
clang 11.0.1
clang 12.0.0
clang 12.0.1
clang 13.0.0
clang 14.0.0
clang 15.0.0
clang 16.0.0
clang 17.0.1
clang 18.1.0
clang 19.1.0
clang 4.0.1
clang 5.0.0
clang 6.0.0
clang 7.0.0
clang 8.0.0
clang 9.0.0
llc (assertions trunk)
llc (trunk)
llc 10.0.0
llc 10.0.1
llc 11.0.0
llc 11.0.1
llc 12.0.0
llc 12.0.1
llc 13.0.0
llc 14.0.0
llc 15.0.0
llc 16.0.0
llc 17.0.1
llc 18.1.0
llc 19.1.0
llc 3.2
llc 3.3
llc 3.9.1
llc 4.0.0
llc 4.0.1
llc 5.0.0
llc 6.0.0
llc 7.0.0
llc 8.0.0
llc 9.0.0
opt (assertions trunk)
opt (trunk)
opt 10.0.0
opt 10.0.1
opt 11.0.0
opt 11.0.1
opt 12.0.0
opt 12.0.1
opt 13.0.0
opt 14.0.0
opt 15.0.0
opt 16.0.0
opt 17.0.1
opt 18.1.0
opt 19.1.0
opt 3.2
opt 3.3
opt 3.9.1
opt 4.0.0
opt 4.0.1
opt 5.0.0
opt 6.0.0
opt 7.0.0
opt 8.0.0
opt 9.0.0
Options
Source code
; ModuleID = '/tmp/test.cpp' source_filename = "/tmp/test.cpp" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @.src = private unnamed_addr constant [14 x i8] c"/tmp/test.cpp\00", align 1 @0 = private unnamed_addr global { { [14 x i8]*, i32, i32 } } { { [14 x i8]*, i32, i32 } { [14 x i8]* @.src, i32 2, i32 16 } } ; Function Attrs: noinline nounwind optnone uwtable define dso_local i8* @_Z4testRcm(i8* dereferenceable(1) %base, i64 %offset) #0 { entry: %base.addr = alloca i8*, align 8 %offset.addr = alloca i64, align 8 store i8* %base, i8** %base.addr, align 8 store i64 %offset, i64* %offset.addr, align 8 %0 = load i8*, i8** %base.addr, align 8 %1 = load i64, i64* %offset.addr, align 8 %idx.neg = sub i64 0, %1 %add.ptr = getelementptr inbounds i8, i8* %0, i64 %idx.neg %2 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 1, i64 %idx.neg), !nosanitize !2 %3 = extractvalue { i64, i1 } %2, 1, !nosanitize !2 %4 = extractvalue { i64, i1 } %2, 0, !nosanitize !2 %5 = ptrtoint i8* %0 to i64, !nosanitize !2 %6 = add i64 %5, %4, !nosanitize !2 %7 = icmp eq i8* %0, null, !nosanitize !2 %8 = icmp eq i64 %6, 0, !nosanitize !2 %9 = icmp eq i1 %7, %8, !nosanitize !2 %10 = xor i1 %3, true, !nosanitize !2 %11 = icmp ule i64 %6, %5, !nosanitize !2 %12 = and i1 %11, %10, !nosanitize !2 %13 = and i1 %9, %12, !nosanitize !2 br i1 %13, label %cont, label %handler.pointer_overflow, !prof !3, !nosanitize !2 handler.pointer_overflow: ; preds = %entry call void @__ubsan_handle_pointer_overflow(i8* bitcast ({ { [14 x i8]*, i32, i32 } }* @0 to i8*), i64 %5, i64 %6) #3, !nosanitize !2 br label %cont, !nosanitize !2 cont: ; preds = %handler.pointer_overflow, %entry ret i8* %add.ptr } ; Function Attrs: nounwind readnone speculatable willreturn declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) #1 ; Function Attrs: nounwind readnone speculatable willreturn declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64) #1 ; Function Attrs: uwtable declare dso_local void @__ubsan_handle_pointer_overflow(i8*, i64, i64) #2 attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #1 = { nounwind readnone speculatable } attributes #2 = { uwtable } attributes #3 = { nounwind } !llvm.module.flags = !{!0} !llvm.ident = !{!1} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{!"clang version 10.0.0 (git@github.com:LebedevRI/llvm-project.git c9f6f2b6789758f3e5399b36e5a51ad319cb5b72)"} !2 = !{} !3 = !{!"branch_weights", i32 1048575, i32 1}
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree