<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - LICM segafaults on simple generated file (a lot of empty loops)"
   href="https://bugs.llvm.org/show_bug.cgi?id=34066">34066</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LICM segafaults on simple generated file (a lot of empty loops)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>konstantin.vladimirov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Use clang 3.9.0

clang++ -v

clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Compile attached file with

clang++ -S -O2 out.c

You will see:

0  clang-4.0       0x00000000011c44d0
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 32
1  clang-4.0       0x00000000011c2285 llvm::sys::RunSignalHandlers() + 69
2  clang-4.0       0x00000000011c23bc
3  libpthread.so.0 0x00007ffff7bcf850
4  clang-4.0       0x000000000104d983
llvm::sinkRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::Loop*,
llvm::AliasSetTracker*, llvm::LoopSafetyInfo*,
llvm::OptimizationRemarkEmitter*) + 35
5  clang-4.0       0x000000000104da53
llvm::sinkRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::Loop*,
llvm::AliasSetTracker*, llvm::LoopSafetyInfo*,
llvm::OptimizationRemarkEmitter*) + 243
6  clang-4.0       0x000000000104da53
llvm::sinkRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::Loop*,
llvm::AliasSetTracker*, llvm::LoopSafetyInfo*,
llvm::OptimizationRemarkEmitter*) + 243
7  clang-4.0       0x000000000104da53
llvm::sinkRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::Loop*,
llvm::AliasSetTracker*, llvm::LoopSafetyInfo*,
llvm::OptimizationRemarkEmitter*) + 243

File is generated with following ruby script:

class IfNode
end

class ForNode
end

class LeafNode
end

class Node
  attr_reader :value
  attr_reader :childs

  def initialize(value, childs)
    @value = value
    @childs = childs
  end
end

def create_node(nlev)
  ret = nil
  if nlev > 0
    value = (rand(2) == 1 ? IfNode.new  : ForNode.new)
    nchilds = rand(10) + 1
    childs = Array.new(nchilds) {create_node(nlev-1)}
    ret = Node.new(value, childs)
  end
  ret = Node.new(LeafNode.new, nil) if ret.nil?
  ret
end

def print_node(n)
  unless n.value.is_a?(LeafNode)
    puts "if (true) {" if n.value.is_a?(IfNode)
    puts "for (int i = 1; i < 1000; ++i) {" if n.value.is_a?(ForNode)
    n.childs.map { |c| print_node c }
    puts "}"
  end
end

top = create_node(8)

puts "void foo() {"
print_node top
puts "}"

i.e. it is guaranteed to be 8 levels of nesting with no more then 11 childs for
each node.

GCC eats such output just fine.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>