[PATCH] D37051: Model cache size and associativity in TargetTransformInfo

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 00:47:32 PDT 2017


fhahn added inline comments.


================
Comment at: include/llvm/Analysis/TargetTransformInfoImpl.h:348
+    case TargetTransformInfo::CL_L2D:
+      return llvm::Optional<unsigned>();
+    }
----------------
grosser wrote:
> asb wrote:
> > Shouldn't this have something like:
> > ````
> > default:
> >   llvm_unreachable("Unknown TargetTransformInfo::CacheLevel")
> > ```
> The switch above is fully covered, but I can add this as a form of defensive programming. Thinking about this, it might also be useful to used typed enums for the cache level. I will update the patch accordingly.
I think using an enum class would be enough. AFAIK, compilers are pretty good at warning about missing cases in switch statements over enum classes. I think there is no need for default, as the compiler would catch missing patterns.


https://reviews.llvm.org/D37051





More information about the llvm-commits mailing list