<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<blockquote type="cite"
cite="mid:OF206AB12A.B7C456D6-ONC125813A.00470C6D-C125813A.0047305D@notes.na.collabserv.com">
<p><tt><font size="2">Ah, interesting. Which is the "canonical"
LLVM IR version?</font></tt><br>
<br>
<tt><font size="2">Can you check what clang generates from
something like:</font></tt><br>
<br>
<tt><font size="2">void test (void)</font></tt><br>
<tt><font size="2">{</font></tt><br>
<tt><font size="2"> __builtin_trap();</font></tt><br>
<tt><font size="2">}</font></tt><br>
<br>
<tt><font size="2">or maybe:</font></tt><br>
<br>
<tt><font size="2">int test (void)</font></tt><br>
<tt><font size="2">{</font></tt><br>
<tt><font size="2"> __builtin_trap();</font></tt><br>
<tt><font size="2"> return 0;</font></tt><br>
<tt><font size="2">}</font></tt><br>
<br>
<br>
</p>
</blockquote>
The clang front-end seems to generate<br>
<br>
define void @test0() #0 {<br>
entry:<br>
call void @llvm.trap()<br>
ret void<br>
}<br>
<br>
or<br>
<br>
define signext i32 @test1() #0 {<br>
entry:<br>
call void @llvm.trap()<br>
ret i32 0<br>
}<br>
<br>
<br>
At -O1 and higher these are both optimized to have the ret removed:<br>
<br>
*** IR Dump After Simplify the CFG ***<br>
; Function Attrs: nounwind<br>
define void @test0() #0 {<br>
entry:<br>
call void @llvm.trap()<br>
unreachable<br>
}<br>
<br>
, so only at -O0 is there a ret remaining.<br>
<br>
/Jonas<br>
<br>
<br>
</body>
</html>