[PATCH] D85894: [BuildLibCalls] Add more noundef to library functions

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 04:40:10 PDT 2020


aqjune created this revision.
aqjune added reviewers: jdoerfert, MaskRay, efriedma, xbolva00, uenoku.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
aqjune requested review of this revision.

This patch follows D85345 <https://reviews.llvm.org/D85345> and adds more noundef attributes to return values/arguments of library functions
that are mostly about accessing the file system or processes.

A few functions like `chmod` or `times` use typedef `mode_t` and `clock_t`.
They are neither struct nor undef, so they cannot contain undef even if they're lowered to iN in IR. So, it is fine to use noundef for them.

- clock_t's actual type is size_t (C17, 7.27.1.3), so it isn't struct or union.

- For mode_t, either int or long is used in practice because programmers use bit manipulation. So, I think it is okay that it's never aggregate in practice.

After this patch, the remaining library functions are those that eagerly participate in optimizations: they can be removed, reordered, or
introduced by a transformation from primitive IR operations.
For them, a few testings is needed, since it may not be valid to add noundef anymore even if C standard says it's okay.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85894

Files:
  llvm/lib/Transforms/Utils/BuildLibCalls.cpp
  llvm/test/Transforms/InferFunctionAttrs/annotate.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85894.285334.patch
Type: text/x-patch
Size: 19974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200813/5afc7360/attachment.bin>


More information about the llvm-commits mailing list