[PATCH] D110583: [Analysis] Add FIXME:s related to size_t type checks

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 06:30:23 PDT 2021


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f5ea14bca71: [Analysis] Add FIXME:s related to size_t type checks (authored by bjope).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110583/new/

https://reviews.llvm.org/D110583

Files:
  llvm/lib/Analysis/TargetLibraryInfo.cpp


Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -727,9 +727,19 @@
                                                    LibFunc F,
                                                    const DataLayout *DL) const {
   LLVMContext &Ctx = FTy.getContext();
+  // FIXME: There is really no guarantee that sizeof(size_t) is equal to
+  // sizeof(int*) for every target. So the assumption used here to derive the
+  // SizeTTy based on DataLayout and getIntPtrType isn't always valid.
   Type *SizeTTy = DL ? DL->getIntPtrType(Ctx, /*AddressSpace=*/0) : nullptr;
   auto IsSizeTTy = [SizeTTy](Type *Ty) {
-    return SizeTTy ? Ty == SizeTTy : Ty->isIntegerTy();
+    // 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 Ty == SizeTTy;
   };
   unsigned NumParams = FTy.getNumParams();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110583.375551.patch
Type: text/x-patch
Size: 1275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/15f2c255/attachment.bin>


More information about the llvm-commits mailing list