[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis
Richard Smith - zygoloid via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 21 14:27:26 PDT 2020
rsmith added inline comments.
================
Comment at: clang/lib/CodeGen/CGCall.cpp:2110
+ DetermineNoUndef(RetTy, getTypes(), DL, RetAI)) {
+ RetAttrs.addAttribute(llvm::Attribute::NoUndef);
+ }
----------------
rsmith wrote:
> This only applies in C++. In C, it's valid for a function to omit its `return` statement if the result value is unused, and in that case the returned value will legitimately be `undef`.
>
> Even in C++, we're conservative about enforcing the constraint that functions return a proper value and control flow doesn't just fall off the bottom of the function. See the full set of checks here: https://github.com/llvm/llvm-project/blob/master/clang/lib/CodeGen/CodeGenFunction.cpp#L1322
It would seem sensible to suppress this for `extern "C"` functions too, on the basis that the definition of such functions is probably in C code, and thus they might return `undef`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81678/new/
https://reviews.llvm.org/D81678
More information about the llvm-commits
mailing list