Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
bindings
cmake
docs
examples
include
lib
projects
resources
runtimes
scripts
test
Analysis
Assembler
Bindings
Bitcode
BugPoint
CodeGen
DebugInfo
Examples
ExecutionEngine
Feature
OperandBundles
adce.ll
basic-aa-argmemonly.ll
dse.ll
early-cse.ll
function-attrs.ll
inliner-conservative.ll
merge-func.ll
pr26510.ll
special-state.ll
NamedMDNode.ll
NamedMDNode2.ll
README.txt
alias2.ll
aliases.ll
alignment.ll
attributes.ll
basictest.ll
callingconventions.ll
calltest.ll
casttest.ll
cfgstructures.ll
cold.ll
comdat.ll
const_pv.ll
constexpr.ll
constpointer.ll
escaped_label.ll
exception.ll
float.ll
fold-fpcast.ll
forwardreftest.ll
fp-intrinsics.ll
global_pv.ll
global_section.ll
globalredefinition3.ll
globalvars.ll
indirectcall.ll
indirectcall2.ll
inlineasm.ll
instructions.ll
intrinsic-noduplicate.ll
intrinsics.ll
load_module.ll
md_on_instruction.ll
memorymarkers.ll
metadata.ll
minsize_attr.ll
newcasts.ll
optnone-llc.ll
optnone-opt.ll
optnone.ll
packed.ll
packed_struct.ll
paramattrs.ll
ppcld.ll
prefixdata.ll
prologuedata.ll
properties.ll
prototype.ll
recursivetype.ll
seh-nounwind.ll
simplecalltest.ll
small.ll
smallest.ll
sparcld.ll
strip_names.ll
terminators.ll
testalloca.ll
testconstants.ll
testlogical.ll
testtype.ll
testvarargs.ll
undefined.ll
unreachable.ll
varargs.ll
varargs_new.ll
vector-cast-constant-exprs.ll
weak_constant.ll
weirdnames.ll
x86ld.ll
FileCheck
Instrumentation
Integer
JitListener
LTO
Linker
MC
Object
ObjectYAML
Other
SafepointIRVerifier
SymbolRewriter
TableGen
ThinLTO
Transforms
Unit
Verifier
YAMLParser
tools
.clang-format
CMakeLists.txt
TestRunner.sh
lit.cfg.py
lit.site.cfg.py.in
tools
unittests
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
version.txt.in
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h

90 lines
2.1 KiB
LLVM
Raw Normal View History

; RUN: opt -S -early-cse < %s | FileCheck %s
; While it is normally okay to do memory optimizations over calls to
; @readonly_function and @readnone_function, we cannot do that if
; they're carrying unknown operand bundles since the presence of
; unknown operand bundles implies arbitrary memory effects.
declare void @readonly_function() readonly nounwind
declare void @readnone_function() readnone nounwind
define i32 @test0(i32* %x) {
; CHECK-LABEL: @test0(
entry:
store i32 100, i32* %x
; CHECK: store i32 100, i32* %x
call void @readonly_function() [ "tag"() ]
; CHECK: call void @readonly_function()
%v = load i32, i32* %x
; CHECK: %v = load i32, i32* %x
; CHECK: ret i32 %v
ret i32 %v
}
define i32 @test1(i32* %x) {
; CHECK: @test1(
entry:
store i32 100, i32* %x
; CHECK: store i32 100, i32* %x
call void @readonly_function() readonly [ "tag"() ]
; CHECK-NOT: call void @readonly_function
%v = load i32, i32* %x
ret i32 %v
; CHECK: ret i32 100
}
define i32 @test3(i32* %x) {
; CHECK-LABEL: @test3(
entry:
store i32 100, i32* %x
; CHECK: store i32 100, i32* %x
call void @readonly_function()
; CHECK-NOT: call void @readonly_function
%v = load i32, i32* %x
ret i32 %v
; CHECK: ret i32 100
}
define void @test4(i32* %x) {
; CHECK-LABEL: @test4(
entry:
store i32 100, i32* %x
; CHECK: store i32 100, i32* %x
call void @readnone_function() [ "tag"() ]
; CHECK: call void @readnone_function
store i32 200, i32* %x
; CHECK: store i32 200, i32* %x
ret void
}
define void @test5(i32* %x) {
; CHECK-LABEL: @test5(
entry:
store i32 100, i32* %x
; CHECK-NOT: store i32 100, i32* %x
; CHECK-NOT: call void @readnone_function
call void @readnone_function() readnone [ "tag"() ]
store i32 200, i32* %x
; CHECK: store i32 200, i32* %x
ret void
}
define void @test6(i32* %x) {
; The "deopt" operand bundle does not make the call to
; @readonly_function read-write; and so the nounwind readonly call can
; be deleted.
; CHECK-LABEL: @test6(
entry:
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 200, i32* %x
; CHECK-NEXT: ret void
store i32 100, i32* %x
call void @readonly_function() [ "deopt"() ]
store i32 200, i32* %x
ret void
}