Issue 237835
Summary llubi accepts loop-carried dependencies forbidden by parallel_accesses metadata
Labels new issue
Assignees
Reporter Roticv912
    A loop with llvm.loop.parallel_accesses metadata repeatedly reads and writes the same location across iterations without reporting undefined behavior.

### Program
```llvm
@g = global i32 0
!0 = distinct !{}
!1 = distinct !{!1, !2}
!2 = !{!"llvm.loop.parallel_accesses", !0}

define i32 @main() {
entry:
  br label %loop
loop:
  %i = phi i32 [ 0, %entry ], [ %next, %loop ]
  %v = load i32, ptr @g, !llvm.access.group !0
  %w = add i32 %v, 1
  store i32 %w, ptr @g, !llvm.access.group !0
  %next = add i32 %i, 1
  %again = icmp ult i32 %next, 2
  br i1 %again, label %loop, label %done, !llvm.loop !1
done:
  ret i32 0
}
```

### Output
```
Entering function: main
 br label %loop jump to %loop
  %i = phi i32 [ 0, %entry ], [ %next, %loop ] => i32 0
  %v = load i32, ptr @g, align 4, !llvm.access.group !0 => i32 0
 %w = add i32 %v, 1 => i32 1
  store i32 %w, ptr @g, align 4, !llvm.access.group !0
  %next = add i32 %i, 1 => i32 1
  %again = icmp ult i32 %next, 2 => T
  br i1 %again, label %loop, label %done, !llvm.loop !3 jump to %loop
  %i = phi i32 [ 0, %entry ], [ %next, %loop ] => i32 1
  %v = load i32, ptr @g, align 4, !llvm.access.group !0 => i32 1
  %w = add i32 %v, 1 => i32 2
  store i32 %w, ptr @g, align 4, !llvm.access.group !0
 %next = add i32 %i, 1 => i32 2
  %again = icmp ult i32 %next, 2 => F
  br i1 %again, label %loop, label %done, !llvm.loop !3 jump to %done
  ret i32 0
Exiting function: main
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to