[PATCH] D103288: [SanCov] Properly set ABI parameter attributes
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 27 15:15:44 PDT 2021
aeubanks updated this revision to Diff 348400.
aeubanks added a comment.
use FunctionCallee's function
this is actually a bit more verbose since we have to cast FunctionCallee's callee to a Function
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103288/new/
https://reviews.llvm.org/D103288
Files:
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
llvm/test/Instrumentation/SanitizerCoverage/div-tracing.ll
Index: llvm/test/Instrumentation/SanitizerCoverage/div-tracing.ll
===================================================================
--- llvm/test/Instrumentation/SanitizerCoverage/div-tracing.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/div-tracing.ll
@@ -12,7 +12,7 @@
}
; CHECK-LABEL: @div_a_b
-; CHECK: call void @__sanitizer_cov_trace_div4(i32 %b)
+; CHECK: call void @__sanitizer_cov_trace_div4(i32 zeroext %b)
; CHECK: ret
Index: llvm/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
===================================================================
--- llvm/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
@@ -14,12 +14,12 @@
; compare (const, non-const)
icmp slt i32 %a, 1
-; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 1, i32 %a)
+; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 zeroext 1, i32 zeroext %a)
; CHECK-NEXT: icmp slt i32 %a, 1
; compare (non-const, const)
icmp slt i32 1, %a
-; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 1, i32 %a)
+; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 zeroext 1, i32 zeroext %a)
; CHECK-NEXT: icmp slt i32 1, %a
; compare (const, const) - should not be instrumented
@@ -31,22 +31,22 @@
%x = trunc i32 %a to i8
icmp slt i8 %x, 1
-; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 1, i8 %x)
+; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 zeroext 1, i8 zeroext %x)
; CHECK-NEXT: icmp slt i8 %x, 1
icmp slt i8 1, %x
-; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 1, i8 %x)
+; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 zeroext 1, i8 zeroext %x)
; CHECK-NEXT: icmp slt i8 1, %x
; compare variables of word size
%y = trunc i32 %a to i16
icmp slt i16 %y, 1
-; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 1, i16 %y)
+; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 zeroext 1, i16 zeroext %y)
; CHECK-NEXT: icmp slt i16 %y, 1
icmp slt i16 1, %y
-; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 1, i16 %y)
+; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 zeroext 1, i16 zeroext %y)
; CHECK-NEXT: icmp slt i16 1, %y
; compare variables of qword size
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -840,8 +840,11 @@
TypeSize == 64 ? 1 : -1;
if (CallbackIdx < 0) continue;
auto Ty = Type::getIntNTy(*C, TypeSize);
- IRB.CreateCall(SanCovTraceDivFunction[CallbackIdx],
- {IRB.CreateIntCast(A1, Ty, true)});
+ auto *CB = IRB.CreateCall(SanCovTraceDivFunction[CallbackIdx],
+ {IRB.CreateIntCast(A1, Ty, true)});
+ CB->setAttributes(
+ cast<Function>(SanCovTraceDivFunction[CallbackIdx].getCallee())
+ ->getAttributes());
}
}
@@ -885,8 +888,11 @@
}
auto Ty = Type::getIntNTy(*C, TypeSize);
- IRB.CreateCall(CallbackFunc, {IRB.CreateIntCast(A0, Ty, true),
- IRB.CreateIntCast(A1, Ty, true)});
+ auto *CB =
+ IRB.CreateCall(CallbackFunc, {IRB.CreateIntCast(A0, Ty, true),
+ IRB.CreateIntCast(A1, Ty, true)});
+ CB->setAttributes(
+ cast<Function>(CallbackFunc.getCallee())->getAttributes());
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103288.348400.patch
Type: text/x-patch
Size: 3531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210527/46ddaef5/attachment.bin>
More information about the llvm-commits
mailing list