[all-commits] [llvm/llvm-project] 481c62: [BuildLibCalls] Add noundef to allocator fns' size

Juneyoung Lee via All-commits all-commits at lists.llvm.org
Mon Feb 22 20:58:56 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 481c62277d5669e15e6a0ec14240c5f5410ca954
      https://github.com/llvm/llvm-project/commit/481c62277d5669e15e6a0ec14240c5f5410ca954
  Author: Juneyoung Lee <aqjune at gmail.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/BuildLibCalls.cpp
    M llvm/test/Transforms/InferFunctionAttrs/annotate.ll

  Log Message:
  -----------
  [BuildLibCalls] Add noundef to allocator fns' size

This is a patch to explicitly mark the size parameter of allocator functions like malloc/realloc/... as noundef.

For C/C++: undef can be created from reading an uninitialized variable or padding.
Calling a function with uninitialized variable is already UB.
Calling malloc with padding value is.. something that's not expected. Padding bits may appear in a coerced aggregate, which doesn't apply to malloc's size.
Therefore, malloc's size can be marked as noundef.

For transformations that introduce malloc/realloc/..: I ran LLVM unit tests with an updated Alive2 semantics, and found no regression, so it seems okay.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D97045




More information about the All-commits mailing list