diff options
author | ak <ak@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-08 23:41:38 +0000 |
---|---|---|
committer | ak <ak@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-08 23:41:38 +0000 |
commit | 5a5c1f812b36f728ab676db6b45242e1fc28e9a6 (patch) | |
tree | 8ffb6df62f9e66b086cef2af05cda842981860ed /gcc/tree-inline.c | |
parent | 786f817740a7dca966e5f49b0b4976b32d0be744 (diff) | |
download | gcc-5a5c1f812b36f728ab676db6b45242e1fc28e9a6.tar.gz |
Fix handling of very long asm statements in inliner
An auto generated program with a 6.4mio line asm statement gave
with 4.7 and 4.8:
xxx.c:6400017:1: internal compiler error: in account_size_time, at
ipa-inline-analysis.c:601
The problem is that the inliner counts the number of lines in the asm
statement and multiplies that with a weight. With the weight this
overflows 32bit signed int, and triggers an assert for negative time.
Fix this by limiting the number of lines to 1000 for asm cost
estimation. The RTL backend also does similar multiplications for
jump shortening. I haven't tried to address this, but presumably
it's less likely to result in a failure.
gcc/:
2013-09-08 Andi Kleen <ak@linux.intel.com>
* tree-inline.c (estimate_num_insns): Limit asm cost to 1000.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202374 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index af26c85150d..40eb3807119 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3744,7 +3744,14 @@ estimate_num_insns (gimple stmt, eni_weights *weights) return 0; case GIMPLE_ASM: - return asm_str_count (gimple_asm_string (stmt)); + { + int count = asm_str_count (gimple_asm_string (stmt)); + /* 1000 means infinity. This avoids overflows later + with very long asm statements. */ + if (count > 1000) + count = 1000; + return count; + } case GIMPLE_RESX: /* This is either going to be an external function call with one |