[llvm] r362290 - Extend the DWARFExpression address handling to support 16-bit addresses
Dylan McKay via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 1 02:18:26 PDT 2019
Author: dylanmckay
Date: Sat Jun 1 02:18:26 2019
New Revision: 362290
URL: http://llvm.org/viewvc/llvm-project?rev=362290&view=rev
Log:
Extend the DWARFExpression address handling to support 16-bit addresses
This allows the DWARFExpression class to handle addresses without
crashing on targets with 16-bit pointers like AVR.
This is required in order to generate assembly from clang via the '-S'
flag.
This fixes an error with the following message:
clang: llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h:132: llvm::DWARFExpression::DWARFExpression(llvm::DataExtractor, uint16_t, uint8_t):
Assertion `AddressSize == 8 || AddressSize == 4' failed.
Added:
llvm/trunk/test/MC/AVR/dwarf-asm-no-code.s
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h?rev=362290&r1=362289&r2=362290&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h Sat Jun 1 02:18:26 2019
@@ -129,7 +129,7 @@ public:
DWARFExpression(DataExtractor Data, uint16_t Version, uint8_t AddressSize)
: Data(Data), Version(Version), AddressSize(AddressSize) {
- assert(AddressSize == 8 || AddressSize == 4);
+ assert(AddressSize == 8 || AddressSize == 4 || AddressSize == 2);
}
iterator begin() const { return iterator(this, 0); }
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp?rev=362290&r1=362289&r2=362290&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp Sat Jun 1 02:18:26 2019
@@ -155,17 +155,21 @@ bool DWARFExpression::Operation::extract
case Operation::SizeAddr:
if (AddressSize == 8) {
Operands[Operand] = Data.getU64(&Offset);
- } else {
- assert(AddressSize == 4);
+ } else if (AddressSize == 4) {
Operands[Operand] = Data.getU32(&Offset);
+ } else {
+ assert(AddressSize == 2);
+ Operands[Operand] = Data.getU16(&Offset);
}
break;
case Operation::SizeRefAddr:
if (getRefAddrSize(AddressSize, Version) == 8) {
Operands[Operand] = Data.getU64(&Offset);
- } else {
- assert(getRefAddrSize(AddressSize, Version) == 4);
+ } else if (getRefAddrSize(AddressSize, Version) == 4) {
Operands[Operand] = Data.getU32(&Offset);
+ } else {
+ assert(getRefAddrSize(AddressSize, Version) == 2);
+ Operands[Operand] = Data.getU16(&Offset);
}
break;
case Operation::SizeLEB:
Added: llvm/trunk/test/MC/AVR/dwarf-asm-no-code.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AVR/dwarf-asm-no-code.s?rev=362290&view=auto
==============================================================================
--- llvm/trunk/test/MC/AVR/dwarf-asm-no-code.s (added)
+++ llvm/trunk/test/MC/AVR/dwarf-asm-no-code.s Sat Jun 1 02:18:26 2019
@@ -0,0 +1,19 @@
+// RUN: llvm-mc < %s -triple=avr -filetype=obj -o %t -g -fdebug-compilation-dir=/tmp
+// RUN: llvm-dwarfdump -v %t | FileCheck -check-prefix DWARF %s
+// RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC %s
+
+// If there is no code in an assembly file, no debug info is produced
+
+.section .data, "aw"
+a:
+.long 42
+
+// DWARF: ELF32-avr
+// DWARF-NOT: contents:
+// DWARF: .debug_line contents:
+
+// RELOC-NOT: RELOCATION RECORDS FOR [.rel.debug_info]:
+
+// RELOC-NOT: RELOCATION RECORDS FOR [.rel.debug_ranges]:
+
+// RELOC-NOT: RELOCATION RECORDS FOR [.rel.debug_aranges]:
More information about the llvm-commits
mailing list