<div dir="ltr">Test cases that only test that the program doesn't crash are a bit of a sign of missing coverage - what behavior was expected beyond "doesn't crash"? Could you add some CHECK lines to the test to ensure that behavior occurs?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 30, 2016 at 11:49 AM, Yunzhong Gao via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ygao<br>
Date: Thu Jun 30 13:49:04 2016<br>
New Revision: 274263<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=274263&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=274263&view=rev</a><br>
Log:<br>
Add an artificial line-0 debug location when the compiler emits a call to<br>
__stack_chk_fail(). This avoids a compiler crash.<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D21818" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21818</a><br>
<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/StackProtector.cpp<br>
    llvm/trunk/test/CodeGen/X86/stack-protector.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/StackProtector.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackProtector.cpp?rev=274263&r1=274262&r2=274263&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackProtector.cpp?rev=274263&r1=274262&r2=274263&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/StackProtector.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/StackProtector.cpp Thu Jun 30 13:49:04 2016<br>
@@ -24,6 +24,7 @@<br>
 #include "llvm/IR/Attributes.h"<br>
 #include "llvm/IR/Constants.h"<br>
 #include "llvm/IR/DataLayout.h"<br>
+#include "llvm/IR/DebugInfo.h"<br>
 #include "llvm/IR/DerivedTypes.h"<br>
 #include "llvm/IR/Function.h"<br>
 #include "llvm/IR/GlobalValue.h"<br>
@@ -447,6 +448,7 @@ BasicBlock *StackProtector::CreateFailBB<br>
   LLVMContext &Context = F->getContext();<br>
   BasicBlock *FailBB = BasicBlock::Create(Context, "CallStackCheckFailBlk", F);<br>
   IRBuilder<> B(FailBB);<br>
+  B.SetCurrentDebugLocation(DebugLoc::get(0, 0, F->getSubprogram()));<br>
   if (Trip.isOSOpenBSD()) {<br>
     Constant *StackChkFail =<br>
         M->getOrInsertFunction("__stack_smash_handler",<br>
<br>
Modified: llvm/trunk/test/CodeGen/X86/stack-protector.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-protector.ll?rev=274263&r1=274262&r2=274263&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-protector.ll?rev=274263&r1=274262&r2=274263&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/X86/stack-protector.ll (original)<br>
+++ llvm/trunk/test/CodeGen/X86/stack-protector.ll Thu Jun 30 13:49:04 2016<br>
@@ -3880,6 +3880,17 @@ entry:<br>
   ret i32 %call<br>
 }<br>
<br>
+define void @__stack_chk_fail() #1 !dbg !6 {<br>
+entry:<br>
+  ret void<br>
+}<br>
+<br>
+define void @test32() #1 !dbg !7 {<br>
+entry:<br>
+  %0 = alloca [5 x i8], align 1<br>
+  ret void<br>
+}<br>
+<br>
 declare double @testi_aux()<br>
 declare i8* @strcpy(i8*, i8*)<br>
 declare i32 @printf(i8*, ...)<br>
@@ -3899,3 +3910,16 @@ attributes #2 = { sspreq }<br>
 attributes #3 = { ssp "stack-protector-buffer-size"="33" }<br>
 attributes #4 = { ssp "stack-protector-buffer-size"="5" }<br>
 attributes #5 = { ssp "stack-protector-buffer-size"="6" }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!3, !4}<br>
+!llvm.ident = !{!5}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)<br>
+!1 = !DIFile(filename: "test.c", directory: "/tmp")<br>
+!2 = !{}<br>
+!3 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!4 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!5 = !{!"clang version x.y.z"}<br>
+!6 = distinct !DISubprogram(name: "__stack_chk_fail", scope: !1, unit: !0)<br>
+!7 = distinct !DISubprogram(name: "foo", scope: !1, unit: !0)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>