realloc(null, N) -> malloc(N)
I would like to hear your feedback on these three changes
- malloc(N) + realloc(ptr, N + X) -> fold to -> malloc(N + X), remove realloc
- malloc(N) + realloc(ptr, N - X) -> fold to -> malloc(N), remove realloc
- realloc(NULL, N) -> malloc(N)
Edit: I think only 3. should stay in this patch..
|847 ↗||(On Diff #141545)|
|1059 ↗||(On Diff #142131)|
Why are the implementations of emitMalloc and emitCalloc different? (I'm specifically concerned about missing call to inferLibFuncAttributes.)
|13 ↗||(On Diff #142131)|
This doesn't look like it's what you meant to test.
|1062 ↗||(On Diff #142247)|
Anyway, emitCalloc function I just copied from SimplifyLibCalls since it has no sense to have it there. So some time ago when it was merged and there was without proper review?
The patch doesn't compile as-is. Please post a corrected patch.
/llvm/lib/Transforms/Utils/BuildLibCalls.cpp:1061:11: error: member reference type 'const llvm::TargetLibraryInfo' is not a pointer; did you mean to use '.'? if (!TLI->has(LibFunc_calloc)) ~~~^~ . /llvm/lib/Transforms/Utils/BuildLibCalls.cpp:1069:53: error: indirection requires pointer operand ('const llvm::TargetLibraryInfo' invalid) inferLibFuncAttributes(*M->getFunction("calloc"), *TLI);