[PATCH] D144673: Add tests to reproduce pointer/index width confusion crashes
Krzysztof Drewniak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 14:15:54 PST 2023
krzysz00 updated this revision to Diff 499978.
krzysz00 added a comment.
Switch an XFAIL to a not --crash
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144673/new/
https://reviews.llvm.org/D144673
Files:
llvm/test/Transforms/LowerTypeTests/distinct-index-width-crash.ll
llvm/test/Transforms/MergeFunc/different-index-width-gep-crash.ll
llvm/test/Transforms/MergeICmps/X86/distinct-index-width-crash.ll
Index: llvm/test/Transforms/MergeICmps/X86/distinct-index-width-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/MergeICmps/X86/distinct-index-width-crash.ll
@@ -0,0 +1,32 @@
+; RUN: not --crash opt < %s -passes=mergeicmps -verify-dom-info -disable-output
+
+target triple = "x86_64"
+
+; This is very much not an x86 ABI, in current use, but we're testing
+; that we've fixed a bug where accumulateConstantOffset() was called incorrectly.
+target datalayout = "e-p:64:64:64:32"
+
+; Define a cunstom data layout that has index width < pointer width
+; and make sure that doesn't mreak anything
+define void @fat_ptrs(ptr dereferenceable(16) %a, ptr dereferenceable(16) %b) {
+bb0:
+ %ptr_a1 = getelementptr inbounds [2 x i64], ptr %a, i64 0, i64 1
+ %ptr_b1 = getelementptr inbounds [2 x i64], ptr %b, i64 0, i64 1
+ br label %bb1
+
+bb1: ; preds = %bb0
+ %a0 = load i64, ptr %a
+ %b0 = load i64, ptr %b
+ %cond0 = icmp eq i64 %a0, %b0
+ br i1 %cond0, label %bb2, label %bb3
+
+bb2: ; preds = %bb1
+ %a1 = load i64, ptr %ptr_a1
+ %b1 = load i64, ptr %ptr_b1
+ %cond1 = icmp eq i64 %a1, %b1
+ br label %bb3
+
+bb3: ; preds = %bb2, %bb1
+ %necessary = phi i1 [ %cond1, %bb2 ], [ false, %bb1 ]
+ ret void
+}
Index: llvm/test/Transforms/MergeFunc/different-index-width-gep-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/MergeFunc/different-index-width-gep-crash.ll
@@ -0,0 +1,13 @@
+; RUN: not --crash opt -disable-output -passes=mergefunc -S < %s
+
+target datalayout = "e-p:64:64-p2:128:128:128:32"
+
+define void @foo(ptr addrspace(2) %x) {
+ %tmp = getelementptr i32, ptr addrspace(2) %x, i32 1
+ ret void
+}
+
+define void @bar(ptr addrspace(2) %x) {
+ %tmp = getelementptr i32, ptr addrspace(2) %x, i32 1
+ ret void
+}
Index: llvm/test/Transforms/LowerTypeTests/distinct-index-width-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LowerTypeTests/distinct-index-width-crash.ll
@@ -0,0 +1,17 @@
+; RUN: not --crash opt -passes=lowertypetests %s -disable-output
+target datalayout = "e-p:64:64:64:32"
+
+ at a = constant i32 1, !type !0
+ at b = constant [2 x i32] [i32 2, i32 3], !type !1
+
+!0 = !{i32 0, !"typeid1"}
+!1 = !{i32 4, !"typeid1"}
+
+declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone
+
+; CHECK: @bar(
+define i1 @bar() {
+ ; CHECK: ret i1 true
+ %x = call i1 @llvm.type.test(ptr getelementptr ([2 x i32], ptr @b, i32 0, i32 1), metadata !"typeid1")
+ ret i1 %x
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144673.499978.patch
Type: text/x-patch
Size: 2764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230223/a343a4eb/attachment.bin>
More information about the llvm-commits
mailing list