mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +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:
@ -396,7 +396,7 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) {
|
||||
/// parameters with noalias metadata specifying the new scope, and tag all
|
||||
/// non-derived loads, stores and memory intrinsics with the new alias scopes.
|
||||
static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
|
||||
const DataLayout *DL, AliasAnalysis *AA) {
|
||||
const DataLayout &DL, AliasAnalysis *AA) {
|
||||
if (!EnableNoAliasConversion)
|
||||
return;
|
||||
|
||||
@ -646,8 +646,9 @@ static void AddAlignmentAssumptions(CallSite CS, InlineFunctionInfo &IFI) {
|
||||
// If we can already prove the asserted alignment in the context of the
|
||||
// caller, then don't bother inserting the assumption.
|
||||
Value *Arg = CS.getArgument(I->getArgNo());
|
||||
if (getKnownAlignment(Arg, &DL, &IFI.ACT->getAssumptionCache(*CalledFunc),
|
||||
CS.getInstruction(), &DT) >= Align)
|
||||
if (getKnownAlignment(Arg, DL, CS.getInstruction(),
|
||||
&IFI.ACT->getAssumptionCache(*CalledFunc),
|
||||
&DT) >= Align)
|
||||
continue;
|
||||
|
||||
IRBuilder<>(CS.getInstruction())
|
||||
@ -755,12 +756,13 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall,
|
||||
if (ByValAlignment <= 1) // 0 = unspecified, 1 = no particular alignment.
|
||||
return Arg;
|
||||
|
||||
const DataLayout &DL = Caller->getParent()->getDataLayout();
|
||||
|
||||
// If the pointer is already known to be sufficiently aligned, or if we can
|
||||
// round it up to a larger alignment, then we don't need a temporary.
|
||||
auto &DL = Caller->getParent()->getDataLayout();
|
||||
if (getOrEnforceKnownAlignment(Arg, ByValAlignment, &DL,
|
||||
&IFI.ACT->getAssumptionCache(*Caller),
|
||||
TheCall) >= ByValAlignment)
|
||||
if (getOrEnforceKnownAlignment(Arg, ByValAlignment, DL, TheCall,
|
||||
&IFI.ACT->getAssumptionCache(*Caller)) >=
|
||||
ByValAlignment)
|
||||
return Arg;
|
||||
|
||||
// Otherwise, we have to make a memcpy to get a safe alignment. This is bad
|
||||
@ -1042,7 +1044,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||
// happy with whatever the cloner can do.
|
||||
CloneAndPruneFunctionInto(Caller, CalledFunc, VMap,
|
||||
/*ModuleLevelChanges=*/false, Returns, ".i",
|
||||
&InlinedFunctionInfo, &DL, TheCall);
|
||||
&InlinedFunctionInfo, TheCall);
|
||||
|
||||
// Remember the first block that is newly cloned over.
|
||||
FirstNewBlock = LastBlock; ++FirstNewBlock;
|
||||
@ -1063,7 +1065,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||
CloneAliasScopeMetadata(CS, VMap);
|
||||
|
||||
// Add noalias metadata if necessary.
|
||||
AddAliasScopeMetadata(CS, VMap, &DL, IFI.AA);
|
||||
AddAliasScopeMetadata(CS, VMap, DL, IFI.AA);
|
||||
|
||||
// FIXME: We could register any cloned assumptions instead of clearing the
|
||||
// whole function's cache.
|
||||
@ -1443,7 +1445,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||
// block other optimizations.
|
||||
if (PHI) {
|
||||
auto &DL = Caller->getParent()->getDataLayout();
|
||||
if (Value *V = SimplifyInstruction(PHI, &DL, nullptr, nullptr,
|
||||
if (Value *V = SimplifyInstruction(PHI, DL, nullptr, nullptr,
|
||||
&IFI.ACT->getAssumptionCache(*Caller))) {
|
||||
PHI->replaceAllUsesWith(V);
|
||||
PHI->eraseFromParent();
|
||||
|
Reference in New Issue
Block a user