From isanbard at gmail.com Mon Jun 13 01:23:02 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 13 Jun 2011 06:23:02 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r132904 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Message-ID: <20110613062302.8C4292A6C12C@llvm.org> Author: void Date: Mon Jun 13 01:23:02 2011 New Revision: 132904 URL: http://llvm.org/viewvc/llvm-project?rev=132904&view=rev Log: An attempt to make the buildbot happy. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp?rev=132904&r1=132903&r2=132904&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Mon Jun 13 01:23:02 2011 @@ -47,10 +47,12 @@ # Load support procs. load_lib profopt.exp -set profile_options "-fprofile-arcs -ftest-coverage" -set feedback_options "-fbranch-probabilities" +#set profile_options "-fprofile-arcs -ftest-coverage" +#set feedback_options "-fbranch-probabilities" +set profile_option "-fprofile-arcs -ftest-coverage" +set feedback_option "-fbranch-probabilities" -foreach profile_option $profile_options feedback_option $feedback_options { +#foreach profile_option $profile_options feedback_option $feedback_options { foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.c]] { # If we're only testing specific files and this isn't one of them, skip it. if ![runtest_file_p $runtests $src] then { @@ -58,4 +60,4 @@ } profopt-execute $src } -} +#} From nicholas at mxc.ca Mon Jun 13 02:17:56 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 13 Jun 2011 00:17:56 -0700 Subject: [llvm-commits] patch: teach mem2reg to delete lifetime intrinsics Message-ID: <4DF5B9A4.5050102@mxc.ca> In this patch, I add another scan over an alloca's uses to delete any lifetime intrinsics, or casts to i8* to be used by lifetime intrinsics. This is part of PR10121. Please review! Nick -------------- next part -------------- A non-text attachment was scrubbed... Name: mem2reg-lifetime.patch Type: text/x-patch Size: 3264 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110613/84026a07/attachment.bin From nicholas at mxc.ca Mon Jun 13 02:52:46 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 13 Jun 2011 07:52:46 -0000 Subject: [llvm-commits] [llvm] r132906 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <20110613075246.C53242A6C12D@llvm.org> Author: nicholas Date: Mon Jun 13 02:52:46 2011 New Revision: 132906 URL: http://llvm.org/viewvc/llvm-project?rev=132906&view=rev Log: It's possible that an all-zero GEP may be used as the argument to lifetime intrinsics. In fact, we'll optimize a bitcast to that when possible. Detect it when looking for the lifetime intrinsics. No test case, noticed by inspection. Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=132906&r1=132905&r2=132906&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jun 13 02:52:46 2011 @@ -734,11 +734,15 @@ if (AI->getType() == Int8PtrTy) return isUsedByLifetimeMarker(AI); - // Do a scan to find all the bitcasts to i8*. + // Do a scan to find all the bitcasts or GEPs to i8*. for (Value::use_iterator I = AI->use_begin(), E = AI->use_end(); I != E; ++I) { if (I->getType() != Int8PtrTy) continue; - if (!isa(*I)) continue; + if (GetElementPtrInst *GEPI = dyn_cast(*I)) { + if (!GEPI->hasAllZeroIndices()) continue; + } else if (!isa(*I)) { + continue; + } if (isUsedByLifetimeMarker(*I)) return true; } From isanbard at gmail.com Mon Jun 13 03:24:18 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 13 Jun 2011 08:24:18 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r132907 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Message-ID: <20110613082418.23AFC2A6C12D@llvm.org> Author: void Date: Mon Jun 13 03:24:17 2011 New Revision: 132907 URL: http://llvm.org/viewvc/llvm-project?rev=132907&view=rev Log: Okay...try this to fix the buildbots. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp?rev=132907&r1=132906&r2=132907&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Mon Jun 13 03:24:17 2011 @@ -47,17 +47,18 @@ # Load support procs. load_lib profopt.exp -#set profile_options "-fprofile-arcs -ftest-coverage" -#set feedback_options "-fbranch-probabilities" -set profile_option "-fprofile-arcs -ftest-coverage" -set feedback_option "-fbranch-probabilities" +set profile_options "-fprofile-arcs -ftest-coverage" +set feedback_options "-fbranch-probabilities" -#foreach profile_option $profile_options feedback_option $feedback_options { +foreach profile_option $profile_options feedback_option $feedback_options { foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.c]] { # If we're only testing specific files and this isn't one of them, skip it. if ![runtest_file_p $runtests $src] then { continue } + if {[string compare $src bprob-2.c]} then { + continue + } profopt-execute $src } -#} +} From bigcheesegs at gmail.com Mon Jun 13 06:11:39 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 13 Jun 2011 11:11:39 -0000 Subject: [llvm-commits] [llvm] r132908 - in /llvm/trunk: include/llvm/Support/ELF.h include/llvm/Support/system_error.h lib/Object/CMakeLists.txt Message-ID: <20110613111139.593532A6C12C@llvm.org> Author: mspencer Date: Mon Jun 13 06:11:39 2011 New Revision: 132908 URL: http://llvm.org/viewvc/llvm-project?rev=132908&view=rev Log: Fix spelling and sort CMakeLists.txt. Modified: llvm/trunk/include/llvm/Support/ELF.h llvm/trunk/include/llvm/Support/system_error.h llvm/trunk/lib/Object/CMakeLists.txt Modified: llvm/trunk/include/llvm/Support/ELF.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=132908&r1=132907&r2=132908&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ELF.h (original) +++ llvm/trunk/include/llvm/Support/ELF.h Mon Jun 13 06:11:39 2011 @@ -487,11 +487,11 @@ SHT_REL = 9, // Relocation entries; no explicit addends. SHT_SHLIB = 10, // Reserved. SHT_DYNSYM = 11, // Symbol table. - SHT_INIT_ARRAY = 14, // Pointers to initialisation functions. + SHT_INIT_ARRAY = 14, // Pointers to initialization functions. SHT_FINI_ARRAY = 15, // Pointers to termination functions. SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions. SHT_GROUP = 17, // Section group. - SHT_SYMTAB_SHNDX = 18, // Indicies for SHN_XINDEX entries. + SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries. SHT_LOOS = 0x60000000, // Lowest operating system-specific type. SHT_HIOS = 0x6fffffff, // Highest operating system-specific type. SHT_LOPROC = 0x70000000, // Lowest processor architecture-specific type. @@ -630,7 +630,7 @@ STT_FUNC = 2, // Symbol is executable code (function, etc.) STT_SECTION = 3, // Symbol refers to a section STT_FILE = 4, // Local, absolute symbol that refers to a file - STT_COMMON = 5, // An uninitialised common block + STT_COMMON = 5, // An uninitialized common block STT_TLS = 6, // Thread local data object STT_LOPROC = 13, // Lowest processor-specific symbol type STT_HIPROC = 15 // Highest processor-specific symbol type @@ -804,7 +804,7 @@ DT_RELENT = 19, // Size of a Rel relocation entry. DT_PLTREL = 20, // Type of relocation entry used for linking. DT_DEBUG = 21, // Reserved for debugger. - DT_TEXTREL = 22, // Relocations exist for non-writable segements. + DT_TEXTREL = 22, // Relocations exist for non-writable segments. DT_JMPREL = 23, // Address of relocations associated with PLT. DT_BIND_NOW = 24, // Process all relocations before execution. DT_INIT_ARRAY = 25, // Pointer to array of initialization functions. Modified: llvm/trunk/include/llvm/Support/system_error.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/system_error.h?rev=132908&r1=132907&r2=132908&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/system_error.h (original) +++ llvm/trunk/include/llvm/Support/system_error.h Mon Jun 13 06:11:39 2011 @@ -669,7 +669,7 @@ const error_category& system_category(); /// Get the error_category used for errno values from POSIX functions. This is -/// the same as the system_category on POISIX systems, but is the same as the +/// the same as the system_category on POSIX systems, but is the same as the /// generic_category on Windows. const error_category& posix_category(); Modified: llvm/trunk/lib/Object/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/CMakeLists.txt?rev=132908&r1=132907&r2=132908&view=diff ============================================================================== --- llvm/trunk/lib/Object/CMakeLists.txt (original) +++ llvm/trunk/lib/Object/CMakeLists.txt Mon Jun 13 06:11:39 2011 @@ -1,8 +1,8 @@ add_llvm_library(LLVMObject + COFFObjectFile.cpp + ELFObjectFile.cpp MachOObject.cpp MachOObjectFile.cpp Object.cpp ObjectFile.cpp - COFFObjectFile.cpp - ELFObjectFile.cpp ) From bigcheesegs at gmail.com Mon Jun 13 06:11:59 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 13 Jun 2011 11:11:59 -0000 Subject: [llvm-commits] [llvm] r132909 - in /llvm/trunk: include/llvm/Object/Error.h lib/Object/CMakeLists.txt lib/Object/Error.cpp Message-ID: <20110613111200.033A82A6C12C@llvm.org> Author: mspencer Date: Mon Jun 13 06:11:59 2011 New Revision: 132909 URL: http://llvm.org/viewvc/llvm-project?rev=132909&view=rev Log: Add Object/Error. Added: llvm/trunk/include/llvm/Object/Error.h llvm/trunk/lib/Object/Error.cpp Modified: llvm/trunk/lib/Object/CMakeLists.txt Added: llvm/trunk/include/llvm/Object/Error.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Error.h?rev=132909&view=auto ============================================================================== --- llvm/trunk/include/llvm/Object/Error.h (added) +++ llvm/trunk/include/llvm/Object/Error.h Mon Jun 13 06:11:59 2011 @@ -0,0 +1,49 @@ +//===- Error.h - system_error extensions for Object -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This declares a new error_category for the Object library. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECT_ERROR_H +#define LLVM_OBJECT_ERROR_H + +#include "llvm/Support/system_error.h" + +namespace llvm { +namespace object { + +const error_category &object_category(); + +struct object_error { +enum _ { + success = 0, + invalid_file_type, + parse_failed +}; + _ v_; + + object_error(_ v) : v_(v) {} + explicit object_error(int v) : v_(_(v)) {} + operator int() const {return v_;} +}; + +} // end namespace object. + +template <> struct is_error_code_enum : true_type { }; + +template <> struct is_error_code_enum : true_type { }; + +inline error_code make_error_code(object::object_error e) { + return error_code(static_cast(e), object::object_category()); +} + +} // end namespace llvm. + +#endif Modified: llvm/trunk/lib/Object/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/CMakeLists.txt?rev=132909&r1=132908&r2=132909&view=diff ============================================================================== --- llvm/trunk/lib/Object/CMakeLists.txt (original) +++ llvm/trunk/lib/Object/CMakeLists.txt Mon Jun 13 06:11:59 2011 @@ -1,6 +1,7 @@ add_llvm_library(LLVMObject COFFObjectFile.cpp ELFObjectFile.cpp + Error.cpp MachOObject.cpp MachOObjectFile.cpp Object.cpp Added: llvm/trunk/lib/Object/Error.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=132909&view=auto ============================================================================== --- llvm/trunk/lib/Object/Error.cpp (added) +++ llvm/trunk/lib/Object/Error.cpp Mon Jun 13 06:11:59 2011 @@ -0,0 +1,55 @@ +//===- Error.cpp - system_error extensions for Object -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This defines a new error_category for the Object library. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Object/Error.h" +#include "llvm/Support/ErrorHandling.h" + +using namespace llvm; +using namespace object; + +namespace { +class _object_error_category : public _do_message { +public: + virtual const char* name() const; + virtual std::string message(int ev) const; + virtual error_condition default_error_condition(int ev) const; +}; +} + +const char *_object_error_category::name() const { + return "llvm.object"; +} + +std::string _object_error_category::message(int ev) const { + switch (ev) { + case object_error::success: return "Success"; + case object_error::invalid_file_type: + return "The file was not recognized as a valid object file"; + case object_error::parse_failed: + return "Invalid data was encountered while parsing the file"; + default: + llvm_unreachable("An enumerator of object_error does not have a message " + "defined."); + } +} + +error_condition _object_error_category::default_error_condition(int ev) const { + if (ev == object_error::success) + return errc::success; + return errc::invalid_argument; +} + +const error_category &object::object_category() { + static _object_error_category o; + return o; +} From bigcheesegs at gmail.com Mon Jun 13 06:12:12 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 13 Jun 2011 11:12:12 -0000 Subject: [llvm-commits] [llvm] r132910 - in /llvm/trunk: include/llvm/Object/Binary.h lib/Object/Binary.cpp lib/Object/CMakeLists.txt Message-ID: <20110613111212.8C1212A6C12C@llvm.org> Author: mspencer Date: Mon Jun 13 06:12:12 2011 New Revision: 132910 URL: http://llvm.org/viewvc/llvm-project?rev=132910&view=rev Log: Add Binary class. This is a cleaner parent than ObjectFile. Added: llvm/trunk/include/llvm/Object/Binary.h llvm/trunk/lib/Object/Binary.cpp Modified: llvm/trunk/lib/Object/CMakeLists.txt Added: llvm/trunk/include/llvm/Object/Binary.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Binary.h?rev=132910&view=auto ============================================================================== --- llvm/trunk/include/llvm/Object/Binary.h (added) +++ llvm/trunk/include/llvm/Object/Binary.h Mon Jun 13 06:12:12 2011 @@ -0,0 +1,64 @@ +//===- Binary.h - A generic binary file -------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the Binary class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECT_BINARY_H +#define LLVM_OBJECT_BINARY_H + +#include "llvm/ADT/OwningPtr.h" +#include "llvm/Object/Error.h" + +namespace llvm { + +class MemoryBuffer; +class StringRef; + +namespace object { + +class Binary { +private: + Binary(); // = delete + Binary(const Binary &other); // = delete + + unsigned int TypeID; + +protected: + MemoryBuffer *Data; + + Binary(unsigned int Type, MemoryBuffer *Source); + + enum { + isArchive, + isCOFF, + isELF, + isMachO, + isObject + }; + +public: + virtual ~Binary(); + + StringRef getData() const; + StringRef getFileName() const; + + // Cast methods. + unsigned int getType() const { return TypeID; } + static inline bool classof(Binary const *v) { return true; } +}; + +error_code createBinary(MemoryBuffer *Source, OwningPtr &Result); +error_code createBinary(StringRef Path, OwningPtr &Result); + +} +} + +#endif Added: llvm/trunk/lib/Object/Binary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Binary.cpp?rev=132910&view=auto ============================================================================== --- llvm/trunk/lib/Object/Binary.cpp (added) +++ llvm/trunk/lib/Object/Binary.cpp Mon Jun 13 06:12:12 2011 @@ -0,0 +1,50 @@ +//===- Binary.cpp - A generic binary file -----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the Binary class. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Object/Binary.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Path.h" + +using namespace llvm; +using namespace object; + +Binary::~Binary() { + delete Data; +} + +Binary::Binary(unsigned int Type, MemoryBuffer *Source) + : TypeID(Type) + , Data(Source) {} + +StringRef Binary::getData() const { + return Data->getBuffer(); +} + +StringRef Binary::getFileName() const { + return Data->getBufferIdentifier(); +} + +error_code object::createBinary(MemoryBuffer *Source, + OwningPtr &Result) { + // We don't support any at the moment. + delete Source; + return object_error::invalid_file_type; +} + +error_code object::createBinary(StringRef Path, OwningPtr &Result) { + OwningPtr File; + if (error_code ec = MemoryBuffer::getFile(Path, File)) + return ec; + return createBinary(File.take(), Result); +} Modified: llvm/trunk/lib/Object/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/CMakeLists.txt?rev=132910&r1=132909&r2=132910&view=diff ============================================================================== --- llvm/trunk/lib/Object/CMakeLists.txt (original) +++ llvm/trunk/lib/Object/CMakeLists.txt Mon Jun 13 06:12:12 2011 @@ -1,4 +1,5 @@ add_llvm_library(LLVMObject + Binary.cpp COFFObjectFile.cpp ELFObjectFile.cpp Error.cpp From bigcheesegs at gmail.com Mon Jun 13 06:12:33 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 13 Jun 2011 11:12:33 -0000 Subject: [llvm-commits] [llvm] r132911 - in /llvm/trunk: include/llvm/Object/Binary.h include/llvm/Object/COFF.h include/llvm/Object/ObjectFile.h lib/Object/Binary.cpp lib/Object/COFFObjectFile.cpp lib/Object/ELFObjectFile.cpp lib/Object/MachOObjectFile.cpp lib/Object/ObjectFile.cpp tools/llvm-nm/llvm-nm.cpp Message-ID: <20110613111233.A67132A6C12C@llvm.org> Author: mspencer Date: Mon Jun 13 06:12:33 2011 New Revision: 132911 URL: http://llvm.org/viewvc/llvm-project?rev=132911&view=rev Log: Make Binary the parent of ObjectFile and update children to new interface. Added: llvm/trunk/include/llvm/Object/COFF.h Modified: llvm/trunk/include/llvm/Object/Binary.h llvm/trunk/include/llvm/Object/ObjectFile.h llvm/trunk/lib/Object/Binary.cpp llvm/trunk/lib/Object/COFFObjectFile.cpp llvm/trunk/lib/Object/ELFObjectFile.cpp llvm/trunk/lib/Object/MachOObjectFile.cpp llvm/trunk/lib/Object/ObjectFile.cpp llvm/trunk/tools/llvm-nm/llvm-nm.cpp Modified: llvm/trunk/include/llvm/Object/Binary.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Binary.h?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/Binary.h (original) +++ llvm/trunk/include/llvm/Object/Binary.h Mon Jun 13 06:12:33 2011 @@ -38,10 +38,13 @@ enum { isArchive, + + // Object and children. + isObject, isCOFF, isELF, isMachO, - isObject + lastObject }; public: @@ -52,7 +55,7 @@ // Cast methods. unsigned int getType() const { return TypeID; } - static inline bool classof(Binary const *v) { return true; } + static inline bool classof(const Binary *v) { return true; } }; error_code createBinary(MemoryBuffer *Source, OwningPtr &Result); Added: llvm/trunk/include/llvm/Object/COFF.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=132911&view=auto ============================================================================== --- llvm/trunk/include/llvm/Object/COFF.h (added) +++ llvm/trunk/include/llvm/Object/COFF.h Mon Jun 13 06:12:33 2011 @@ -0,0 +1,111 @@ +//===- COFF.h - COFF object file implementation -----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the COFFObjectFile class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECT_COFF_H +#define LLVM_OBJECT_COFF_H + +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/COFF.h" +#include "llvm/Support/Endian.h" + +namespace llvm { +namespace object { + +struct coff_file_header { + support::ulittle16_t Machine; + support::ulittle16_t NumberOfSections; + support::ulittle32_t TimeDateStamp; + support::ulittle32_t PointerToSymbolTable; + support::ulittle32_t NumberOfSymbols; + support::ulittle16_t SizeOfOptionalHeader; + support::ulittle16_t Characteristics; +}; + +struct coff_symbol { + struct StringTableOffset { + support::ulittle32_t Zeroes; + support::ulittle32_t Offset; + }; + + union { + char ShortName[8]; + StringTableOffset Offset; + } Name; + + support::ulittle32_t Value; + support::little16_t SectionNumber; + + struct { + support::ulittle8_t BaseType; + support::ulittle8_t ComplexType; + } Type; + + support::ulittle8_t StorageClass; + support::ulittle8_t NumberOfAuxSymbols; +}; + +struct coff_section { + char Name[8]; + support::ulittle32_t VirtualSize; + support::ulittle32_t VirtualAddress; + support::ulittle32_t SizeOfRawData; + support::ulittle32_t PointerToRawData; + support::ulittle32_t PointerToRelocations; + support::ulittle32_t PointerToLinenumbers; + support::ulittle16_t NumberOfRelocations; + support::ulittle16_t NumberOfLinenumbers; + support::ulittle32_t Characteristics; +}; + +class COFFObjectFile : public ObjectFile { +private: + uint64_t HeaderOff; + const coff_file_header *Header; + const coff_section *SectionTable; + const coff_symbol *SymbolTable; + const char *StringTable; + + const coff_section *getSection(std::size_t index) const; + const char *getString(std::size_t offset) const; + +protected: + virtual SymbolRef getSymbolNext(DataRefImpl Symb) const; + virtual StringRef getSymbolName(DataRefImpl Symb) const; + virtual uint64_t getSymbolAddress(DataRefImpl Symb) const; + virtual uint64_t getSymbolSize(DataRefImpl Symb) const; + virtual char getSymbolNMTypeChar(DataRefImpl Symb) const; + virtual bool isSymbolInternal(DataRefImpl Symb) const; + + virtual SectionRef getSectionNext(DataRefImpl Sec) const; + virtual StringRef getSectionName(DataRefImpl Sec) const; + virtual uint64_t getSectionAddress(DataRefImpl Sec) const; + virtual uint64_t getSectionSize(DataRefImpl Sec) const; + virtual StringRef getSectionContents(DataRefImpl Sec) const; + virtual bool isSectionText(DataRefImpl Sec) const; + +public: + COFFObjectFile(MemoryBuffer *Object, error_code &ec); + virtual symbol_iterator begin_symbols() const; + virtual symbol_iterator end_symbols() const; + virtual section_iterator begin_sections() const; + virtual section_iterator end_sections() const; + + virtual uint8_t getBytesInAddress() const; + virtual StringRef getFileFormatName() const; + virtual unsigned getArch() const; +}; + +} +} + +#endif Modified: llvm/trunk/include/llvm/Object/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/ObjectFile.h (original) +++ llvm/trunk/include/llvm/Object/ObjectFile.h Mon Jun 13 06:12:33 2011 @@ -14,15 +14,13 @@ #ifndef LLVM_OBJECT_OBJECT_FILE_H #define LLVM_OBJECT_OBJECT_FILE_H +#include "llvm/Object/Binary.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/MemoryBuffer.h" #include namespace llvm { - -class MemoryBuffer; -class StringRef; - namespace object { class ObjectFile; @@ -93,16 +91,17 @@ /// ObjectFile - This class is the base class for all object file types. /// Concrete instances of this object are created by createObjectFile, which /// figure out which type to create. -class ObjectFile { +class ObjectFile : public Binary { private: ObjectFile(); // = delete ObjectFile(const ObjectFile &other); // = delete protected: - MemoryBuffer *MapFile; - const uint8_t *base; + ObjectFile(unsigned int Type, MemoryBuffer *source, error_code &ec); - ObjectFile(MemoryBuffer *Object); + const uint8_t *base() const { + return reinterpret_cast(Data->getBufferStart()); + } // These functions are for SymbolRef to call internally. The main goal of // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol @@ -156,8 +155,6 @@ typedef content_iterator symbol_iterator; typedef content_iterator section_iterator; - virtual ~ObjectFile(); - virtual symbol_iterator begin_symbols() const = 0; virtual symbol_iterator end_symbols() const = 0; @@ -171,8 +168,6 @@ virtual StringRef getFileFormatName() const = 0; virtual /* Triple::ArchType */ unsigned getArch() const = 0; - StringRef getFilename() const; - /// @returns Pointer to ObjectFile subclass to handle this type of object. /// @param ObjectPath The path to the object file. ObjectPath.isObject must /// return true. @@ -180,12 +175,16 @@ static ObjectFile *createObjectFile(StringRef ObjectPath); static ObjectFile *createObjectFile(MemoryBuffer *Object); -private: + static inline bool classof(const Binary *v) { + return v->getType() >= isObject && + v->getType() < lastObject; + } + static inline bool classof(const ObjectFile *v) { return true; } + +public: static ObjectFile *createCOFFObjectFile(MemoryBuffer *Object); static ObjectFile *createELFObjectFile(MemoryBuffer *Object); static ObjectFile *createMachOObjectFile(MemoryBuffer *Object); - static ObjectFile *createArchiveObjectFile(MemoryBuffer *Object); - static ObjectFile *createLibObjectFile(MemoryBuffer *Object); }; // Inline function definitions. Modified: llvm/trunk/lib/Object/Binary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Binary.cpp?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/lib/Object/Binary.cpp (original) +++ llvm/trunk/lib/Object/Binary.cpp Mon Jun 13 06:12:33 2011 @@ -16,6 +16,10 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" +// Include headers for createBinary. +#include "llvm/Object/ObjectFile.h" +#include "llvm/Object/COFF.h" + using namespace llvm; using namespace object; @@ -37,9 +41,51 @@ error_code object::createBinary(MemoryBuffer *Source, OwningPtr &Result) { - // We don't support any at the moment. - delete Source; - return object_error::invalid_file_type; + OwningPtr scopedSource(Source); + if (!Source) + return make_error_code(errc::invalid_argument); + if (Source->getBufferSize() < 64) + return object_error::invalid_file_type; + sys::LLVMFileType type = sys::IdentifyFileType(Source->getBufferStart(), + static_cast(Source->getBufferSize())); + error_code ec; + switch (type) { + case sys::ELF_Relocatable_FileType: + case sys::ELF_Executable_FileType: + case sys::ELF_SharedObject_FileType: + case sys::ELF_Core_FileType: { + OwningPtr ret( + ObjectFile::createELFObjectFile(scopedSource.take())); + if (!ret) + return object_error::invalid_file_type; + Result.swap(ret); + return object_error::success; + } + case sys::Mach_O_Object_FileType: + case sys::Mach_O_Executable_FileType: + case sys::Mach_O_FixedVirtualMemorySharedLib_FileType: + case sys::Mach_O_Core_FileType: + case sys::Mach_O_PreloadExecutable_FileType: + case sys::Mach_O_DynamicallyLinkedSharedLib_FileType: + case sys::Mach_O_DynamicLinker_FileType: + case sys::Mach_O_Bundle_FileType: + case sys::Mach_O_DynamicallyLinkedSharedLibStub_FileType: { + OwningPtr ret( + ObjectFile::createMachOObjectFile(scopedSource.take())); + if (!ret) + return object_error::invalid_file_type; + Result.swap(ret); + return object_error::success; + } + case sys::COFF_FileType: { + OwningPtr ret(new COFFObjectFile(scopedSource.take(), ec)); + if (ec) return ec; + Result.swap(ret); + return object_error::success; + } + default: // Unrecognized object file format. + return object_error::invalid_file_type; + } } error_code object::createBinary(StringRef Path, OwningPtr &Result) { Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Mon Jun 13 06:12:33 2011 @@ -11,11 +11,9 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Object/COFF.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" -#include "llvm/Object/ObjectFile.h" -#include "llvm/Support/COFF.h" -#include "llvm/Support/Endian.h" using namespace llvm; using namespace object; @@ -27,107 +25,6 @@ using support::little16_t; } -namespace { -struct coff_file_header { - ulittle16_t Machine; - ulittle16_t NumberOfSections; - ulittle32_t TimeDateStamp; - ulittle32_t PointerToSymbolTable; - ulittle32_t NumberOfSymbols; - ulittle16_t SizeOfOptionalHeader; - ulittle16_t Characteristics; -}; -} - -extern char coff_file_header_layout_static_assert - [sizeof(coff_file_header) == 20 ? 1 : -1]; - -namespace { -struct coff_symbol { - struct StringTableOffset { - ulittle32_t Zeroes; - ulittle32_t Offset; - }; - - union { - char ShortName[8]; - StringTableOffset Offset; - } Name; - - ulittle32_t Value; - little16_t SectionNumber; - - struct { - ulittle8_t BaseType; - ulittle8_t ComplexType; - } Type; - - ulittle8_t StorageClass; - ulittle8_t NumberOfAuxSymbols; -}; -} - -extern char coff_coff_symbol_layout_static_assert - [sizeof(coff_symbol) == 18 ? 1 : -1]; - -namespace { -struct coff_section { - char Name[8]; - ulittle32_t VirtualSize; - ulittle32_t VirtualAddress; - ulittle32_t SizeOfRawData; - ulittle32_t PointerToRawData; - ulittle32_t PointerToRelocations; - ulittle32_t PointerToLinenumbers; - ulittle16_t NumberOfRelocations; - ulittle16_t NumberOfLinenumbers; - ulittle32_t Characteristics; -}; -} - -extern char coff_coff_section_layout_static_assert - [sizeof(coff_section) == 40 ? 1 : -1]; - -namespace { -class COFFObjectFile : public ObjectFile { -private: - uint64_t HeaderOff; - const coff_file_header *Header; - const coff_section *SectionTable; - const coff_symbol *SymbolTable; - const char *StringTable; - - const coff_section *getSection(std::size_t index) const; - const char *getString(std::size_t offset) const; - -protected: - virtual SymbolRef getSymbolNext(DataRefImpl Symb) const; - virtual StringRef getSymbolName(DataRefImpl Symb) const; - virtual uint64_t getSymbolAddress(DataRefImpl Symb) const; - virtual uint64_t getSymbolSize(DataRefImpl Symb) const; - virtual char getSymbolNMTypeChar(DataRefImpl Symb) const; - virtual bool isSymbolInternal(DataRefImpl Symb) const; - - virtual SectionRef getSectionNext(DataRefImpl Sec) const; - virtual StringRef getSectionName(DataRefImpl Sec) const; - virtual uint64_t getSectionAddress(DataRefImpl Sec) const; - virtual uint64_t getSectionSize(DataRefImpl Sec) const; - virtual StringRef getSectionContents(DataRefImpl Sec) const; - virtual bool isSectionText(DataRefImpl Sec) const; - -public: - COFFObjectFile(MemoryBuffer *Object); - virtual symbol_iterator begin_symbols() const; - virtual symbol_iterator end_symbols() const; - virtual section_iterator begin_sections() const; - virtual section_iterator end_sections() const; - - virtual uint8_t getBytesInAddress() const; - virtual StringRef getFileFormatName() const; - virtual unsigned getArch() const; -}; -} // end namespace - SymbolRef COFFObjectFile::getSymbolNext(DataRefImpl Symb) const { const coff_symbol *symb = reinterpret_cast(Symb.p); symb += 1 + symb->NumberOfAuxSymbols; @@ -274,7 +171,8 @@ StringRef COFFObjectFile::getSectionContents(DataRefImpl Sec) const { const coff_section *sec = reinterpret_cast(Sec.p); - return StringRef(reinterpret_cast(base + sec->PointerToRawData), + return StringRef(reinterpret_cast(base() + + sec->PointerToRawData), sec->SizeOfRawData); } @@ -283,29 +181,30 @@ return sec->Characteristics & COFF::IMAGE_SCN_CNT_CODE; } -COFFObjectFile::COFFObjectFile(MemoryBuffer *Object) - : ObjectFile(Object) { +COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &ec) + : ObjectFile(Binary::isCOFF, Object, ec) { HeaderOff = 0; - if (base[0] == 0x4d && base[1] == 0x5a) { + if (base()[0] == 0x4d && base()[1] == 0x5a) { // PE/COFF, seek through MS-DOS compatibility stub and 4-byte // PE signature to find 'normal' COFF header. - HeaderOff += *reinterpret_cast(base + 0x3c); + HeaderOff += *reinterpret_cast(base() + 0x3c); HeaderOff += 4; } - Header = reinterpret_cast(base + HeaderOff); + Header = reinterpret_cast(base() + HeaderOff); SectionTable = - reinterpret_cast( base + reinterpret_cast( base() + HeaderOff + sizeof(coff_file_header) + Header->SizeOfOptionalHeader); SymbolTable = - reinterpret_cast(base + Header->PointerToSymbolTable); + reinterpret_cast(base() + + Header->PointerToSymbolTable); // Find string table. - StringTable = reinterpret_cast(base) + StringTable = reinterpret_cast(base()) + Header->PointerToSymbolTable + Header->NumberOfSymbols * 18; } @@ -382,7 +281,8 @@ namespace llvm { ObjectFile *ObjectFile::createCOFFObjectFile(MemoryBuffer *Object) { - return new COFFObjectFile(Object); + error_code ec; + return new COFFObjectFile(Object, ec); } } // end namespace llvm Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Mon Jun 13 06:12:33 2011 @@ -237,7 +237,7 @@ virtual bool isSectionText(DataRefImpl Sec) const; public: - ELFObjectFile(MemoryBuffer *Object); + ELFObjectFile(MemoryBuffer *Object, error_code &ec); virtual symbol_iterator begin_symbols() const; virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; @@ -259,9 +259,9 @@ // an error object around. if (!( symb && SymbolTableSection - && symb >= (const Elf_Sym*)(base + && symb >= (const Elf_Sym*)(base() + SymbolTableSection->sh_offset) - && symb < (const Elf_Sym*)(base + && symb < (const Elf_Sym*)(base() + SymbolTableSection->sh_offset + SymbolTableSection->sh_size))) // FIXME: Proper error handling. @@ -444,7 +444,7 @@ StringRef ELFObjectFile ::getSectionContents(DataRefImpl Sec) const { const Elf_Shdr *sec = reinterpret_cast(Sec.p); - const char *start = (char*)base + sec->sh_offset; + const char *start = (char*)base() + sec->sh_offset; return StringRef(start, sec->sh_size); } @@ -458,21 +458,22 @@ } template -ELFObjectFile::ELFObjectFile(MemoryBuffer *Object) - : ObjectFile(Object) +ELFObjectFile::ELFObjectFile(MemoryBuffer *Object + , error_code &ec) + : ObjectFile(Binary::isELF, Object, ec) , SectionHeaderTable(0) , dot_shstrtab_sec(0) , dot_strtab_sec(0) { - Header = reinterpret_cast(base); + Header = reinterpret_cast(base()); if (Header->e_shoff == 0) return; SectionHeaderTable = - reinterpret_cast(base + Header->e_shoff); + reinterpret_cast(base() + Header->e_shoff); uint32_t SectionTableSize = Header->e_shnum * Header->e_shentsize; if (!( (const uint8_t *)SectionHeaderTable + SectionTableSize - <= base + MapFile->getBufferSize())) + <= base() + Data->getBufferSize())) // FIXME: Proper error handling. report_fatal_error("Section table goes past end of file!"); @@ -491,7 +492,7 @@ dot_shstrtab_sec = getSection(Header->e_shstrndx); if (dot_shstrtab_sec) { // Verify that the last byte in the string table in a null. - if (((const char*)base + dot_shstrtab_sec->sh_offset) + if (((const char*)base() + dot_shstrtab_sec->sh_offset) [dot_shstrtab_sec->sh_size - 1] != 0) // FIXME: Proper error handling. report_fatal_error("String table must end with a null terminator!"); @@ -509,7 +510,7 @@ // FIXME: Proper error handling. report_fatal_error("Already found section named .strtab!"); dot_strtab_sec = sh; - const char *dot_strtab = (const char*)base + sh->sh_offset; + const char *dot_strtab = (const char*)base() + sh->sh_offset; if (dot_strtab[sh->sh_size - 1] != 0) // FIXME: Proper error handling. report_fatal_error("String table must end with a null terminator!"); @@ -548,7 +549,7 @@ ::begin_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); - ret.p = reinterpret_cast(base + Header->e_shoff); + ret.p = reinterpret_cast(base() + Header->e_shoff); return section_iterator(SectionRef(ret, this)); } @@ -557,7 +558,7 @@ ::end_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); - ret.p = reinterpret_cast(base + ret.p = reinterpret_cast(base() + Header->e_shoff + (Header->e_shentsize * Header->e_shnum)); return section_iterator(SectionRef(ret, this)); @@ -613,7 +614,7 @@ ELFObjectFile::getSymbol(DataRefImpl Symb) const { const Elf_Shdr *sec = SymbolTableSections[Symb.d.b]; return reinterpret_cast( - base + base() + sec->sh_offset + (Symb.d.a * sec->sh_entsize)); } @@ -656,8 +657,8 @@ assert(section && section->sh_type == ELF::SHT_STRTAB && "Invalid section!"); if (offset >= section->sh_size) // FIXME: Proper error handling. - report_fatal_error("Sybol name offset outside of string table!"); - return (const char *)base + section->sh_offset + offset; + report_fatal_error("Symbol name offset outside of string table!"); + return (const char *)base() + section->sh_offset + offset; } // EI_CLASS, EI_DATA. @@ -673,14 +674,15 @@ ObjectFile *ObjectFile::createELFObjectFile(MemoryBuffer *Object) { std::pair Ident = getElfArchType(Object); + error_code ec; if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2LSB) - return new ELFObjectFile(Object); + return new ELFObjectFile(Object, ec); else if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2MSB) - return new ELFObjectFile(Object); + return new ELFObjectFile(Object, ec); else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2LSB) - return new ELFObjectFile(Object); + return new ELFObjectFile(Object, ec); else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2MSB) - return new ELFObjectFile(Object); + return new ELFObjectFile(Object, ec); // FIXME: Proper error handling. report_fatal_error("Not an ELF object file!"); } Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original) +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon Jun 13 06:12:33 2011 @@ -32,8 +32,8 @@ class MachOObjectFile : public ObjectFile { public: - MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO) - : ObjectFile(Object), + MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, error_code &ec) + : ObjectFile(Binary::isMachO, Object, ec), MachOObj(MOO), RegisteredStringTable(std::numeric_limits::max()) {} @@ -73,11 +73,12 @@ }; ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) { + error_code ec; std::string Err; MachOObject *MachOObj = MachOObject::LoadFromBuffer(Buffer, &Err); if (!MachOObj) return NULL; - return new MachOObjectFile(Buffer, MachOObj); + return new MachOObjectFile(Buffer, MachOObj, ec); } /*===-- Symbols -----------------------------------------------------------===*/ Modified: llvm/trunk/lib/Object/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ObjectFile.cpp?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/lib/Object/ObjectFile.cpp (original) +++ llvm/trunk/lib/Object/ObjectFile.cpp Mon Jun 13 06:12:33 2011 @@ -21,18 +21,8 @@ using namespace llvm; using namespace object; -ObjectFile::ObjectFile(MemoryBuffer *Object) - : MapFile(Object) { - assert(MapFile && "Must be a valid MemoryBuffer!"); - base = reinterpret_cast(MapFile->getBufferStart()); -} - -ObjectFile::~ObjectFile() { - delete MapFile; -} - -StringRef ObjectFile::getFilename() const { - return MapFile->getBufferIdentifier(); +ObjectFile::ObjectFile(unsigned int Type, MemoryBuffer *source, error_code &ec) + : Binary(Type, source) { } ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) { Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=132911&r1=132910&r2=132911&view=diff ============================================================================== --- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original) +++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Mon Jun 13 06:12:33 2011 @@ -277,7 +277,7 @@ SymbolList.push_back(s); } - CurrentFilename = obj->getFilename(); + CurrentFilename = obj->getFileName(); SortAndPrintSymbolList(); } From bigcheesegs at gmail.com Mon Jun 13 06:12:42 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 13 Jun 2011 11:12:42 -0000 Subject: [llvm-commits] [llvm] r132912 - /llvm/trunk/tools/llvm-nm/llvm-nm.cpp Message-ID: <20110613111242.84F6C2A6C12C@llvm.org> Author: mspencer Date: Mon Jun 13 06:12:42 2011 New Revision: 132912 URL: http://llvm.org/viewvc/llvm-project?rev=132912&view=rev Log: Modify llvm-nm to use new Binary creation method. Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=132912&r1=132911&r2=132912&view=diff ============================================================================== --- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original) +++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Mon Jun 13 06:12:42 2011 @@ -317,13 +317,13 @@ MultipleFiles = true; std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule); } else if (aPath.isObjectFile()) { - std::auto_ptr obj(ObjectFile::createObjectFile(aPath.str())); - if (!obj.get()) { - errs() << ToolName << ": " << Filename << ": " - << "Failed to open object file\n"; + OwningPtr obj; + if (error_code ec = object::createBinary(aPath.str(), obj)) { + errs() << ToolName << ": " << Filename << ": " << ec.message() << ".\n"; return; } - DumpSymbolNamesFromObject(obj.get()); + if (object::ObjectFile *o = dyn_cast(obj.get())) + DumpSymbolNamesFromObject(o); } else { errs() << ToolName << ": " << Filename << ": " << "unrecognizable file type\n"; From geek4civic at gmail.com Mon Jun 13 06:40:36 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 13 Jun 2011 20:40:36 +0900 Subject: [llvm-commits] [MSVC] Possible miscompilation on TargetLoweringObjectFileELF::emitPersonalityValue() In-Reply-To: <4DF580D6.6070904@gmail.com> References: <4DF580D6.6070904@gmail.com> Message-ID: Rafael, > Can you try 132898? Bingo! Thank you! > Sorry for the bug. NP, it failed only on msvc10+optimizations. (Apparently looks fine on cygming and linux) ...Takumi From bigcheesegs at gmail.com Mon Jun 13 06:53:32 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 13 Jun 2011 11:53:32 -0000 Subject: [llvm-commits] [llvm] r132913 - in /llvm/trunk: include/llvm/Object/Binary.h include/llvm/Object/COFF.h include/llvm/Object/ObjectFile.h lib/Object/Binary.cpp lib/Object/COFFObjectFile.cpp lib/Object/ELFObjectFile.cpp lib/Object/MachOObjectFile.cpp lib/Object/ObjectFile.cpp tools/llvm-nm/llvm-nm.cpp Message-ID: <20110613115332.34E852A6C12C@llvm.org> Author: mspencer Date: Mon Jun 13 06:53:31 2011 New Revision: 132913 URL: http://llvm.org/viewvc/llvm-project?rev=132913&view=rev Log: Revert the last two commits in the series. r132911, r132912. Removed: llvm/trunk/include/llvm/Object/COFF.h Modified: llvm/trunk/include/llvm/Object/Binary.h llvm/trunk/include/llvm/Object/ObjectFile.h llvm/trunk/lib/Object/Binary.cpp llvm/trunk/lib/Object/COFFObjectFile.cpp llvm/trunk/lib/Object/ELFObjectFile.cpp llvm/trunk/lib/Object/MachOObjectFile.cpp llvm/trunk/lib/Object/ObjectFile.cpp llvm/trunk/tools/llvm-nm/llvm-nm.cpp Modified: llvm/trunk/include/llvm/Object/Binary.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Binary.h?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/Binary.h (original) +++ llvm/trunk/include/llvm/Object/Binary.h Mon Jun 13 06:53:31 2011 @@ -38,13 +38,10 @@ enum { isArchive, - - // Object and children. - isObject, isCOFF, isELF, isMachO, - lastObject + isObject }; public: @@ -55,7 +52,7 @@ // Cast methods. unsigned int getType() const { return TypeID; } - static inline bool classof(const Binary *v) { return true; } + static inline bool classof(Binary const *v) { return true; } }; error_code createBinary(MemoryBuffer *Source, OwningPtr &Result); Removed: llvm/trunk/include/llvm/Object/COFF.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=132912&view=auto ============================================================================== --- llvm/trunk/include/llvm/Object/COFF.h (original) +++ llvm/trunk/include/llvm/Object/COFF.h (removed) @@ -1,111 +0,0 @@ -//===- COFF.h - COFF object file implementation -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the COFFObjectFile class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_OBJECT_COFF_H -#define LLVM_OBJECT_COFF_H - -#include "llvm/Object/ObjectFile.h" -#include "llvm/Support/COFF.h" -#include "llvm/Support/Endian.h" - -namespace llvm { -namespace object { - -struct coff_file_header { - support::ulittle16_t Machine; - support::ulittle16_t NumberOfSections; - support::ulittle32_t TimeDateStamp; - support::ulittle32_t PointerToSymbolTable; - support::ulittle32_t NumberOfSymbols; - support::ulittle16_t SizeOfOptionalHeader; - support::ulittle16_t Characteristics; -}; - -struct coff_symbol { - struct StringTableOffset { - support::ulittle32_t Zeroes; - support::ulittle32_t Offset; - }; - - union { - char ShortName[8]; - StringTableOffset Offset; - } Name; - - support::ulittle32_t Value; - support::little16_t SectionNumber; - - struct { - support::ulittle8_t BaseType; - support::ulittle8_t ComplexType; - } Type; - - support::ulittle8_t StorageClass; - support::ulittle8_t NumberOfAuxSymbols; -}; - -struct coff_section { - char Name[8]; - support::ulittle32_t VirtualSize; - support::ulittle32_t VirtualAddress; - support::ulittle32_t SizeOfRawData; - support::ulittle32_t PointerToRawData; - support::ulittle32_t PointerToRelocations; - support::ulittle32_t PointerToLinenumbers; - support::ulittle16_t NumberOfRelocations; - support::ulittle16_t NumberOfLinenumbers; - support::ulittle32_t Characteristics; -}; - -class COFFObjectFile : public ObjectFile { -private: - uint64_t HeaderOff; - const coff_file_header *Header; - const coff_section *SectionTable; - const coff_symbol *SymbolTable; - const char *StringTable; - - const coff_section *getSection(std::size_t index) const; - const char *getString(std::size_t offset) const; - -protected: - virtual SymbolRef getSymbolNext(DataRefImpl Symb) const; - virtual StringRef getSymbolName(DataRefImpl Symb) const; - virtual uint64_t getSymbolAddress(DataRefImpl Symb) const; - virtual uint64_t getSymbolSize(DataRefImpl Symb) const; - virtual char getSymbolNMTypeChar(DataRefImpl Symb) const; - virtual bool isSymbolInternal(DataRefImpl Symb) const; - - virtual SectionRef getSectionNext(DataRefImpl Sec) const; - virtual StringRef getSectionName(DataRefImpl Sec) const; - virtual uint64_t getSectionAddress(DataRefImpl Sec) const; - virtual uint64_t getSectionSize(DataRefImpl Sec) const; - virtual StringRef getSectionContents(DataRefImpl Sec) const; - virtual bool isSectionText(DataRefImpl Sec) const; - -public: - COFFObjectFile(MemoryBuffer *Object, error_code &ec); - virtual symbol_iterator begin_symbols() const; - virtual symbol_iterator end_symbols() const; - virtual section_iterator begin_sections() const; - virtual section_iterator end_sections() const; - - virtual uint8_t getBytesInAddress() const; - virtual StringRef getFileFormatName() const; - virtual unsigned getArch() const; -}; - -} -} - -#endif Modified: llvm/trunk/include/llvm/Object/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/ObjectFile.h (original) +++ llvm/trunk/include/llvm/Object/ObjectFile.h Mon Jun 13 06:53:31 2011 @@ -14,13 +14,15 @@ #ifndef LLVM_OBJECT_OBJECT_FILE_H #define LLVM_OBJECT_OBJECT_FILE_H -#include "llvm/Object/Binary.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/MemoryBuffer.h" #include namespace llvm { + +class MemoryBuffer; +class StringRef; + namespace object { class ObjectFile; @@ -91,17 +93,16 @@ /// ObjectFile - This class is the base class for all object file types. /// Concrete instances of this object are created by createObjectFile, which /// figure out which type to create. -class ObjectFile : public Binary { +class ObjectFile { private: ObjectFile(); // = delete ObjectFile(const ObjectFile &other); // = delete protected: - ObjectFile(unsigned int Type, MemoryBuffer *source, error_code &ec); + MemoryBuffer *MapFile; + const uint8_t *base; - const uint8_t *base() const { - return reinterpret_cast(Data->getBufferStart()); - } + ObjectFile(MemoryBuffer *Object); // These functions are for SymbolRef to call internally. The main goal of // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol @@ -155,6 +156,8 @@ typedef content_iterator symbol_iterator; typedef content_iterator section_iterator; + virtual ~ObjectFile(); + virtual symbol_iterator begin_symbols() const = 0; virtual symbol_iterator end_symbols() const = 0; @@ -168,6 +171,8 @@ virtual StringRef getFileFormatName() const = 0; virtual /* Triple::ArchType */ unsigned getArch() const = 0; + StringRef getFilename() const; + /// @returns Pointer to ObjectFile subclass to handle this type of object. /// @param ObjectPath The path to the object file. ObjectPath.isObject must /// return true. @@ -175,16 +180,12 @@ static ObjectFile *createObjectFile(StringRef ObjectPath); static ObjectFile *createObjectFile(MemoryBuffer *Object); - static inline bool classof(const Binary *v) { - return v->getType() >= isObject && - v->getType() < lastObject; - } - static inline bool classof(const ObjectFile *v) { return true; } - -public: +private: static ObjectFile *createCOFFObjectFile(MemoryBuffer *Object); static ObjectFile *createELFObjectFile(MemoryBuffer *Object); static ObjectFile *createMachOObjectFile(MemoryBuffer *Object); + static ObjectFile *createArchiveObjectFile(MemoryBuffer *Object); + static ObjectFile *createLibObjectFile(MemoryBuffer *Object); }; // Inline function definitions. Modified: llvm/trunk/lib/Object/Binary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Binary.cpp?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/lib/Object/Binary.cpp (original) +++ llvm/trunk/lib/Object/Binary.cpp Mon Jun 13 06:53:31 2011 @@ -16,10 +16,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" -// Include headers for createBinary. -#include "llvm/Object/ObjectFile.h" -#include "llvm/Object/COFF.h" - using namespace llvm; using namespace object; @@ -41,51 +37,9 @@ error_code object::createBinary(MemoryBuffer *Source, OwningPtr &Result) { - OwningPtr scopedSource(Source); - if (!Source) - return make_error_code(errc::invalid_argument); - if (Source->getBufferSize() < 64) - return object_error::invalid_file_type; - sys::LLVMFileType type = sys::IdentifyFileType(Source->getBufferStart(), - static_cast(Source->getBufferSize())); - error_code ec; - switch (type) { - case sys::ELF_Relocatable_FileType: - case sys::ELF_Executable_FileType: - case sys::ELF_SharedObject_FileType: - case sys::ELF_Core_FileType: { - OwningPtr ret( - ObjectFile::createELFObjectFile(scopedSource.take())); - if (!ret) - return object_error::invalid_file_type; - Result.swap(ret); - return object_error::success; - } - case sys::Mach_O_Object_FileType: - case sys::Mach_O_Executable_FileType: - case sys::Mach_O_FixedVirtualMemorySharedLib_FileType: - case sys::Mach_O_Core_FileType: - case sys::Mach_O_PreloadExecutable_FileType: - case sys::Mach_O_DynamicallyLinkedSharedLib_FileType: - case sys::Mach_O_DynamicLinker_FileType: - case sys::Mach_O_Bundle_FileType: - case sys::Mach_O_DynamicallyLinkedSharedLibStub_FileType: { - OwningPtr ret( - ObjectFile::createMachOObjectFile(scopedSource.take())); - if (!ret) - return object_error::invalid_file_type; - Result.swap(ret); - return object_error::success; - } - case sys::COFF_FileType: { - OwningPtr ret(new COFFObjectFile(scopedSource.take(), ec)); - if (ec) return ec; - Result.swap(ret); - return object_error::success; - } - default: // Unrecognized object file format. - return object_error::invalid_file_type; - } + // We don't support any at the moment. + delete Source; + return object_error::invalid_file_type; } error_code object::createBinary(StringRef Path, OwningPtr &Result) { Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Mon Jun 13 06:53:31 2011 @@ -11,9 +11,11 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Object/COFF.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/COFF.h" +#include "llvm/Support/Endian.h" using namespace llvm; using namespace object; @@ -25,6 +27,107 @@ using support::little16_t; } +namespace { +struct coff_file_header { + ulittle16_t Machine; + ulittle16_t NumberOfSections; + ulittle32_t TimeDateStamp; + ulittle32_t PointerToSymbolTable; + ulittle32_t NumberOfSymbols; + ulittle16_t SizeOfOptionalHeader; + ulittle16_t Characteristics; +}; +} + +extern char coff_file_header_layout_static_assert + [sizeof(coff_file_header) == 20 ? 1 : -1]; + +namespace { +struct coff_symbol { + struct StringTableOffset { + ulittle32_t Zeroes; + ulittle32_t Offset; + }; + + union { + char ShortName[8]; + StringTableOffset Offset; + } Name; + + ulittle32_t Value; + little16_t SectionNumber; + + struct { + ulittle8_t BaseType; + ulittle8_t ComplexType; + } Type; + + ulittle8_t StorageClass; + ulittle8_t NumberOfAuxSymbols; +}; +} + +extern char coff_coff_symbol_layout_static_assert + [sizeof(coff_symbol) == 18 ? 1 : -1]; + +namespace { +struct coff_section { + char Name[8]; + ulittle32_t VirtualSize; + ulittle32_t VirtualAddress; + ulittle32_t SizeOfRawData; + ulittle32_t PointerToRawData; + ulittle32_t PointerToRelocations; + ulittle32_t PointerToLinenumbers; + ulittle16_t NumberOfRelocations; + ulittle16_t NumberOfLinenumbers; + ulittle32_t Characteristics; +}; +} + +extern char coff_coff_section_layout_static_assert + [sizeof(coff_section) == 40 ? 1 : -1]; + +namespace { +class COFFObjectFile : public ObjectFile { +private: + uint64_t HeaderOff; + const coff_file_header *Header; + const coff_section *SectionTable; + const coff_symbol *SymbolTable; + const char *StringTable; + + const coff_section *getSection(std::size_t index) const; + const char *getString(std::size_t offset) const; + +protected: + virtual SymbolRef getSymbolNext(DataRefImpl Symb) const; + virtual StringRef getSymbolName(DataRefImpl Symb) const; + virtual uint64_t getSymbolAddress(DataRefImpl Symb) const; + virtual uint64_t getSymbolSize(DataRefImpl Symb) const; + virtual char getSymbolNMTypeChar(DataRefImpl Symb) const; + virtual bool isSymbolInternal(DataRefImpl Symb) const; + + virtual SectionRef getSectionNext(DataRefImpl Sec) const; + virtual StringRef getSectionName(DataRefImpl Sec) const; + virtual uint64_t getSectionAddress(DataRefImpl Sec) const; + virtual uint64_t getSectionSize(DataRefImpl Sec) const; + virtual StringRef getSectionContents(DataRefImpl Sec) const; + virtual bool isSectionText(DataRefImpl Sec) const; + +public: + COFFObjectFile(MemoryBuffer *Object); + virtual symbol_iterator begin_symbols() const; + virtual symbol_iterator end_symbols() const; + virtual section_iterator begin_sections() const; + virtual section_iterator end_sections() const; + + virtual uint8_t getBytesInAddress() const; + virtual StringRef getFileFormatName() const; + virtual unsigned getArch() const; +}; +} // end namespace + SymbolRef COFFObjectFile::getSymbolNext(DataRefImpl Symb) const { const coff_symbol *symb = reinterpret_cast(Symb.p); symb += 1 + symb->NumberOfAuxSymbols; @@ -171,8 +274,7 @@ StringRef COFFObjectFile::getSectionContents(DataRefImpl Sec) const { const coff_section *sec = reinterpret_cast(Sec.p); - return StringRef(reinterpret_cast(base() - + sec->PointerToRawData), + return StringRef(reinterpret_cast(base + sec->PointerToRawData), sec->SizeOfRawData); } @@ -181,30 +283,29 @@ return sec->Characteristics & COFF::IMAGE_SCN_CNT_CODE; } -COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &ec) - : ObjectFile(Binary::isCOFF, Object, ec) { +COFFObjectFile::COFFObjectFile(MemoryBuffer *Object) + : ObjectFile(Object) { HeaderOff = 0; - if (base()[0] == 0x4d && base()[1] == 0x5a) { + if (base[0] == 0x4d && base[1] == 0x5a) { // PE/COFF, seek through MS-DOS compatibility stub and 4-byte // PE signature to find 'normal' COFF header. - HeaderOff += *reinterpret_cast(base() + 0x3c); + HeaderOff += *reinterpret_cast(base + 0x3c); HeaderOff += 4; } - Header = reinterpret_cast(base() + HeaderOff); + Header = reinterpret_cast(base + HeaderOff); SectionTable = - reinterpret_cast( base() + reinterpret_cast( base + HeaderOff + sizeof(coff_file_header) + Header->SizeOfOptionalHeader); SymbolTable = - reinterpret_cast(base() - + Header->PointerToSymbolTable); + reinterpret_cast(base + Header->PointerToSymbolTable); // Find string table. - StringTable = reinterpret_cast(base()) + StringTable = reinterpret_cast(base) + Header->PointerToSymbolTable + Header->NumberOfSymbols * 18; } @@ -281,8 +382,7 @@ namespace llvm { ObjectFile *ObjectFile::createCOFFObjectFile(MemoryBuffer *Object) { - error_code ec; - return new COFFObjectFile(Object, ec); + return new COFFObjectFile(Object); } } // end namespace llvm Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Mon Jun 13 06:53:31 2011 @@ -237,7 +237,7 @@ virtual bool isSectionText(DataRefImpl Sec) const; public: - ELFObjectFile(MemoryBuffer *Object, error_code &ec); + ELFObjectFile(MemoryBuffer *Object); virtual symbol_iterator begin_symbols() const; virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; @@ -259,9 +259,9 @@ // an error object around. if (!( symb && SymbolTableSection - && symb >= (const Elf_Sym*)(base() + && symb >= (const Elf_Sym*)(base + SymbolTableSection->sh_offset) - && symb < (const Elf_Sym*)(base() + && symb < (const Elf_Sym*)(base + SymbolTableSection->sh_offset + SymbolTableSection->sh_size))) // FIXME: Proper error handling. @@ -444,7 +444,7 @@ StringRef ELFObjectFile ::getSectionContents(DataRefImpl Sec) const { const Elf_Shdr *sec = reinterpret_cast(Sec.p); - const char *start = (char*)base() + sec->sh_offset; + const char *start = (char*)base + sec->sh_offset; return StringRef(start, sec->sh_size); } @@ -458,22 +458,21 @@ } template -ELFObjectFile::ELFObjectFile(MemoryBuffer *Object - , error_code &ec) - : ObjectFile(Binary::isELF, Object, ec) +ELFObjectFile::ELFObjectFile(MemoryBuffer *Object) + : ObjectFile(Object) , SectionHeaderTable(0) , dot_shstrtab_sec(0) , dot_strtab_sec(0) { - Header = reinterpret_cast(base()); + Header = reinterpret_cast(base); if (Header->e_shoff == 0) return; SectionHeaderTable = - reinterpret_cast(base() + Header->e_shoff); + reinterpret_cast(base + Header->e_shoff); uint32_t SectionTableSize = Header->e_shnum * Header->e_shentsize; if (!( (const uint8_t *)SectionHeaderTable + SectionTableSize - <= base() + Data->getBufferSize())) + <= base + MapFile->getBufferSize())) // FIXME: Proper error handling. report_fatal_error("Section table goes past end of file!"); @@ -492,7 +491,7 @@ dot_shstrtab_sec = getSection(Header->e_shstrndx); if (dot_shstrtab_sec) { // Verify that the last byte in the string table in a null. - if (((const char*)base() + dot_shstrtab_sec->sh_offset) + if (((const char*)base + dot_shstrtab_sec->sh_offset) [dot_shstrtab_sec->sh_size - 1] != 0) // FIXME: Proper error handling. report_fatal_error("String table must end with a null terminator!"); @@ -510,7 +509,7 @@ // FIXME: Proper error handling. report_fatal_error("Already found section named .strtab!"); dot_strtab_sec = sh; - const char *dot_strtab = (const char*)base() + sh->sh_offset; + const char *dot_strtab = (const char*)base + sh->sh_offset; if (dot_strtab[sh->sh_size - 1] != 0) // FIXME: Proper error handling. report_fatal_error("String table must end with a null terminator!"); @@ -549,7 +548,7 @@ ::begin_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); - ret.p = reinterpret_cast(base() + Header->e_shoff); + ret.p = reinterpret_cast(base + Header->e_shoff); return section_iterator(SectionRef(ret, this)); } @@ -558,7 +557,7 @@ ::end_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); - ret.p = reinterpret_cast(base() + ret.p = reinterpret_cast(base + Header->e_shoff + (Header->e_shentsize * Header->e_shnum)); return section_iterator(SectionRef(ret, this)); @@ -614,7 +613,7 @@ ELFObjectFile::getSymbol(DataRefImpl Symb) const { const Elf_Shdr *sec = SymbolTableSections[Symb.d.b]; return reinterpret_cast( - base() + base + sec->sh_offset + (Symb.d.a * sec->sh_entsize)); } @@ -657,8 +656,8 @@ assert(section && section->sh_type == ELF::SHT_STRTAB && "Invalid section!"); if (offset >= section->sh_size) // FIXME: Proper error handling. - report_fatal_error("Symbol name offset outside of string table!"); - return (const char *)base() + section->sh_offset + offset; + report_fatal_error("Sybol name offset outside of string table!"); + return (const char *)base + section->sh_offset + offset; } // EI_CLASS, EI_DATA. @@ -674,15 +673,14 @@ ObjectFile *ObjectFile::createELFObjectFile(MemoryBuffer *Object) { std::pair Ident = getElfArchType(Object); - error_code ec; if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2LSB) - return new ELFObjectFile(Object, ec); + return new ELFObjectFile(Object); else if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2MSB) - return new ELFObjectFile(Object, ec); + return new ELFObjectFile(Object); else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2LSB) - return new ELFObjectFile(Object, ec); + return new ELFObjectFile(Object); else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2MSB) - return new ELFObjectFile(Object, ec); + return new ELFObjectFile(Object); // FIXME: Proper error handling. report_fatal_error("Not an ELF object file!"); } Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original) +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon Jun 13 06:53:31 2011 @@ -32,8 +32,8 @@ class MachOObjectFile : public ObjectFile { public: - MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, error_code &ec) - : ObjectFile(Binary::isMachO, Object, ec), + MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO) + : ObjectFile(Object), MachOObj(MOO), RegisteredStringTable(std::numeric_limits::max()) {} @@ -73,12 +73,11 @@ }; ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) { - error_code ec; std::string Err; MachOObject *MachOObj = MachOObject::LoadFromBuffer(Buffer, &Err); if (!MachOObj) return NULL; - return new MachOObjectFile(Buffer, MachOObj, ec); + return new MachOObjectFile(Buffer, MachOObj); } /*===-- Symbols -----------------------------------------------------------===*/ Modified: llvm/trunk/lib/Object/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ObjectFile.cpp?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/lib/Object/ObjectFile.cpp (original) +++ llvm/trunk/lib/Object/ObjectFile.cpp Mon Jun 13 06:53:31 2011 @@ -21,8 +21,18 @@ using namespace llvm; using namespace object; -ObjectFile::ObjectFile(unsigned int Type, MemoryBuffer *source, error_code &ec) - : Binary(Type, source) { +ObjectFile::ObjectFile(MemoryBuffer *Object) + : MapFile(Object) { + assert(MapFile && "Must be a valid MemoryBuffer!"); + base = reinterpret_cast(MapFile->getBufferStart()); +} + +ObjectFile::~ObjectFile() { + delete MapFile; +} + +StringRef ObjectFile::getFilename() const { + return MapFile->getBufferIdentifier(); } ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) { Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=132913&r1=132912&r2=132913&view=diff ============================================================================== --- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original) +++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Mon Jun 13 06:53:31 2011 @@ -277,7 +277,7 @@ SymbolList.push_back(s); } - CurrentFilename = obj->getFileName(); + CurrentFilename = obj->getFilename(); SortAndPrintSymbolList(); } @@ -317,13 +317,13 @@ MultipleFiles = true; std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule); } else if (aPath.isObjectFile()) { - OwningPtr obj; - if (error_code ec = object::createBinary(aPath.str(), obj)) { - errs() << ToolName << ": " << Filename << ": " << ec.message() << ".\n"; + std::auto_ptr obj(ObjectFile::createObjectFile(aPath.str())); + if (!obj.get()) { + errs() << ToolName << ": " << Filename << ": " + << "Failed to open object file\n"; return; } - if (object::ObjectFile *o = dyn_cast(obj.get())) - DumpSymbolNamesFromObject(o); + DumpSymbolNamesFromObject(obj.get()); } else { errs() << ToolName << ": " << Filename << ": " << "unrecognizable file type\n"; From benny.kra at googlemail.com Mon Jun 13 07:56:51 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 13 Jun 2011 12:56:51 -0000 Subject: [llvm-commits] [llvm] r132914 - in /llvm/trunk: include/llvm/Object/Binary.h include/llvm/Object/Error.h lib/Object/Binary.cpp lib/Object/CMakeLists.txt lib/Object/Error.cpp Message-ID: <20110613125651.A00992A6C12C@llvm.org> Author: d0k Date: Mon Jun 13 07:56:51 2011 New Revision: 132914 URL: http://llvm.org/viewvc/llvm-project?rev=132914&view=rev Log: Revert r132910 and r132909 on behalf of Michael. They didn't build with clang. Removed: llvm/trunk/include/llvm/Object/Binary.h llvm/trunk/include/llvm/Object/Error.h llvm/trunk/lib/Object/Binary.cpp llvm/trunk/lib/Object/Error.cpp Modified: llvm/trunk/lib/Object/CMakeLists.txt Removed: llvm/trunk/include/llvm/Object/Binary.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Binary.h?rev=132913&view=auto ============================================================================== --- llvm/trunk/include/llvm/Object/Binary.h (original) +++ llvm/trunk/include/llvm/Object/Binary.h (removed) @@ -1,64 +0,0 @@ -//===- Binary.h - A generic binary file -------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the Binary class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_OBJECT_BINARY_H -#define LLVM_OBJECT_BINARY_H - -#include "llvm/ADT/OwningPtr.h" -#include "llvm/Object/Error.h" - -namespace llvm { - -class MemoryBuffer; -class StringRef; - -namespace object { - -class Binary { -private: - Binary(); // = delete - Binary(const Binary &other); // = delete - - unsigned int TypeID; - -protected: - MemoryBuffer *Data; - - Binary(unsigned int Type, MemoryBuffer *Source); - - enum { - isArchive, - isCOFF, - isELF, - isMachO, - isObject - }; - -public: - virtual ~Binary(); - - StringRef getData() const; - StringRef getFileName() const; - - // Cast methods. - unsigned int getType() const { return TypeID; } - static inline bool classof(Binary const *v) { return true; } -}; - -error_code createBinary(MemoryBuffer *Source, OwningPtr &Result); -error_code createBinary(StringRef Path, OwningPtr &Result); - -} -} - -#endif Removed: llvm/trunk/include/llvm/Object/Error.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Error.h?rev=132913&view=auto ============================================================================== --- llvm/trunk/include/llvm/Object/Error.h (original) +++ llvm/trunk/include/llvm/Object/Error.h (removed) @@ -1,49 +0,0 @@ -//===- Error.h - system_error extensions for Object -------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This declares a new error_category for the Object library. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_OBJECT_ERROR_H -#define LLVM_OBJECT_ERROR_H - -#include "llvm/Support/system_error.h" - -namespace llvm { -namespace object { - -const error_category &object_category(); - -struct object_error { -enum _ { - success = 0, - invalid_file_type, - parse_failed -}; - _ v_; - - object_error(_ v) : v_(v) {} - explicit object_error(int v) : v_(_(v)) {} - operator int() const {return v_;} -}; - -} // end namespace object. - -template <> struct is_error_code_enum : true_type { }; - -template <> struct is_error_code_enum : true_type { }; - -inline error_code make_error_code(object::object_error e) { - return error_code(static_cast(e), object::object_category()); -} - -} // end namespace llvm. - -#endif Removed: llvm/trunk/lib/Object/Binary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Binary.cpp?rev=132913&view=auto ============================================================================== --- llvm/trunk/lib/Object/Binary.cpp (original) +++ llvm/trunk/lib/Object/Binary.cpp (removed) @@ -1,50 +0,0 @@ -//===- Binary.cpp - A generic binary file -----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the Binary class. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Object/Binary.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Path.h" - -using namespace llvm; -using namespace object; - -Binary::~Binary() { - delete Data; -} - -Binary::Binary(unsigned int Type, MemoryBuffer *Source) - : TypeID(Type) - , Data(Source) {} - -StringRef Binary::getData() const { - return Data->getBuffer(); -} - -StringRef Binary::getFileName() const { - return Data->getBufferIdentifier(); -} - -error_code object::createBinary(MemoryBuffer *Source, - OwningPtr &Result) { - // We don't support any at the moment. - delete Source; - return object_error::invalid_file_type; -} - -error_code object::createBinary(StringRef Path, OwningPtr &Result) { - OwningPtr File; - if (error_code ec = MemoryBuffer::getFile(Path, File)) - return ec; - return createBinary(File.take(), Result); -} Modified: llvm/trunk/lib/Object/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/CMakeLists.txt?rev=132914&r1=132913&r2=132914&view=diff ============================================================================== --- llvm/trunk/lib/Object/CMakeLists.txt (original) +++ llvm/trunk/lib/Object/CMakeLists.txt Mon Jun 13 07:56:51 2011 @@ -1,8 +1,6 @@ add_llvm_library(LLVMObject - Binary.cpp COFFObjectFile.cpp ELFObjectFile.cpp - Error.cpp MachOObject.cpp MachOObjectFile.cpp Object.cpp Removed: llvm/trunk/lib/Object/Error.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=132913&view=auto ============================================================================== --- llvm/trunk/lib/Object/Error.cpp (original) +++ llvm/trunk/lib/Object/Error.cpp (removed) @@ -1,55 +0,0 @@ -//===- Error.cpp - system_error extensions for Object -----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This defines a new error_category for the Object library. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Object/Error.h" -#include "llvm/Support/ErrorHandling.h" - -using namespace llvm; -using namespace object; - -namespace { -class _object_error_category : public _do_message { -public: - virtual const char* name() const; - virtual std::string message(int ev) const; - virtual error_condition default_error_condition(int ev) const; -}; -} - -const char *_object_error_category::name() const { - return "llvm.object"; -} - -std::string _object_error_category::message(int ev) const { - switch (ev) { - case object_error::success: return "Success"; - case object_error::invalid_file_type: - return "The file was not recognized as a valid object file"; - case object_error::parse_failed: - return "Invalid data was encountered while parsing the file"; - default: - llvm_unreachable("An enumerator of object_error does not have a message " - "defined."); - } -} - -error_condition _object_error_category::default_error_condition(int ev) const { - if (ev == object_error::success) - return errc::success; - return errc::invalid_argument; -} - -const error_category &object::object_category() { - static _object_error_category o; - return o; -} From rafael.espindola at gmail.com Mon Jun 13 09:22:43 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Mon, 13 Jun 2011 10:22:43 -0400 Subject: [llvm-commits] Enable early dup for small bb, take2 In-Reply-To: <4DF5A6BE.1050501@gmail.com> References: <4DF5A6BE.1050501@gmail.com> Message-ID: <4DF61D33.4090906@gmail.com> > The size increase in clang is coming mostly from CGClass.o. With the > patch we decide to duplicate a block with one instruction into its only > predecessor (and remove the original one). Everything goes fine until > branch folding decides to create many copies of a block with 4 > instructions in it. I haven't debugged what causes branch folding to > change its mind. I added the testcase and logs to http://people.mozilla.org/~respindola/CGClass.ii.bz2 http://people.mozilla.org/~respindola/patch.log.bz2 http://people.mozilla.org/~respindola/trunk.log.bz2 Cheers, Rafael From benny.kra at googlemail.com Mon Jun 13 10:24:24 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 13 Jun 2011 15:24:24 -0000 Subject: [llvm-commits] [llvm] r132915 - in /llvm/trunk: lib/Target/README.txt lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20110613152424.D0ADA2A6C12C@llvm.org> Author: d0k Date: Mon Jun 13 10:24:24 2011 New Revision: 132915 URL: http://llvm.org/viewvc/llvm-project?rev=132915&view=rev Log: InstCombine: Fold A-b == C --> b == A-C if A and C are constants. The backend already knew this trick. Modified: llvm/trunk/lib/Target/README.txt llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/test/Transforms/InstCombine/icmp.ll Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=132915&r1=132914&r2=132915&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Mon Jun 13 10:24:24 2011 @@ -870,11 +870,6 @@ bar (); } -void neg_eq_cst(unsigned int a) { -if (-a == 123) -bar(); -} - All should simplify to a single comparison. All of these are currently not optimized with "clang -emit-llvm-bc | opt -std-compile-opts". Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=132915&r1=132914&r2=132915&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jun 13 10:24:24 2011 @@ -1407,18 +1407,27 @@ case Instruction::Xor: // For the xor case, we can xor two constants together, eliminating // the explicit xor. - if (Constant *BOC = dyn_cast(BO->getOperand(1))) - return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), + if (Constant *BOC = dyn_cast(BO->getOperand(1))) { + return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), ConstantExpr::getXor(RHS, BOC)); - - // FALLTHROUGH + } else if (RHSV == 0) { + // Replace ((xor A, B) != 0) with (A != B) + return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), + BO->getOperand(1)); + } + break; case Instruction::Sub: - // Replace (([sub|xor] A, B) != 0) with (A != B) - if (RHSV == 0) + // Replace ((sub A, B) != C) with (B != A-C) if A & C are constants. + if (ConstantInt *BOp0C = dyn_cast(BO->getOperand(0))) { + if (BO->hasOneUse()) + return new ICmpInst(ICI.getPredicate(), BO->getOperand(1), + ConstantExpr::getSub(BOp0C, RHS)); + } else if (RHSV == 0) { + // Replace ((sub A, B) != 0) with (A != B) return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), BO->getOperand(1)); + } break; - case Instruction::Or: // If bits are being or'd in that are not present in the constant we // are comparing against, then the comparison could never succeed! Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=132915&r1=132914&r2=132915&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Mon Jun 13 10:24:24 2011 @@ -531,3 +531,19 @@ %ret = icmp eq i32 %and, 128 ret i1 %ret } + +; CHECK: @test55 +; CHECK-NEXT: icmp eq i32 %a, -123 +define i1 @test55(i32 %a) { + %sub = sub i32 0, %a + %cmp = icmp eq i32 %sub, 123 + ret i1 %cmp +} + +; CHECK: @test56 +; CHECK-NEXT: icmp eq i32 %a, -113 +define i1 @test56(i32 %a) { + %sub = sub i32 10, %a + %cmp = icmp eq i32 %sub, 123 + ret i1 %cmp +} From stoklund at 2pi.dk Mon Jun 13 10:40:33 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 13 Jun 2011 08:40:33 -0700 Subject: [llvm-commits] patch for Bug #10125 In-Reply-To: References: Message-ID: <36D616F1-4361-4BBF-932D-BE1F7378A98E@2pi.dk> On Jun 13, 2011, at 12:18 AM, Shajrawi, Yousef wrote: > Thanks for the helpful reply. The bug I encountered caused the DBG_VALUE instructions not to be written back with references to the correct registers/spills? (unless I kept the DBG_VALUE for the corner-case I described in the bug) > > What happened in when reading the DWARF I couldn?t see that variable associated with its register, a dump of the output assembly/sections/..etc showed that the variable is not in the ?.section .debug_info?. > > I found the problem on AMD?s OpenCL Compiler (http://llvm.org/devmtg/2010-11/Villmow-OpenCL.pdf ) on the AMDIL Codegen backend (slide 3), Unfortunately I wasn?t able to reproduce it with other backbends (x86) that have much less physical registers/more spills. That makes it difficult to help you. You can try using llc -debug -print-machineinstrs -debug-pass=Executions to find out what happened to your DBG_VALUE. /jakob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110613/7d29f01c/attachment.html From Yousef.Shajrawi at amd.com Mon Jun 13 02:18:45 2011 From: Yousef.Shajrawi at amd.com (Shajrawi, Yousef) Date: Mon, 13 Jun 2011 03:18:45 -0400 Subject: [llvm-commits] patch for Bug #10125 In-Reply-To: References: Message-ID: Hi Jackob, Thanks for the helpful reply. The bug I encountered caused the DBG_VALUE instructions not to be written back with references to the correct registers/spills... (unless I kept the DBG_VALUE for the corner-case I described in the bug) What happened in when reading the DWARF I couldn't see that variable associated with its register, a dump of the output assembly/sections/..etc showed that the variable is not in the ".section .debug_info". I found the problem on AMD's OpenCL Compiler (http://llvm.org/devmtg/2010-11/Villmow-OpenCL.pdf ) on the AMDIL Codegen backend (slide 3), Unfortunately I wasn't able to reproduce it with other backbends (x86) that have much less physical registers/more spills. Regards, ---Yousef From: Jakob Stoklund Olesen [mailto:stoklund at 2pi.dk] Sent: Sunday, June 12, 2011 8:45 PM To: Shajrawi, Yousef Cc: llvm-commits at cs.uiuc.edu; Villmow, Micah Subject: Re: [llvm-commits] patch for Bug #10125 On Jun 12, 2011, at 12:50 AM, Shajrawi, Yousef wrote: I've reported bug #10125 about debug variables incorrectly deleted by LLVM in the Live Debug Variables pass: http://llvm.org/bugs/show_bug.cgi?id=10125 Attached is a patch resolving this bug via adding a check to live ins of a basic block (description is in bugzilla) Hi Yousef, I think you are misunderstanding the purpose of the Live Debug Variables pass. It is supposed to remove all DBG_VALUE instructions. It builds a data structure that is easier to work with for the register allocator passes. After register allocation, the DBG_VALUE instructions are written back with references to the correct physical registers and spill slots. This is all necessary to keep track of debug variables while the register allocator coalesces and splits and spills live ranges. Please see if this is suitable for adding to LLVM and/or please advise on what to do next, This is my first contribution to LLVM so I don't know the procedure... You are on the right track, but please make sure that you describe the actual symptoms when you file a bug report. The behavior you describe sounds correct to me, and when I run your IR through the ARM backend, the result looks fine. So what caused you to file a bug in the first place? /jakob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110613/8b91fc65/attachment.html From sabre at nondot.org Mon Jun 13 10:59:36 2011 From: sabre at nondot.org (Chris Lattner) Date: Mon, 13 Jun 2011 15:59:36 -0000 Subject: [llvm-commits] [llvm] r132916 - /llvm/trunk/docs/ProgrammersManual.html Message-ID: <20110613155936.379B82A6C12C@llvm.org> Author: lattner Date: Mon Jun 13 10:59:35 2011 New Revision: 132916 URL: http://llvm.org/viewvc/llvm-project?rev=132916&view=rev Log: mention graph vis isn't available in Release builds. Modified: llvm/trunk/docs/ProgrammersManual.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=132916&r1=132915&r2=132916&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Mon Jun 13 10:59:35 2011 @@ -811,6 +811,10 @@ Attributes.) If you want to restart and clear all the current graph attributes, then you can call DAG.clearGraphAttrs().

+

Note that graph visualization features are compiled out of Release builds +to reduce file size. This means that you need a Debug+Asserts or +Release+Asserts build to use these features.

+ From clattner at apple.com Mon Jun 13 12:10:54 2011 From: clattner at apple.com (Chris Lattner) Date: Mon, 13 Jun 2011 10:10:54 -0700 Subject: [llvm-commits] [llvm] r132906 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp In-Reply-To: <20110613075246.C53242A6C12D@llvm.org> References: <20110613075246.C53242A6C12D@llvm.org> Message-ID: On Jun 13, 2011, at 12:52 AM, Nick Lewycky wrote: > Author: nicholas > Date: Mon Jun 13 02:52:46 2011 > New Revision: 132906 > > URL: http://llvm.org/viewvc/llvm-project?rev=132906&view=rev > Log: > It's possible that an all-zero GEP may be used as the argument to lifetime > intrinsics. In fact, we'll optimize a bitcast to that when possible. Detect it > when looking for the lifetime intrinsics. > > No test case, noticed by inspection. Would it make sense to use Value::stripPointerCasts here? -Chris > > Modified: > llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > > Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=132906&r1=132905&r2=132906&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jun 13 02:52:46 2011 > @@ -734,11 +734,15 @@ > if (AI->getType() == Int8PtrTy) > return isUsedByLifetimeMarker(AI); > > - // Do a scan to find all the bitcasts to i8*. > + // Do a scan to find all the bitcasts or GEPs to i8*. > for (Value::use_iterator I = AI->use_begin(), E = AI->use_end(); I != E; > ++I) { > if (I->getType() != Int8PtrTy) continue; > - if (!isa(*I)) continue; > + if (GetElementPtrInst *GEPI = dyn_cast(*I)) { > + if (!GEPI->hasAllZeroIndices()) continue; > + } else if (!isa(*I)) { > + continue; > + } > if (isUsedByLifetimeMarker(*I)) > return true; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Mon Jun 13 12:16:26 2011 From: gohman at apple.com (Dan Gohman) Date: Mon, 13 Jun 2011 10:16:26 -0700 Subject: [llvm-commits] [llvm] r132882 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/X86/X86InstrInfo.cpp test/CodeGen/Thumb2/machine-licm.ll In-Reply-To: <5EA38794-3EAE-4F93-90AB-7683CEF05AFF@2pi.dk> References: <20110612032033.086FB2A6C12C@llvm.org> <22E522CD-27D8-4C2D-A89E-3F9004CC9D3C@2pi.dk> <4DF46CDA.9030509@gmail.com> <5EA38794-3EAE-4F93-90AB-7683CEF05AFF@2pi.dk> Message-ID: <40D8EA4F-144A-4668-B59F-F71585CBD8BB@apple.com> On Jun 12, 2011, at 12:57 AM, Jakob Stoklund Olesen wrote: > > On Jun 12, 2011, at 12:38 AM, Rafael ?vila de Esp?ndola wrote: > >>> The double-CFG-edge hack was added as a compile time optimization. It was also a simplification. Before that, several places in codegen that modified successor lists needed extra code to avoid duplicates. >>> While I like to see it go, we should at least confirm that it was a >>> premature optimization. >>> >>> Did you measure before/after compile times? The -O0 compile times are >>> extra interesting. >> >> I compiled two release versions of clang. One before my first patch and one after the last one. I then used those to build a debug version of clang. >> >> The current trunk took 5m13.630s to build a debug version of clang. The old revision took 5m11.130s. >> >> Is there some other test you would like me to run? > > It think it's OK. Here is what I measure on 403.gcc with llc -O0 -time-passes: > > Before: > 0.6719 ( 12.9%) 0.0624 ( 14.7%) 0.7343 ( 13.0%) 0.7345 ( 13.0%) X86 AT&T-Style Assembly Printer > After: > 0.6873 ( 13.1%) 0.0628 ( 14.8%) 0.7501 ( 13.3%) 0.7501 ( 13.3%) X86 AT&T-Style Assembly Printer Additional speedup comes from the assembler spending less time parsing and managing extra symbols. But this is all less important now that assembly printing is no longer a hot path. Dan From bob.wilson at apple.com Mon Jun 13 12:29:26 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 13 Jun 2011 10:29:26 -0700 Subject: [llvm-commits] Enable early dup for small bb, take2 In-Reply-To: <4DF5A6BE.1050501@gmail.com> References: <4DF5A6BE.1050501@gmail.com> Message-ID: <0B571C7A-9C85-4238-B5EE-C4689405F5BA@apple.com> It seems to me that this isn't a clear win. It helps some cases but hurts others. As you've seen, updating PHIs for tail duplication is tricky. I'd really prefer to avoid that. If we only run the taildup pass after regalloc, we can remove all that complexity. Something similar would still be needed in the separate indirect branch duplication pass (that I'm still working on), but at least we wouldn't have to do it in taildup as well. How important do you think it is to do this? Am I misreading your data? On Jun 12, 2011, at 10:57 PM, Rafael ?vila de Esp?ndola wrote: > I did some benchmarking on my previous patch. A first run building clang itself found an interesting case. For a bb that looks like > > foo: > jmp bar > > the patch would duplicate foo to some but not all predecessor. Phi elimination would then add copies too foo and it would stay there. If no duplication was done, branch folding was able fully remove it. > > To solve the problem I added a bit more logic to early dup. It is now also able to duplicate a trivial block to non-trivial ones. > > I did the tests on my home computer, so they are not directly comparable with my previous email. The "time to build clang" is the time needed to build a release version of trunk with both a patched and an unmodified clang binary. > > trunk: > time to build clang Release: > real 4m28.049s > user 30m38.493s > sys 1m26.766s > size of clang: 25155904 > real 0m29.864s > user 0m29.424s > sys 0m0.412s > time to build firefox: > real 12m54.397s > user 31m7.256s > sys 3m31.197s > size of XUL 48212708 > dromaeo 1735.08runs/s (Total) http://dromaeo.com/?id=142161 > > patch: > time to build clang Release: > real 4m25.234s > user 30m37.794s > sys 1m26.153s > size of clang 25164096 > real 0m29.873s > user 0m29.433s > sys 0m0.409s > time to build firefox: > real 12m19.259s > user 30m56.124s > sys 3m11.275s > size of XUL 48187036 > dromaeo 1756.52runs/s (Total) http://dromaeo.com/?id=142162 > > The size increase in clang is coming mostly from CGClass.o. With the patch we decide to duplicate a block with one instruction into its only predecessor (and remove the original one). Everything goes fine until branch folding decides to create many copies of a block with 4 instructions in it. I haven't debugged what causes branch folding to change its mind. > > On the llvm testsuite the performance improvements were: > > MultiSource/Benchmarks/McCat/04-bisect/bisect.exec -11.11% > MultiSource/Applications/ClamAV/clamscan.exec -8.33% > SingleSource/Benchmarks/Shootout-C++/methcall.exec -1.89% > SingleSource/Benchmarks/Misc/ffbench.exec -1.43% > SingleSource/Benchmarks/BenchmarkGame/nsieve-bits.exec -1.41% > SingleSource/Benchmarks/Misc/ReedSolomon.exec -1.32% > > and the regressions were > > SingleSource/Benchmarks/CoyoteBench/huffbench.exec 17.73% > SingleSource/Benchmarks/BenchmarkGame/recursive.exec 5.49% > MultiSource/Benchmarks/Ptrdist/bc/bc.exec 1.59% > MultiSource/Applications/lua/lua.exec 1.21% > MultiSource/Benchmarks/SciMark2-C/scimark2.exec 1.10% > > I decided to see what was going on with huffbench. Dumping the machine instructions shows some small blocks being merged, but nothing significant. The final binaries are exactly the same size. Instruments then found the hot spot: > > patch: | samples > +0x6d0 movq -12840(%rbp, %rcx, 8), %rsi | 2180 > +0x6d8 incq %rcx | 1966 > +0x6db cmpq %rdi, %rsi | 447 > > > trunk: | samples > +0x6d0 movq -12840(%rbp, %rdi, 8), %rdx | 1613 > +0x6d8 incq %rdi | 1768 > +0x6db cmpq %rax, %rdx | 429 > > Same instructions at the same address with different registers. I don't know why one is faster than the other... > > Cheers, > Rafael > From stoklund at 2pi.dk Mon Jun 13 12:36:58 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 13 Jun 2011 10:36:58 -0700 Subject: [llvm-commits] [llvm] r132882 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/X86/X86InstrInfo.cpp test/CodeGen/Thumb2/machine-licm.ll In-Reply-To: <40D8EA4F-144A-4668-B59F-F71585CBD8BB@apple.com> References: <20110612032033.086FB2A6C12C@llvm.org> <22E522CD-27D8-4C2D-A89E-3F9004CC9D3C@2pi.dk> <4DF46CDA.9030509@gmail.com> <5EA38794-3EAE-4F93-90AB-7683CEF05AFF@2pi.dk> <40D8EA4F-144A-4668-B59F-F71585CBD8BB@apple.com> Message-ID: <37EBA7B5-FE45-4ED2-8E79-DF8157E75C9E@2pi.dk> On Jun 13, 2011, at 10:16 AM, Dan Gohman wrote: > On Jun 12, 2011, at 12:57 AM, Jakob Stoklund Olesen wrote: > >> >> On Jun 12, 2011, at 12:38 AM, Rafael ?vila de Esp?ndola wrote: >> >>>> The double-CFG-edge hack was added as a compile time optimization. > > It was also a simplification. Before that, several places in codegen that modified > successor lists needed extra code to avoid duplicates. Do we need to add that back in? It seems to me that we can accept double CFG edges as long as it only happens on degenerate IR input. I am more concerned with adding double edges on 'normal' code. They look a lot like critical edges, disabling optimizations. > Additional speedup comes from the assembler spending less time parsing > and managing extra symbols. But this is all less important now that assembly > printing is no longer a hot path. Rafael, are you emitting more labels now, or does the extra AnalyzeBranch call take care of that? /jakob From isanbard at gmail.com Mon Jun 13 13:08:54 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 13 Jun 2011 18:08:54 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r132922 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests: bprob-2.c bprob.exp disable.bprob-2.c Message-ID: <20110613180854.9C1DE2A6C12C@llvm.org> Author: void Date: Mon Jun 13 13:08:54 2011 New Revision: 132922 URL: http://llvm.org/viewvc/llvm-project?rev=132922&view=rev Log: Just disable this test. For some reason, it's refusing to change its behavior on the buildbot. The correct fix is to make it use -ftest-coverage. But I don't know how to get this expect script to do that. Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/disable.bprob-2.c - copied unchanged from r132921, llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob-2.c Removed: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob-2.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Removed: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob-2.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob-2.c?rev=132921&view=auto ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob-2.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob-2.c (removed) @@ -1,45 +0,0 @@ -/* Test profile-directed block ordering with computed gotos. - * - This is the same as test gcc.c-torture/execute/980526-1.c and - gcc.misc-tests/gcov-3.c */ - -extern void abort (void); -extern void exit (int); - -int expect_do1 = 1, expect_do2 = 2; - -static int doit(int x){ - __label__ lbl1; - __label__ lbl2; - static int jtab_init = 0; - static void *jtab[2]; - - if(!jtab_init) { - jtab[0] = &&lbl1; - jtab[1] = &&lbl2; - jtab_init = 1; - } - goto *jtab[x]; -lbl1: - return 1; -lbl2: - return 2; -} - -static void do1(void) { - if (doit(0) != expect_do1) - abort (); -} - -static void do2(void){ - if (doit(1) != expect_do2) - abort (); -} - -int main(void){ -#ifndef NO_LABEL_VALUES - do1(); - do2(); -#endif - exit(0); -} Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp?rev=132922&r1=132921&r2=132922&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.misc-tests/bprob.exp Mon Jun 13 13:08:54 2011 @@ -56,9 +56,6 @@ if ![runtest_file_p $runtests $src] then { continue } - if {[string compare $src bprob-2.c]} then { - continue - } profopt-execute $src } } From rafael.espindola at gmail.com Mon Jun 13 13:16:17 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 13 Jun 2011 14:16:17 -0400 Subject: [llvm-commits] Enable early dup for small bb, take2 In-Reply-To: <0B571C7A-9C85-4238-B5EE-C4689405F5BA@apple.com> References: <4DF5A6BE.1050501@gmail.com> <0B571C7A-9C85-4238-B5EE-C4689405F5BA@apple.com> Message-ID: <4DF653F1.4070508@gmail.com> On 11-06-13 01:29 PM, Bob Wilson wrote: > It seems to me that this isn't a clear win. It helps some cases but > hurts others. The cases I have looked at, the hurt is by luck (different registers, same code) or because other passes do something silly when given a reduced IL. Take a look at the two logs: http://people.mozilla.com/~respindola/patch.log.bz2 http://people.mozilla.com/~respindola/trunk.log.bz2 It is actually funny :-) > As you've seen, updating PHIs for tail duplication is tricky. I'd > really prefer to avoid that. If we only run the taildup pass after > regalloc, we can remove all that complexity. Something similar would > still be needed in the separate indirect branch duplication pass > (that I'm still working on), but at least we wouldn't have to do it > in taildup as well. > > How important do you think it is to do this? Am I misreading your > data? > I do think it is important. The way I read the data is that there is useful cleanup that duplicating small blocks can do. Some passes run afterwards can currently make bad decisions on the new input, but that is a problem that should be fixed on them. Ideally, the blocks the early pass is duplicating are the same ones the late one would. So this is really just cleaning it up. One thing that was surprising even to me was the clang became a tiny bit faster. I guess because it is passing fewer blocks down the pipeline. I started looking at this because my old patch (duplicating indirectbr in clang) shows that having more cleanup happening from the duplication to the register allocator can help firefox. Note that the speed improvement in firefox was measured in a full js benchmark. I can run instruments on it if you are curious on what the impact was on the JS interpreter only. As for correctness, I would argue that it is safer to have code that is executed (and therefor tested) more often. The issues I fixed were found by increasing the dup size limit to 8 and bootstrapping clang. The bugs were there and are real, it is just hard to trigger then with an indirectbr only pass (as early dup is right now). When someone does hit them, they would have been incredibly harder to debug. Cheers, Rafael From nadav.rotem at intel.com Mon Jun 13 13:13:25 2011 From: nadav.rotem at intel.com (Nadav Rotem) Date: Mon, 13 Jun 2011 18:13:25 -0000 Subject: [llvm-commits] [llvm] r132923 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Message-ID: <20110613181325.190AC2A6C12C@llvm.org> Author: nadav Date: Mon Jun 13 13:13:24 2011 New Revision: 132923 URL: http://llvm.org/viewvc/llvm-project?rev=132923&view=rev Log: Fix a bug in FindMemType. When widening vector loads, use a wider memory type only if the number of packed elements is a power of two. Bug found in Duncan's testcase. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=132923&r1=132922&r2=132923&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Mon Jun 13 13:13:24 2011 @@ -2164,6 +2164,7 @@ if (MemVT.getSizeInBits() <= WidenEltWidth) break; if (TLI.isTypeLegal(MemVT) && (WidenWidth % MemVTWidth) == 0 && + isPowerOf2_32(WidenWidth / MemVTWidth) && (MemVTWidth <= Width || (Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) { RetVT = MemVT; @@ -2179,6 +2180,7 @@ unsigned MemVTWidth = MemVT.getSizeInBits(); if (TLI.isTypeLegal(MemVT) && WidenEltVT == MemVT.getVectorElementType() && (WidenWidth % MemVTWidth) == 0 && + isPowerOf2_32(WidenWidth / MemVTWidth) && (MemVTWidth <= Width || (Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) { if (RetVT.getSizeInBits() < MemVTWidth || MemVT == WidenVT) From rafael.espindola at gmail.com Mon Jun 13 13:31:40 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 13 Jun 2011 14:31:40 -0400 Subject: [llvm-commits] [llvm] r132882 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/X86/X86InstrInfo.cpp test/CodeGen/Thumb2/machine-licm.ll In-Reply-To: <37EBA7B5-FE45-4ED2-8E79-DF8157E75C9E@2pi.dk> References: <20110612032033.086FB2A6C12C@llvm.org> <22E522CD-27D8-4C2D-A89E-3F9004CC9D3C@2pi.dk> <4DF46CDA.9030509@gmail.com> <5EA38794-3EAE-4F93-90AB-7683CEF05AFF@2pi.dk> <40D8EA4F-144A-4668-B59F-F71585CBD8BB@apple.com> <37EBA7B5-FE45-4ED2-8E79-DF8157E75C9E@2pi.dk> Message-ID: <4DF6578C.8070606@gmail.com> > Rafael, are you emitting more labels now, or does the extra AnalyzeBranch call take care of that? On X86, yes. On ARM there was on test that AnalyzeBranch is bailing out, so we printed one extra label (machine-licm.ll). > /jakob > Cheers, Rafael From gkistanova at gmail.com Mon Jun 13 13:36:02 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Mon, 13 Jun 2011 11:36:02 -0700 Subject: [llvm-commits] [llvm] r132735 - in /llvm/trunk: lib/CodeGen/TargetLoweringObjectFileImpl.cpp test/CodeGen/X86/eh_frame.ll In-Reply-To: <20110607232646.20A1B2A6C12C@llvm.org> References: <20110607232646.20A1B2A6C12C@llvm.org> Message-ID: Hello, It seems the change in llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp makes ld.exe crush on one of windows builders: http://google1.osuosl.org:8011/builders/llvm-gcc-mingw32-cross-arm-linux-gnueabi-hard-float/builds/1117 Please let me know if you need more information on this. Thanks Galina On Tue, Jun 7, 2011 at 4:26 PM, Rafael Espindola wrote: > Author: rafael > Date: Tue Jun ?7 18:26:45 2011 > New Revision: 132735 > > URL: http://llvm.org/viewvc/llvm-project?rev=132735&view=rev > Log: > Fix a silly error I introduce in r131951. > Fixes PR10095. > > Modified: > ? ?llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp > ? ?llvm/trunk/test/CodeGen/X86/eh_frame.ll > > Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=132735&r1=132734&r2=132735&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) > +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Jun ?7 18:26:45 2011 > @@ -255,9 +255,6 @@ > ? ? ? Name.startswith(".llvm.linkonce.tb.")) > ? ? return SectionKind::getThreadBSS(); > > - ?if (Name == ".eh_frame") > - ? ?return SectionKind::getReadOnlyWithRel(); > - > ? return K; > ?} > > @@ -290,7 +287,7 @@ > ? if (K.isText()) > ? ? Flags |= ELF::SHF_EXECINSTR; > > - ?if (K.isWriteable() && !K.isReadOnlyWithRel()) > + ?if (K.isWriteable()) > ? ? Flags |= ELF::SHF_WRITE; > > ? if (K.isThreadLocal()) > > Modified: llvm/trunk/test/CodeGen/X86/eh_frame.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/eh_frame.ll?rev=132735&r1=132734&r2=132735&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/eh_frame.ll (original) > +++ llvm/trunk/test/CodeGen/X86/eh_frame.ll Tue Jun ?7 18:26:45 2011 > @@ -1,5 +1,14 @@ > -; RUN: llc < %s -mtriple x86_64-unknown-linux-gnu | FileCheck %s > +; RUN: llc < %s -mtriple x86_64-unknown-linux-gnu | FileCheck -check-prefix=STATIC %s > +; RUN: llc < %s -mtriple x86_64-unknown-linux-gnu -relocation-model=pic | FileCheck -check-prefix=PIC %s > > ?@__FRAME_END__ = constant [1 x i32] zeroinitializer, section ".eh_frame" > > -; CHECK: .section ? ? ?.eh_frame,"a", at progbits > + at foo = external global i32 > + at bar1 = constant i8* bitcast (i32* @foo to i8*), section "my_bar1", align 8 > + > + > +; STATIC: .section ? ? .eh_frame,"a", at progbits > +; STATIC: .section ? ? my_bar1,"a", at progbits > + > +; PIC: .section ? ? ? ?.eh_frame,"a", at progbits > +; PIC: .section ? ? ? ?my_bar1,"aw", at progbits > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From jstaszak at apple.com Mon Jun 13 13:37:13 2011 From: jstaszak at apple.com (Jakub Staszak) Date: Mon, 13 Jun 2011 11:37:13 -0700 Subject: [llvm-commits] Machine Branch Probability Info Message-ID: Hello, This patch introduces MachineBranchProbabilityInfo class, which has similar API to BranchProbabilityInfo (except setEdgeWeight which is not available here). Branch Weights are keep in MachineBasicBlock. They have the same order (and length) as Successors vector. You can turn off this analysis using -use-mbpi=false. Comments are welcome. Thanks! -- Jakub Staszak -------------- next part -------------- A non-text attachment was scrubbed... Name: mbpi_mbb.patch Type: application/octet-stream Size: 16729 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110613/c54ac276/attachment.obj From rafael.espindola at gmail.com Mon Jun 13 13:42:14 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 13 Jun 2011 14:42:14 -0400 Subject: [llvm-commits] [llvm] r132735 - in /llvm/trunk: lib/CodeGen/TargetLoweringObjectFileImpl.cpp test/CodeGen/X86/eh_frame.ll In-Reply-To: References: <20110607232646.20A1B2A6C12C@llvm.org> Message-ID: <4DF65A06.1020601@gmail.com> On 11-06-13 02:36 PM, Galina Kistanova wrote: > Hello, > > It seems the change in > llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp > makes ld.exe crush on one of windows builders: > http://google1.osuosl.org:8011/builders/llvm-gcc-mingw32-cross-arm-linux-gnueabi-hard-float/builds/1117 > Please let me know if you need more information on this. The log shows: command timed out: 1200 seconds without output, killing pid 2996 SIGKILL failed to kill process using fake rc=-1 program finished with exit code -1 Is this really ld crashing? If so, I do have a windows machine I could use to try to reproduce the problem. What are the build instructions, host compiler, host and target linker, etc? > Thanks > > Galina Cheers, Rafael From benny.kra at googlemail.com Mon Jun 13 13:38:56 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 13 Jun 2011 18:38:56 -0000 Subject: [llvm-commits] [llvm] r132925 - /llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Message-ID: <20110613183856.3D0492A6C12C@llvm.org> Author: d0k Date: Mon Jun 13 13:38:56 2011 New Revision: 132925 URL: http://llvm.org/viewvc/llvm-project?rev=132925&view=rev Log: Move class into an anonymous namespace. Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=132925&r1=132924&r2=132925&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp (original) +++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Mon Jun 13 13:38:56 2011 @@ -25,7 +25,7 @@ char BranchProbabilityInfo::ID = 0; - +namespace { // Please note that BranchProbabilityAnalysis is not a FunctionPass. // It is created by BranchProbabilityInfo (which is a FunctionPass), which // provides a clear interface. Thanks to that, all heuristics and other @@ -143,6 +143,7 @@ bool runOnFunction(Function &F); }; +} // end anonymous namespace // Calculate Edge Weights using "Return Heuristics". Predict a successor which // leads directly to Return Instruction will not be taken. From stuart at apple.com Mon Jun 13 13:48:50 2011 From: stuart at apple.com (Stuart Hastings) Date: Mon, 13 Jun 2011 18:48:50 -0000 Subject: [llvm-commits] [llvm] r132926 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCasts.cpp test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll Message-ID: <20110613184850.0E23E2A6C12C@llvm.org> Author: stuart Date: Mon Jun 13 13:48:49 2011 New Revision: 132926 URL: http://llvm.org/viewvc/llvm-project?rev=132926&view=rev Log: Avoid fusing bitcasts with dynamic allocas if the amount-to-allocate might overflow. Re-typing the alloca to a larger type (e.g. double) hoists a shift into the alloca, potentially exposing overflow in the expression. rdar://problem/9265821 Added: llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=132926&r1=132925&r2=132926&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Mon Jun 13 13:48:49 2011 @@ -71,6 +71,11 @@ // This requires TargetData to get the alloca alignment and size information. if (!TD) return 0; + // Insist that the amount-to-allocate not overflow. + OverflowingBinaryOperator *OBI = + dyn_cast(AI.getOperand(0)); + if (OBI && !(OBI->hasNoSignedWrap() || OBI->hasNoUnsignedWrap())) return 0; + const PointerType *PTy = cast(CI.getType()); BuilderTy AllocaBuilder(*Builder); Added: llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll?rev=132926&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll Mon Jun 13 13:48:49 2011 @@ -0,0 +1,60 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" +target triple = "i386-apple-darwin10.0.0" + +define void @fu1(i32 %parm) nounwind ssp { + %1 = alloca i32, align 4 + %ptr = alloca double*, align 4 + store i32 %parm, i32* %1, align 4 + store double* null, double** %ptr, align 4 + %2 = load i32* %1, align 4 + %3 = icmp ne i32 %2, 0 + br i1 %3, label %4, label %10 + +;