44 lines · python
1"""2Test PHI nodes work in the IR interpreter.3"""4 5 6import lldb7from lldbsuite.test.lldbtest import *8import lldbsuite.test.lldbutil as lldbutil9 10 11class IRInterpreterPHINodesTestCase(TestBase):12 def test_phi_node_support(self):13 """Test support for PHI nodes in the IR interpreter."""14 15 self.build()16 exe = self.getBuildArtifact("a.out")17 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)18 19 # Break on the first assignment to i20 line = line_number("main.cpp", "i = 5")21 lldbutil.run_break_set_by_file_and_line(22 self, "main.cpp", line, num_expected_locations=1, loc_exact=True23 )24 25 self.runCmd("run", RUN_SUCCEEDED)26 27 # The stop reason of the thread should be breakpoint28 self.expect(29 "thread list",30 STOPPED_DUE_TO_BREAKPOINT,31 substrs=["stopped", "stop reason = breakpoint"],32 )33 34 self.runCmd("s")35 36 # The logical 'or' causes a PHI node to be generated. Execute without JIT37 # to test that the interpreter can handle this38 self.expect("expr -j 0 -- i == 3 || i == 5", substrs=["true"])39 40 self.runCmd("s")41 self.expect("expr -j 0 -- i == 3 || i == 5", substrs=["false"])42 self.runCmd("s")43 self.expect("expr -j 0 -- i == 3 || i == 5", substrs=["true"])44