I have created two new function as below without any return statement.
As per int function not having return statement.
The return value in this case, depending on the exact platform, will likely be whatever random value happened to be left in the return register (e.g. EAX on x86) at the assembly level. Not explicitly returning a value is allowed, but gives an undefined value.
int test()
{
}
int caller()
{
test();
}
Command: gcc test.c -o test -c -O2 -fno-tree-vectorize && objdump -d test -r -M intel
0000000000000000 <test>:
0: f3 c3 repz ret
2: 66 66 66 66 66 2e 0f data32 data32 data32 data32 nop WORD PTR cs:[rax+rax*1+0x0]
9: 1f 84 00 00 00 00 00
0000000000000010 <caller>:
10: f3 c3 repz ret
Now why do I have repz ret
statement incase of test
function?
I have gone through What does rept mean?
But what kind of branch prediction issue is here so that repz ret
was needed.