Skip to content

Commit

Permalink
Add speculation test that shows noalias_addrspace is dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenm committed Oct 8, 2024
1 parent 6d8bab8 commit 4e5e920
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,26 @@ out:
ret void
}

; !noalias_addrspace is not safe to speculate as it causes immediate undefined behavior.
define ptr @speculate_noalias_addrspace(i1 %c, ptr dereferenceable(8) align 8 %p) {
; CHECK-LABEL: @speculate_noalias_addrspace(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[V:%.*]] = load ptr, ptr [[P:%.*]], align 8, !nonnull [[META2]]
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C:%.*]], ptr [[V]], ptr null
; CHECK-NEXT: ret ptr [[SPEC_SELECT]]
;
entry:
br i1 %c, label %if, label %join

if:
%v = load ptr, ptr %p, !nonnull !{}, !noundef !{}, !noalias.addrspace !4
br label %join

join:
%phi = phi ptr [ %v, %if ], [ null, %entry ]
ret ptr %phi
}

!0 = !{ i8 0, i8 1 }
!1 = !{ i8 3, i8 5 }
!2 = !{}
Expand Down

0 comments on commit 4e5e920

Please sign in to comment.