[llvm] r274263 - Add an artificial line-0 debug location when the compiler emits a call to

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 8 14:41:19 PDT 2016


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?

On Thu, Jun 30, 2016 at 11:49 AM, Yunzhong Gao via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: ygao
> Date: Thu Jun 30 13:49:04 2016
> New Revision: 274263
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274263&view=rev
> Log:
> Add an artificial line-0 debug location when the compiler emits a call to
> __stack_chk_fail(). This avoids a compiler crash.
>
> Differential Revision: http://reviews.llvm.org/D21818
>
>
> Modified:
>     llvm/trunk/lib/CodeGen/StackProtector.cpp
>     llvm/trunk/test/CodeGen/X86/stack-protector.ll
>
> Modified: llvm/trunk/lib/CodeGen/StackProtector.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackProtector.cpp?rev=274263&r1=274262&r2=274263&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/StackProtector.cpp (original)
> +++ llvm/trunk/lib/CodeGen/StackProtector.cpp Thu Jun 30 13:49:04 2016
> @@ -24,6 +24,7 @@
>  #include "llvm/IR/Attributes.h"
>  #include "llvm/IR/Constants.h"
>  #include "llvm/IR/DataLayout.h"
> +#include "llvm/IR/DebugInfo.h"
>  #include "llvm/IR/DerivedTypes.h"
>  #include "llvm/IR/Function.h"
>  #include "llvm/IR/GlobalValue.h"
> @@ -447,6 +448,7 @@ BasicBlock *StackProtector::CreateFailBB
>    LLVMContext &Context = F->getContext();
>    BasicBlock *FailBB = BasicBlock::Create(Context,
> "CallStackCheckFailBlk", F);
>    IRBuilder<> B(FailBB);
> +  B.SetCurrentDebugLocation(DebugLoc::get(0, 0, F->getSubprogram()));
>    if (Trip.isOSOpenBSD()) {
>      Constant *StackChkFail =
>          M->getOrInsertFunction("__stack_smash_handler",
>
> Modified: llvm/trunk/test/CodeGen/X86/stack-protector.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-protector.ll?rev=274263&r1=274262&r2=274263&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/stack-protector.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/stack-protector.ll Thu Jun 30 13:49:04 2016
> @@ -3880,6 +3880,17 @@ entry:
>    ret i32 %call
>  }
>
> +define void @__stack_chk_fail() #1 !dbg !6 {
> +entry:
> +  ret void
> +}
> +
> +define void @test32() #1 !dbg !7 {
> +entry:
> +  %0 = alloca [5 x i8], align 1
> +  ret void
> +}
> +
>  declare double @testi_aux()
>  declare i8* @strcpy(i8*, i8*)
>  declare i32 @printf(i8*, ...)
> @@ -3899,3 +3910,16 @@ attributes #2 = { sspreq }
>  attributes #3 = { ssp "stack-protector-buffer-size"="33" }
>  attributes #4 = { ssp "stack-protector-buffer-size"="5" }
>  attributes #5 = { ssp "stack-protector-buffer-size"="6" }
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!3, !4}
> +!llvm.ident = !{!5}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
> +!1 = !DIFile(filename: "test.c", directory: "/tmp")
> +!2 = !{}
> +!3 = !{i32 2, !"Dwarf Version", i32 4}
> +!4 = !{i32 2, !"Debug Info Version", i32 3}
> +!5 = !{!"clang version x.y.z"}
> +!6 = distinct !DISubprogram(name: "__stack_chk_fail", scope: !1, unit: !0)
> +!7 = distinct !DISubprogram(name: "foo", scope: !1, unit: !0)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160708/0fde015e/attachment.html>


More information about the llvm-commits mailing list