Skip to content

Commit 2e0ef17

Browse files
committed
[lldb] Add a positive test for getelementptr constant args
The IR interpreter supports const operands to the `GetElementPtr` IR instruction, so it should be able to evaluate expression without JIT. Follow up to https://reviews.llvm.org/D113498 Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D119734
1 parent 16fcc2f commit 2e0ef17

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,20 @@ def test_no_crash_in_IR_arithmetic(self):
7171
# Evaluating the expression via JIT should work fine.
7272
value = self.target().EvaluateExpression(expr)
7373
self.assertSuccess(value.GetError())
74+
75+
# We fail to lookup static members on Windows.
76+
@expectedFailureAll(oslist=["windows"])
77+
def test_IR_interpreter_can_handle_getelementptr_constants_args(self):
78+
self.build()
79+
lldbutil.run_to_source_breakpoint(self, "// stop in main", lldb.SBFileSpec("main.cpp"))
80+
81+
# This expression contains the following IR code:
82+
# ... getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
83+
expr = "arr[0]"
84+
85+
# The IR interpreter supports const operands to the `GetElementPtr` IR
86+
# instruction, so it should be able to evaluate expression without JIT.
87+
opts = lldb.SBExpressionOptions()
88+
opts.SetAllowJIT(False)
89+
value = self.target().EvaluateExpression(expr, opts)
90+
self.assertSuccess(value.GetError())

lldb/test/API/lang/cpp/static_members/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ int main() {
1515
A my_a;
1616
my_a.m_a = 1;
1717

18+
int arr[2]{0};
19+
1820
my_a.access(); // stop in main
1921
return 0;
2022
}

0 commit comments

Comments
 (0)