LLVM 20.0.0git
Macros | Functions
WebAssemblyMemIntrinsicResults.cpp File Reference

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)
 

Detailed Description

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.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "wasm-mem-intrinsic-results"

Definition at line 43 of file WebAssemblyMemIntrinsicResults.cpp.

Function Documentation

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( WebAssemblyMemIntrinsicResults  ,
DEBUG_TYPE  ,
"Optimize memory intrinsic result values for WebAssembly"  ,
false  ,
false   
)

Definition at line 75 of file WebAssemblyMemIntrinsicResults.cpp.

◆ optimizeCall()

static bool optimizeCall ( MachineBasicBlock MBB,
MachineInstr MI,
const MachineRegisterInfo MRI,
MachineDominatorTree MDT,
LiveIntervals LIS,
const WebAssemblyTargetLowering TLI,
const TargetLibraryInfo LibInfo 
)
static

◆ replaceDominatedUses()

static bool replaceDominatedUses ( MachineBasicBlock MBB,
MachineInstr MI,
unsigned  FromReg,
unsigned  ToReg,
const MachineRegisterInfo MRI,
MachineDominatorTree MDT,
LiveIntervals LIS 
)
static