Skip to content

Commit 4e5e920

Browse files
committed
Add speculation test that shows noalias_addrspace is dropped
1 parent 6d8bab8 commit 4e5e920

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,26 @@ out:
404404
ret void
405405
}
406406

407+
; !noalias_addrspace is not safe to speculate as it causes immediate undefined behavior.
408+
define ptr @speculate_noalias_addrspace(i1 %c, ptr dereferenceable(8) align 8 %p) {
409+
; CHECK-LABEL: @speculate_noalias_addrspace(
410+
; CHECK-NEXT: entry:
411+
; CHECK-NEXT: [[V:%.*]] = load ptr, ptr [[P:%.*]], align 8, !nonnull [[META2]]
412+
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C:%.*]], ptr [[V]], ptr null
413+
; CHECK-NEXT: ret ptr [[SPEC_SELECT]]
414+
;
415+
entry:
416+
br i1 %c, label %if, label %join
417+
418+
if:
419+
%v = load ptr, ptr %p, !nonnull !{}, !noundef !{}, !noalias.addrspace !4
420+
br label %join
421+
422+
join:
423+
%phi = phi ptr [ %v, %if ], [ null, %entry ]
424+
ret ptr %phi
425+
}
426+
407427
!0 = !{ i8 0, i8 1 }
408428
!1 = !{ i8 3, i8 5 }
409429
!2 = !{}

0 commit comments

Comments
 (0)