Issue 76939
Summary clang-16 introduces a repeat function call
Labels new issue
Assignees
Reporter Absoler
    Hi, here's the code. From what I can tell, func_35 should only be called once, but actually it executes twice in binary ( compiled witjh clang-16 -O2 ), once inlined and once directly called.

```
const int64_t func_1() {
    uint8_t *a;
 int32_t b[] = {};
    int16_t *c = &g_706;
    *c = *c | (func_16(5, g_21, a, g_21), g_638) < b ^ g_824 % -1L;
}
int16_t func_4(int64_t, int64_t, int32_t) {}
int32_t func_16(int32_t, int64_t, uint8_t *, uint8_t d) {
    int32_t *e;
    if (func_32(func_35(0, g_40), e), 2 / ***g_441)
        if (d)
        --g_729;
    ++g_778;
    return g;
}
int32_t func_32(uint8_t *p_33, int32_t *p_34) {
    uint64_t f[4][10][6];
    int g, h, i;
    for (g = 0; g < 4; g++)
 for (h = 0; h < 10; h++)
            for (i = 0; i < 6; i++)
 f[g][h][i] = 5;
    
    if (f[2][9][0]) {
        int32_t j;
        if (j) {
            int32_t k;
        }
    }
 return 0;
}
uint8_t *func_35(int16_t, uint8_t *) {
    int32_t l;
    int16_t *m = &g_256;
    g_52--;
    g_63--;
    int32_t *n = &l;
    g_77 = n;
    if (*m &= 7)
        g_21 = g_140;
 return &g_824;
}
```

the disassembly is:
```
0000000000001130 <func_1>:
func_1():
/root/storetest/test/output2.c:55
 1130:	push   %rbp
    1131:	push   %rbx
    1132:	push %rax
/root/storetest/test/output2.c:59
    1133:	movzwl 0x2f90(%rip),%ebx        # 40ca <g_706>
    113a:	movzbl 0x2eef(%rip),%ebp        # 4030 <g_21>
func_35():                  # ----------------------------------------- inline, first execution ----------------------------------------
/root/storetest/test/output2.c:89
 1141:	decl   0x2f45(%rip)        # 408c <g_52>
/root/storetest/test/output2.c:90
    1147:	decq   0x2f42(%rip) # 4090 <g_63>
    114e:	lea 0x4(%rsp),%rax
/root/storetest/test/output2.c:92
    1153:	mov %rax,0x2f3e(%rip)        # 4098 <g_77>
/root/storetest/test/output2.c:93
    115a:	andw $0x7,0x2f48(%rip)        # 40aa <g_256>
    1162:	je     1172 <func_1+0x42>
/root/storetest/test/output2.c:94
    1164:	movzwl 0x2f35(%rip),%eax        # 40a0 <g_140>
    116b:	mov    %ax,0x2ebe(%rip) # 4030 <g_21>
func_16():
/root/storetest/test/output2.c:64
 1172:	call   1270 <func_35>  # ---------------------------------------- direct call, second execution ----------------------------
```

I wonder how to understand this situation
[case.zip](https://github.com/llvm/llvm-project/files/13829063/case.zip)

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to