[PATCH] D90199: [CodeView] Encode signed int values correctly when emitting S_CONSTANTs
Amy Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 17:17:57 PDT 2020
akhuang created this revision.
akhuang added a reviewer: rnk.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
akhuang requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90199
Files:
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/DebugInfo/COFF/global-constants.ll
llvm/test/DebugInfo/COFF/globals.ll
Index: llvm/test/DebugInfo/COFF/globals.ll
===================================================================
--- llvm/test/DebugInfo/COFF/globals.ll
+++ llvm/test/DebugInfo/COFF/globals.ll
@@ -86,19 +86,19 @@
; ASM: .short 4359 # Record kind: S_CONSTANT
; ASM-NEXT: .long 4100 # Type
-; ASM-NEXT: .byte 0x08, 0x00 # Value
+; ASM-NEXT: .byte 0x00, 0x80, 0x08 # Value
; ASM-NEXT: .asciz "foo::constExpr" # Name
; ASM-NEXT: .p2align 2
; ASM: .short 4359 # Record kind: S_CONSTANT
; ASM-NEXT: .long 4100 # Type
-; ASM-NEXT: .byte 0x09, 0x00 # Value
+; ASM-NEXT: .byte 0x00, 0x80, 0x09 # Value
; ASM-NEXT: .asciz "foo::constVal" # Name
; ASM-NEXT: .p2align 2
; ASM: .short 4359 # Record kind: S_CONSTANT
; ASM-NEXT: .long 4100 # Type
-; ASM-NEXT: .byte 0x0e, 0x00 # Value
+; ASM-NEXT: .byte 0x00, 0x80, 0x0e # Value
; ASM-NEXT: .asciz "foo::Data::DataConstExpr" # Name
; ASM-NEXT: .p2align 2
Index: llvm/test/DebugInfo/COFF/global-constants.ll
===================================================================
--- llvm/test/DebugInfo/COFF/global-constants.ll
+++ llvm/test/DebugInfo/COFF/global-constants.ll
@@ -37,9 +37,8 @@
; ASM: .short 4359 # Record kind: S_CONSTANT
; ASM-NEXT: .long 4101 # Type
-; ASM-NEXT: .byte 0x0a, 0x80, 0x40, 0x61 # Value
-; ASM-NEXT: .byte 0x07, 0x80, 0xff, 0xff
-; ASM-NEXT: .byte 0xff, 0xff
+; ASM-NEXT: .byte 0x03, 0x80, 0x40, 0x61 # Value
+; ASM-NEXT: .byte 0x07, 0x80
; ASM-NEXT: .asciz "ENUM_B" # Name
; ASM-NEXT: .p2align 2
; ASM-NOT: .asciz "S::SEnum" # Name
@@ -64,7 +63,7 @@
; OBJ-NEXT: ConstantSym {
; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
; OBJ-NEXT: Type: TestEnum (0x1005)
-; OBJ-NEXT: Value: 18446744071562551616
+; OBJ-NEXT: Value: -214700000
; OBJ-NEXT: Name: ENUM_B
; OBJ-NEXT: }
; OBJ-NOT: Name: S::SEnum
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -3140,6 +3140,9 @@
return Encoding == dwarf::DW_ATE_unsigned ||
Encoding == dwarf::DW_ATE_unsigned_char ||
Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
+ Encoding == dwarf::DW_ATE_float ||
+ Encoding == dwarf::DW_ATE_complex_float ||
+ Encoding == dwarf::DW_ATE_address ||
Ty->getTag() == dwarf::DW_TAG_unspecified_type;
}
@@ -3213,7 +3216,8 @@
const DIExpression *DIE = CVGV.GVInfo.get<const DIExpression *>();
assert(DIE->isConstant() &&
"Global constant variables must contain a constant expression.");
- uint64_t Val = DIE->getElement(1);
+ APSInt Value(APInt(/*BitWidth=*/64, DIE->getElement(1)),
+ isStaticConstUnsigned(DIGV->getType()));
MCSymbol *SConstantEnd = beginSymbolRecord(SymbolKind::S_CONSTANT);
OS.AddComment("Type");
@@ -3224,7 +3228,7 @@
uint8_t data[10];
BinaryStreamWriter Writer(data, llvm::support::endianness::little);
CodeViewRecordIO IO(Writer);
- cantFail(IO.mapEncodedInteger(Val));
+ cantFail(IO.mapEncodedInteger(Value));
StringRef SRef((char *)data, Writer.getOffset());
OS.emitBinaryData(SRef);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90199.300833.patch
Type: text/x-patch
Size: 3603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201027/264a3141/attachment.bin>
More information about the llvm-commits
mailing list