[LLVMbugs] [Bug 8672] New: emitting SFENCE memory barrier for JIT fails with assertion / unreachable

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 23 08:44:01 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8672

           Summary: emitting SFENCE memory barrier for JIT fails with
                    assertion / unreachable
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: hammacher at cs.uni-saarland.de
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=5823)
 --> (http://llvm.org/bugs/attachment.cgi?id=5823)
bitcode file causing lli to crash

I found that lli is unable to execute a memory barrier which only requires an
SFENCE instruction in x86. I can reproduce the behavior in TOT (r120026).

Simple bitcode file (bc file attached):
    define internal i32 @main() {
    entry:
      call void @llvm.memory.barrier(i1 false, i1 false, i1 false, i1 true, i1
true)
      ret i32 47
    }

    declare void @llvm.memory.barrier(i1, i1, i1, i1, i1) nounwind

The error disappears if any of the first three arguments to llvm.memory.barrier
is changed to true, because then an MFENCE is generated instead of SFENCE
(checked by adding --debug-only=x86-emitter).
Setting only the first and the last parameter produces an LFENCE which
surprisingly does also work!

Trying to run the "program" with lli version 2.7 fails with this assertion:
Assertion failed: (i < getNumOperands() && "getOperand() out of range!"),
function getOperand, file
/usr/src/llvm-2.7/include/llvm/CodeGen/MachineInstr.h, line 159.

Stacktrace:
    #0  0x00007fff85fd5616 in __kill ()
    #1  0x00007fff86075cca in abort ()
    #2  0x00007fff86062c90 in __assert_rtn ()
    #3  0x000000010013549f in llvm::MachineInstr::getOperand (this=0x103836a20,
i=0) at MachineInstr.h:159
    #4  0x0000000100133bb2 in emitInstruction (this=0x10311c310,
MI=@0x103836a20, Desc=0x10028f6f8) at X86CodeEmitter.cpp:765
    #5  0x0000000100132760 in runOnMachineFunction (this=0x10311c310,
MF=@0x10311d550) at X86CodeEmitter.cpp:136
    #6  0x0000000100d77faf in llvm::MachineFunctionPass::runOnFunction
(this=0x10311c310, F=@0x103107cf0) at MachineFunctionPass.cpp:27
    #7  0x000000010271de13 in llvm::FPPassManager::runOnFunction
(this=0x10310a190, F=@0x103107cf0) at PassManager.cpp:1350
    #8  0x000000010271daeb in llvm::FunctionPassManagerImpl::run
(this=0x103109c20, F=@0x103107cf0) at PassManager.cpp:1301
    #9  0x000000010271d791 in llvm::FunctionPassManager::run (this=0x103109210,
F=@0x103107cf0) at PassManager.cpp:1231
    #10 0x0000000100b1e3d2 in llvm::JIT::runJITOnFunctionUnlocked
(this=0x103109b20, F=0x103107cf0, locked=@0x7fff5fbfef80) at JIT.cpp:631
    #11 0x0000000100b1e7a3 in llvm::JIT::getPointerToFunction
(this=0x103109b20, F=0x103107cf0) at JIT.cpp:683
    #12 0x0000000100b1d09b in llvm::JIT::runFunction (this=0x103109b20,
F=0x103107cf0, ArgValues=@0x7fff5fbff440) at JIT.cpp:401
    #13 0x0000000100c4a0f1 in llvm::ExecutionEngine::runFunctionAsMain
(this=0x103109b20, Fn=0x103107cf0, argv=@0x10000f138, envp=0x7fff5fbff788) at
ExecutionEngine.cpp:372
    #14 0x0000000100003c7c in main (argc=3, argv=0x7fff5fbff768,
envp=0x7fff5fbff788) at lli.cpp:234

lli version:
    Low Level Virtual Machine (http://llvm.org/):
      llvm version 2.7
      DEBUG build with assertions.
      Built Nov 20 2010 (11:44:09).
      Host: x86_64-apple-darwin10
      Host CPU: penryn

      Registered Targets:
        x86    - 32-bit X86: Pentium-Pro and above
        x86-64 - 64-bit X86: EM64T and AMD64


lli from TOT (2.9svn) produces these errors:
    Unknown FormMask value in X86 MachineCodeEmitter!
    UNREACHABLE executed at X86CodeEmitter.cpp:712!

Stacktrace:
    #0  0x00007fff86062cae in __pthread_kill ()
    #1  0x00007fff860625d2 in pthread_kill ()
    #2  0x00000001000259ab in raise (sig=6) at Signals.inc:278
    #3  0x0000000100025a40 in abort () at Signals.inc:298
    #4  0x00000001007c0155 in llvm::llvm_unreachable_internal (msg=Could not
find the frame base for "llvm::llvm_unreachable_internal(char const*, char
const*, unsigned int)".
) at ErrorHandling.cpp:99
    #5  0x0000000100082294 in emitInstruction (this=0x10231b5b0,
MI=@0x102838e60, Desc=0x100c24680) at X86CodeEmitter.cpp:712
    #6  0x00000001000818bc in runOnMachineFunction (this=0x10231b5b0,
MF=@0x10231c300) at X86CodeEmitter.cpp:136
    #7  0x00000001003b6987 in llvm::MachineFunctionPass::runOnFunction
(this=0x10231b5b0, F=@0x102305c70) at MachineFunctionPass.cpp:33
    #8  0x0000000100756c55 in llvm::FPPassManager::runOnFunction
(this=0x1023054a0, F=@0x102305c70) at PassManager.cpp:1452
    #9  0x000000010075691d in llvm::FunctionPassManagerImpl::run
(this=0x102305160, F=@0x102305c70) at PassManager.cpp:1403
    #10 0x00000001007565c3 in llvm::FunctionPassManager::run (this=0x102304e40,
F=@0x102305c70) at PassManager.cpp:1333
    #11 0x0000000100315342 in llvm::JIT::jitTheFunction (this=0x102306eb0,
F=0x102305c70, locked=@0x7fff5fbfef60) at JIT.cpp:661
    #12 0x0000000100315209 in llvm::JIT::runJITOnFunctionUnlocked
(this=0x102306eb0, F=0x102305c70, locked=@0x7fff5fbfef60) at JIT.cpp:640
    #13 0x0000000100315617 in llvm::JIT::getPointerToFunction
(this=0x102306eb0, F=0x102305c70) at JIT.cpp:697
    #14 0x0000000100313eef in llvm::JIT::runFunction (this=0x102306eb0,
F=0x102305c70, ArgValues=@0x7fff5fbff460) at JIT.cpp:412
    #15 0x000000010060af3f in llvm::ExecutionEngine::runFunctionAsMain
(this=0x102306eb0, Fn=0x102305c70, argv=@0x100c51478, envp=0x7fff5fbff810) at
ExecutionEngine.cpp:403
    #16 0x000000010002685d in main (argc=3, argv=0x7fff5fbff7f0,
envp=0x7fff5fbff810) at lli.cpp:251


lli version:
    Low Level Virtual Machine (http://llvm.org/):
      llvm version 2.9svn
      DEBUG build with assertions.
      Built Nov 23 2010 (17:00:30).
      Host: x86_64-apple-darwin10
      Host CPU: penryn

      Registered Targets:
        x86    - 32-bit X86: Pentium-Pro and above
        x86-64 - 64-bit X86: EM64T and AMD64

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list