[LLVMbugs] [Bug 2471] New: Illegal instcombine for load of address from select
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Wed Jun 18 02:04:26 PDT 2008
http://llvm.org/bugs/show_bug.cgi?id=2471
Summary: Illegal instcombine for load of address from select
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sharparrow1 at yahoo.com
CC: llvmbugs at cs.uiuc.edu
Consider the following testcase:
declare i32 @x(i32*)
define i32 @b(i32* %a, i32* %b) {
entry:
%tmp1 = load i32* %a ; <i32> [#uses=1]
%tmp3 = load i32* %b ; <i32> [#uses=1]
%add = add i32 %tmp1, %tmp3 ; <i32> [#uses=1]
%call = call i32 @x( i32* %a ) ; <i32> [#uses=0]
%tobool = icmp ne i32 %add, 0 ; <i1> [#uses=1]
%cond = select i1 %tobool, i32* %b, i32* %a ; <i32*>
[#uses=1]
%tmp8 = load i32* %cond ; <i32> [#uses=1]
ret i32 %tmp8
}
Instcombine transforms this to the following:
declare i32 @x(i32*)
define i32 @b(i32* %a, i32* %b) {
entry:
%tmp1 = load i32* %a ; <i32> [#uses=1]
%tmp3 = load i32* %b ; <i32> [#uses=1]
%call = call i32 @x( i32* %a ) ; <i32> [#uses=0]
%add = sub i32 0, %tmp3 ; <i32> [#uses=1]
%tobool = icmp ne i32 %tmp1, %add ; <i1> [#uses=1]
%b.val = load i32* %b ; <i32> [#uses=1]
%a.val = load i32* %a ; <i32> [#uses=1]
%tmp8 = select i1 %tobool, i32 %b.val, i32 %a.val ; <i32>
[#uses=1]
ret i32 %tmp8
}
The extra loads instcombine has inserted are dangerous; for example, suppose %a
was allocated by malloc(), and @x calls free() on %a.
isSafeToLoadUnconditionally is being too aggressive here.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list