Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,8 @@ void ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
->setCannotMerge(); // gets the PC using GET_CALLER_PC.
}
if (Options.TracePCGuard) {
auto GuardPtr = IRB.CreateIntToPtr(
IRB.CreateAdd(IRB.CreatePointerCast(FunctionGuardArray, IntptrTy),
ConstantInt::get(IntptrTy, Idx * 4)),
PtrTy);
auto GuardPtr = IRB.CreateConstInBoundsGEP2_64(
FunctionGuardArray->getValueType(), FunctionGuardArray, 0, Idx);
if (Options.GatedCallbacks) {
Instruction *I = &*IP;
auto GateBranch = CreateGateBranch(F, FunctionGateCmp, I);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ target triple = "i386-unknown-linux-gnu"
define i32 @foo() #0 {
; CHECK-LABEL: define i32 @foo() comdat {
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @__sanitizer_cov_trace_pc_guard(ptr inttoptr (i32 ptrtoint (ptr @__sancov_gen_ to i32) to ptr)) #[[ATTR1:[0-9]+]]
; CHECK-NEXT: call void @__sanitizer_cov_trace_pc_guard(ptr @__sancov_gen_) #[[ATTR1:[0-9]+]]
; CHECK-NEXT: ret i32 0
;
entry:
ret i32 0
}

; UTC_ARGS: --disable
; CHECK-DAG: declare void @__sanitizer_cov_trace_pc_indir(i32)
; CHECK-DAG: declare void @__sanitizer_cov_trace_cmp1(i8 zeroext, i8 zeroext)
; CHECK-DAG: declare void @__sanitizer_cov_trace_cmp2(i16 zeroext, i16 zeroext)
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define i32 @with_dbg(ptr %a, ptr %b) !dbg !3 {
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP1]], 42
; CHECK-NEXT: br i1 [[CMP]], label %[[BB0:.*]], label %[[BB1:.*]]
; CHECK: [[BB0]]:
; CHECK-NEXT: call void @__sanitizer_cov_trace_pc_guard(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_ to i64), i64 4) to ptr)) #[[ATTR1]], !dbg [[DBG7:![0-9]+]]
; CHECK-NEXT: call void @__sanitizer_cov_trace_pc_guard(ptr getelementptr inbounds ([2 x i32], ptr @__sancov_gen_, i64 0, i64 1)) #[[ATTR1]], !dbg [[DBG7:![0-9]+]]
; CHECK-NEXT: store i32 [[TMP1]], ptr [[B]], align 4
; CHECK-NEXT: br label %[[BB1]]
; CHECK: [[BB1]]:
Expand All @@ -38,7 +38,7 @@ define i32 @without_dbg(ptr %a, ptr %b) {
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP1]], 42
; CHECK-NEXT: br i1 [[CMP]], label %[[BB0:.*]], label %[[BB1:.*]]
; CHECK: [[BB0]]:
; CHECK-NEXT: call void @__sanitizer_cov_trace_pc_guard(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_.1 to i64), i64 4) to ptr)) #[[ATTR1]]
; CHECK-NEXT: call void @__sanitizer_cov_trace_pc_guard(ptr getelementptr inbounds ([2 x i32], ptr @__sancov_gen_.1, i64 0, i64 1)) #[[ATTR1]]
; CHECK-NEXT: store i32 [[TMP1]], ptr [[B]], align 4
; CHECK-NEXT: br label %[[BB1]]
; CHECK: [[BB1]]:
Expand Down
Loading