[llvm-bugs] [Bug 24426] New: load instruction erroneously removed by GVN
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 11 00:07:50 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24426
Bug ID: 24426
Summary: load instruction erroneously removed by GVN
Product: tools
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: opt
Assignee: unassignedbugs at nondot.org
Reporter: mikael.holmen at ericsson.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
I have the following program:
declare void @check(i8)
declare void @write(i8* %res)
define i8 @TEST1() {
%buf = alloca [10 x i8]
%_tmp30 = bitcast [10 x i8]* %buf to i8*
call void @write(i8* %_tmp30)
%_tmp33 = load i8, i8* %_tmp30
call void @check(i8 %_tmp33)
ret i8 0
}
and I run opt on it with
build-all/bin/opt -S -memcpyopt -mldst-motion -gvn -O3 ./f2.ll
and then the load is removed by GVN and %_tmp33 is replaced with undef.
GVN iteration: 0
GVN removed: %_tmp33 = load i8, i8* %_tmp30
I notice that if I change TEST1 slightly, and rewrite it as
define i8 @TEST2() {
%buf = alloca i8
call void @write(i8* %buf)
%_tmp33 = load i8, i8* %buf
call void @check(i8 %_tmp33)
ret i8 0
}
then the load is left intact
GVN iteration: 0
GVN: load i8 %_tmp33 is clobbered by call void @write(i8* %buf.17)
In this case it seems to be the code
if (llvm::PointerMayBeCapturedBefore(Object, /* ReturnCaptures */ true,
/* StoreCaptures */ true, I, DT,
/* include Object */ true,
/* OrderedBasicBlock */ OBB))
return MRI_ModRef;
in AliasAnalysis::callCapturesBefore that saves the load, which it doesn't in
the first case.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150811/d4185a74/attachment.html>
More information about the llvm-bugs
mailing list