[llvm-commits] [PATCH] Fix a miscompile in memory dependency analysis

Manman Ren mren at apple.com
Tue Dec 18 10:16:26 PST 2012


ping

-------------- 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/20121218/c0c370d8/attachment.obj>
-------------- next part --------------

On Dec 14, 2012, at 3:01 PM, Manman Ren wrote:

> 
> ping
> 
> On Dec 13, 2012, at 10:34 AM, Manman Ren <mren at apple.com> wrote:
> 
>> 
>> 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
>> 
>> <mem_dep.patch>_______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list