[llvm] [InstCombine] Emit fatal error on void to non-void conversion (PR #96574)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 21:22:06 PDT 2024


================
@@ -207,78 +207,78 @@ define i32 @fn2_rv(ptr %obj) #0 {
   ret i32 %result
 }
 
-; CHECK-LABEL: define i32 @fn3
+; CHECK-LABEL: define noundef i32 @fn3
 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
-define i32 @fn3(ptr %obj) #0 {
+define noundef i32 @fn3(ptr %obj) #0 {
   %vtable = load ptr, ptr %obj
   %p = call i1 @llvm.type.test(ptr %vtable, metadata !4)
   call void @llvm.assume(i1 %p)
   %fptr = load ptr, ptr %vtable
   ; RETP: call i32 @branch_funnel(ptr
   ; NORETP: call i32 %
-  %result = call i32 %fptr(ptr %obj, i32 1)
-  ret i32 %result
+  call i32 %fptr(ptr %obj, i32 1)
+  ret i32 0
 }
 
-; CHECK-LABEL: define i32 @fn3_rv
+; CHECK-LABEL: define noundef i32 @fn3_rv
 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
-define i32 @fn3_rv(ptr %obj) #0 {
+define noundef i32 @fn3_rv(ptr %obj) #0 {
   %vtable = load ptr, ptr %obj
   %p = call i1 @llvm.type.test(ptr %vtable, metadata !9)
   call void @llvm.assume(i1 %p)
   %fptr = call ptr @llvm.load.relative.i32(ptr %vtable, i32 0)
   ; RETP: call i32 @branch_funnel.1(ptr
   ; NORETP: call i32 %
-  %result = call i32 %fptr(ptr %obj, i32 1)
-  ret i32 %result
+  call i32 %fptr(ptr %obj, i32 1)
+  ret i32 0
 }
 
-; CHECK-LABEL: define i32 @fn4
+; CHECK-LABEL: define noundef i32 @fn4
 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
-define i32 @fn4(ptr %obj) #0 {
+define noundef i32 @fn4(ptr %obj) #0 {
   %p = call i1 @llvm.type.test(ptr @vt1_1, metadata !"typeid1")
   call void @llvm.assume(i1 %p)
   %fptr = load ptr, ptr @vt1_1
   ; RETP: call i32 @__typeid_typeid1_0_branch_funnel(ptr nest @vt1_1, ptr %obj, i32 1)
-  %result = call i32 %fptr(ptr %obj, i32 1)
+  call i32 %fptr(ptr %obj, i32 1)
   ; NORETP: call i32 %
-  ret i32 %result
+  ret i32 0
 }
 
-; CHECK-LABEL: define i32 @fn4_cpy
+; CHECK-LABEL: define noundef i32 @fn4_cpy
 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
-define i32 @fn4_cpy(ptr %obj) #0 {
+define noundef i32 @fn4_cpy(ptr %obj) #0 {
   %p = call i1 @llvm.type.test(ptr @vt1_1, metadata !"typeid1")
   call void @llvm.assume(i1 %p)
   %fptr = load ptr, ptr @vt1_1
   ; RETP: call i32 @__typeid_typeid1_0_branch_funnel(ptr nest @vt1_1, ptr %obj, i32 1)
-  %result = call i32 %fptr(ptr %obj, i32 1)
+  call i32 %fptr(ptr %obj, i32 1)
   ; NORETP: call i32 %
-  ret i32 %result
+  ret i32 0
 }
 
-; CHECK-LABEL: define i32 @fn4_rv
+; CHECK-LABEL: define noundef i32 @fn4_rv
 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
-define i32 @fn4_rv(ptr %obj) #0 {
+define noundef i32 @fn4_rv(ptr %obj) #0 {
   %p = call i1 @llvm.type.test(ptr @vt1_1_rv, metadata !"typeid1_rv")
   call void @llvm.assume(i1 %p)
   %fptr = call ptr @llvm.load.relative.i32(ptr @vt1_1_rv, i32 0)
   ; RETP: call i32 @__typeid_typeid1_rv_0_branch_funnel(ptr nest @vt1_1_rv, ptr %obj, i32 1)
-  %result = call i32 %fptr(ptr %obj, i32 1)
+  call i32 %fptr(ptr %obj, i32 1)
   ; NORETP: call i32 %
-  ret i32 %result
+  ret i32 0
 }
 
-; CHECK-LABEL: define i32 @fn4_rv_cpy
+; CHECK-LABEL: define noundef i32 @fn4_rv_cpy
 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
-define i32 @fn4_rv_cpy(ptr %obj) #0 {
+define noundef i32 @fn4_rv_cpy(ptr %obj) #0 {
   %p = call i1 @llvm.type.test(ptr @vt1_1_rv, metadata !"typeid1_rv")
   call void @llvm.assume(i1 %p)
   %fptr = call ptr @llvm.load.relative.i32(ptr @vt1_1_rv, i32 0)
   ; RETP: call i32 @__typeid_typeid1_rv_0_branch_funnel(ptr nest @vt1_1_rv, ptr %obj, i32 1)
-  %result = call i32 %fptr(ptr %obj, i32 1)
+  call i32 %fptr(ptr %obj, i32 1)
   ; NORETP: call i32 %
-  ret i32 %result
+  ret i32 0
 }
----------------
yozhu wrote:

The existing test would fail with this change, so I had to change all the places in the test that had void to non-void conversions.

https://github.com/llvm/llvm-project/pull/96574


More information about the llvm-commits mailing list