llvm.org GIT mirror llvm / 886a32b
[sancov] Fix PR33732 Coverage hooks that take less-than-64-bit-integers as parameters need the zeroext parameter attribute (http://llvm.org/docs/LangRef.html#paramattrs) to make sure they are properly extended by the x86_64 ABI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308296 91177308-0d34-0410-b5e6-96231b3b80d8 Alexander Potapenko 2 years ago
3 changed file(s) with 54 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
280280 SanCovTraceSwitchFunction =
281281 checkSanitizerInterfaceFunction(M.getOrInsertFunction(
282282 SanCovTraceSwitchName, VoidTy, Int64Ty, Int64PtrTy));
283 // Make sure smaller parameters are zero-extended to i64 as required by the
284 // x86_64 ABI.
285 if (TargetTriple.getArch() == Triple::x86_64) {
286 for (int i = 0; i < 3; i++) {
287 SanCovTraceCmpFunction[i]->addParamAttr(0, Attribute::ZExt);
288 SanCovTraceCmpFunction[i]->addParamAttr(1, Attribute::ZExt);
289 }
290 SanCovTraceDivFunction[0]->addParamAttr(0, Attribute::ZExt);
291 }
292
283293
284294 // We insert an empty inline asm after cov callbacks to avoid callback merge.
285295 EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
0 ; Test -sanitizer-coverage-trace-compares=1 API declarations on a non-x86_64 arch
1 ; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-trace-compares=1 -S | FileCheck %s
2
3 target triple = "x86_32-unknown-linux-gnu"
4 define i32 @foo() #0 {
5 entry:
6 ret i32 0
7 }
8
9 ; CHECK: declare void @__sanitizer_cov_trace_pc_indir(i64)
10 ; CHECK: declare void @__sanitizer_cov_trace_cmp1(i8, i8)
11 ; CHECK: declare void @__sanitizer_cov_trace_cmp2(i16, i16)
12 ; CHECK: declare void @__sanitizer_cov_trace_cmp4(i32, i32)
13 ; CHECK: declare void @__sanitizer_cov_trace_cmp8(i64, i64)
14 ; CHECK: declare void @__sanitizer_cov_trace_div4(i32)
15 ; CHECK: declare void @__sanitizer_cov_trace_div8(i64)
16 ; CHECK: declare void @__sanitizer_cov_trace_gep(i64)
17 ; CHECK: declare void @__sanitizer_cov_trace_switch(i64, i64*)
18 ; CHECK: declare void @__sanitizer_cov_trace_pc()
19 ; CHECK: declare void @__sanitizer_cov_trace_pc_guard(i32*)
20 ; CHECK: declare void @__sanitizer_cov_trace_pc_guard_init(i32*, i32*)
21 ; CHECK-NOT: declare
0 ; Test -sanitizer-coverage-trace-compares=1 API declarations on x86_64
1 ; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-trace-compares=1 -S | FileCheck %s
2
3 target triple = "x86_64-unknown-linux-gnu"
4 define i32 @foo() #0 {
5 entry:
6 ret i32 0
7 }
8
9 ; CHECK: declare void @__sanitizer_cov_trace_pc_indir(i64)
10 ; CHECK: declare void @__sanitizer_cov_trace_cmp1(i8 zeroext, i8 zeroext)
11 ; CHECK: declare void @__sanitizer_cov_trace_cmp2(i16 zeroext, i16 zeroext)
12 ; CHECK: declare void @__sanitizer_cov_trace_cmp4(i32 zeroext, i32 zeroext)
13 ; CHECK: declare void @__sanitizer_cov_trace_cmp8(i64, i64)
14 ; CHECK: declare void @__sanitizer_cov_trace_div4(i32 zeroext)
15 ; CHECK: declare void @__sanitizer_cov_trace_div8(i64)
16 ; CHECK: declare void @__sanitizer_cov_trace_gep(i64)
17 ; CHECK: declare void @__sanitizer_cov_trace_switch(i64, i64*)
18 ; CHECK: declare void @__sanitizer_cov_trace_pc()
19 ; CHECK: declare void @__sanitizer_cov_trace_pc_guard(i32*)
20 ; CHECK: declare void @__sanitizer_cov_trace_pc_guard_init(i32*, i32*)
21 ; CHECK-NOT: declare