gallivm: Make sure the bitcode buffer is followed by a 0 byte.
authorMichel Dänzer <daenzer@vmware.com>
Mon, 12 Jan 2009 14:05:05 +0000 (15:05 +0100)
committerMichel Dänzer <daenzer@vmware.com>
Mon, 12 Jan 2009 14:05:05 +0000 (15:05 +0100)
May fail to parse otherwise.

src/gallium/auxiliary/gallivm/Makefile
src/gallium/auxiliary/gallivm/gallivm_builtins.cpp
src/gallium/auxiliary/gallivm/instructionssoa.cpp

index c3f7bfba93be5ed8ebc33f55d4194fd734665058..5a96d94ec378835c7986f5790beb36abbdb0b0b0 100644 (file)
@@ -66,12 +66,12 @@ depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(INC_SOURCES)
 
 gallivm_builtins.cpp: llvm_builtins.c
        clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp1.bin
-       (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp1.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/};/") >$@
+       (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp1.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
        rm temp1.bin
 
 gallivmsoabuiltins.cpp: soabuiltins.c
        clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp2.bin
-       (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp2.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/};/") >$@
+       (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp2.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
        rm temp2.bin
 
 # Emacs tags
index fcc5c05794aa32eaa365e4c34813beb0a99ea85c..634bac01507f8c38d25be5ddff87c349def1b44d 100644 (file)
@@ -137,4 +137,4 @@ static const unsigned char llvm_builtins_data[] = {
 0x58,0x85,0x05,0x14,0xbe,0x34,0x45,0xb5,0x21,0x10,0x82,0x23,0x15,0x46,0x30,0x2c,
 0xc8,0x64,0x02,0x06,0xf0,0x3c,0x91,0x73,0x19,0x00,0xe1,0x4b,0x53,0x64,0x0a,0x84,
 0x84,0x34,0x85,0x25,0x0c,0x92,0x20,0x59,0xc1,0x20,0x30,0x8f,0x2d,0x10,0x95,0x84,
-0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
index f93a31d54ba62bad230502fb94b919692864602c..925e948763ecf4139784b8606e8de01d15c57f26 100644 (file)
@@ -209,7 +209,7 @@ void InstructionsSoa::createBuiltins()
    std::string ErrMsg;
    MemoryBuffer *buffer = MemoryBuffer::getMemBuffer(
       (const char*)&soabuiltins_data[0],
-      (const char*)&soabuiltins_data[Elements(soabuiltins_data)]);
+      (const char*)&soabuiltins_data[Elements(soabuiltins_data) - 1]);
    m_builtins = ParseBitcodeFile(buffer, &ErrMsg);
    std::cout<<"Builtins created at "<<m_builtins<<" ("<<ErrMsg<<")"<<std::endl;
    assert(m_builtins);