Skip to content

Different codegen with/without -g #41483

@llvmbot

Description

@llvmbot
Bugzilla Link 42138
Resolution FIXED
Resolved on Jan 13, 2021 13:34
Version trunk
OS Linux
Blocks #37076
Reporter LLVM Bugzilla Contributor
CC @gregbedwell,@MaskRay,@JDevlieghere,@jmorse,@walkerkd,@pogo59,@vedantk

Extended Description

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.

$ cat PowerParser.ii.cc

template <typename, typename = int> class e;
class allocator {
public:
~allocator();
};
template <typename, typename> class e {
public:
e(char *, allocator = allocator());
};
template <typename b, typename c, typename d> bool operator==(e<c, d>, b);
class f {
public:
f(int *, int *, int *, int, int, int, int);
e g();
void j();
};
int h, i;
class k {
void l();
bool m_fn4();
int m;
int n;
int q;
int fmap;
};
void k::l() {
e o = "";
for (;;) {
int p = 0;
for (;;) {
if (m_fn4())
break;
f a(&q, &fmap, &m, n, h, i, 0);
if (a.g() == "")
a.j();
}
}
}

$ ./llvm-project/clang/utils/check_cfc/clang++ PowerParser.ii.cc -w -c -O1 -o tmp.ll

Check CFC, checking: dash_g_no_change
PowerParser.ii.cc Code difference detected with -g
--- /tmp/tmpcdg_LH.o

+++ /tmp/tmpfkaPkW.o

@@ -19,6 +19,6 @@

28: 4c 8d 73 08 lea 0x8(%rbx),%r14
2c: 4c 8d 7b 0c lea 0xc(%rbx),%r15
30: 4c 8d 64 24 08 lea 0x8(%rsp),%r12

  • 35: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
  • 3c: 00 00 00
  • 3f: 90 nop
  • 35: eb 09 jmp 40 <_ZN1k1lEv+0x40>
  • 37: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1)
  • 3e: 00 00
    *** Diff truncated ***

Metadata

Metadata

Assignees

No one assigned

    Labels

    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