1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

DebugInfo: PR14404: Avoid truncating 64 bit values into 32 bits for ULEB128/SLEB128 generation

llvm-svn: 184669
This commit is contained in:
David Blaikie 2013-06-23 18:31:11 +00:00
parent b9f0bb7e98
commit 2075b3d872
5 changed files with 45 additions and 8 deletions

View File

@ -371,10 +371,10 @@ namespace llvm {
//===------------------------------------------------------------------===//
/// EmitSLEB128 - emit the specified signed leb128 value.
void EmitSLEB128(int Value, const char *Desc = 0) const;
void EmitSLEB128(int64_t Value, const char *Desc = 0) const;
/// EmitULEB128 - emit the specified unsigned leb128 value.
void EmitULEB128(unsigned Value, const char *Desc = 0,
void EmitULEB128(uint64_t Value, const char *Desc = 0,
unsigned PadTo = 0) const;
/// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.

View File

@ -344,8 +344,8 @@ namespace llvm {
virtual ~MCAsmInfo();
// FIXME: move these methods to DwarfPrinter when the JIT stops using them.
static unsigned getSLEB128Size(int Value);
static unsigned getULEB128Size(unsigned Value);
static unsigned getSLEB128Size(int64_t Value);
static unsigned getULEB128Size(uint64_t Value);
/// getPointerSize - Get the pointer size in bytes.
unsigned getPointerSize() const {

View File

@ -33,7 +33,7 @@ using namespace llvm;
//===----------------------------------------------------------------------===//
/// EmitSLEB128 - emit the specified signed leb128 value.
void AsmPrinter::EmitSLEB128(int Value, const char *Desc) const {
void AsmPrinter::EmitSLEB128(int64_t Value, const char *Desc) const {
if (isVerbose() && Desc)
OutStreamer.AddComment(Desc);
@ -41,7 +41,7 @@ void AsmPrinter::EmitSLEB128(int Value, const char *Desc) const {
}
/// EmitULEB128 - emit the specified signed leb128 value.
void AsmPrinter::EmitULEB128(unsigned Value, const char *Desc,
void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc,
unsigned PadTo) const {
if (isVerbose() && Desc)
OutStreamer.AddComment(Desc);

View File

@ -98,7 +98,7 @@ MCAsmInfo::~MCAsmInfo() {
}
unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
unsigned Size = 0;
do {
Value >>= 7;
@ -107,7 +107,7 @@ unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
return Size;
}
unsigned MCAsmInfo::getSLEB128Size(int Value) {
unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
unsigned Size = 0;
int Sign = Value >> (8 * sizeof(Value) - 1);
bool IsMore;

37
test/DebugInfo/pr14404.ll Normal file
View File

@ -0,0 +1,37 @@
; REQUIRES: object-emission
; RUN: llc -O0 -filetype=obj < %s > %t
; RUN: llvm-dwarfdump %t | FileCheck %s
; IR generated from the following code compiled with clang -g:
; enum e { I, J = 0xffffffffU, K = 0xf000000000000000ULL } x;
; These values were previously being truncated to -1 and 0 respectively.
; CHECK: debug_info contents
; CHECK: DW_TAG_enumerator
; CHECK: DW_TAG_enumerator
; CHECK-NEXT: DW_AT_name{{.*}} = "J"
; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata] (4294967295)
; CHECK: DW_TAG_enumerator
; CHECK-NEXT: DW_AT_name{{.*}} = "K"
; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata] (-1152921504606846976)
@x = common global i64 0, align 8
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!12}
!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !8, metadata !8, metadata !9, metadata !8, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/enum.c] [DW_LANG_C99]
!1 = metadata !{metadata !"enum.c", metadata !"/tmp"}
!2 = metadata !{metadata !3}
!3 = metadata !{i32 786436, metadata !1, null, metadata !"e", i32 1, i64 64, i64 64, i32 0, i32 0, null, metadata !4, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] [e] [line 1, size 64, align 64, offset 0] [def] [from ]
!4 = metadata !{metadata !5, metadata !6, metadata !7}
!5 = metadata !{i32 786472, metadata !"I", i64 0} ; [ DW_TAG_enumerator ] [I :: 0]
!6 = metadata !{i32 786472, metadata !"J", i64 4294967295} ; [ DW_TAG_enumerator ] [J :: 4294967295]
!7 = metadata !{i32 786472, metadata !"K", i64 -1152921504606846976} ; [ DW_TAG_enumerator ] [K :: 17293822569102704640]
!8 = metadata !{i32 0}
!9 = metadata !{metadata !10}
!10 = metadata !{i32 786484, i32 0, null, metadata !"x", metadata !"x", metadata !"", metadata !11, i32 1, metadata !3, i32 0, i32 1, i64* @x, null} ; [ DW_TAG_variable ] [x] [line 1] [def]
!11 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/tmp/enum.c]
!12 = metadata !{i32 2, metadata !"Dwarf Version", i32 3}