[llvm] [llubi] Extract the declaration of class InstExecutor (PR #185817)

Zhige Chen via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 15 20:22:03 PDT 2026


nofe1248 wrote:

As an alternative to the current PR, we can extract the reusable methods (`reportImmediateUB`, `verifyMemAccess`, `load`, `store`, etc.) into a separate interface:
```cpp
// ExecutionAPI.h
class ExecutionAPI {
public:
  virtual ~ExecutionAPI() = default;
  virtual void reportImmediateUB(StringRef Msg) = 0;
  virtual void reportError(StringRef Msg) = 0;
  // ... other reusable methods
};
```
Then, `InstExecutor` can inherit from both `InstVisitor` and `ExecutionAPI`. The `LibraryEnvironment` would then be implemented as:
```cpp
// Library.h
class LibraryEnvironment {
public:
  AnyValue callLibFunc(ExecutionAPI &Exec, CallBase &CB, Function &Callee);
};
```
This approach avoids leaking implementation details, as the `LibraryEnvironment` only depends on the abstract `ExecutionAPI` interface. However, it introduces potential overhead from virtual function calls and uses multiple inheritance. If this design is feasible and preferred, I can open a separate PR to implement it.

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


More information about the llvm-commits mailing list