Issue |
100847
|
Summary |
The inconsistency in debug information produced with "-g -O2", "-g -O1", and "-g -O0".
|
Labels |
new issue
|
Assignees |
|
Reporter |
edumoot
|
The value of the structure variable **g_7** at line 36 varies depending on the compilation flags "-g -O0", "-g -O1", "-g -O2", and "-g O3".
In LLVM 18.1.8, binaries compiled with "-g -O0" and "-g -O1" both produce the same value for g_7 (`(S0) (f0 = 1901962039155879305, f1 = 0, f2 = 4799, f3 = -117, f4 = 4, f5 = 1)`), whereas this value differs from what are produced with "-g -O2" and "-g -O3" (`(S0) (f0 = 1, f1 = 3, f2 = -12892, f3 = 19, f4 = 1, f5 = 2)`). In contrast, in LLVM 17.0.6, binaries compiled with "-g -O1", "-g -O2", and "-g -O3" yield the same value for g_7 (`(S0) (f0 = 1, f1 = 3, f2 = -12892, f3 = 19, f4 = 1, f5 = 2)`), which is different from the value obtained with "-g -O0" (`(S0) (f0 = 1901962039155879305, f1 = 0, f2 = 4799, f3 = -117, f4 = 4, f5 = 1)`).
Reproducing them in LLVM18.1.8
```
clang -g -O0 case.c -o case_O0.out
clang -g -O1 case.c -o case_O1.out
clang -g -O2 case.c -o case_O2.out
clang -g -O3 case.c -o case_O3.out
lldb case_O0.out
b case.c:36
r
[...]
33 {
34 func_1();
35 csmith_sink_ = g_3;
-> 36 csmith_sink_ = g_5;
37 csmith_sink_ = g_7.f0;
38 csmith_sink_ = g_7.f1;
39 csmith_sink_ = g_7.f2;
(lldb) p g_7
(S0) (f0 = 1901962039155879305, f1 = 0, f2 = 4799, f3 = -117, f4 = 4, f5 = 1)
.
.
.
lldb case_O3.out
b case.c:36
r
[...]
33 {
34 func_1();
35 csmith_sink_ = g_3;
-> 36 csmith_sink_ = g_5;
37 csmith_sink_ = g_7.f0;
38 csmith_sink_ = g_7.f1;
39 csmith_sink_ = g_7.f2;
(lldb) p g_7
(S0) (f0 = 1, f1 = 3, f2 = -12892, f3 = 19, f4 = 1, f5 = 2)
```
```
cat case.c
#include "stdint.h"
volatile uint64_t csmith_sink_ = 0;
#pragma pack(push)
#pragma pack(1)
struct S0 {
uint64_t f0;
unsigned f1 : 8;
volatile signed f2 : 28;
volatile signed f3 : 14;
int32_t f4;
volatile uint64_t f5;
};
#pragma pack(pop)
static int32_t g_3 = 0x5ED06576L;
static uint16_t g_5 = 8UL;
static struct S0 g_6[1][7] = {{{0x1A652065C829ED89LL,0,4799,-117,4L,1UL},{0x1A652065C829ED89LL,0,4799,-117,4L,1UL},{0x1A652065C829ED89LL,0,4799,-117,4L,1UL},{0x1A652065C829ED89LL,0,4799,-117,4L,1UL},{0x1A652065C829ED89LL,0,4799,-117,4L,1UL},{0x1A652065C829ED89LL,0,4799,-117,4L,1UL},{0x1A652065C829ED89LL,0,4799,-117,4L,1UL}}};
static struct S0 g_7 = {1UL,3,-12892,19,1L,2UL};
static uint8_t func_1(void)
{
int32_t *l_2 = &g_3;
uint16_t *l_4 = &g_5;
(*l_2) |= 1L;
(*l_2) = (((*l_4) = g_3) && ((*l_2) , ((void*)0 != &g_3)));
g_7 = g_6[0][6];
return (*l_2);
}
int main (int argc, char* argv[])
{
func_1();
csmith_sink_ = g_3;
csmith_sink_ = g_5;
csmith_sink_ = g_7.f0;
csmith_sink_ = g_7.f1;
csmith_sink_ = g_7.f2;
csmith_sink_ = g_7.f3;
csmith_sink_ = g_7.f4;
csmith_sink_ = g_7.f5;
return 0;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs