LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1197 - switch lowering infinitely loops, chews memory.
Summary: switch lowering infinitely loops, chews memory.
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: 1.9
Hardware: All All
: P normal
Assignee: Chris Lattner
URL:
Keywords: compile-fail
Depends on:
Blocks:
 
Reported: 2007-02-12 16:03 PST by Duncan Sands
Modified: 2010-02-22 12:51 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
bytecode obtained by compiling gcc/ada/exp_attr.adb (77.08 KB, application/octet-stream)
2007-02-12 16:05 PST, Duncan Sands
Details
bugpoint reduced bytecode (1.45 KB, application/octet-stream)
2007-02-12 18:07 PST, Duncan Sands
Details
Same attachment as assembly (5.87 KB, text/plain)
2007-02-12 18:52 PST, Reid Spencer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan Sands 2007-02-12 16:03:36 PST
The following llvm bytecode file causes llc
to eat up all memory on my machine then die.
To reproduce, run as follows:
 llc exp_attr.bc
This is not x86 specific, since
 llc -march=ppc32 exp_attr.bc
also uses up vast (maybe infinite) amounts
of memory.  However the C backend works ok.
I'll attach the bytecode file in a second.
Comment 1 Duncan Sands 2007-02-12 16:05:43 PST
Created attachment 655 [details]
bytecode obtained by compiling gcc/ada/exp_attr.adb
Comment 2 Duncan Sands 2007-02-12 18:07:22 PST
Created attachment 656 [details]
bugpoint reduced bytecode

The reduced test-case consists of nothing more than a switch statement!
Yet the code generators continue to use up all memory and die.
Comment 3 Reid Spencer 2007-02-12 18:52:56 PST
Created attachment 657 [details]
Same attachment as assembly
Comment 4 Chris Lattner 2007-02-12 18:55:06 PST
testing a patch
Comment 5 Chris Lattner 2007-02-12 19:06:58 PST
Fixed.  Testcase here: test/CodeGen/Generic/switch-lower.ll

Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070212/044404.html

-Chris
Comment 6 Anton Korobeynikov 2007-02-21 05:31:10 PST
switch lowering is still broken somehow.

Consider the folowing code:

define i32 @main(i32 %argc, i8** %argv) {
old_entry1:
        br label %cond_next
cond_next:
        %not.tmp14 = icmp slt i32 %argc, 11
        %hvar2 = zext i1 %not.tmp14 to i32
        switch i32 %hvar2, label %old_entry [
                 i32 -2, label %cond_true
                 i32 -1, label %cond_next
                 i32 0, label %cond_true15
                 i32 1, label %cond_next22
        ]
cond_true15:
        ret i32 1
cond_true:
        ret i32 2
cond_next22:
        ret i32 3
old_entry:
        ret i32 4
}

(Yes, I know, that cases -1 and -2 are really dead).

Resulting binary will always produce result code 4. Commenting out "-1" and "-2"
cases will fix the problem.
Comment 7 Chris Lattner 2007-02-23 19:29:15 PST
Moving new bug to a new bugzilla: Bug 1219.

The original issue is fixed.

-Chris