[llvm] r230772 - Centralize handling of the eh_begin and eh_end labels.

Eric Christopher echristo at gmail.com
Fri Feb 27 10:34:35 PST 2015


>
>
> +  if (!MMI->getLandingPads().empty()) {
> +    CurrentFnBegin = createTempSymbol("eh_func_begin",
> getFunctionNumber());
> +
> +    if (MAI->useAssignmentForEHBegin()) {
> +      MCSymbol *CurPos = OutContext.CreateTempSymbol();
> +      OutStreamer.EmitLabel(CurPos);
> +      OutStreamer.EmitAssignment(CurrentFnBegin,
> +                                 MCSymbolRefExpr::Create(CurPos,
> OutContext));
> +    } else {
> +      OutStreamer.EmitLabel(CurrentFnBegin);
> +    }
> +  }
> +
>

At some point it might be nice to be able to use these symbols in the debug
info too (or reuse those, etc) if we're not.

-eric


>    // Emit pre-function debug and/or EH information.
>    for (const HandlerInfo &HI : Handlers) {
>      NamedRegionTimer T(HI.TimerName, HI.TimerGroupName,
> TimePassesIsEnabled);
> @@ -867,6 +882,12 @@ void AsmPrinter::EmitFunctionBody() {
>    // Emit target-specific gunk after the function body.
>    EmitFunctionBodyEnd();
>
> +  if (!MMI->getLandingPads().empty()) {
> +    // Create a symbol for the end of function.
> +    CurrentFnEnd = createTempSymbol("eh_func_end", getFunctionNumber());
> +    OutStreamer.EmitLabel(CurrentFnEnd);
> +  }
> +
>    // If the target wants a .size directive for the size of the function,
> emit
>    // it.
>    if (MAI->hasDotTypeDotSizeDirective()) {
> @@ -2273,6 +2294,9 @@ MCSymbol *AsmPrinter::GetTempSymbol(cons
>                                        Name);
>  }
>
> +MCSymbol *AsmPrinter::createTempSymbol(const Twine &Name, unsigned ID)
> const {
> +  return OutContext.createTempSymbol(Name + Twine(ID));
> +}
>
>  MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BlockAddress *BA)
> const {
>    return MMI->getAddrLabelSymbol(BA->getBasicBlock());
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=230772&r1=230771&r2=230772&
> view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Fri Feb 27
> 12:18:39 2015
> @@ -113,18 +113,6 @@ void DwarfCFIException::beginFunction(co
>        TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI);
>    Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding);
>
> -  MCSymbol *EHBegin =
> -      Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
> -  if (Asm->MAI->useAssignmentForEHBegin()) {
> -    MCContext &Ctx = Asm->OutContext;
> -    MCSymbol *CurPos = Ctx.CreateTempSymbol();
> -    Asm->OutStreamer.EmitLabel(CurPos);
> -    Asm->OutStreamer.EmitAssignment(EHBegin,
> -                                    MCSymbolRefExpr::Create(CurPos,
> Ctx));
> -  } else {
> -    Asm->OutStreamer.EmitLabel(EHBegin);
> -  }
> -
>    // Provide LSDA information.
>    if (!shouldEmitLSDA)
>      return;
> @@ -145,9 +133,6 @@ void DwarfCFIException::endFunction(cons
>    if (!shouldEmitPersonality)
>      return;
>
> -  Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
> -
> Asm->getFunctionNumber()));
> -
>    // Map all labels and get rid of any dead landing pads.
>    MMI->TidyLandingPads();
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/EHStreamer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/EHStreamer.cpp?rev=230772&r1=230771&r2=230772&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/EHStreamer.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/EHStreamer.cpp Fri Feb 27 12:18:39
> 2015
> @@ -552,16 +552,14 @@ void EHStreamer::emitExceptionTable() {
>           I = CallSites.begin(), E = CallSites.end(); I != E; ++I) {
>        const CallSiteEntry &S = *I;
>
> -      MCSymbol *EHFuncBeginSym =
> -        Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
> +      MCSymbol *EHFuncBeginSym = Asm->getFunctionBegin();
>
>        MCSymbol *BeginLabel = S.BeginLabel;
>        if (!BeginLabel)
>          BeginLabel = EHFuncBeginSym;
>        MCSymbol *EndLabel = S.EndLabel;
>        if (!EndLabel)
> -        EndLabel = Asm->GetTempSymbol("eh_func_end",
> Asm->getFunctionNumber());
> -
> +        EndLabel = Asm->getFunctionEnd();
>
>        // Offset of the call site relative to the previous call site,
> counted in
>        // number of 16-byte bundles. The first call site is counted
> relative to
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/Win64Exception.cpp?rev=230772&
> r1=230771&r2=230772&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp Fri Feb 27
> 12:18:39 2015
> @@ -80,9 +80,6 @@ void Win64Exception::beginFunction(const
>    const MCSymbol *PersHandlerSym =
>        TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI);
>    Asm->OutStreamer.EmitWinEHHandler(PersHandlerSym, true, true);
> -
> -  Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
> -
> Asm->getFunctionNumber()));
>  }
>
>  /// endFunction - Gather and emit post-function exception information.
> @@ -91,9 +88,6 @@ void Win64Exception::endFunction(const M
>    if (!shouldEmitPersonality && !shouldEmitMoves)
>      return;
>
> -  Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
> -
> Asm->getFunctionNumber()));
> -
>    // Map all labels and get rid of any dead landing pads.
>    MMI->TidyLandingPads();
>
> @@ -170,10 +164,8 @@ void Win64Exception::emitCSpecificHandle
>    SmallVector<CallSiteEntry, 64> CallSites;
>    computeCallSiteTable(CallSites, LandingPads, FirstActions);
>
> -  MCSymbol *EHFuncBeginSym =
> -      Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
> -  MCSymbol *EHFuncEndSym =
> -      Asm->GetTempSymbol("eh_func_end", Asm->getFunctionNumber());
> +  MCSymbol *EHFuncBeginSym = Asm->getFunctionBegin();
> +  MCSymbol *EHFuncEndSym = Asm->getFunctionEnd();
>
>    // Emit the number of table entries.
>    unsigned NumEntries = 0;
>
> Modified: llvm/trunk/lib/MC/MCContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/
> MCContext.cpp?rev=230772&r1=230771&r2=230772&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/MC/MCContext.cpp (original)
> +++ llvm/trunk/lib/MC/MCContext.cpp Fri Feb 27 12:18:39 2015
> @@ -160,6 +160,12 @@ MCSymbol *MCContext::CreateSymbol(String
>    return Result;
>  }
>
> +MCSymbol *MCContext::createTempSymbol(const Twine &Name) {
> +  SmallString<128> NameSV;
> +  raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
> +  return CreateSymbol(NameSV);
> +}
> +
>  MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
>    SmallString<128> NameSV;
>    return GetOrCreateSymbol(Name.toStringRef(NameSV));
>
> Modified: llvm/trunk/test/CodeGen/Mips/mips16ex.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> CodeGen/Mips/mips16ex.ll?rev=230772&r1=230771&r2=230772&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/CodeGen/Mips/mips16ex.ll (original)
> +++ llvm/trunk/test/CodeGen/Mips/mips16ex.ll Fri Feb 27 12:18:39 2015
> @@ -1,8 +1,10 @@
>  ; RUN: llc  -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s |
> FileCheck %s -check-prefix=16
>
> -;16: .cfi_personality
> +;16: main:
>  ;16-NEXT: [[TMP:.*]]:
>  ;16-NEXT: $eh_func_begin0 = ([[TMP]])
> +;16-NEXT: .cfi_startproc
> +;16-NEXT: .cfi_personality
>  @.str = private unnamed_addr constant [7 x i8] c"hello\0A\00", align 1
>  @_ZTIi = external constant i8*
>  @.str1 = private unnamed_addr constant [15 x i8] c"exception %i \0A\00",
> align 1
>
> Added: llvm/trunk/test/CodeGen/X86/eh-label.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> CodeGen/X86/eh-label.ll?rev=230772&view=auto
> ============================================================
> ==================
> --- llvm/trunk/test/CodeGen/X86/eh-label.ll (added)
> +++ llvm/trunk/test/CodeGen/X86/eh-label.ll Fri Feb 27 12:18:39 2015
> @@ -0,0 +1,24 @@
> +; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s
> +; Test that we don't crashe if the .Leh_func_end0 name is taken.
> +
> +declare void @g()
> +
> +define void @f() {
> +bb0:
> +  call void asm ".Leh_func_end0:", ""()
> +; CHECK: #APP
> +; CHECK-NEXT: .Leh_func_end0:
> +; CHECK-NEXT: #NO_APP
> +
> +  invoke void @g() to label %bb2 unwind label %bb1
> +bb1:
> +  landingpad { i8*, i32 } personality i8* bitcast (void ()* @g to i8*)
> +          catch i8* null
> +  call void @g()
> +  ret void
> +bb2:
> +  ret void
> +
> +; CHECK: [[END:.Leh_func_end.*]]:
> +; CHECK: .long [[END]]-
> +}
>
> Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> CodeGen/X86/global-sections.ll?rev=230772&r1=230771&r2=230772&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/CodeGen/X86/global-sections.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/global-sections.ll Fri Feb 27 12:18:39
> 2015
> @@ -84,8 +84,8 @@ bb7:
>  }
>
>  ; DARWIN64: _F3:
> -; DARWIN64: .cfi_endproc
> -; DARWIN64-NEXT: Leh_func_end
> +; DARWIN64: Leh_func_end
> +; DARWIN64-NEXT: .cfi_endproc
>  ; DARWIN64-NEXT: .section        __TEXT,__gcc_except_tab
>  ; DARWIN64-NOT: .section
>  ; DARWIN64: .section        __TEXT,__text,regular,pure_instructions
>
> Modified: llvm/trunk/test/CodeGen/X86/patchpoint-invoke.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> CodeGen/X86/patchpoint-invoke.ll?rev=230772&r1=230771&r2=230772&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/CodeGen/X86/patchpoint-invoke.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/patchpoint-invoke.ll Fri Feb 27 12:18:39
> 2015
> @@ -5,8 +5,8 @@
>  define i64 @patchpoint_invoke(i64 %p1, i64 %p2) {
>  entry:
>  ; CHECK-LABEL: patchpoint_invoke:
> +; CHECK-NEXT:  [[FUNC_BEGIN:.L.*]]:
>  ; CHECK-NEXT: .cfi_startproc
> -; CHECK:      [[FUNC_BEGIN:.L.*]]:
>  ; CHECK:      .cfi_lsda 3, [[EXCEPTION_LABEL:.L[^ ]*]]
>  ; CHECK:      pushq %rbp
>
>
> Modified: llvm/trunk/test/CodeGen/XCore/exception.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> CodeGen/XCore/exception.ll?rev=230772&r1=230771&r2=230772&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/CodeGen/XCore/exception.ll (original)
> +++ llvm/trunk/test/CodeGen/XCore/exception.ll Fri Feb 27 12:18:39 2015
> @@ -39,10 +39,10 @@ entry:
>    unreachable
>  }
>
> -; CHECK-LABEL: fn_catch
> +; CHECK-LABEL: fn_catch:
> +; CHECK-NEXT: [[START:.L[a-zA-Z0-9_]+]]
>  ; CHECK: .cfi_startproc
>  ; CHECK: .cfi_personality 0, __gxx_personality_v0
> -; CHECK: [[START:.L[a-zA-Z0-9_]+]]
>  ; CHECK: .cfi_lsda 0, [[LSDA:.L[a-zA-Z0-9_]+]]
>  ; CHECK: entsp 4
>  ; CHECK: .cfi_def_cfa_offset 16
> @@ -91,8 +91,8 @@ lpad:
>  ; CHECK: bf r0, [[RETURN]]
>  ; CHECK: mov r0, r4
>  ; CHECK: bl _Unwind_Resume
> -; CHECK: .cfi_endproc
>  ; CHECK: [[END:.L[a-zA-Z0-9_]+]]
> +; CHECK: .cfi_endproc
>    %6 = icmp eq i32 %5, %2
>    br i1 %6, label %Resume, label %Exit
>  Resume:
>
>
> _______________________________________________
> 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/20150227/d9ee0f04/attachment.html>


More information about the llvm-commits mailing list