Evening,<div><br></div><div>I am working on a few changes to make Clang 3.1 accept a few more Microsoft-specific extensions and play nice with the MSVC linker (via ClangVSx). </div><div><br></div><div>My current task is to implement __debugbreak(), which is boiled down into an INT3 instruction when MSVC deals with it. Should be simple enough, or so I thought...</div>

<div><br></div><div>During CodeGenFunction::EmitX86BuiltinExpr() I added a call to the x86_int interrupt intrinsic, thus:</div><div><br></div><div><div>  case Builtin::BI__debugbreak:</div><div>    {</div><div>      int32_t Interrupt = 3;</div>

<div>      Value *ArgValue = llvm::ConstantInt::get(Int8Ty, Interrupt);</div><div>      llvm::Type *ArgType = ArgValue->getType();</div><div><br></div><div>      Value *F = CGM.getIntrinsic(Intrinsic::x86_int, ArgType);</div>

<div>      return Builder.CreateCall(F, ArgValue);</div><div>    }</div></div><div><br></div><div>which arrives in the LL disassembly as</div><div><br></div><div> call void @llvm.x86.int.i8(i8 3)<br></div><div><br></div>
<div>
... but so far I can't discern how to properly lower that into an INT3 during code generation (or earlier ... I'm still pretty new to the LLVM codebase). In the x86 dasm I end up with</div><div><br></div><div> E8 00 00 00 00     call        _llvm.x86.int.i8<br>

</div><div><br></div><div><br></div><div>I notice that there is a definition for INT3 in the X86InstrSystem.td table file:</div><div><br></div><div><div>def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3",</div>

<div>              [(int_x86_int (i8 3))]>;</div></div><div><br></div><div>Which suggests to me that it should already be able to figure out what I'm after.. but perhaps I'm being naive.</div><div><br></div><div>

Anyone who can help point me to the right area of the project to examine (I've been sat trying to trace through and find what's missing but to no avail) or has any other hints / tips .. some guidance would be very appreciated!</div>

<div><br></div><div>Thanks,</div><div>-h</div>