[llvm] 611f5b8 - [GVN] Add test for #116668 (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 08:23:33 PST 2024
Author: Nikita Popov
Date: 2024-11-27T17:23:23+01:00
New Revision: 611f5b8ff913c21cfd85b0f4170ab880838a4c9e
URL: https://github.com/llvm/llvm-project/commit/611f5b8ff913c21cfd85b0f4170ab880838a4c9e
DIFF: https://github.com/llvm/llvm-project/commit/611f5b8ff913c21cfd85b0f4170ab880838a4c9e.diff
LOG: [GVN] Add test for #116668 (NFC)
Added:
llvm/test/Transforms/GVN/setjmp.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GVN/setjmp.ll b/llvm/test/Transforms/GVN/setjmp.ll
new file mode 100644
index 00000000000000..0277fcfa226ed6
--- /dev/null
+++ b/llvm/test/Transforms/GVN/setjmp.ll
@@ -0,0 +1,37 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=gvn < %s | FileCheck %s
+
+declare i32 @setjmp() returns_twice
+declare void @longjmp()
+declare ptr @malloc(i64)
+
+; FIXME: This is a miscompile.
+define i32 @test() {
+; CHECK-LABEL: define i32 @test() {
+; CHECK-NEXT: [[MALLOC:%.*]] = call noalias ptr @malloc(i64 4)
+; CHECK-NEXT: store i32 10, ptr [[MALLOC]], align 4
+; CHECK-NEXT: [[SJ:%.*]] = call i32 @setjmp()
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SJ]], 0
+; CHECK-NEXT: br i1 [[CMP]], label %[[IF_THEN:.*]], label %[[IF_END:.*]]
+; CHECK: [[IF_THEN]]:
+; CHECK-NEXT: store i32 20, ptr [[MALLOC]], align 4
+; CHECK-NEXT: call void @longjmp()
+; CHECK-NEXT: unreachable
+; CHECK: [[IF_END]]:
+; CHECK-NEXT: ret i32 10
+;
+ %malloc = call noalias ptr @malloc(i64 4)
+ store i32 10, ptr %malloc, align 4
+ %sj = call i32 @setjmp()
+ %cmp = icmp eq i32 %sj, 0
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ store i32 20, ptr %malloc
+ call void @longjmp()
+ unreachable
+
+if.end:
+ %res = load i32, ptr %malloc
+ ret i32 %res
+}
More information about the llvm-commits
mailing list