[PATCH] D138796: ObjCARC: Try to fix faulty tests

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 05:19:40 PST 2022


arsenm created this revision.
arsenm added reviewers: rjmccall, sunfish.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

These were trying to check if there was not an llvm.objc call before a
closing "}", which presumably was intended to match the end of the
function. Really this was matching the closing } in "bitcast {}* %selfto i8*", 
which can't be what anyone intended. This broke after converting the test 
to opaque pointer deleted this bitcast.

      

There are in fact @llvm.obj calls remaining in the function, so this
may indicate the transform this was intended to check is actually
broken. In @"\01-[A z]" (great test name), the first retain call seems
to move down to the printf. The second case, @"\01-[Top0 _getX]", has
no change.


https://reviews.llvm.org/D138796

Files:
  llvm/test/Transforms/ObjCARC/basic.ll


Index: llvm/test/Transforms/ObjCARC/basic.ll
===================================================================
--- llvm/test/Transforms/ObjCARC/basic.ll
+++ llvm/test/Transforms/ObjCARC/basic.ll
@@ -2706,62 +2706,66 @@
 declare i32 @puts(i8* nocapture) nounwind
 @str = internal constant [16 x i8] c"-[ Top0 _getX ]\00"
 
-; CHECK: define { <2 x float>, <2 x float> } @"\01-[A z]"({}* %self, i8* nocapture %_cmd) [[NUW]] {
-; CHECK-NOT: @llvm.objc.
-; CHECK: }
-
-define {<2 x float>, <2 x float>} @"\01-[A z]"({}* %self, i8* nocapture %_cmd) nounwind {
+; CHECK-LABEL: define { <2 x float>, <2 x float> } @"\01-[A z]"({}* %self, i8* nocapture %_cmd)
+; CHECK: [[SELF_CAST0:%[0-9]+]] = bitcast {}* %self to i8*
+; CHECK: tail call i8* @llvm.objc.retain(i8* [[SELF_CAST0]])
+; CHECK-NEXT: %call = tail call i32 (i8*, ...) @printf(
+; CHECK: [[SELF_CAST1:%[0-9]+]] = bitcast {}* %self to i8*
+; CHECK: tail call void @llvm.objc.release(i8* [[SELF_CAST1]])
+; CHECK: }
+define { <2 x float>, <2 x float> } @"\01-[A z]"({}* %self, i8* nocapture %_cmd) nounwind {
 invoke.cont:
-  %0 = bitcast {}* %self to i8*
-  %1 = tail call i8* @llvm.objc.retain(i8* %0) nounwind
+  %i = bitcast {}* %self to i8*
+  %i1 = tail call i8* @llvm.objc.retain(i8* %i) nounwind
   tail call void @llvm.dbg.value(metadata {}* %self, metadata !DILocalVariable(scope: !2), metadata !DIExpression()), !dbg !DILocation(scope: !2)
   tail call void @llvm.dbg.value(metadata {}* %self, metadata !DILocalVariable(scope: !2), metadata !DIExpression()), !dbg !DILocation(scope: !2)
   %ivar = load i64, i64* @"OBJC_IVAR_$_A.myZ", align 8
-  %add.ptr = getelementptr i8, i8* %0, i64 %ivar
+  %add.ptr = getelementptr i8, i8* %i, i64 %ivar
   %tmp1 = bitcast i8* %add.ptr to float*
   %tmp2 = load float, float* %tmp1, align 4
   %conv = fpext float %tmp2 to double
   %add.ptr.sum = add i64 %ivar, 4
-  %tmp6 = getelementptr inbounds i8, i8* %0, i64 %add.ptr.sum
-  %2 = bitcast i8* %tmp6 to float*
-  %tmp7 = load float, float* %2, align 4
+  %tmp6 = getelementptr inbounds i8, i8* %i, i64 %add.ptr.sum
+  %i2 = bitcast i8* %tmp6 to float*
+  %tmp7 = load float, float* %i2, align 4
   %conv8 = fpext float %tmp7 to double
   %add.ptr.sum36 = add i64 %ivar, 8
-  %tmp12 = getelementptr inbounds i8, i8* %0, i64 %add.ptr.sum36
+  %tmp12 = getelementptr inbounds i8, i8* %i, i64 %add.ptr.sum36
   %arrayidx = bitcast i8* %tmp12 to float*
   %tmp13 = load float, float* %arrayidx, align 4
   %conv14 = fpext float %tmp13 to double
   %tmp12.sum = add i64 %ivar, 12
-  %arrayidx19 = getelementptr inbounds i8, i8* %0, i64 %tmp12.sum
-  %3 = bitcast i8* %arrayidx19 to float*
-  %tmp20 = load float, float* %3, align 4
+  %arrayidx19 = getelementptr inbounds i8, i8* %i, i64 %tmp12.sum
+  %i3 = bitcast i8* %arrayidx19 to float*
+  %tmp20 = load float, float* %i3, align 4
   %conv21 = fpext float %tmp20 to double
   %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str4, i64 0, i64 0), double %conv, double %conv8, double %conv14, double %conv21)
   %ivar23 = load i64, i64* @"OBJC_IVAR_$_A.myZ", align 8
-  %add.ptr24 = getelementptr i8, i8* %0, i64 %ivar23
-  %4 = bitcast i8* %add.ptr24 to i128*
-  %srcval = load i128, i128* %4, align 4
-  tail call void @llvm.objc.release(i8* %0) nounwind
+  %add.ptr24 = getelementptr i8, i8* %i, i64 %ivar23
+  %i4 = bitcast i8* %add.ptr24 to i128*
+  %srcval = load i128, i128* %i4, align 4
+  tail call void @llvm.objc.release(i8* %i) nounwind
   %tmp29 = trunc i128 %srcval to i64
   %tmp30 = bitcast i64 %tmp29 to <2 x float>
-  %tmp31 = insertvalue {<2 x float>, <2 x float>} undef, <2 x float> %tmp30, 0
+  %tmp31 = insertvalue { <2 x float>, <2 x float> } undef, <2 x float> %tmp30, 0
   %tmp32 = lshr i128 %srcval, 64
   %tmp33 = trunc i128 %tmp32 to i64
   %tmp34 = bitcast i64 %tmp33 to <2 x float>
-  %tmp35 = insertvalue {<2 x float>, <2 x float>} %tmp31, <2 x float> %tmp34, 1
-  ret {<2 x float>, <2 x float>} %tmp35
+  %tmp35 = insertvalue { <2 x float>, <2 x float> } %tmp31, <2 x float> %tmp34, 1
+  ret { <2 x float>, <2 x float> } %tmp35
 }
 
-; CHECK: @"\01-[Top0 _getX]"({}* %self, i8* nocapture %_cmd) [[NUW]] {
-; CHECK-NOT: @llvm.objc.
-; CHECK: }
-
+; CHECK-LABEL: @"\01-[Top0 _getX]"({}* %self, i8* nocapture %_cmd)
+; CHECK: %i = bitcast {}* %self to i8*
+; CHECK: tail call i8* @llvm.objc.retain(i8* %i)
+; CHECK: %puts = tail call i32 @puts
+; CHECK: tail call void @llvm.objc.release(i8* %i)
 define i32 @"\01-[Top0 _getX]"({}* %self, i8* nocapture %_cmd) nounwind {
 invoke.cont:
-  %0 = bitcast {}* %self to i8*
-  %1 = tail call i8* @llvm.objc.retain(i8* %0) nounwind
+  %i = bitcast {}* %self to i8*
+  %i1 = tail call i8* @llvm.objc.retain(i8* %i) nounwind
   %puts = tail call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
-  tail call void @llvm.objc.release(i8* %0) nounwind
+  tail call void @llvm.objc.release(i8* %i) nounwind
   ret i32 0
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138796.478199.patch
Type: text/x-patch
Size: 4970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221128/f27579fd/attachment.bin>


More information about the llvm-commits mailing list