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
Odin
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
Vyper
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; PR2967 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32" target triple = "i386-pc-linux-gnu" define void @test1(i32 %x) nounwind { ; CHECK-LABEL: @test1( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[X:%.*]], 0 ; CHECK-NEXT: br i1 [[TMP0]], label [[BB:%.*]], label [[RETURN:%.*]] ; CHECK: bb: ; CHECK-NEXT: [[TMP1:%.*]] = load volatile i32, i32* null, align 4 ; CHECK-NEXT: unreachable ; CHECK: return: ; CHECK-NEXT: ret void ; entry: %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1] br i1 %0, label %bb, label %return bb: ; preds = %entry %1 = load volatile i32, i32* null unreachable br label %return return: ; preds = %entry ret void } define void @test1_no_null_opt(i32 %x) nounwind #0 { ; CHECK-LABEL: @test1_no_null_opt( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[X:%.*]], 0 ; CHECK-NEXT: br i1 [[TMP0]], label [[BB:%.*]], label [[RETURN:%.*]] ; CHECK: bb: ; CHECK-NEXT: [[TMP1:%.*]] = load volatile i32, i32* null, align 4 ; CHECK-NEXT: unreachable ; CHECK: return: ; CHECK-NEXT: ret void ; entry: %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1] br i1 %0, label %bb, label %return bb: ; preds = %entry %1 = load volatile i32, i32* null unreachable br label %return return: ; preds = %entry ret void } ; rdar://7958343 define void @test2() nounwind { ; CHECK-LABEL: @test2( ; CHECK-NEXT: entry: ; CHECK-NEXT: call void @llvm.trap() ; CHECK-NEXT: unreachable ; entry: store i32 4,i32* null ret void } define void @test2_no_null_opt() nounwind #0 { ; CHECK-LABEL: @test2_no_null_opt( ; CHECK-NEXT: entry: ; CHECK-NEXT: store i32 4, i32* null, align 4 ; CHECK-NEXT: ret void ; entry: store i32 4,i32* null ret void } ; PR7369 define void @test3() nounwind { ; CHECK-LABEL: @test3( ; CHECK-NEXT: entry: ; CHECK-NEXT: store volatile i32 4, i32* null, align 4 ; CHECK-NEXT: ret void ; entry: store volatile i32 4, i32* null ret void } define void @test3_no_null_opt() nounwind #0 { ; CHECK-LABEL: @test3_no_null_opt( ; CHECK-NEXT: entry: ; CHECK-NEXT: store volatile i32 4, i32* null, align 4 ; CHECK-NEXT: ret void ; entry: store volatile i32 4, i32* null ret void } ; Check store before unreachable. define void @test4(i1 %C, i32* %P) { ; CHECK-LABEL: @test4( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]] ; CHECK: T: ; CHECK-NEXT: store volatile i32 0, i32* [[P:%.*]], align 4 ; CHECK-NEXT: unreachable ; CHECK: F: ; CHECK-NEXT: ret void ; entry: br i1 %C, label %T, label %F T: store volatile i32 0, i32* %P unreachable F: ret void } ; Check cmpxchg before unreachable. define void @test5(i1 %C, i32* %P) { ; CHECK-LABEL: @test5( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]] ; CHECK: T: ; CHECK-NEXT: [[TMP0:%.*]] = cmpxchg volatile i32* [[P:%.*]], i32 0, i32 1 seq_cst seq_cst, align 4 ; CHECK-NEXT: unreachable ; CHECK: F: ; CHECK-NEXT: ret void ; entry: br i1 %C, label %T, label %F T: cmpxchg volatile i32* %P, i32 0, i32 1 seq_cst seq_cst unreachable F: ret void } ; Check atomicrmw before unreachable. define void @test6(i1 %C, i32* %P) { ; CHECK-LABEL: @test6( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]] ; CHECK: T: ; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw volatile xchg i32* [[P:%.*]], i32 0 seq_cst, align 4 ; CHECK-NEXT: unreachable ; CHECK: F: ; CHECK-NEXT: ret void ; entry: br i1 %C, label %T, label %F T: atomicrmw volatile xchg i32* %P, i32 0 seq_cst unreachable F: ret void } attributes #0 = { null_pointer_is_valid }
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
CE on Bluesky
About the author
Statistics
Changelog
Version tree