[llvm-commits] [PATCH] Fix a miscompile in memory dependency analysis
Manman Ren
mren at apple.com
Thu Dec 13 10:34:34 PST 2012
Given input:
while.body:
call void @RunInMode(i32 100) nounwind
%1 = load i32* %tasksIdle, align 4
%tobool = icmp eq i32 %1, 0
br i1 %tobool, label %while.cond.backedge, label %if.then
if.then:
store i32 0, i32* %tasksIdle, align 4
call void @TimerCreate(i32* %shouldExit) nounwind
br label %while.cond.backedge
while.cond.backedge:
%2 = load i32* %shouldExit, align 4
%cmp = icmp eq i32 %2, 0
br i1 %cmp, label %while.body, label %while.cond.while.end_crit_edge
Make sure we are not returning "call RunInMode" does not modify %shouldExit.
Currently, we optimize this into
while.cond.backedge: ; preds = %if.then, %while.body
%1 = phi i32 [ %.pre, %if.then ], [ 0, %while.body ]
%cmp = icmp eq i32 %1, 0
br i1 %cmp, label %while.body, label %while.cond.while.end_crit_edge
The proper fix is to check all uses of %shouldExit as long as there is a possible
path from the use to "call RunInMode". The proposed patch uses LoopInfo to approximate the reachability analysis.
Suggestions on how to approximate this are welcome.
Please review, Thanks,
Manman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mem_dep.patch
Type: application/octet-stream
Size: 10069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121213/411c2cf6/attachment.obj>
More information about the llvm-commits
mailing list