<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div><br></div><div>Hi Eli (or others),</div><div><br></div><div>If you could kindly have a look at this updated proposed patch to correct the errors. </div><div><br></div><div>The current svn version (r167575) has an additional problem with naked functions than the version released with Xcode due to r165914 which inserts llvm.trap and unreachable annotations in debug builds in naked functions that need to return a value.</div><div><br></div><div>test.cpp:</div><div><div><font face="Courier New">class MyClass</font></div><div><font face="Courier New">{</font></div><div><font face="Courier New">public:</font></div><div><font face="Courier New"><span class="Apple-tab-span" style="white-space:pre"> </span>int NakedTest(int value, int value2);</font></div><div><font face="Courier New">};</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">__attribute((noinline, naked)) int MyClass::NakedTest(int value, int value2)</font></div><div><font face="Courier New">{</font></div><div><font face="Courier New"><span class="Apple-tab-span" style="white-space:pre"> </span>asm("");</font></div><div><font face="Courier New">}</font></div></div><div><br></div><div>clang -S -flto test.cpp</div><div>test.s:</div><div><br></div><div><div><font face="Courier New">; ModuleID = 'test.cpp'</font></div><div><font face="Courier New">target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"</font></div><div><font face="Courier New">target triple = "x86_64-apple-macosx10.8.0"</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">%class.MyClass = type { i8 }</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">define i32 @_ZN7MyClass9NakedTestEii(%class.MyClass* %this, i32 %value, i32 %value2) nounwind uwtable noinline ssp naked align 2 {</font></div><div><font face="Courier New">entry:</font></div><div><font face="Courier New"> %retval = alloca i32, align 4</font></div><div><font face="Courier New"> %this.addr = alloca %class.MyClass*, align 8</font></div><div><font face="Courier New"> %value.addr = alloca i32, align 4</font></div><div><font face="Courier New"> %value2.addr = alloca i32, align 4</font></div><div><font face="Courier New"> store %class.MyClass* %this, %class.MyClass** %this.addr, align 8</font></div><div><font face="Courier New"> store i32 %value, i32* %value.addr, align 4</font></div><div><font face="Courier New"> store i32 %value2, i32* %value2.addr, align 4</font></div><div><font face="Courier New"> %this1 = load %class.MyClass** %this.addr</font></div><div><font face="Courier New"> call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0</font></div><div><font face="Courier New"><b> call void @llvm.trap()</b></font></div><div><font face="Courier New"><b> unreachable</b></font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">return: ; No predecessors!</font></div><div><font face="Courier New"> %0 = load i32* %retval</font></div><div><font face="Courier New"> ret i32 %0</font></div><div><font face="Courier New">}</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">declare void @llvm.trap() noreturn nounwind</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">!0 = metadata !{i32 154}</font></div></div><div><br></div><div><br></div><div>The bolded lines are new compare to the clang that shipped with Xcode 4.5.2</div><div><br></div><div>I've added a separate path for naked functions in GenerateCode, and avoid the generation of trap/unreachable for undefined return paths for naked functions.</div><div><br></div><div>I'm also not sure whether I'm doing the right thing with return types -- if the function is naked, then there can't be a value around for it to return, so I've forced it to be void. This then fails the Verifier for return types, so I've attached a llvm.naked.patch which bypasses the return type check for naked functions.</div><div><br></div><div>I've left a bunch of commented out code in StartNakedFunction( ) for review by someone more knowledgeable than me because I'm not particularly confident my understanding of what should be there or not is adequate. Ideally all of this commented section would be stripped before submitting.</div><div><br></div><div>I've also run "make clang-test" before submitting these patches - hopefully that means I haven't messed things up too bad :)</div><div><br></div><div><br></div><div></div></body></html>