summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-06-23 18:31:11 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-06-23 18:31:11 +0000
commitfe2e66a6dab6162fb10ed2d576cd122f34d2626f (patch)
treee5a3ced413efe71d005f3acf6159f4e8af54b198
parent7130a9561787cf14d5349d22cde1e0b3a4d5c21d (diff)
downloadllvm-fe2e66a6dab6162fb10ed2d576cd122f34d2626f.tar.gz
llvm-fe2e66a6dab6162fb10ed2d576cd122f34d2626f.tar.bz2
llvm-fe2e66a6dab6162fb10ed2d576cd122f34d2626f.tar.xz
DebugInfo: PR14404: Avoid truncating 64 bit values into 32 bits for ULEB128/SLEB128 generation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184669 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/AsmPrinter.h4
-rw-r--r--include/llvm/MC/MCAsmInfo.h4
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp4
-rw-r--r--lib/MC/MCAsmInfo.cpp4
-rw-r--r--test/DebugInfo/pr14404.ll37
5 files changed, 45 insertions, 8 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index 5f489e0511..28c0f4d494 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -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.
diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h
index 781a9d010b..201b2eb182 100644
--- a/include/llvm/MC/MCAsmInfo.h
+++ b/include/llvm/MC/MCAsmInfo.h
@@ -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 {
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
index e6d67e8822..c141d60452 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -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);
diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp
index 3d843b7c94..84e4075621 100644
--- a/lib/MC/MCAsmInfo.cpp
+++ b/lib/MC/MCAsmInfo.cpp
@@ -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;
diff --git a/test/DebugInfo/pr14404.ll b/test/DebugInfo/pr14404.ll
new file mode 100644
index 0000000000..fd96afe97f
--- /dev/null
+++ b/test/DebugInfo/pr14404.ll
@@ -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}