LLVM 17.0.0git
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/NoFolder.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/DeadArgumentElimination.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <cassert>
#include <utility>
#include <vector>

Go to the source code of this file.

## Functions

STATISTIC (NumArgumentsEliminated, "Number of unread args removed")

STATISTIC (NumRetValsEliminated, "Number of unused return values removed")

STATISTIC (NumArgumentsReplacedWithPoison, "Number of unread args replaced with poison")

INITIALIZE_PASS (DAH, "deadarghaX0r", "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)", false, false) ModulePass *llvm
This pass removes arguments from functions which are not used by the body of the function.

Convenience function that returns the number of return values It returns for void functions and for functions not returning a struct It returns the number of struct elements for functions returning a struct static unsigned numRetVals (const Function *F)

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one Idx (i.e. only top-level structure is considered). static Type *getRetComponentType(const Function *F

assert (!RetTy->isVoidTy() &&"void type has no subtype")

if (StructType *STy=dyn_cast< StructType >(RetTy)) return STy -> getElementType(Idx)

if (ArrayType *ATy=dyn_cast< ArrayType >(RetTy)) return ATy -> getElementType()

Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is MaybeLiveUses might be modified but its content should be ignored (since it might not be complete). DeadArgumentEliminationPass

Mark the given Function as meaning that it cannot be changed in any way mark any values that are used as this function s parameters or by its return values (according to Uses) live as well. void DeadArgumentEliminationPass

Mark the given return value or argument as live mark any values that are used by this value (according to Uses) live as well. void DeadArgumentEliminationPass

Given that RA is a live propagate it s liveness to any other values it uses (according to Uses). void DeadArgumentEliminationPass

## Variables

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx

return RetTy

Checks Use for liveness in LiveValues If Use is not live

Looks at a single use of an argument or return value and determines if it should be alive or not Adds this use to MaybeLiveUses if it causes the used value to become MaybeLive RetValNum is the return value number to use when this use is used in a return instruction This is used in the recursion

Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is Live

Performs the initial survey of the specified function

Marks the liveness of RA depending on L If L is MaybeLive

Marks the liveness of RA depending on L If L is it also takes all uses in MaybeLiveUses and records them in Uses

Mark the given Function as alive

Mark the given Function as meaning that it cannot be changed in any way Additionally

Given that RA is a live value

## ◆ DEBUG_TYPE

Definition at line 54 of file DeadArgumentElimination.cpp.

## ◆ assert()

 assert ( !RetTy->isVoidTy() &&"void type has no subtype" )

## ◆ Idx()

 Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one Idx ( i.e. only top-level structure is considered ) const

## ◆ if() [1/2]

 if ( ArrayType * ATy = dyn_cast< ArrayType >(RetTy) ) -> getElementType()

## ◆ if() [2/2]

 if ( StructType * STy = dyn_cast< StructType >(RetTy) ) -> getElementType(Idx)

## ◆ ignored()

 Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is MaybeLiveUses might be modified but its content should be ignored ( since it might not be complete )

## ◆ INITIALIZE_PASS()

 INITIALIZE_PASS ( DAH , "deadarghaX0r" , "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)" , false , false )

This pass removes arguments from functions which are not used by the body of the function.

Definition at line 115 of file DeadArgumentElimination.cpp.

## ◆ numRetVals()

 Convenience function that returns the number of return values It returns for void functions and for functions not returning a struct It returns the number of struct elements for functions returning a struct static unsigned numRetVals ( const Function * F )

Definition at line 338 of file DeadArgumentElimination.cpp.

References F, and RetTy.

Referenced by values().

## ◆ STATISTIC() [1/3]

 STATISTIC ( NumArgumentsEliminated , "Number of unread args removed" )

## ◆ STATISTIC() [2/3]

 STATISTIC ( NumArgumentsReplacedWithPoison , "Number of unread args replaced with poison" )

## ◆ STATISTIC() [3/3]

 STATISTIC ( NumRetValsEliminated , "Number of unused return values removed" )

## ◆ uses()

 Given that RA is a live propagate it s liveness to any other values it uses ( according to Uses )

Definition at line 716 of file DeadArgumentElimination.cpp.

References E, I, RA, and llvm::DeadArgumentEliminationPass::Uses.

## ◆ value()

 Mark the given return value or argument as live mark any values that are used by this value ( according to Uses )

## ◆ values()

 Mark the given Function as meaning that it cannot be changed in any way mark any values that are used as this function s parameters or by its return values ( according to Uses )

## Variable Documentation

 Mark the given return value or argument as live Additionally

Definition at line 683 of file DeadArgumentElimination.cpp.

## ◆ alive

 Mark the given Function as alive

Definition at line 682 of file DeadArgumentElimination.cpp.

## ◆ function

 Performs the initial survey of the specified function

Definition at line 487 of file DeadArgumentElimination.cpp.

## ◆ live

 Checks Use for liveness in LiveValues If Use is not live

Definition at line 363 of file DeadArgumentElimination.cpp.

Referenced by findBasePointers().

## ◆ Live

 Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is Live

Definition at line 471 of file DeadArgumentElimination.cpp.

## ◆ MaybeLive

 Marks the liveness of RA depending on L If L is MaybeLive

Definition at line 657 of file DeadArgumentElimination.cpp.

## ◆ recursion

 Looks at a single use of an argument or return value and determines if it should be alive or not Adds this use to MaybeLiveUses if it causes the used value to become MaybeLive RetValNum is the return value number to use when this use is used in a return instruction This is used in the recursion

Definition at line 383 of file DeadArgumentElimination.cpp.

## ◆ Uses

 Marks the liveness of RA depending on L If L is it also takes all uses in MaybeLiveUses and records them in Uses

Definition at line 658 of file DeadArgumentElimination.cpp.