[llvm] [llvm][opt][Transforms] Replacement `calloc` should match replaced `malloc` (PR #110524)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 09:09:01 PDT 2024


================

----------------
nikic wrote:

This test looks way too complicated for what it's testing. For example, this is one of the basic malloc to call tests from a different file:
```llvm
define ptr @zero_memset_after_malloc(i64 %size) {
; CHECK-LABEL: @zero_memset_after_malloc(
; CHECK-NEXT:    [[CALLOC:%.*]] = call ptr @calloc(i64 1, i64 [[SIZE:%.*]])
; CHECK-NEXT:    ret ptr [[CALLOC]]
;
  %call = call ptr @malloc(i64 %size) inaccessiblememonly
  call void @llvm.memset.p0.i64(ptr %call, i8 0, i64 %size, i1 false)
  ret ptr %call
}
```

Your test should basically look like that, modulo the different address space.

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


More information about the llvm-commits mailing list