Issue 182954
Summary Significant IR compilation regression from LLVM 21 to LLVM 22
Labels new issue
Assignees
Reporter jeaye
    Branching from #179611, I have found **a broader LLVM JIT perf regression**. I can demonstrate this using an unmodified `clang-repl`, simply by creating many symbols and asking LLVM to resolve one of them.

**I believe everyone on Linux using ORC is affected by this, though they may not realize it yet.**

## `test.cpp`
```cpp
template <int N> struct SymbolFactory {
  static void create() { SymbolFactory<N - 1>::create(); }
};

template <> struct SymbolFactory<0> {
  static void create() {}
};

extern "C" int printf(const char *, ...);
extern "C" void find_me() {
 SymbolFactory<1000>::create();
  printf("found!\n");
}
```

## Timing
To run this test, we just need to invoke `clang-repl` and tell it to include this file.

```bash
time echo -e "#include \"test.cpp\"\n find_me();" | clang-repl
```

## Results
Note the exponential growth here.

|| LLVM 21 | LLVM 22|
| --| -- | -- |
|N=1 | 36ms | 45ms|
|N=100|51ms|80ms|
|N=500|135ms|355ms|
|N=1000| 300ms | 1800ms|
|N=2000|450ms|8700ms|

<img height="400" alt="Image" src="" />

## Flamegraph (click to expand)
<img width="2521" height="1883" alt="Image" src="" />

## Notes
This problem is not specific to the `SymbolFactory` template. That is just a helper to create more symbols. Instead, if we just did the following, to introduce 1000 symbols, we would arrive at the same performance discrepancy between LLVM 21 and LLVM 22.

```cpp
void foo1() {}
void foo2() {}
// ... continue until foo1000
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to