summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes
diff options
context:
space:
mode:
authorMarianne Mailhot-Sarrasin <marianne.mailhot.sarrasin@gmail.com>2016-05-12 20:00:53 +0000
committerMarianne Mailhot-Sarrasin <marianne.mailhot.sarrasin@gmail.com>2016-05-12 20:00:53 +0000
commit3fe71581743ceb838b113ee728e6de7f7ee8d25d (patch)
treec87db2d9a24ac05559c2a4b0da0e8cb2d4e1b06d /lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes
parentbc8397cdf0a76c614e53dc1deede78b0e568f753 (diff)
downloadbcm5719-llvm-3fe71581743ceb838b113ee728e6de7f7ee8d25d.tar.gz
bcm5719-llvm-3fe71581743ceb838b113ee728e6de7f7ee8d25d.zip
[LLDB] Added support for PHI nodes to IR interpreter
This allows expressions such as 'i == 1 || i == 2` to be executed using the IR interpreter, instead of relying on JIT code injection (which may not be available on some platforms). Patch by cameron314 Differential Revision: http://reviews.llvm.org/D19124 llvm-svn: 269340
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes')
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py40
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp17
2 files changed, 57 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py b/lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py
new file mode 100644
index 00000000000..c4f17670322
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py
@@ -0,0 +1,40 @@
+"""
+Test PHI nodes work in the IR interpreter.
+"""
+
+import os, os.path
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class IRInterpreterPHINodesTestCase(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_phi_node_support(self):
+ """Test support for PHI nodes in the IR interpreter."""
+
+ self.build()
+ exe = os.path.join(os.getcwd(), 'a.out')
+ self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break on the first assignment to i
+ line = line_number('main.cpp', 'i = 5')
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp', line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd('run', RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint
+ self.expect('thread list', STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped', 'stop reason = breakpoint'])
+
+ self.runCmd('s')
+
+ # The logical 'or' causes a PHI node to be generated. Execute without JIT
+ # to test that the interpreter can handle this
+ self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['true'])
+
+ self.runCmd('s')
+ self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['false'])
+ self.runCmd('s')
+ self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['true'])
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp b/lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp
new file mode 100644
index 00000000000..b144f9cc1b4
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp
@@ -0,0 +1,17 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+ int i;
+ i = 5;
+ i = 2;
+ i = 3;
+ return 0;
+}
OpenPOWER on IntegriCloud