Forum > Embedded - ARM

Problem with optimization -O2

(1/2) > >>

devport:
Hello,
I have a problem with the compiler.
I write quite extensive code and I encountered a problem with "optimization". If I use -O2 optimization, the problem occurs, if I don't use optimization, the problem is gone.

Maybe you will advise how to find out where the problem is?

A few tips I have noticed:
- There is a problem with the procedural procedure
- if I don't use the last third variable, it works fine
- if I use this variable, the data changed in this procedure do not affect the outside.

Now some code:
1. In file project_eth.lpr in the loop calling SocketProcess(data_buf) from ethernet.pas.
2. In SocketProcess calling ETH_Process from 117 line
3. ETH_Process calling ETH_Process_Frame from 99 line
4. ETH_Process_Frame calling ETH_Protocol_IP from ETH_Process_Frame (55 line)
5. ETH_Protocol_IP_TCP calling socket^.recv_func from line 341

socket^.recv_func it contains the address  server_recv80 procedure
the procedure is performed but has no effect on external variables.

if use variable "rcv_size" in server_recv80 procedure, that server_recv80 not change data with the help of SocketSendData(tcb_id, @snd_buff[0], size);  <<< ---- write the addres snd_buff and write size to TCB
  SocketClose(tcb_id);   <<< ---- Set flag = FLAG_FIN in TCB

I test this with code after calling this procedure in ethernet_ip_tcp.pas line 342

I no use optimization in FPC, all calling OK and code from 342 line is true.

my question is what makes the same code after -O2 optimization not work.
Or why if I use the -O2 optimization and comment the code from line 84-95, it also works correctly.

how to find it?

In lib directory asm in non -O2 version, and -O2 version

Link to sources : https://github.com/devport/LPC1114

Sorry for the english, written with the help of google translator

Laksen:
Which compiler version are you using?

devport:
Free Pascal Compiler version 3.3.1

Compiler date      : 2019/12/22
Compiler CPU target: arm

No tested last sources..

julkas:
Read https://forum.lazarus.freepascal.org/index.php/topic,47649.0.html

devport:
the difference is that I won't get any warning message
the code compiles correctly

I tested last trunk and the error still occurs.

For Target ARM source from
https://bugs.freepascal.org/view.php?id=36242
compiled no bugs

I tried to reproduce my problem on simple code, but everything works.

Navigation

[0] Message Index

[#] Next page

Go to full version