28#define DEBUG_TYPE "riscv-zacas-abi-fix"
29#define PASS_NAME "RISC-V Zacas ABI fix"
32class RISCVZacasABIFixImpl :
public InstVisitor<RISCVZacasABIFixImpl, bool> {
48 RISCVZacasABIFixLegacy() : FunctionPass(ID) {}
52 StringRef getPassName()
const override {
return PASS_NAME; }
54 void getAnalysisUsage(AnalysisUsage &AU)
const override {
65 assert(ST->hasStdExtZacas() &&
"only necessary to run in presence of zacas");
67 if (
I.getFailureOrdering() != AtomicOrdering::SequentiallyConsistent)
70 Builder.CreateFence(AtomicOrdering::SequentiallyConsistent);
74bool RISCVZacasABIFixImpl::run(Function &
F) {
75 if (!ST->hasStdExtZacas())
78 bool MadeChange =
false;
86bool RISCVZacasABIFixLegacy::runOnFunction(Function &
F) {
87 auto &TPC = getAnalysis<TargetPassConfig>();
88 auto &TM = TPC.getTM<RISCVTargetMachine>();
89 auto *
ST = &TM.getSubtarget<RISCVSubtarget>(
F);
94 return RISCVZacasABIFixImpl(ST).run(
F);
102char RISCVZacasABIFixLegacy::ID = 0;
105 return new RISCVZacasABIFixLegacy();
112 bool Changed = RISCVZacasABIFixImpl(ST).run(
F);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool runOnFunction(Function &F, bool PostInlining)
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static void visit(BasicBlock &Start, std::function< bool(BasicBlock *)> op)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
Target-Independent Code Generator Pass Configuration Options pass.
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
An instruction that atomically checks whether a specified value is in a memory location,...
FunctionPass class - This class is used to implement most global optimizations.
Base class for instruction visitors.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static PreservedAnalyses allInSet()
Construct a preserved analyses object with a single preserved set.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
FunctionPass * createRISCVZacasABIFixPass()