Skip to content

more compact sequence of x86 movs generated when using -g #40314

@gregbedwell

Description

@gregbedwell
Bugzilla Link 40969
Version trunk
OS Linux
Blocks #37076
CC @cmtice,@echristo,@JDevlieghere,@walkerkd,@RKSimon,@pogo59,@vedantk

Extended Description

In response to this llvm-dev post: http://lists.llvm.org/pipermail/llvm-dev/2019-March/130779.html

Here is an example using the check-cfc tool ( https://github.com/llvm/llvm-project/tree/master/clang/utils/check_cfc ) to spot a codegen difference depending on whether -g is specified or not. The reduced source example is a little bit nasty as there's some dodgy looking pointer casting in there, but regardless the absence or presence of -g should not make a difference to generated code.

Here's my check_cfc.cfg file contents:

[Checks]
dash_g_no_change = true

and here it is in action:

$ clang -v
Check CFC, checking: dash_g_no_change
clang version 9.0.0 (trunk 355410) (llvm/trunk 355412)
Target: x86_64-scei-ps4
Thread model: posix
InstalledDir: E:\work\upstream-llvm\build-vs2015-ps4-ninja\bin

$ cat 1.cpp

using alpha = float __attribute__((ext_vector_type(4)));

void bravo(alpha charlie) {
  unsigned char *delta = (unsigned char *)&charlie;
  delta[0] = 0;
  volatile alpha echo = charlie;
}

$ clang -c 1.cpp -O2 -g -fno-strict-aliasing --target=x86_64-unknown-unknown
Check CFC, checking: dash_g_no_change
1.cpp Code difference detected with -g
--- c:\tmp\gnochange\example\tmp\tmp_v5akp.o

+++ c:\tmp\gnochange\example\tmp\tmpvhabwu.o

@@ -5,6 +5,6 @@

 0x00000001: 48 89 E5                mov      rbp,rsp
 0x00000004: 0F 29 45 F0             movaps   xmmword ptr [rbp-10h],xmm0
 0x00000008: C6 45 F0 00             mov      byte ptr [rbp-10h],0
-0x0000000C: 0F 28 45 F0             movaps   xmm0,xmmword ptr [rbp-10h]
-0x00000010: 0F 29 45 E0             movaps   xmmword ptr [rbp-20h],xmm0
-0x00000014: 5D                      pop      rbp
+0x0000000C: 8A 45 F0                mov      al,byte ptr [rbp-10h]
+0x0000000F: 88 45 E0                mov      byte ptr [rbp-20h],al
+0x00000012: 48 8B 45 F1             mov      rax,qword ptr [rbp-0Fh]
*** Diff truncated ***

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions