LLVM 20.0.0git
|
This file implements an optimization pass using memory intrinsic results. More...
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "WebAssembly.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySubtarget.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "wasm-mem-intrinsic-results" |
Functions | |
INITIALIZE_PASS (WebAssemblyMemIntrinsicResults, DEBUG_TYPE, "Optimize memory intrinsic result values for WebAssembly", false, false) FunctionPass *llvm | |
static bool | replaceDominatedUses (MachineBasicBlock &MBB, MachineInstr &MI, unsigned FromReg, unsigned ToReg, const MachineRegisterInfo &MRI, MachineDominatorTree &MDT, LiveIntervals &LIS) |
static bool | optimizeCall (MachineBasicBlock &MBB, MachineInstr &MI, const MachineRegisterInfo &MRI, MachineDominatorTree &MDT, LiveIntervals &LIS, const WebAssemblyTargetLowering &TLI, const TargetLibraryInfo &LibInfo) |
This file implements an optimization pass using memory intrinsic results.
Calls to memory intrinsics (memcpy, memmove, memset) return the destination address. They are in the form of dst_new = call @memcpy dst, src, len where dst and dst_new registers contain the same value.
This is to enable an optimization wherein uses of the dst register used in the parameter can be replaced by uses of the dst_new register used in the result, making the dst register more likely to be single-use, thus more likely to be useful to register stackifying, and potentially also exposing the call instruction itself to register stackifying. These both can reduce local.get/local.set traffic.
The LLVM intrinsics for these return void so they can't use the returned attribute and consequently aren't handled by the OptimizeReturned pass.
Definition in file WebAssemblyMemIntrinsicResults.cpp.
#define DEBUG_TYPE "wasm-mem-intrinsic-results" |
Definition at line 43 of file WebAssemblyMemIntrinsicResults.cpp.
INITIALIZE_PASS | ( | WebAssemblyMemIntrinsicResults | , |
DEBUG_TYPE | , | ||
"Optimize memory intrinsic result values for WebAssembly" | , | ||
false | , | ||
false | |||
) |
Definition at line 75 of file WebAssemblyMemIntrinsicResults.cpp.
|
static |
Definition at line 148 of file WebAssemblyMemIntrinsicResults.cpp.
References llvm::TargetLoweringBase::getLibcallName(), llvm::TargetLibraryInfo::getLibFunc(), llvm::MachineOperand::getSymbolName(), llvm::MachineOperand::isSymbol(), MBB, MI, MRI, Name, replaceDominatedUses(), and llvm::report_fatal_error().
|
static |
Definition at line 84 of file WebAssemblyMemIntrinsicResults.cpp.
References llvm::dbgs(), llvm::MachineDominatorTree::dominates(), llvm::LiveIntervals::extendToIndices(), llvm::SlotIndex::getDeadSlot(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), llvm::MachineBasicBlock::getParent(), llvm::WebAssemblySubtarget::getRegisterInfo(), llvm::SlotIndex::getRegSlot(), llvm::MachineFunction::getSubtarget(), llvm::LiveRange::getVNInfoAt(), llvm::LiveRange::liveAt(), LLVM_DEBUG, llvm::make_early_inc_range(), MBB, MI, MRI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::LiveIntervals::shrinkToUses().
Referenced by optimizeCall().