[llvm-commits] [llvm] r169456 - in /llvm/trunk: include/llvm/MC/MCContext.h lib/CodeGen/MachineModuleInfo.cpp lib/MC/MCContext.cpp

Chandler Carruth chandlerc at google.com
Wed Dec 5 17:24:17 PST 2012


This patch doesn't appear to do the right thing w/ memory management.

http://lab.llvm.org:8011/builders/llvm-ppc64-linux1/builds/2258

Please revert so we can get our builds back.

Does it pass under Valgrind or other memory safety tools? Those are likely
to be able to reproduce these types of failures.


On Wed, Dec 5, 2012 at 4:50 PM, Pedro Artigas <partigas at apple.com> wrote:

> Author: partigas
> Date: Wed Dec  5 18:50:55 2012
> New Revision: 169456
>
> URL: http://llvm.org/viewvc/llvm-project?rev=169456&view=rev
> Log:
>
> change MCContext to work on the doInitialization/doFinalization model
>
> reviewed by Evan Cheng <evan.cheng at apple.com>
>
>
> Modified:
>     llvm/trunk/include/llvm/MC/MCContext.h
>     llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
>     llvm/trunk/lib/MC/MCContext.cpp
>
> Modified: llvm/trunk/include/llvm/MC/MCContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=169456&r1=169455&r2=169456&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCContext.h (original)
> +++ llvm/trunk/include/llvm/MC/MCContext.h Wed Dec  5 18:50:55 2012
> @@ -154,6 +154,17 @@
>
>      void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels =
> Value; }
>
> +    /// @name Module Lifetime Management
> +    /// @{
> +
> +    /// doInitialization - prepare to process a new module
> +    void doInitialization();
> +
> +    /// doFinalization - clean up state from the current module
> +    void doFinalization();
> +
> +    /// @}
> +
>      /// @name Symbol Management
>      /// @{
>
>
> Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=169456&r1=169455&r2=169456&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Wed Dec  5 18:50:55 2012
> @@ -270,6 +270,9 @@
>  }
>
>  bool MachineModuleInfo::doInitialization(Module &M) {
> +
> +  Context.doInitialization();
> +
>    ObjFileMMI = 0;
>    CompactUnwindEncoding = 0;
>    CurCallSite = 0;
> @@ -291,6 +294,8 @@
>    delete AddrLabelSymbols;
>    AddrLabelSymbols = 0;
>
> +  Context.doFinalization();
> +
>    return false;
>  }
>
>
> Modified: llvm/trunk/lib/MC/MCContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=169456&r1=169455&r2=169456&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/MCContext.cpp (original)
> +++ llvm/trunk/lib/MC/MCContext.cpp Wed Dec  5 18:50:55 2012
> @@ -44,23 +44,48 @@
>    SecureLogFile = getenv("AS_SECURE_LOG_FILE");
>    SecureLog = 0;
>    SecureLogUsed = false;
> +}
>
> +MCContext::~MCContext() {
> +  // NOTE: The symbols are all allocated out of a bump pointer allocator,
> +  // we don't need to free them here.
> +
> +  // If the stream for the .secure_log_unique directive was created free
> it.
> +  delete (raw_ostream*)SecureLog;
> +}
> +
>
> +//===----------------------------------------------------------------------===//
> +// Module Lifetime Management
>
> +//===----------------------------------------------------------------------===//
> +
> +void MCContext::doInitialization() {
> +  NextUniqueID = 0;
> +  AllowTemporaryLabels = true;
>    DwarfLocSeen = false;
>    GenDwarfForAssembly = false;
>    GenDwarfFileNumber = 0;
>  }
>
> -MCContext::~MCContext() {
> -  // NOTE: The symbols are all allocated out of a bump pointer allocator,
> -  // we don't need to free them here.
> +void MCContext::doFinalization() {
> +  UsedNames.clear();
> +  Symbols.clear();
> +  Allocator.Reset();
> +  Instances.clear();
> +  MCDwarfFiles.clear();
> +  MCDwarfDirs.clear();
> +  MCGenDwarfLabelEntries.clear();
> +  DwarfDebugFlags = StringRef();
> +  MCLineSections.clear();
> +  MCLineSectionOrder.clear();
> +  CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0);
>
>    // If we have the MachO uniquing map, free it.
>    delete (MachOUniqueMapTy*)MachOUniquingMap;
>    delete (ELFUniqueMapTy*)ELFUniquingMap;
>    delete (COFFUniqueMapTy*)COFFUniquingMap;
> -
> -  // If the stream for the .secure_log_unique directive was created free
> it.
> -  delete (raw_ostream*)SecureLog;
> +  MachOUniquingMap = 0;
> +  ELFUniquingMap = 0;
> +  COFFUniquingMap = 0;
>  }
>
>
>  //===----------------------------------------------------------------------===//
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121205/03c70d7d/attachment.html>


More information about the llvm-commits mailing list