[llvm] r309610 - [sanitizer-coverage] ensure minimal alignment for coverage counters and guards

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 12:49:46 PDT 2017


Author: kcc
Date: Mon Jul 31 12:49:45 2017
New Revision: 309610

URL: http://llvm.org/viewvc/llvm-project?rev=309610&view=rev
Log:
[sanitizer-coverage] ensure minimal alignment for coverage counters and guards

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
    llvm/trunk/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
    llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll

Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=309610&r1=309609&r2=309610&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Mon Jul 31 12:49:45 2017
@@ -487,6 +487,8 @@ GlobalVariable *SanitizerCoverageModule:
   if (auto Comdat = F.getComdat())
     Array->setComdat(Comdat);
   Array->setSection(getSectionName(Section));
+  Array->setAlignment(Ty->isPointerTy() ? DL->getPointerSize()
+                                        : Ty->getPrimitiveSizeInBits() / 8);
   return Array;
 }
 
@@ -505,7 +507,6 @@ void SanitizerCoverageModule::CreatePCAr
   FunctionPCsArray->setInitializer(
       ConstantArray::get(ArrayType::get(Int8PtrTy, N), PCs));
   FunctionPCsArray->setConstant(true);
-  FunctionPCsArray->setAlignment(DL->getPointerSize());
 }
 
 void SanitizerCoverageModule::CreateFunctionLocalArrays(

Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll?rev=309610&r1=309609&r2=309610&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll (original)
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll Mon Jul 31 12:49:45 2017
@@ -5,6 +5,7 @@ target datalayout = "e-p:64:64:64-i1:8:8
 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

Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll?rev=309610&r1=309609&r2=309610&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll (original)
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll Mon Jul 31 12:49:45 2017
@@ -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




More information about the llvm-commits mailing list