forked from OSchip/llvm-project
[sanitizer-coverage] Return the array from CreatePCArray. NFC
Be more consistent with CreateFunctionLocalArrayInSection in the API of CreatePCArray, and assign the member variable in the caller like we do for the guard and 8-bit counter arrays. This also tweaks the order of method declarations to match the order of definitions in the file. llvm-svn: 311955
This commit is contained in:
parent
be757de2b6
commit
873a0746f1
|
@ -204,8 +204,8 @@ private:
|
||||||
GlobalVariable *CreateFunctionLocalArrayInSection(size_t NumElements,
|
GlobalVariable *CreateFunctionLocalArrayInSection(size_t NumElements,
|
||||||
Function &F, Type *Ty,
|
Function &F, Type *Ty,
|
||||||
const char *Section);
|
const char *Section);
|
||||||
|
GlobalVariable *CreatePCArray(Function &F, ArrayRef<BasicBlock *> AllBlocks);
|
||||||
void CreateFunctionLocalArrays(Function &F, ArrayRef<BasicBlock *> AllBlocks);
|
void CreateFunctionLocalArrays(Function &F, ArrayRef<BasicBlock *> AllBlocks);
|
||||||
void CreatePCArray(Function &F, ArrayRef<BasicBlock *> AllBlocks);
|
|
||||||
void InjectCoverageAtBlock(Function &F, BasicBlock &BB, size_t Idx);
|
void InjectCoverageAtBlock(Function &F, BasicBlock &BB, size_t Idx);
|
||||||
Function *CreateInitCallsForSections(Module &M, const char *InitFunctionName,
|
Function *CreateInitCallsForSections(Module &M, const char *InitFunctionName,
|
||||||
Type *Ty, const char *Section);
|
Type *Ty, const char *Section);
|
||||||
|
@ -541,8 +541,9 @@ GlobalVariable *SanitizerCoverageModule::CreateFunctionLocalArrayInSection(
|
||||||
return Array;
|
return Array;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SanitizerCoverageModule::CreatePCArray(Function &F,
|
GlobalVariable *
|
||||||
ArrayRef<BasicBlock *> AllBlocks) {
|
SanitizerCoverageModule::CreatePCArray(Function &F,
|
||||||
|
ArrayRef<BasicBlock *> AllBlocks) {
|
||||||
size_t N = AllBlocks.size();
|
size_t N = AllBlocks.size();
|
||||||
assert(N);
|
assert(N);
|
||||||
SmallVector<Constant *, 32> PCs;
|
SmallVector<Constant *, 32> PCs;
|
||||||
|
@ -559,15 +560,17 @@ void SanitizerCoverageModule::CreatePCArray(Function &F,
|
||||||
ConstantInt::get(IntptrTy, 0), IntptrPtrTy));
|
ConstantInt::get(IntptrTy, 0), IntptrPtrTy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FunctionPCsArray = CreateFunctionLocalArrayInSection(N * 2, F, IntptrPtrTy,
|
auto *PCArray = CreateFunctionLocalArrayInSection(N * 2, F, IntptrPtrTy,
|
||||||
SanCovPCsSectionName);
|
SanCovPCsSectionName);
|
||||||
FunctionPCsArray->setInitializer(
|
PCArray->setInitializer(
|
||||||
ConstantArray::get(ArrayType::get(IntptrPtrTy, N * 2), PCs));
|
ConstantArray::get(ArrayType::get(IntptrPtrTy, N * 2), PCs));
|
||||||
FunctionPCsArray->setConstant(true);
|
PCArray->setConstant(true);
|
||||||
|
|
||||||
// We don't reference the PCs array in any of our runtime functions, so we
|
// We don't reference the PCs array in any of our runtime functions, so we
|
||||||
// need to prevent it from being dead stripped.
|
// need to prevent it from being dead stripped.
|
||||||
appendToUsed(*F.getParent(), {FunctionPCsArray});
|
appendToUsed(*F.getParent(), {PCArray});
|
||||||
|
|
||||||
|
return PCArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SanitizerCoverageModule::CreateFunctionLocalArrays(
|
void SanitizerCoverageModule::CreateFunctionLocalArrays(
|
||||||
|
@ -579,7 +582,7 @@ void SanitizerCoverageModule::CreateFunctionLocalArrays(
|
||||||
Function8bitCounterArray = CreateFunctionLocalArrayInSection(
|
Function8bitCounterArray = CreateFunctionLocalArrayInSection(
|
||||||
AllBlocks.size(), F, Int8Ty, SanCovCountersSectionName);
|
AllBlocks.size(), F, Int8Ty, SanCovCountersSectionName);
|
||||||
if (Options.PCTable)
|
if (Options.PCTable)
|
||||||
CreatePCArray(F, AllBlocks);
|
FunctionPCsArray = CreatePCArray(F, AllBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SanitizerCoverageModule::InjectCoverage(Function &F,
|
bool SanitizerCoverageModule::InjectCoverage(Function &F,
|
||||||
|
|
Loading…
Reference in New Issue