[PATCH] D119582: BuildLibCalls: also set allocsize() attributes
    Nikita Popov via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Apr  6 02:18:18 PDT 2022
    
    
  
nikic requested changes to this revision.
nikic added inline comments.
This revision now requires changes to proceed.
================
Comment at: llvm/lib/Transforms/Utils/BuildLibCalls.cpp:234
+                         Optional<unsigned> NumElemsArg) {
+  if (F.hasFnAttribute(Attribute::AllocSize)) {
+    return false;
----------------
Remove braces for single-line if.
================
Comment at: llvm/lib/Transforms/Utils/BuildLibCalls.cpp:375
   case LibFunc_strndup:
+    Changed |= setAllocSize(F, 1, None);
     Changed |= setArgNoUndef(F, 1);
----------------
This is incorrect: allocsize is a lower bound on the allocation size, while the strndup argument is an upper bound. strndup may allocate less if it encounters a null byte earlier.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119582/new/
https://reviews.llvm.org/D119582
    
    
More information about the llvm-commits
mailing list