[llvm-bugs] [Bug 39433] New: CodeExtractor makes phi nodes with incoming values from the outlined function

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 25 10:37:04 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39433

            Bug ID: 39433
           Summary: CodeExtractor makes phi nodes with incoming values
                    from the outlined function
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: vsk at apple.com
                CC: llvm-bugs at lists.llvm.org

This test case is pulled from CodeExtractorTest.cpp (in unittests/).

```
    define i32 @foo(i32 %x, i32 %y, i32 %z) {
    header:
      %0 = icmp ugt i32 %x, %y
      br i1 %0, label %body1, label %body2

    body1:
      %1 = add i32 %z, 2
      br label %notExtracted

    body2:
      %2 = mul i32 %z, 7
      br label %notExtracted

    notExtracted:
      %3 = phi i32 [ %1, %body1 ], [ %2, %body2 ]
      %4 = add i32 %3, %x
      ret i32 %4
    }
```

When extracting body{1,2}, CE adds two reloads in the codeReplacer block:

```
  codeRepl:                                         ; preds = %header
    call void @foo_header.split(i32 %z, i32 %x, i32 %y, i32* %.loc, i32*
%.loc1)
    %.reload = load i32, i32* %.loc
    %.reload2 = load i32, i32* %.loc1
    br label %notExtracted
```

These reloads must flow into the notExtracted block:

```
  notExtracted:                                     ; preds = %codeRepl
    %0 = phi i32 [ %.reload, %codeRepl ], [ %.reload2, %body2 ]
```

The problem is that the PHI node in notExtracted now has an incoming
value from a BasicBlock that's in a different function.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181025/4014e4bf/attachment.html>


More information about the llvm-bugs mailing list