[llvm] r194285 - X86: Assembly files with .cfi_cfa_def shouldn't hit llvm_unreachable()

Bill Wendling isanbard at gmail.com
Sun Nov 10 04:16:40 PST 2013


Oof...Sorry that I missed this bit. :-( Thanks for fixing it!

-bw

On Nov 8, 2013, at 2:33 PM, Jim Grosbach <grosbach at apple.com> wrote:

> Author: grosbach
> Date: Fri Nov  8 16:33:06 2013
> New Revision: 194285
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=194285&view=rev
> Log:
> X86: Assembly files with .cfi_cfa_def shouldn't hit llvm_unreachable()
> 
> On darwin, when trying to create compact unwind info, a .cfi_cfa_def
> directive would case an llvm_unreachable() to be hit. Back off when we
> see this directive and generate the regular DWARF style eh_frame.
> 
> rdar://15406518
> 
> Added:
>    llvm/trunk/test/MC/X86/cfi_def_cfa-crash.s
> Modified:
>    llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
> 
> Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp?rev=194285&r1=194284&r2=194285&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (original)
> +++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp Fri Nov  8 16:33:06 2013
> @@ -450,7 +450,9 @@ protected:
> 
>       switch (Inst.getOperation()) {
>       default:
> -        llvm_unreachable("cannot handle CFI directive for compact unwind!");
> +        // Any other CFI directives indicate a frame that we aren't prepared
> +        // to represent via compact unwind, so just bail out.
> +        return 0;
>       case MCCFIInstruction::OpDefCfaRegister: {
>         // Defines a frame pointer. E.g.
>         //
> 
> Added: llvm/trunk/test/MC/X86/cfi_def_cfa-crash.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/cfi_def_cfa-crash.s?rev=194285&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/X86/cfi_def_cfa-crash.s (added)
> +++ llvm/trunk/test/MC/X86/cfi_def_cfa-crash.s Fri Nov  8 16:33:06 2013
> @@ -0,0 +1,73 @@
> +// RUN: llvm-mc -triple x86_64-apple-darwin -filetype=obj %s -o - | macho-dump | FileCheck %s
> +
> +// We were trying to generate compact unwind info for assembly like this.
> +// The .cfi_def_cfa directive, however, throws a wrench into that and was
> +// causing an llvm_unreachable() failure. Make sure the assembler can handle
> +// the input. The actual eh_frames created using these directives are checked
> +// elsewhere. This test is a simpler "does the code assemble" check.
> +
> +// rdar://15406518
> +
> +.macro SaveRegisters
> +
> + push %rbp
> + .cfi_def_cfa_offset 16
> + .cfi_offset rbp, -16
> +
> + mov %rsp, %rbp
> + .cfi_def_cfa_register rbp
> +
> + sub $$0x80+8, %rsp
> +
> + movdqa %xmm0, -0x80(%rbp)
> + push %rax
> + movdqa %xmm1, -0x70(%rbp)
> + push %rdi
> + movdqa %xmm2, -0x60(%rbp)
> + push %rsi
> + movdqa %xmm3, -0x50(%rbp)
> + push %rdx
> + movdqa %xmm4, -0x40(%rbp)
> + push %rcx
> + movdqa %xmm5, -0x30(%rbp)
> + push %r8
> + movdqa %xmm6, -0x20(%rbp)
> + push %r9
> + movdqa %xmm7, -0x10(%rbp)
> +
> +.endmacro
> +.macro RestoreRegisters
> +
> + movdqa -0x80(%rbp), %xmm0
> + pop %r9
> + movdqa -0x70(%rbp), %xmm1
> + pop %r8
> + movdqa -0x60(%rbp), %xmm2
> + pop %rcx
> + movdqa -0x50(%rbp), %xmm3
> + pop %rdx
> + movdqa -0x40(%rbp), %xmm4
> + pop %rsi
> + movdqa -0x30(%rbp), %xmm5
> + pop %rdi
> + movdqa -0x20(%rbp), %xmm6
> + pop %rax
> + movdqa -0x10(%rbp), %xmm7
> +
> + leave
> + .cfi_def_cfa rsp, 8
> + .cfi_same_value rbp
> +
> +.endmacro
> +
> +_foo:
> +.cfi_startproc
> +  SaveRegisters
> +
> +  RestoreRegisters
> +  ret
> + .cfi_endproc
> +
> +
> +
> +// CHECK: 'section_name', '__eh_frame\x00
> 
> 
> _______________________________________________
> 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