From 3bd2513ebd788a48394ababbc62b5cdcfa3dde12 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Thu, 13 Aug 2020 16:04:34 +0300 Subject: [PATCH] [NFC] Add test case showing the miscompile being fixed by D83507 See https://reviews.llvm.org/D83507 --- .../d83507-knowledge-retention-bug.ll | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll diff --git a/llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll b/llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll new file mode 100644 index 000000000000..968136108f92 --- /dev/null +++ b/llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll @@ -0,0 +1,36 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -O1 -enable-knowledge-retention -S < %s | FileCheck %s --check-prefixes=ANY,OLDPM +; RUN: opt -passes='default' -enable-knowledge-retention -S < %s | FileCheck %s --check-prefixes=ANY,NEWPM + +%0 = type { %0* } + +define %0* @f1() local_unnamed_addr { +; ANY-LABEL: @f1( +; ANY-NEXT: bb: +; ANY-NEXT: br label [[BB3:%.*]] +; ANY: bb3: +; ANY-NEXT: [[I1:%.*]] = phi %0* [ [[I5:%.*]], [[BB3]] ], [ undef, [[BB:%.*]] ] +; ANY-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(%0* [[I1]]) ] +; ANY-NEXT: [[I4:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[I1]], i64 0, i32 0 +; ANY-NEXT: [[I5]] = load %0*, %0** [[I4]], align 8 +; ANY-NEXT: br label [[BB3]] +; +bb: + br label %bb1 + +bb1: + %i = phi %0* [ undef, %bb ], [ %i5, %bb3 ] + %i2 = icmp eq %0* %i, null + br i1 %i2, label %bb6, label %bb3 + +bb3: + call void @llvm.assume(i1 true) [ "nonnull"(%0* %i) ] + %i4 = getelementptr inbounds %0, %0* %i, i64 0, i32 0 + %i5 = load %0*, %0** %i4, align 8 + br label %bb1 + +bb6: + ret %0* undef +} + +declare void @llvm.assume(i1)