[PATCH] D62229: [TargetTransformInfo] early return on nullptr

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 19:11:17 PDT 2019


nickdesaulniers created this revision.
nickdesaulniers added reviewers: Carrot, chandlerc.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No.
38".

Rather than proceed in calculating the cost of the GEP, assume the cost
is TTI::TCC_Basic, which seems to be used elsewhere as the default value
or base cost on failure.  In practice, the whole test suite runs without
this pointer being NULL, so this could alternatively be an assert.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62229

Files:
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h


Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -681,6 +681,8 @@
 
   int getGEPCost(Type *PointeeType, const Value *Ptr,
                  ArrayRef<const Value *> Operands) {
+    if (Ptr == nullptr)
+      return TTI::TCC_Basic;
     const GlobalValue *BaseGV = nullptr;
     if (Ptr != nullptr) {
       // TODO: will remove this when pointers have an opaque type.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62229.200628.patch
Type: text/x-patch
Size: 565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190522/fd1ba9ca/attachment-0001.bin>


More information about the llvm-commits mailing list