llvm.org GIT mirror llvm / 31491ee
Merging r143194: ------------------------------------------------------------------------ r143194 | chapuni | 2011-10-28 07:12:22 -0700 (Fri, 28 Oct 2011) | 7 lines Dwarf: [PR11022] Fix emitting DW_AT_const_value(>i64), to be host-endian-neutral. Don't assume APInt::getRawData() would hold target-aware endianness nor host-compliant endianness. rawdata[0] holds most lower i64, even on big endian host. FIXME: Add a testcase for big endian target. FIXME: Ditto on CompileUnit::addConstantFPValue() ? ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_30@143449 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
2 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
526526
527527 // Get the raw data form of the large APInt.
528528 const APInt Val = CI->getValue();
529 const char *Ptr = (const char*)Val.getRawData();
529 const uint64_t *Ptr64 = Val.getRawData();
530530
531531 int NumBytes = Val.getBitWidth() / 8; // 8 bits per byte.
532532 bool LittleEndian = Asm->getTargetData().isLittleEndian();
533 int Incr = (LittleEndian ? 1 : -1);
534 int Start = (LittleEndian ? 0 : NumBytes - 1);
535 int Stop = (LittleEndian ? NumBytes : -1);
536533
537534 // Output the constant to DWARF one byte at a time.
538 for (; Start != Stop; Start += Incr)
539 addUInt(Block, 0, dwarf::DW_FORM_data1,
540 (unsigned char)0xFF & Ptr[Start]);
535 for (int i = 0; i < NumBytes; i++) {
536 uint8_t c;
537 if (LittleEndian)
538 c = Ptr64[i / 8] >> (8 * (i & 7));
539 else
540 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
541 addUInt(Block, 0, dwarf::DW_FORM_data1, c);
542 }
541543
542544 addBlock(Die, dwarf::DW_AT_const_value, 0, Block);
543545 return true;
None ; RUN: llc < %s | FileCheck %s
0 ; RUN: llc -mtriple=x86_64-linux < %s | FileCheck %s
11
22 ; CHECK: DW_AT_const_value
33 ; CHECK-NEXT: 42