[PATCH] D53342: [SimplifyLibCalls] Mark known arguments with nonnull

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 06:21:05 PDT 2019


xbolva00 marked an inline comment as done.
xbolva00 added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1149
+    removeNonNull(CI, {0});
+    // FIXME: InstCombine infinite loops :( Only when isIntrinsic == true
+  }
----------------
xbolva00 wrote:
> @spatel @jdoerfert @lebedev.ri infinite loop here
> 
> https://github.com/llvm/llvm-project/blob/master/llvm/test/Transforms/InstCombine/memset-1.ll#L63
> If I add return CI; -> memset is removed:
> 
> 
> define float* @pr25892(i32 %size) #0 {
> ; CHECK-LABEL: @pr25892(
> ; CHECK-NEXT:  entry:
> ; CHECK-NEXT:    [[CALL:%.*]] = tail call i8* @malloc(i32 [[SIZE:%.*]]) #0
> ; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8* [[CALL]], null
> ; CHECK-NEXT:    br i1 [[CMP]], label [[CLEANUP:%.*]], label [[IF_END:%.*]]
> ; CHECK:       if.end:
> ; CHECK-NEXT:    [[BC:%.*]] = bitcast i8* [[CALL]] to float*
> ; CHECK-NEXT:    br label [[CLEANUP]]
> ; CHECK:       cleanup:
> ; CHECK-NEXT:    [[RETVAL_0:%.*]] = phi float* [ [[BC]], [[IF_END]] ], [ null, [[ENTRY:%.*]] ]
> ; CHECK-NEXT:    ret float* [[RETVAL_0]]
> ;
> 
> 
> Maybe you can give me a hint what is wrong? Thanks
Anyway, we dont need to drop removeNonNull(CI, {0}); for llvm.memset.

It is only issue for libc's memset, and we catch it, e.g:

if (LenC && LenC->getZExtValue() > 0) {
    annotateDereferenceableBytes(CI, {0}, LenC->getZExtValue());
    annotateNonNull(CI, {0});
  } else if (!isIntrinsic) {
     removeNonNull(CI, {0});
}

But I would like to know what is going here :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53342/new/

https://reviews.llvm.org/D53342





More information about the llvm-commits mailing list