[all-commits] [llvm/llvm-project] 3b1474: free(nullptr) does not violate the nofree specific...

Philip Reames via All-commits all-commits at lists.llvm.org
Tue Apr 20 09:08:44 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3b1474cab26b27c4d71a2c21cb45a62eefdacb6a
      https://github.com/llvm/llvm-project/commit/3b1474cab26b27c4d71a2c21cb45a62eefdacb6a
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-04-20 (Tue, 20 Apr 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/malloc-free-delete.ll

  Log Message:
  -----------
  free(nullptr) does not violate the nofree specification

This fixes a subtle and nasty bug in my 86664638. The problem is that free(nullptr) is well defined (and common).

The specification for the nofree attributes talks about memory objects, and doesn't explicitly address null, but I think it's reasonable to assume that nofree doesn't disallow a call to free(nullptr). If it did, we'd have to prove nonnull on an argument to ever infer nofree which doesn't seem to be the intent.

This was found by Nuno and Alive2 over in https://reviews.llvm.org/D100141#2697374.

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




More information about the All-commits mailing list