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

Manman Ren mren at apple.com
Fri Dec 14 15:01:43 PST 2012


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




More information about the llvm-commits mailing list