[llvm-bugs] [Bug 34066] New: LICM segafaults on simple generated file (a lot of empty loops)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 4 07:25:43 PDT 2017


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

            Bug ID: 34066
           Summary: LICM segafaults on simple generated file (a lot of
                    empty loops)
           Product: libraries
           Version: 3.9
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: konstantin.vladimirov at gmail.com
                CC: llvm-bugs at lists.llvm.org

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.

-- 
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/20170804/b17c99c4/attachment.html>


More information about the llvm-bugs mailing list