Skip to content

Commit

Permalink
SelectionDAG: Add AssumptionCache analysis dependency
Browse files Browse the repository at this point in the history
Fixes compile time regression after
bb70b5d
  • Loading branch information
arsenm committed Sep 19, 2022
1 parent 94049db commit bcb931c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions llvm/include/llvm/CodeGen/SelectionDAGISel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace llvm {
class AAResults;
class AssumptionCache;
class TargetInstrInfo;
class TargetMachine;
class SelectionDAGBuilder;
Expand Down Expand Up @@ -48,6 +49,7 @@ class SelectionDAGISel : public MachineFunctionPass {
SelectionDAG *CurDAG;
std::unique_ptr<SelectionDAGBuilder> SDB;
AAResults *AA = nullptr;
AssumptionCache *AC = nullptr;
GCFunctionInfo *GFI = nullptr;
CodeGenOpt::Level OptLevel;
const TargetInstrInfo *TII;
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,10 @@ RegsForValue::getRegsAndSizes() const {
}

void SelectionDAGBuilder::init(GCFunctionInfo *gfi, AliasAnalysis *aa,
AssumptionCache *ac,
const TargetLibraryInfo *li) {
AA = aa;
AC = ac;
GFI = gfi;
LibInfo = li;
Context = DAG.getContext();
Expand Down Expand Up @@ -4139,7 +4141,7 @@ void SelectionDAGBuilder::visitLoad(const LoadInst &I) {
}

if (isDereferenceableAndAlignedPointer(SV, Ty, Alignment, DAG.getDataLayout(),
&I, nullptr, nullptr, LibInfo))
&I, AC, nullptr, LibInfo))
MMOFlags |= MachineMemOperand::MODereferenceable;

SDLoc dl = getCurSDLoc();
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AAResults;
class AllocaInst;
class AtomicCmpXchgInst;
class AtomicRMWInst;
class AssumptionCache;
class BasicBlock;
class BranchInst;
class CallInst;
Expand Down Expand Up @@ -191,6 +192,7 @@ class SelectionDAGBuilder {

SelectionDAG &DAG;
AAResults *AA = nullptr;
AssumptionCache *AC = nullptr;
const TargetLibraryInfo *LibInfo;

class SDAGSwitchLowering : public SwitchCG::SwitchLowering {
Expand Down Expand Up @@ -244,7 +246,7 @@ class SelectionDAGBuilder {
SL(std::make_unique<SDAGSwitchLowering>(this, funcinfo)), FuncInfo(funcinfo),
SwiftError(swifterror) {}

void init(GCFunctionInfo *gfi, AAResults *AA,
void init(GCFunctionInfo *gfi, AAResults *AA, AssumptionCache *AC,
const TargetLibraryInfo *li);

/// Clear out the current SelectionDAG and the associated state and prepare
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/EHPersonalities.h"
Expand Down Expand Up @@ -336,6 +337,7 @@ void SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<GCModuleInfo>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
AU.addRequired<TargetTransformInfoWrapperPass>();
AU.addRequired<AssumptionCacheTracker>();
if (UseMBPI && OptLevel != CodeGenOpt::None)
AU.addRequired<BranchProbabilityInfoWrapperPass>();
AU.addRequired<ProfileSummaryInfoWrapperPass>();
Expand Down Expand Up @@ -403,6 +405,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
LibInfo = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(Fn);
GFI = Fn.hasGC() ? &getAnalysis<GCModuleInfo>().getFunctionInfo(Fn) : nullptr;
ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(mf.getFunction());
auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
BlockFrequencyInfo *BFI = nullptr;
if (PSI && PSI->hasProfileSummary() && OptLevel != CodeGenOpt::None)
Expand Down Expand Up @@ -430,7 +433,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
else
AA = nullptr;

SDB->init(GFI, AA, LibInfo);
SDB->init(GFI, AA, AC, LibInfo);

MF->setHasInlineAsm(false);

Expand Down

0 comments on commit bcb931c

Please sign in to comment.