diff options
author | Reid Kleckner <reid@kleckner.net> | 2009-08-21 21:03:57 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2009-08-21 21:03:57 +0000 |
commit | 4f2c6f1de4ca7b4f64fedc08a8b61249e2edb9d3 (patch) | |
tree | 634944a488e2aec43a5a5becffae59912a8097d6 /include/llvm | |
parent | 8446276f4b086edd69bf329e88a2047dafc8a31f (diff) | |
download | external_llvm-4f2c6f1de4ca7b4f64fedc08a8b61249e2edb9d3.zip external_llvm-4f2c6f1de4ca7b4f64fedc08a8b61249e2edb9d3.tar.gz external_llvm-4f2c6f1de4ca7b4f64fedc08a8b61249e2edb9d3.tar.bz2 |
Fix a bug where the DWARF emitter in the JIT was not initializing alignment
bytes. libgcc doesn't seem to mind, but if you pass this DWARF to GDB, it
doesn't like it.
Also make the JIT memory manager to initialize it's memory to garbage in debug
mode, so that it's easier to find bugs like these in the future.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79674 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/CodeGen/JITCodeEmitter.h | 24 | ||||
-rw-r--r-- | include/llvm/Support/Dwarf.h | 1 |
2 files changed, 18 insertions, 7 deletions
diff --git a/include/llvm/CodeGen/JITCodeEmitter.h b/include/llvm/CodeGen/JITCodeEmitter.h index c3f95b4..180783a 100644 --- a/include/llvm/CodeGen/JITCodeEmitter.h +++ b/include/llvm/CodeGen/JITCodeEmitter.h @@ -19,6 +19,7 @@ #include <string> #include "llvm/Support/DataTypes.h" +#include "llvm/Support/MathExtras.h" #include "llvm/CodeGen/MachineCodeEmitter.h" using namespace std; @@ -161,17 +162,26 @@ public: /// alignment (saturated to BufferEnd of course). void emitAlignment(unsigned Alignment) { if (Alignment == 0) Alignment = 1; + uint8_t *NewPtr = (uint8_t*)RoundUpToAlignment((uintptr_t)CurBufferPtr, + Alignment); + CurBufferPtr = std::min(NewPtr, BufferEnd); + } - if(Alignment <= (uintptr_t)(BufferEnd-CurBufferPtr)) { - // Move the current buffer ptr up to the specified alignment. - CurBufferPtr = - (uint8_t*)(((uintptr_t)CurBufferPtr+Alignment-1) & - ~(uintptr_t)(Alignment-1)); - } else { + /// emitAlignmentWithFill - Similar to emitAlignment, except that the + /// extra bytes are filled with the provided byte. + void emitAlignmentWithFill(unsigned Alignment, uint8_t Fill) { + if (Alignment == 0) Alignment = 1; + uint8_t *NewPtr = (uint8_t*)RoundUpToAlignment((uintptr_t)CurBufferPtr, + Alignment); + // Fail if we don't have room. + if (NewPtr > BufferEnd) { CurBufferPtr = BufferEnd; + return; + } + while (CurBufferPtr < NewPtr) { + *CurBufferPtr++ = Fill; } } - /// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be /// written to the output stream. diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 55838b8..bfccc52 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -449,6 +449,7 @@ enum dwarf_constants { // Call frame instruction encodings DW_CFA_extended = 0x00, + DW_CFA_nop = 0x00, DW_CFA_advance_loc = 0x40, DW_CFA_offset = 0x80, DW_CFA_restore = 0xc0, |