[llvm-bugs] [Bug 50427] New: Emitted binary code changes when -g is enabled at -O1

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 20 20:59:50 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50427

            Bug ID: 50427
           Summary: Emitted binary code changes when -g is enabled at -O1
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tlwang at uwaterloo.ca
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

The .text section for the following program (transformed_program0.c) changes
after toggling the -g flag.

$ cat transformed_program0.c
int a;
char b, c;
short d() {
  {
    int e;
  f:;
    int g = b != 7;
    if (!g)
      goto h;
    if (!a)
      goto i;
    return a;
  i:
    b = b + 1;
    goto f;
  h:;
  }
  return c;
}
int main() {}
$
$ /home/cnsun/usr/bin/clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
ac06f6d06de408c00923708dd8a795b6ba9d23d7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ /home/cnsun/usr/bin/clang-trunk -O1 -w transformed_program0.c ; objdump
--disassemble a.out > "no-g.txt"
$ /home/cnsun/usr/bin/clang-trunk -O1 -g -w transformed_program0.c ; objdump
--disassemble a.out > "g.txt"
$ diff g.txt no-g.txt
104c104
<   401120:     eb 28                   jmp    40114a <d+0x3a>
---
>   401120:	eb 27                	jmp    401149 <d+0x39>
106c106
<   401128:     80 c2 f9                add    $0xf9,%dl
---
>   401128:	80 c2 01             	add    $0x1,%dl
109,123c109,122
<   401132:     75 14                   jne    401148 <d+0x38>
<   401134:     8d 4a 08                lea    0x8(%rdx),%ecx
<   401137:     88 0d ef 2e 00 00       mov    %cl,0x2eef(%rip)        # 40402c
<b>
<   40113d:     fe c2                   inc    %dl
<   40113f:     0f 94 c1                sete   %cl
<   401142:     84 d2                   test   %dl,%dl
<   401144:     75 ea                   jne    401130 <d+0x20>
<   401146:     eb 02                   jmp    40114a <d+0x3a>
<   401148:     89 c1                   mov    %eax,%ecx
<   40114a:     0f be 05 e3 2e 00 00    movsbl 0x2ee3(%rip),%eax        #
404034 <c>
<   401151:     84 c9                   test   %cl,%cl
<   401153:     0f 44 c6                cmove  %esi,%eax
<   401156:     c3                      retq
<   401157:     66 0f 1f 84 00 00 00    nopw   0x0(%rax,%rax,1)
<   40115e:     00 00
---
>   401132:	75 13                	jne    401147 <d+0x37>
>   401134:	88 15 f2 2e 00 00    	mov    %dl,0x2ef2(%rip)        # 40402c <b>
>   40113a:	80 c2 01             	add    $0x1,%dl
>   40113d:	80 fa 08             	cmp    $0x8,%dl
>   401140:	0f 94 c1             	sete   %cl
>   401143:	75 eb                	jne    401130 <d+0x20>
>   401145:	eb 02                	jmp    401149 <d+0x39>
>   401147:	89 c1                	mov    %eax,%ecx
>   401149:	0f be 05 e4 2e 00 00 	movsbl 0x2ee4(%rip),%eax        # 404034 <c>
>   401150:	84 c9                	test   %cl,%cl
>   401152:	0f 44 c6             	cmove  %esi,%eax
>   401155:	c3                   	retq
>   401156:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
>   40115d:	00 00 00

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210521/b0f6a047/attachment.html>


More information about the llvm-bugs mailing list