mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
DataLayout is mandatory, update the API to reflect it with references.
Summary: Now that the DataLayout is a mandatory part of the module, let's start cleaning the codebase. This patch is a first attempt at doing that. This patch is not exactly NFC as for instance some places were passing a nullptr instead of the DataLayout, possibly just because there was a default value on the DataLayout argument to many functions in the API. Even though it is not purely NFC, there is no change in the validation. I turned as many pointer to DataLayout to references, this helped figuring out all the places where a nullptr could come up. I had initially a local version of this patch broken into over 30 independant, commits but some later commit were cleaning the API and touching part of the code modified in the previous commits, so it seemed cleaner without the intermediate state. Test Plan: Reviewers: echristo Subscribers: llvm-commits From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231740 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -217,7 +217,6 @@ class DataFlowSanitizer : public ModulePass {
|
||||
WK_Custom
|
||||
};
|
||||
|
||||
const DataLayout *DL;
|
||||
Module *Mod;
|
||||
LLVMContext *Ctx;
|
||||
IntegerType *ShadowTy;
|
||||
@ -422,13 +421,13 @@ bool DataFlowSanitizer::doInitialization(Module &M) {
|
||||
bool IsMIPS64 = TargetTriple.getArch() == llvm::Triple::mips64 ||
|
||||
TargetTriple.getArch() == llvm::Triple::mips64el;
|
||||
|
||||
DL = &M.getDataLayout();
|
||||
const DataLayout &DL = M.getDataLayout();
|
||||
|
||||
Mod = &M;
|
||||
Ctx = &M.getContext();
|
||||
ShadowTy = IntegerType::get(*Ctx, ShadowWidth);
|
||||
ShadowPtrTy = PointerType::getUnqual(ShadowTy);
|
||||
IntptrTy = DL->getIntPtrType(*Ctx);
|
||||
IntptrTy = DL.getIntPtrType(*Ctx);
|
||||
ZeroShadow = ConstantInt::getSigned(ShadowTy, 0);
|
||||
ShadowPtrMul = ConstantInt::getSigned(IntptrTy, ShadowWidth / 8);
|
||||
if (IsX86_64)
|
||||
@ -1050,7 +1049,7 @@ Value *DFSanFunction::loadShadow(Value *Addr, uint64_t Size, uint64_t Align,
|
||||
|
||||
uint64_t ShadowAlign = Align * DFS.ShadowWidth / 8;
|
||||
SmallVector<Value *, 2> Objs;
|
||||
GetUnderlyingObjects(Addr, Objs, DFS.DL);
|
||||
GetUnderlyingObjects(Addr, Objs, Pos->getModule()->getDataLayout());
|
||||
bool AllConstants = true;
|
||||
for (SmallVector<Value *, 2>::iterator i = Objs.begin(), e = Objs.end();
|
||||
i != e; ++i) {
|
||||
@ -1151,7 +1150,8 @@ Value *DFSanFunction::loadShadow(Value *Addr, uint64_t Size, uint64_t Align,
|
||||
}
|
||||
|
||||
void DFSanVisitor::visitLoadInst(LoadInst &LI) {
|
||||
uint64_t Size = DFSF.DFS.DL->getTypeStoreSize(LI.getType());
|
||||
auto &DL = LI.getModule()->getDataLayout();
|
||||
uint64_t Size = DL.getTypeStoreSize(LI.getType());
|
||||
if (Size == 0) {
|
||||
DFSF.setShadow(&LI, DFSF.DFS.ZeroShadow);
|
||||
return;
|
||||
@ -1161,7 +1161,7 @@ void DFSanVisitor::visitLoadInst(LoadInst &LI) {
|
||||
if (ClPreserveAlignment) {
|
||||
Align = LI.getAlignment();
|
||||
if (Align == 0)
|
||||
Align = DFSF.DFS.DL->getABITypeAlignment(LI.getType());
|
||||
Align = DL.getABITypeAlignment(LI.getType());
|
||||
} else {
|
||||
Align = 1;
|
||||
}
|
||||
@ -1229,8 +1229,8 @@ void DFSanFunction::storeShadow(Value *Addr, uint64_t Size, uint64_t Align,
|
||||
}
|
||||
|
||||
void DFSanVisitor::visitStoreInst(StoreInst &SI) {
|
||||
uint64_t Size =
|
||||
DFSF.DFS.DL->getTypeStoreSize(SI.getValueOperand()->getType());
|
||||
auto &DL = SI.getModule()->getDataLayout();
|
||||
uint64_t Size = DL.getTypeStoreSize(SI.getValueOperand()->getType());
|
||||
if (Size == 0)
|
||||
return;
|
||||
|
||||
@ -1238,7 +1238,7 @@ void DFSanVisitor::visitStoreInst(StoreInst &SI) {
|
||||
if (ClPreserveAlignment) {
|
||||
Align = SI.getAlignment();
|
||||
if (Align == 0)
|
||||
Align = DFSF.DFS.DL->getABITypeAlignment(SI.getValueOperand()->getType());
|
||||
Align = DL.getABITypeAlignment(SI.getValueOperand()->getType());
|
||||
} else {
|
||||
Align = 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user