[llvm] [lli] fix lli crash when run variable arguments function as a interpret (PR #173719)

via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 27 04:44:29 PST 2025


Fushj89 wrote:

The problem happen `Interpreter::visitVAStartInst`  method,  it set  `ArgIndex`  with `VAStartInst` , but should set `ArgIndex`  with `VAStartInst.getOperand(0)` which is `va_list`.
```
void Interpreter::visitVAStartInst(VAStartInst &I) {
  ExecutionContext &SF = ECStack.back();
  GenericValue ArgIndex;
  ArgIndex.UIntPairVal.first = ECStack.size() - 1;
  ArgIndex.UIntPairVal.second = 0;
  **SetValue(&I, ArgIndex, SF);**   // should  set ArgIndex with I.getOperand(0)
}
```

The `Interpreter::visitVAArgInst` method get `ArgIndex` from ` VAArgInst.getOperand(0)` which is the `va_list` 

```
void Interpreter::visitVAArgInst(VAArgInst &I) {
  ExecutionContext &SF = ECStack.back();

  // Get the incoming valist parameter.  LLI treats the valist as a
  // (ec-stack-depth var-arg-index) pair.
  
  GenericValue VAList = getOperandValue(I.getOperand(0), SF);
 
  ......
  }
```
so the mismatch cause the crash. 

 
Another problem happen  in `Interpreter::visitVAArgInst` function is  the var `VAList` updated   did not set back. 


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


More information about the llvm-commits mailing list