[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:13:50 PST 2025


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

Run `lli` comand with the flag `-force-interpreter=true` to execute bytecode, if `lli` run `variable arguments` function in the bytecode, it will crash.
Fix #173718

>From 6da5e385283e4c50177c8f08a12289b73b28e755 Mon Sep 17 00:00:00 2001
From: fushijian <fsjzzu at 126.com>
Date: Sat, 27 Dec 2025 20:07:29 +0800
Subject: [PATCH] [lli] fix lli crash when run variable arguments function as a
 interpret

---
 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
index 2d69edef878e6..02ec403807861 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -1084,7 +1084,7 @@ void Interpreter::visitVAStartInst(VAStartInst &I) {
   GenericValue ArgIndex;
   ArgIndex.UIntPairVal.first = ECStack.size() - 1;
   ArgIndex.UIntPairVal.second = 0;
-  SetValue(&I, ArgIndex, SF);
+  SetValue(I.getArgList(), ArgIndex, SF);
 }
 
 void Interpreter::visitVAEndInst(VAEndInst &I) {
@@ -1731,7 +1731,8 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
 
   // 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);
+  Value *V = I.getOperand(0);
+  GenericValue VAList = getOperandValue(V, SF);
   GenericValue Dest;
   GenericValue Src = ECStack[VAList.UIntPairVal.first]
                       .VarArgs[VAList.UIntPairVal.second];
@@ -1751,8 +1752,9 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
   // Set the Value of this Instruction.
   SetValue(&I, Dest, SF);
 
-  // Move the pointer to the next vararg.
+  // Move the pointer to the next vararg and set new value back.
   ++VAList.UIntPairVal.second;
+  SetValue(V, VAList, SF);
 }
 
 void Interpreter::visitExtractElementInst(ExtractElementInst &I) {



More information about the llvm-commits mailing list