[Lldb-commits] [lldb] 2e0ef17 - [lldb] Add a positive test for `getelementptr` constant args

Andy Yankovsky via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 14 10:04:51 PST 2022


Author: Andy Yankovsky
Date: 2022-02-14T18:04:37Z
New Revision: 2e0ef179d8838de06bf694ae6ca43c2b24847a8c

URL: https://github.com/llvm/llvm-project/commit/2e0ef179d8838de06bf694ae6ca43c2b24847a8c
DIFF: https://github.com/llvm/llvm-project/commit/2e0ef179d8838de06bf694ae6ca43c2b24847a8c.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
index 7cb4c51b02b3..85ebd5fe6853 100644
--- a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
+++ b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
@@ -71,3 +71,20 @@ def test_no_crash_in_IR_arithmetic(self):
         # 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())

diff  --git a/lldb/test/API/lang/cpp/static_members/main.cpp b/lldb/test/API/lang/cpp/static_members/main.cpp
index 87ea6aa87747..df11c4c5cf7e 100644
--- a/lldb/test/API/lang/cpp/static_members/main.cpp
+++ b/lldb/test/API/lang/cpp/static_members/main.cpp
@@ -15,6 +15,8 @@ int main() {
   A my_a;
   my_a.m_a = 1;
 
+  int arr[2]{0};
+
   my_a.access(); // stop in main
   return 0;
 }


        


More information about the lldb-commits mailing list