[llvm] [NFC][DirectX] Infrastructure to collect shader flags for each function (PR #112967)

Damyan Pepper via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 16:30:21 PDT 2024


================
@@ -20,29 +20,37 @@
 using namespace llvm;
 using namespace llvm::dxil;
 
-static void updateFlags(ComputedShaderFlags &Flags, const Instruction &I) {
+static void updateFlags(DXILModuleShaderFlagsInfo &MSFI, const Instruction &I) {
+  ComputedShaderFlags &FSF = MSFI.FuncShaderFlagsMap[I.getFunction()];
----------------
damyanp wrote:

It looks like this is being called inside a loop that looks something like:

```
for (const auto& BB: F) 
  for (const auto &I : BB)
    update(MSGI, I);
```

So say we have 100 functions with 1,000 instructions in each one, this ends up looking the function up in the map 100,000 times. If it were rearranged so that the lookup happens once per function this could be reduced to just 100 times.

Something like:

```
for (const auto& BB: F) {
  ComputedShaderFlags &CSF = MSFI.FuncShaderFlagsMap[F];
  for (const auto &I : BB) 
    update(CSF, I);
}

  



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


More information about the llvm-commits mailing list