[Lldb-commits] [PATCH] D119734: [lldb] Add a positive test for `getelementptr` constant args

Andy Yankovsky via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 14 09:27:49 PST 2022


werat created this revision.
werat added a reviewer: shafik.
werat requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The IR interpreter supports const operands to the `GetElementPtr` IR
instruction, so it should be able to evaluate expression without JIT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119734

Files:
  lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
  lldb/test/API/lang/cpp/static_members/main.cpp


Index: lldb/test/API/lang/cpp/static_members/main.cpp
===================================================================
--- lldb/test/API/lang/cpp/static_members/main.cpp
+++ lldb/test/API/lang/cpp/static_members/main.cpp
@@ -15,6 +15,8 @@
   A my_a;
   my_a.m_a = 1;
 
+  int arr[2]{0};
+
   my_a.access(); // stop in main
   return 0;
 }
Index: lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
===================================================================
--- lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
+++ lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
@@ -71,3 +71,20 @@
         # Evaluating the expression via JIT should work fine.
         value = self.target().EvaluateExpression(expr)
         self.assertSuccess(value.GetError())
+
+    # We fail to lookup static members on Windows.
+    @expectedFailureAll(oslist=["windows"])
+    def test_IR_interpreter_can_handle_getelementptr_constants_args(self):
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// stop in main", lldb.SBFileSpec("main.cpp"))
+
+        # This expression contains the following IR code:
+        # ... getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
+        expr = "arr[0]"
+
+        # The IR interpreter supports const operands to the `GetElementPtr` IR
+        # instruction, so it should be able to evaluate expression without JIT.
+        opts = lldb.SBExpressionOptions()
+        opts.SetAllowJIT(False)
+        value = self.target().EvaluateExpression(expr, opts)
+        self.assertSuccess(value.GetError())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119734.408456.patch
Type: text/x-patch
Size: 1599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220214/ca5ce15a/attachment.bin>


More information about the lldb-commits mailing list