[llvm-bugs] [Bug 36168] New: [DebugInfo] Wrong representation of enumerator values in debug info metadata
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jan 31 06:05:32 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36168
Bug ID: 36168
Summary: [DebugInfo] Wrong representation of enumerator values
in debug info metadata
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: momchil.velikov at arm.com
CC: llvm-bugs at lists.llvm.org
Created attachment 19780
--> https://bugs.llvm.org/attachment.cgi?id=19780&action=edit
C language test case
There are a few issue with the representation of enumeration types in the debug
info metadata as well as in DWARF.
The representation of enumerator values uses a single `int64_t`, which does not
convey enough information about the enumerator value. For example, when
compiling
the attached `e.c`, `clang` encodes the values of `A5` and `A7` wrong in the
DWARF debug info:
```
$ clang -c -g e.c && llvm-dwarfdump --debug-info e.o | grep -A1 A[0-9]
DW_AT_name ("A0")
DW_AT_const_value (-128)
--
DW_AT_name ("A1")
DW_AT_const_value (255)
--
DW_AT_name ("A2")
DW_AT_const_value (-32768)
--
DW_AT_name ("A3")
DW_AT_const_value (65535)
--
DW_AT_name ("A4")
DW_AT_const_value (-2147483648)
--
DW_AT_name ("A5")
DW_AT_const_value (-1)
--
DW_AT_name ("A6")
DW_AT_const_value (-9223372036854775808)
--
DW_AT_name ("A7")
DW_AT_const_value (-9223372036854775808)
```
Compiling the same program as C++ and using the `-fshort-enums` gets wrong the
value of A3 as well:
> $ clang -fshort-enums -x c++ -c -g e.c && llvm-dwarfdump --debug-info e.o | grep -A1 A3
> DW_AT_name ("A3")
> DW_AT_const_value (-1)
>
Similar issues are present with C++11 enumerations with a fixed underlying
type, e.g. compiling the attached `e.cc`, yields wrong values for `A1`, `A3`,
`A5`, and `A7`:
```
$ clang -c -g e.cc && llvm-dwarfdump --debug-info e.o | grep -A1 A[0-9]
DW_AT_name ("A0")
DW_AT_const_value (-128)
--
DW_AT_name ("A1")
DW_AT_const_value (-1)
--
DW_AT_name ("A2")
DW_AT_const_value (-32768)
--
DW_AT_name ("A3")
DW_AT_const_value (-1)
--
DW_AT_name ("A4")
DW_AT_const_value (-2147483648)
--
DW_AT_name ("A5")
DW_AT_const_value (-1)
--
DW_AT_name ("A6")
DW_AT_const_value (-9223372036854775808)
--
DW_AT_name ("A7")
DW_AT_const_value (-9223372036854775808)
```
--
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/20180131/673792c1/attachment.html>
More information about the llvm-bugs
mailing list