Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

ICE when compiling with -g3 at -O0 #51450

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52483
Status NEW
Importance P enhancement
Reported by Theodore Wang (tlwang@uwaterloo.ca)
Reported on 2021-11-11 18:35:24 -0800
Last modified on 2021-11-12 10:43:12 -0800
Version trunk
Hardware PC All
CC cnsun@uwaterloo.ca, craig.topper@gmail.com, dblaikie@gmail.com, jeremy.morse.llvm@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, paul_robinson@playstation.sony.com, pengfei.wang@intel.com, spatel+llvm@rotateright.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The following program compiles at -O0 without -g3, but ICE's when you add the -
g3 flag.

$ clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
3330a6670ee8d725f16c61fa127ba93613f1fc1f)
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
$
$ cat line_program-234c9c.c
a() {
  for (;; 1)
# 0
  {
  }
}
main() {}
$
$ clang-trunk -w -O0 -g3 line_program-234c9c.c
cannot have column info without line info
!15 = distinct !DILexicalBlock(scope: !16, file: !1, column: 3)
cannot have column info without line info
!15 = distinct !DILexicalBlock(scope: !16, file: !1, column: 3)
fatal error: error in backend: Broken module found, compilation aborted!
clang-14: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
3330a6670ee8d725f16c61fa127ba93613f1fc1f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
clang-14: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/line_program-234c9c-56d2f2.c
clang-14: note: diagnostic msg: /tmp/line_program-234c9c-56d2f2.sh
clang-14: note: diagnostic msg:

********************
$
$ clang-trunk -w -O0 line_program-234c9c.c
$
Quuxplusone commented 3 years ago

I think this is a front end issue. It crashes with -emit-llvm.

Quuxplusone commented 3 years ago

Yeah, /probably/ should just relax the verifier and allow this - GCC seems fine with using line 0 if the user asked for it like this.

(also, why are we complaining about the decl line/column on a lexical scope? We don't emit them anyway - perhaps we should remove them?)

Quuxplusone commented 3 years ago
(In reply to David Blaikie from comment #2)
> (also, why are we complaining about the decl line/column on a lexical scope?
> We don't emit them anyway - perhaps we should remove them?)

We emit them sometimes... if there's a local declaration.  The front-end
would have to notice whether there are any locals, in order to suppress
the unnecessarily lexical scopes.
Quuxplusone commented 3 years ago
(In reply to Paul Robinson from comment #3)
> (In reply to David Blaikie from comment #2)
> > (also, why are we complaining about the decl line/column on a lexical scope?
> > We don't emit them anyway - perhaps we should remove them?)
>
> We emit them sometimes... if there's a local declaration.  The front-end
> would have to notice whether there are any locals, in order to suppress
> the unnecessarily lexical scopes.

Sorry, I meant we don't emit the line/file of lexical scopes (I get that we
emit lexical scopes - if they contain variables, etc, but we don't seem to ever
put a file/line/column on those)

https://github.com/llvm/llvm-project/blob/f0d997c4723214f5bc098b0acd2e61f3215d4a49/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L696