86 lines · plain
1; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-inline-8bit-counters=1 -sanitizer-coverage-pc-table=1 -S | FileCheck %s2 3; Make sure we use the right comdat groups for COFF to avoid relocations4; against discarded sections. Internal linkage functions are also different from5; ELF. We don't add a module unique identifier.6 7; Test based on this source:8; int baz(int);9; static int __attribute__((noinline)) bar(int x) {10; if (x)11; return baz(x);12; return 0;13; }14; int foo(int x) {15; if (baz(0))16; x = bar(x);17; return x;18; }19 20; Both new comdats should no duplicates on COFF.21 22; CHECK: $foo = comdat nodeduplicate23; CHECK: $bar = comdat nodeduplicate24 25; Tables for 'foo' should be in the 'foo' comdat.26 27; CHECK: @__sancov_gen_{{.*}} = private global [1 x i8] zeroinitializer, section ".SCOV$CM", comdat($foo), align 128 29; CHECK: @__sancov_gen_{{.*}} = private constant [2 x ptr]30; CHECK-SAME: [ptr @foo, ptr inttoptr (i64 1 to ptr)],31; CHECK-SAME: section ".SCOVP$M", comdat($foo), align 832 33; Tables for 'bar' should be in the 'bar' comdat.34 35; CHECK: @__sancov_gen_{{.*}} = private global [1 x i8] zeroinitializer, section ".SCOV$CM", comdat($bar), align 136 37; CHECK: @__sancov_gen_{{.*}} = private constant [2 x ptr]38; CHECK-SAME: [ptr @bar, ptr inttoptr (i64 1 to ptr)],39; CHECK-SAME: section ".SCOVP$M", comdat($bar), align 840 41; 'foo' and 'bar' should be in their new comdat groups.42 43; CHECK: define dso_local i32 @foo(i32 %x){{.*}} comdat {44; CHECK: define internal fastcc i32 @bar(i32 %x){{.*}} comdat {45 46target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"47target triple = "x86_64-pc-windows-msvc19.14.26433"48 49; Function Attrs: nounwind uwtable50define dso_local i32 @foo(i32 %x) local_unnamed_addr #0 {51entry:52 %call = tail call i32 @baz(i32 0) #353 %tobool = icmp eq i32 %call, 054 br i1 %tobool, label %if.end, label %if.then55 56if.then: ; preds = %entry57 %call1 = tail call fastcc i32 @bar(i32 %x)58 br label %if.end59 60if.end: ; preds = %entry, %if.then61 %x.addr.0 = phi i32 [ %call1, %if.then ], [ %x, %entry ]62 ret i32 %x.addr.063}64 65declare dso_local i32 @baz(i32) local_unnamed_addr #166 67; Function Attrs: noinline nounwind uwtable68define internal fastcc i32 @bar(i32 %x) unnamed_addr #2 {69entry:70 %tobool = icmp eq i32 %x, 071 br i1 %tobool, label %return, label %if.then72 73if.then: ; preds = %entry74 %call = tail call i32 @baz(i32 %x) #375 br label %return76 77return: ; preds = %entry, %if.then78 %retval.0 = phi i32 [ %call, %if.then ], [ 0, %entry ]79 ret i32 %retval.080}81 82attributes #0 = { nounwind uwtable }83attributes #1 = { "asdf" }84attributes #2 = { noinline nounwind uwtable }85attributes #3 = { nounwind }86