[PATCH] D110584: [Analysis] Be defensive when matching size_t in lib call signatures
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 27 13:41:41 PDT 2021
bjope created this revision.
bjope added a reviewer: spatel.
Herald added a subscriber: hiraditya.
bjope requested review of this revision.
Herald added a project: LLVM.
When TargetLibraryInfoImpl::isValidProtoForLibFunc is checking
function signatures to detect lib calls it may check that a parameter
or return value matches with the "size_t" type. For this to work it
has to derive the IR type matching with "size_t". Depending on if
a DataLayout is provided or not, this has been done in two different
way. Either a more strict check being based on IntPtrType (which is
given by the DataLayout) or a more relaxed check assuming that any
integer type matches with "size_t".
Given that the stricter approach exist it seems like we do not want
to trigger rewrites etc if we aren't sure that a function calls
actually match with the library function. Therefore it was questioned
why we actually have the more relaxed approach when not being able
to derive an IR type for "size_t". This patch will take a more
defensive approach, avoiding lib call transformations when we do not
know if the signature matches (when we do not know the size of
"size_t").
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110584
Files:
llvm/lib/Analysis/TargetLibraryInfo.cpp
Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -734,13 +734,8 @@
// SizeTTy based on DataLayout and getIntPtrType isn't always valid.
Type *SizeTTy = DL ? DL->getIntPtrType(Ctx, /*AddressSpace=*/0) : nullptr;
auto IsSizeTTy = [SizeTTy](Type *Ty) {
- // FIXME: For uknown historical reasons(?) we use a relaxed condition saying
- // that any integer type may size_t, for example if we got no
- // DataLayout. This seems like a potentially error prone relaxation (or why
- // should we only be more strict and checking the exact type when we have a
- // DataLayout?).
if (!SizeTTy)
- return Ty->isIntegerTy();
+ return false;
return Ty == SizeTTy;
};
unsigned NumParams = FTy.getNumParams();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110584.375390.patch
Type: text/x-patch
Size: 899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210927/aabe51b9/attachment.bin>
More information about the llvm-commits
mailing list