[PATCH] D105313: [ValueTracking] Use call arguments for nonnull attribute check
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 13:26:08 PDT 2021
nikic created this revision.
nikic added reviewers: opaque-pointers, spatel.
Herald added subscribers: dexonsmith, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
isKnownNonZero() can determine nonnull-ness from a dominating call with a nonnull parameter. Currently, this works by inspecting the attributes on the called function.
This code currently crashes with opaque pointers if the call-site and the called function have a different number of arguments (which no longer requires a bitcast to sit in between). Fix this by directly working with the call arguments instead.
As seen by changes on existing tests, this has the additional benefit that we now take into account attributes that are present only on the callsite, and not on the function declaration.
Unfortunately, this means we need to duplicate the function-level Attribute::hasNonNullAttr() logic into a call-level CallBase::paramIsNonNull() function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105313
Files:
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/IR/Instructions.cpp
llvm/test/Transforms/InstCombine/align-addr.ll
llvm/test/Transforms/InstCombine/memset_chk-1.ll
llvm/test/Transforms/InstCombine/sprintf-1.ll
llvm/test/Transforms/InstCombine/strstr-1.ll
llvm/test/Transforms/InstSimplify/known-non-zero-opaque-ptrs.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105313.356000.patch
Type: text/x-patch
Size: 9092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210701/1121b920/attachment.bin>
More information about the llvm-commits
mailing list