Bug 42941 - -fsched-pressure -fschedule-insns - valgrind warns about using uninitialized variable
Summary: -fsched-pressure -fschedule-insns - valgrind warns about using uninitialized ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-02-02 21:30 UTC by Zdenek Sojka
Modified: 2010-03-13 02:51 UTC (History)
2 users (show)

See Also:
Host: x86(_64)-pc-linux-gnu
Target: x86(_64)-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
valgrind output for less trivial testcase (3.29 KB, text/plain)
2010-02-02 21:32 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-02-02 21:30:08 UTC
Command line:
gcc -fsched-pressure -fschedule-insns -c testcase.c

Tested revisions:
r156367 - fail

------- testcase.c --------
int foo(void)
{
	return 0;
}
---------------------------

Output:
$ valgrind --track-origins=yes /mnt/svn/gcc-trunk/binary-156367-lto/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/cc1plus -fsched-pressure -fschedule-insns testcase.c 
==15355== Memcheck, a memory error detector
==15355== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==15355== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==15355== Command: /mnt/svn/gcc-trunk/binary-156367-lto/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/cc1plus -fsched-pressure -fschedule-insns testcase.c
==15355==                                                                                                                                              
 int foo()                                                                                                                                             
Analyzing compilation unit                                                                                                                             
Performing interprocedural optimizations                                                                                                               
 <visibility> <*free_lang_data> <early_local_cleanups> <whole-program> <inline>Assembling functions:                                                   
 int foo()==15355== Conditional jump or move depends on uninitialised value(s)                                                                         
==15355==    at 0xD35F88: setup_insn_max_reg_pressure (haifa-sched.c:1597)                                                                             
==15355==    by 0x8A9C5F: schedule_insns (sched-rgn.c:2965)                                                                                            
==15355==    by 0x8A9DFD: rest_of_handle_sched (sched-rgn.c:3512)                                                                                      
==15355==    by 0x84FEEA: execute_one_pass (passes.c:1561)                                                                                             
==15355==    by 0x850174: execute_pass_list (passes.c:1616)                                                                                            
==15355==    by 0x850186: execute_pass_list (passes.c:1617)                                                                                            
==15355==    by 0x945C34: tree_rest_of_compilation (tree-optimize.c:413)                                                                               
==15355==    by 0xAC70A0: cgraph_expand_function (cgraphunit.c:1543)                                                                                   
==15355==    by 0xAC7E1F: cgraph_output_in_order (cgraphunit.c:1719)                                                                                   
==15355==    by 0xAC9E4E: cgraph_optimize (cgraphunit.c:1867)                                                                                          
==15355==    by 0xACA024: cgraph_finalize_compilation_unit (cgraphunit.c:1093)                                                                         
==15355==    by 0x54E4DA: cp_write_global_declarations (decl2.c:3798)                                                                                  
==15355==  Uninitialised value was created by a heap allocation                                                                                        
==15355==    at 0x4C280AC: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)                                                           
==15355==    by 0xDE78D7: xmalloc (xmalloc.c:147)                                                                                                      
==15355==    by 0xD7CD78: sched_analyze_insn (sched-deps.c:2036)                                                                                       
==15355==    by 0xD7D294: deps_analyze_insn (sched-deps.c:3248)                                                                                        
==15355==    by 0xD7DA43: sched_analyze (sched-deps.c:3398)                                                                                            
==15355==    by 0x8A819D: sched_rgn_compute_dependencies (sched-rgn.c:2726)                                                                            
==15355==    by 0x8A9827: schedule_insns (sched-rgn.c:2938)                                                                                            
==15355==    by 0x8A9DFD: rest_of_handle_sched (sched-rgn.c:3512)                                                                                      
==15355==    by 0x84FEEA: execute_one_pass (passes.c:1561)                                                                                             
==15355==    by 0x850174: execute_pass_list (passes.c:1616)                                                                                            
==15355==    by 0x850186: execute_pass_list (passes.c:1617)                                                                                            
==15355==    by 0x945C34: tree_rest_of_compilation (tree-optimize.c:413)                                                                               
==15355==                                                                                                                                              
==15355== Conditional jump or move depends on uninitialised value(s)                                                                                   
==15355==    at 0xD35F88: setup_insn_max_reg_pressure (haifa-sched.c:1597)                                                                             
==15355==    by 0xD3BE48: schedule_insn (haifa-sched.c:1632)                                                                                           
==15355==    by 0xD3E9D0: schedule_block (haifa-sched.c:3143)                                                                                          
==15355==    by 0x8A9B09: schedule_insns (sched-rgn.c:3001)                                                                                            
==15355==    by 0x8A9DFD: rest_of_handle_sched (sched-rgn.c:3512)                                                                                      
==15355==    by 0x84FEEA: execute_one_pass (passes.c:1561)                                                                                             
==15355==    by 0x850174: execute_pass_list (passes.c:1616)                                                                                            
==15355==    by 0x850186: execute_pass_list (passes.c:1617)                                                                                            
==15355==    by 0x945C34: tree_rest_of_compilation (tree-optimize.c:413)                                                                               
==15355==    by 0xAC70A0: cgraph_expand_function (cgraphunit.c:1543)                                                                                   
==15355==    by 0xAC7E1F: cgraph_output_in_order (cgraphunit.c:1719)                                                                                   
==15355==    by 0xAC9E4E: cgraph_optimize (cgraphunit.c:1867)                                                                                          
==15355==  Uninitialised value was created by a heap allocation                                                                                        
==15355==    at 0x4C280AC: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)                                                           
==15355==    by 0xDE78D7: xmalloc (xmalloc.c:147)                                                                                                      
==15355==    by 0xD7CD78: sched_analyze_insn (sched-deps.c:2036)                                                                                       
==15355==    by 0xD7D294: deps_analyze_insn (sched-deps.c:3248)                                                                                        
==15355==    by 0xD7DA43: sched_analyze (sched-deps.c:3398)                                                                                            
==15355==    by 0x8A819D: sched_rgn_compute_dependencies (sched-rgn.c:2726)                                                                            
==15355==    by 0x8A9827: schedule_insns (sched-rgn.c:2938)                                                                                            
==15355==    by 0x8A9DFD: rest_of_handle_sched (sched-rgn.c:3512)                                                                                      
==15355==    by 0x84FEEA: execute_one_pass (passes.c:1561)                                                                                             
==15355==    by 0x850174: execute_pass_list (passes.c:1616)                                                                                            
==15355==    by 0x850186: execute_pass_list (passes.c:1617)                                                                                            
==15355==    by 0x945C34: tree_rest_of_compilation (tree-optimize.c:413)                                                                               
==15355==                                                                                                                                              
With more complicated code more warnings are issued. I wasn't able to cause difference in code generated with different --malloc-fill.
Comment 1 Zdenek Sojka 2010-02-02 21:32:25 UTC
Created attachment 19791 [details]
valgrind output for less trivial testcase

Generally, compiling any non-trivial file gives similiar output.
With --malloc-fill=0xff, far less warnings are generated.
Comment 2 Richard Biener 2010-02-03 10:40:26 UTC
Vlad?
Comment 3 Vladimir Makarov 2010-02-03 18:57:09 UTC
  This is a rare case when the algorithm works the same whatever values are in memory.  Roughly speaking, if the value is not as expected (for example a garbage) the value is set up to what it needed.  If it is one as expected we do nothing and have the same result.  Valgrind warns because the data is not initialized.

  I'll submit a patch soon for initialization of the values.  The compiler will work absolutely the same (may be a bit slower because of the initialization) but there will be no valgrind warnings which will simplify compiler debugging 
by valgrind.
Comment 4 Vladimir Makarov 2010-02-03 19:01:48 UTC
Subject: Bug 42941

Author: vmakarov
Date: Wed Feb  3 19:01:31 2010
New Revision: 156472

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156472
Log:
2010-02-03  Vladimir Makarov  <vmakarov@redhat.com>

	PR rtl-optimizations/42941
	* sched-deps.c (setup_insn_reg_pressure_info): Use xcalloc instead
	of xmalloc.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sched-deps.c

Comment 5 Andrew Pinski 2010-02-07 20:57:40 UTC
Fixed.
Comment 6 Andrew Pinski 2010-03-13 02:51:43 UTC
*** Bug 43332 has been marked as a duplicate of this bug. ***