Variables in Specified Registers

2009-08-07 Thread Sergey Senozhatsky
Hello,

Following code (written just for fun) leads to:

Program received signal SIGSEGV, Segmentation fault.
main () at main-general.cpp:95
95  printf("%d\n", x_reg);


BTW, there is warning when using ecx, eax, edx.
should there be any warning for esp?

GCC 4.4
X86

Compile flags: -g3 -O2
---

volatile register int x_reg asm ("esp");

int ff_()
{
x_reg = rand();
return x_reg;
}


int main()
{
x_reg = ff_();
x_reg++;
printf("%d\n", x_reg);

return 1;
}


Dump of assembler code for function _Z3ff_v:
0x080489c0 <_Z3ff_v+0>: push   %ebp
0x080489c1 <_Z3ff_v+1>: mov%esp,%ebp
0x080489c3 <_Z3ff_v+3>: sub$0x8,%esp
0x080489c6 <_Z3ff_v+6>: call   0x80487a4 
0x080489cb <_Z3ff_v+11>:mov%eax,%esp
0x080489cd <_Z3ff_v+13>:mov%esp,%eax
0x080489cf <_Z3ff_v+15>:leave  
0x080489d0 <_Z3ff_v+16>:ret

(gdb) disassemble main
Dump of assembler code for function main:
0x080489e0 :push   %ebp
0x080489e1 :mov%esp,%ebp
0x080489e3 :and$0xfff0,%esp
0x080489e6 :sub$0x10,%esp
0x080489e9 :call   0x80489c0 <_Z3ff_v>
0x080489ee :   lea0x1(%eax),%esp
0x080489f1 :   mov%esp,0x4(%esp)
0x080489f5 :   movl   $0x8048bd0,(%esp)
0x080489fc :   call   0x8048774<<
0x08048a01 :   mov$0x1,%eax
0x08048a06 :   leave  
0x08048a07 :   ret



Sergey

signature.asc
Description: Digital signature


[gcc 10-20190728] internal compiler error: in speculative_call_info, at cgraph.c:1114

2019-07-28 Thread Sergey Senozhatsky
Hi,

While compiling gcc-10-20190728 snapshot:

src/gcc-10-20190728/gcc/tree-ssa-sccvn.c:7323:1: internal compiler error: in 
speculative_call_info, at cgraph.c:1114
 7323 | }
  | ^
0x5d34b9 cgraph_edge::speculative_call_info(cgraph_edge*&, cgraph_edge*&, 
ipa_ref*&)
/home/ss/gcc10/src/gcc-10-20190728/gcc/cgraph.c:1114
0x84121c cgraph_edge::resolve_speculation(tree_node*)
/home/ss/gcc10/src/gcc-10-20190728/gcc/cgraph.c:1155
0x841620 cgraph_edge::make_direct(cgraph_node*)
/home/ss/gcc10/src/gcc-10-20190728/gcc/cgraph.c:1215
0xa1248e ipa_make_edge_direct_to_target(cgraph_edge*, tree_node*, bool)
/home/ss/gcc10/src/gcc-10-20190728/gcc/ipa-prop.c:2978
0x13a2ee9 ipcp_discover_new_direct_edges
/home/ss/gcc10/src/gcc-10-20190728/gcc/ipa-cp.c:3347
0x13a2ee9 create_specialized_node
/home/ss/gcc10/src/gcc-10-20190728/gcc/ipa-cp.c:3913
0x13abf99 decide_whether_version_node
/home/ss/gcc10/src/gcc-10-20190728/gcc/ipa-cp.c:4803
0x13abf99 ipcp_decision_stage
/home/ss/gcc10/src/gcc-10-20190728/gcc/ipa-cp.c:4915
0x13abf99 ipcp_driver
/home/ss/gcc10/src/gcc-10-20190728/gcc/ipa-cp.c:5092
0x13abf99 execute
/home/ss/gcc10/src/gcc-10-20190728/gcc/ipa-cp.c:5183

-ss