Static Value-Flow Analysis
Loading...
Searching...
No Matches
BreakConstantExpr.cpp File Reference
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/InstIterator.h"
#include "SVF-LLVM/BasicTypes.h"
#include "SVF-LLVM/BreakConstantExpr.h"
#include "Util/GeneralType.h"
#include "Util/SVFUtil.h"
#include <iostream>
#include <map>
#include <utility>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "break-constgeps"

Functions

 STATISTIC (GEPChanges, "Number of Converted GEP Constant Expressions")
 STATISTIC (TotalChanges, "Number of Converted Constant Expressions")
static ConstantExpr * hasConstantGEP (Value *V)
static ConstantExpr * hasConstantBinaryOrUnaryOp (Value *V)
static ConstantExpr * hasConstantExpr (Value *V)
static Instruction * convertExpression (ConstantExpr *CE, Instruction *InsertPt)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "break-constgeps"

Definition at line 67 of file BreakConstantExpr.cpp.

Function Documentation

◆ convertExpression()

Instruction * convertExpression ( ConstantExpr * CE,
Instruction * InsertPt )
static

Definition at line 164 of file BreakConstantExpr.cpp.

165{
166 //
167 // Convert this constant expression into a regular instruction.
168 //
169 if (CE->getOpcode() == Instruction::GetElementPtr)
170 ++GEPChanges;
171 ++TotalChanges;
172 Instruction* Result = CE->getAsInstruction();
173 Result->insertBefore(InsertPt->getIterator());
174 return Result;
175}
llvm::Instruction Instruction
Definition BasicTypes.h:85

◆ hasConstantBinaryOrUnaryOp()

ConstantExpr * hasConstantBinaryOrUnaryOp ( Value * V)
static

Definition at line 114 of file BreakConstantExpr.cpp.

115{
117 {
118 if (Instruction::isBinaryOp(CE->getOpcode()) || Instruction::isUnaryOp(CE->getOpcode()))
119 {
120 return CE;
121 }
122 else
123 {
124 for (u32_t index = 0; index < CE->getNumOperands(); ++index)
125 {
126 if (hasConstantBinaryOrUnaryOp (CE->getOperand(index)))
127 return CE;
128 }
129 }
130 }
131
132 return nullptr;
133}
static ConstantExpr * hasConstantBinaryOrUnaryOp(Value *V)
unsigned u32_t
Definition CommandLine.h:18
int index
Definition cJSON.h:170
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
Definition Casting.h:405
llvm::ConstantExpr ConstantExpr
Definition BasicTypes.h:118

◆ hasConstantExpr()

ConstantExpr * hasConstantExpr ( Value * V)
static

Definition at line 138 of file BreakConstantExpr.cpp.

139{
140 if (ConstantExpr * gep = hasConstantGEP(V))
141 {
142 return gep;
143 }
144 else if (ConstantExpr * buop = hasConstantBinaryOrUnaryOp(V))
145 {
146 return buop;
147 }
148 else
149 {
150 return nullptr;
151 }
152}
static ConstantExpr * hasConstantGEP(Value *V)

◆ hasConstantGEP()

ConstantExpr * hasConstantGEP ( Value * V)
static

Definition at line 89 of file BreakConstantExpr.cpp.

90{
92 {
93 if (CE->getOpcode() == Instruction::GetElementPtr)
94 {
95 return CE;
96 }
97 else
98 {
99 for (u32_t index = 0; index < CE->getNumOperands(); ++index)
100 {
101 if (hasConstantGEP (CE->getOperand(index)))
102 return CE;
103 }
104 }
105 }
106
107 return nullptr;
108}

◆ STATISTIC() [1/2]

STATISTIC ( GEPChanges ,
"Number of Converted GEP Constant Expressions"  )

◆ STATISTIC() [2/2]

STATISTIC ( TotalChanges ,
"Number of Converted Constant Expressions"  )