Skip to content

CodeGen assert on invalid inline assembly #9878

@pageexec

Description

@pageexec
mannequin
Bugzilla Link 9506
Version trunk
OS Linux
CC @chandlerc,@rovka,@kbeyls,@pageexec

Extended Description

the following code extracted from linux/arch/x86/kvm/emulate.c triggers an assert with r127872.

void f(void)
{
unsigned long _tmp, _rax, _rdx, _val, _eflags;
unsigned char _ex;

    __asm__ __volatile__ (
            "idivl %6;"
            : "=m" (_eflags), "=&r" (_tmp),
              "+a" (_rax), "+d" (_rdx), "+qm"(_ex)
            : "i" (0x1234), "m" (_val),
              "a" (_rax), "d" (_rdx));

}

clang output:

clang: /src/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1159: virtual bool::TwoAddressInstructionPass::runOnMachineFunction(llvm::MachineFunction&): Assertion `i == DstIdx || !mi->getOperand(i).isReg() || mi->getOperand(i).getReg() != regA' failed.
0 libLLVM-3.0svn.so 0xa16c10b8
Stack dump:
0. Program arguments: clang -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name a.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.21 -momit-leaf-frame-pointer -resource-dir /src/build.i386/bin/../lib/clang/3.0 -ferror-limit 19 -fmessage-length 277 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o a.o -x c a.c

  1.  <eof> parser at end of file
    
  2.  Code generation
    
  3.  Running pass 'Function Pass Manager' on module 'a.c'.
    
  4.  Running pass 'Two-Address instruction pass' on function '@f'
    

clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal 1 (use -v to see invocation)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions