Global variables with strong definitions cannot be freed
authorPhilip Reames <listmail@philipreames.com>
Wed, 14 Jul 2021 20:19:48 +0000 (13:19 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 14 Jul 2021 20:26:18 +0000 (13:26 -0700)
With the current deref semantics, this is redundant - since we assume that anything which is dereferenceable (ever) can't be freed - but it becomes neccessary for the deref-at-point semantics.

Testing wise, this is covered by test/CodeGen/X86/hoist-invariant-load.ll when -use-dereferenceable-at-point-semantics is active.  I didn't bother duplicating the command line since a) it's an in-development mode, and b) the change is pretty obvious.

llvm/lib/IR/Value.cpp

index 9cb0056..1c59565 100644 (file)
@@ -897,6 +897,7 @@ uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL,
       // CanBeNull flag.
       DerefBytes = DL.getTypeStoreSize(GV->getValueType()).getFixedSize();
       CanBeNull = false;
+      CanBeFreed = false;
     }
   }
   return DerefBytes;