[llvm-commits] [llvm] r169785 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/LLVMTargetMachine.cpp lib/MC/MCStreamer.cpp

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Dec 11 09:13:49 PST 2012


The bug was  hard to trigger bu deterministic, no? Do you have a testcase?

On 10 December 2012 17:49, Lang Hames <lhames at gmail.com> wrote:
> Author: lhames
> Date: Mon Dec 10 16:49:11 2012
> New Revision: 169785
>
> URL: http://llvm.org/viewvc/llvm-project?rev=169785&view=rev
> Log:
> Defer call to InitSections until after MCContext has been initialized. If
> InitSections is called before the MCContext is initialized it could cause
> duplicate temporary symbols to be emitted later (after context initialization
> resets the temporary label counter).
>
> Modified:
>     llvm/trunk/include/llvm/MC/MCStreamer.h
>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>     llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
>     llvm/trunk/lib/MC/MCStreamer.cpp
>
> Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=169785&r1=169784&r2=169785&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
> +++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Dec 10 16:49:11 2012
> @@ -70,6 +70,8 @@
>      SmallVector<std::pair<const MCSection *,
>                  const MCSection *>, 4> SectionStack;
>
> +    bool AutoInitSections;
> +
>    protected:
>      MCStreamer(MCContext &Ctx);
>
> @@ -214,6 +216,17 @@
>          SectionStack.back().first = Section;
>      }
>
> +    /// Initialize the streamer.
> +    void InitStreamer() {
> +      if (AutoInitSections)
> +        InitSections();
> +    }
> +
> +    /// Tell this MCStreamer to call InitSections upon initialization.
> +    void setAutoInitSections(bool AutoInitSections) {
> +      this->AutoInitSections = AutoInitSections;
> +    }
> +
>      /// InitSections - Create the default sections and set the initial one.
>      virtual void InitSections() = 0;
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=169785&r1=169784&r2=169785&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Dec 10 16:49:11 2012
> @@ -149,6 +149,8 @@
>  }
>
>  bool AsmPrinter::doInitialization(Module &M) {
> +  OutStreamer.InitStreamer();
> +
>    MMI = getAnalysisIfAvailable<MachineModuleInfo>();
>    MMI->AnalyzeModule(M);
>
>
> Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=169785&r1=169784&r2=169785&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
> +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Dec 10 16:49:11 2012
> @@ -202,7 +202,7 @@
>                                                           *Context, *MAB, Out,
>                                                           MCE, hasMCRelaxAll(),
>                                                           hasMCNoExecStack()));
> -    AsmStreamer.get()->InitSections();
> +    AsmStreamer.get()->setAutoInitSections(true);
>      break;
>    }
>    case CGFT_Null:
>
> Modified: llvm/trunk/lib/MC/MCStreamer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=169785&r1=169784&r2=169785&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCStreamer.cpp (original)
> +++ llvm/trunk/lib/MC/MCStreamer.cpp Mon Dec 10 16:49:11 2012
> @@ -23,7 +23,8 @@
>
>  MCStreamer::MCStreamer(MCContext &Ctx)
>    : Context(Ctx), EmitEHFrame(true), EmitDebugFrame(false),
> -    CurrentW64UnwindInfo(0), LastSymbol(0) {
> +    CurrentW64UnwindInfo(0), LastSymbol(0),
> +    AutoInitSections(false) {
>    const MCSection *section = NULL;
>    SectionStack.push_back(std::make_pair(section, section));
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list