diff options
| author | Kunqiu Chen <camsyn@foxmail.com> | 2025-10-28 21:45:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-28 21:45:17 +0800 |
| commit | a8471342fae518796232208929a23c2b8a127a68 (patch) | |
| tree | 6489a916ebb7e2261510eb6adbed28ab56fcd031 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
| parent | cc22c9c4559f9436c9c3f9f2fa95f0c7a3b4b31d (diff) | |
| download | llvm-a8471342fae518796232208929a23c2b8a127a68.zip llvm-a8471342fae518796232208929a23c2b8a127a68.tar.gz llvm-a8471342fae518796232208929a23c2b8a127a68.tar.bz2 | |
[AbstractCallSite] Handle Indirect Calls Properly (#163003)
AbstractCallSite handles three types of calls (direct, indirect, and
callback).
This patch fixes the handling of indirect calls in some methods, which
incorrectly assumed that non-direct calls are always callback calls.
Moreover, this PR adds 2 unit tests for direct call type and indirect
call type.
The aforementioned misassumption leads to the following problem:
---
## Problem
When the underlying call is **indirect**, some APIs of
`AbstractCallSite` behave unexpectedly.
E.g., `AbstractCallSite::getCalledFunction()` currently triggers an
**assertion failure**, instead of returning `nullptr` as documented:
```cpp
/// Return the function being called if this is a direct call, otherwise
/// return null (if it's an indirect call).
Function *getCalledFunction() const;
```
Actual unexpected assertion failure:
```
AbstractCallSite.h:197: int llvm::AbstractCallSite::getCallArgOperandNoForCallee() const: Assertion `isCallbackCall()' failed.
```
This is because `AbstractCallSite` mistakenly entered the branch that
handles Callback Calls as its guard condition (`!isDirectCall()`) does
not take into account the case of indirect calls
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
0 files changed, 0 insertions, 0 deletions
