Skip to content

Commit

Permalink
[sanitizer-coverage] ensure minimal alignment for coverage counters a…
Browse files Browse the repository at this point in the history
…nd guards

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309610 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kcc committed Jul 31, 2017
1 parent 548addb commit 7569609
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ GlobalVariable *SanitizerCoverageModule::CreateFunctionLocalArrayInSection(
if (auto Comdat = F.getComdat())
Array->setComdat(Comdat);
Array->setSection(getSectionName(Section));
Array->setAlignment(Ty->isPointerTy() ? DL->getPointerSize()
: Ty->getPrimitiveSizeInBits() / 8);
return Array;
}

Expand All @@ -505,7 +507,6 @@ void SanitizerCoverageModule::CreatePCArray(Function &F,
FunctionPCsArray->setInitializer(
ConstantArray::get(ArrayType::get(Int8PtrTy, N), PCs));
FunctionPCsArray->setConstant(true);
FunctionPCsArray->setAlignment(DL->getPointerSize());
}

void SanitizerCoverageModule::CreateFunctionLocalArrays(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
target triple = "x86_64-unknown-linux-gnu"
define void @foo() {
entry:
; CHECK: section "__sancov_cntrs", align 1
; CHECK: %0 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__sancov_gen_, i64 0, i64 0), !nosanitize
; CHECK: %1 = add i8 %0, 1
; CHECK: store i8 %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__sancov_gen_, i64 0, i64 0), !nosanitize
Expand Down
1 change: 1 addition & 0 deletions test/Instrumentation/SanitizerCoverage/tracing.ll
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ entry:
; CHECK_PC: ret void
; CHECK_PC-NOT: call void @__sanitizer_cov_module_init

; CHECK_PC_GUARD: section "__sancov_guards", align 4
; CHECK_PC_GUARD-LABEL: define void @foo
; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
Expand Down

0 comments on commit 7569609

Please sign in to comment.