[llvm] [llubi] Reset retval for noop inline asm (PR #230849)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 10 13:06:37 PDT 2026
https://github.com/dtcxzyw created https://github.com/llvm/llvm-project/pull/230849
When a call is followed by a call to noop inline asm, `setResult` inside `returnFromCallee` will reuse the previous return value (moved) and trigger assertions.
The test is generated by DeepSeek-V4.1-Flash.
>From 4da60984bff48414377447fe1a6e0e0c113bd6b8 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: Sun, 11 Oct 2026 04:02:26 +0800
Subject: [PATCH] [llubi] Reset retval for noop inline asm
---
llvm/test/tools/llubi/controlflow.ll | 2 ++
llvm/tools/llubi/lib/Interpreter.cpp | 1 +
2 files changed, 3 insertions(+)
diff --git a/llvm/test/tools/llubi/controlflow.ll b/llvm/test/tools/llubi/controlflow.ll
index dd2f91e79713e..d92edfcf4bb43 100644
--- a/llvm/test/tools/llubi/controlflow.ll
+++ b/llvm/test/tools/llubi/controlflow.ll
@@ -93,6 +93,7 @@ next1:
]
next2:
+ call i32 @llvm.ctpop.i32(i32 0)
; call blackbox
call void asm sideeffect "", ""()
; invoke blackbox
@@ -225,6 +226,7 @@ exit:
; CHECK-NEXT: switch i32 %result_recursive, label %next2 [
; CHECK-NEXT: i32 0, label %exit
; CHECK-NEXT: ] jump to %next2
+; CHECK-NEXT: %1 = call i32 @llvm.ctpop.i32(i32 0) => i32 0
; CHECK-NEXT: call void asm sideeffect "", ""()
; CHECK-NEXT: invoke void asm sideeffect "", ""()
; CHECK-NEXT: to label %next3 unwind label %cleanup
diff --git a/llvm/tools/llubi/lib/Interpreter.cpp b/llvm/tools/llubi/lib/Interpreter.cpp
index 1154804b10d23..34d26eaae5879 100644
--- a/llvm/tools/llubi/lib/Interpreter.cpp
+++ b/llvm/tools/llubi/lib/Interpreter.cpp
@@ -2141,6 +2141,7 @@ class InstExecutor : public InstVisitor<InstExecutor, void>,
Value *CalledOperand = CB.getCalledOperand();
if (isNoopInlineAsm(CalledOperand, CB.getType())) {
CurrentFrame->ResolvedCallee = nullptr;
+ CurrentFrame->CalleeRetVal = AnyValue();
returnFromCallee();
return;
}
More information about the llvm-commits
mailing list