[llvm] [DXIL][Analysis] Collect Function properties in Metadata Analysis (PR #105728)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 16:11:43 PDT 2024


================
@@ -19,12 +20,16 @@ namespace llvm {
 
 namespace dxil {
 
+struct FunctionProperties {
+  unsigned NumThreads[3];
+};
+
 struct ModuleMetadataInfo {
   VersionTuple DXILVersion{};
   VersionTuple ShaderModelVersion{};
   Triple::EnvironmentType ShaderStage = Triple::UnknownEnvironment;
   VersionTuple ValidatorVersion{};
-
+  std::unordered_map<Function *, FunctionProperties> FunctionPropertyMap{};
----------------
bogner wrote:

Do we actually need to look up functions in a map for the function properties, or do we just need to be able to iterate through them? It might be nice to wire up the metadata analysis into DXILTranslateMetadata before adding more properties so that we can see how they'll be used.

In any case, `std::unordered_map` is very expensive as data structures go. Since this mapping is built up first and then queried later, we can probably just use a sorted vector instead of something heavyweight like this. There are some good tips on how to choose data structures for situations like this in the [LLVM Programmer's Manual](https://llvm.org/docs/ProgrammersManual.html#map-like-containers-std-map-densemap-etc)


https://github.com/llvm/llvm-project/pull/105728


More information about the llvm-commits mailing list