Skip to content

[fuzzDI] -O1 + -g cause the generated code to change. #36654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
llvmbot opened this issue May 1, 2018 · 13 comments
Closed

[fuzzDI] -O1 + -g cause the generated code to change. #36654

llvmbot opened this issue May 1, 2018 · 13 comments
Labels
bugzilla Issues migrated from bugzilla debuginfo

Comments

@llvmbot
Copy link
Member

llvmbot commented May 1, 2018

Bugzilla Link 37306
Resolution FIXED
Resolved on Sep 18, 2019 08:27
Version trunk
OS All
Blocks #37076
Reporter LLVM Bugzilla Contributor
CC @adrian-prantl,@chengniansun,@dwblaikie,@JDevlieghere,@pogo59,@zhendongsu,@vedantk

Extended Description

I'll update the bug title once this is triaged/analyzed.

/Users/dcci/work/llvm/build/bin/clang -Wno-everything try.c -O1 -o try-nodebug

$ cat red.c
b, a, c;
d() { return b; }
f(g) {
int e = d();
c && (a = e + g);
}
main() {}

Difference between text sections (with and without -g)

$ diff text-nodebug text-debug
3,4c3,4
< 100000f70 488d0591 00000083 3800741e 554889e5 H.......8.t.UH..
< 100000f80 535089fb e8d7ffff ff01d848 8d0d6e00 SP.........H..n.

100000f70 554889e5 535089fb 488d0589 00000083 UH..SP..H.......
100000f80 38007410 e8d7ffff ff01d848 8d0d6e00 8.t........H..n.

@pogo59
Copy link
Collaborator

pogo59 commented May 1, 2018

Diffing a disassembly might be more instructive. You can use
-ffunction-sections to keep size differences from introducing
too many spurious differences.

@llvmbot
Copy link
Member Author

llvmbot commented May 1, 2018

Only significant difference in codegen:

%bb.0: ## %entry

  • movq _c@GOTPCREL(%rip), %rax
  • cmpl $0, (%rax)
  • je LBB1_2
    +## %bb.1: ## %land.rhs
    pushq %rbp
    .cfi_def_cfa_offset 16
    .cfi_offset %rbp, -16
    @@ -39,46 +33,21 @@

@llvmbot
Copy link
Member Author

llvmbot commented May 1, 2018

This might be the same root cause of the PostRA one, but I haven't confirmed.

@chengniansun
Copy link

Hi Davide,

Is it a requirement to emit the same code for "-g" and no "-g"?

@adrian-prantl
Copy link
Collaborator

Is it a requirement to emit the same code for "-g" and no "-g"?

Yas.

@llvmbot
Copy link
Member Author

llvmbot commented May 1, 2018

It's a bug if debug informations change the code generated as debug informations have no semantic value associated.

@pogo59
Copy link
Collaborator

pogo59 commented May 1, 2018

Is it a requirement to emit the same code for "-g" and no "-g"?

Yas.

The principle here is that if "-g" changes the generated code, it can
potentially hide a bug. That is, you are not actually debugging the
exact same program that exhibited the bug you are looking for. One
hopes that the two versions of the program (i.e., with and without -g)
do have the same behavior, but it is far far better to know that you
are debugging the exact same program.

This is more of a problem for LLVM than some other compilers, because
LLVM introduces additional meta-instructions into the IR to help track
debugging information. This can affect optimization and code generation
passes that don't take care to ignore these extra instructions. Most
of the code-generation differences we find can be resolved by handling
the debug-info instructions correctly.

@chengniansun
Copy link

Thank you for the reply.

GCC has a similar policy (https://gcc.gnu.org/ml/gcc/2018-05/msg00011.html).

It would be interesting to test this requirement.

@llvmbot
Copy link
Member Author

llvmbot commented May 1, 2018

Thank you for the reply.

GCC has a similar policy (https://gcc.gnu.org/ml/gcc/2018-05/msg00011.html).

It would be interesting to test this requirement.

We have an ongoing effort in llvm (and, at least for me, swift), to find and squash the bugs which cause the differences.

@llvmbot
Copy link
Member Author

llvmbot commented Mar 6, 2019

Hi,

Whether this bug is resolved? Because I can't able to reproduce this issue with llvm 8.0.0 svn. I have compared the assembly code between "-O1" and "-O1 + g", I didn't saw any diff.

whether source is correct? I think the compiled source is try.c but mentioned
cat eats red.c.

Thanks

@llvmbot
Copy link
Member Author

llvmbot commented Sep 18, 2019

I could also not reproduce this issue with clang 10.0.0.

@pogo59
Copy link
Collaborator

pogo59 commented Sep 18, 2019

Resolving as FIXED, as two people have failed to reproduce with a more
recent LLVM.

@vedantk
Copy link
Collaborator

vedantk commented Nov 27, 2021

mentioned in issue #37076

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla debuginfo
Projects
None yet
Development

No branches or pull requests

5 participants