Static Value-Flow Analysis
Loading...
Searching...
No Matches
Macros | Functions
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 <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 ConstantExprhasConstantGEP (Value *V)
 
static ConstantExprhasConstantBinaryOrUnaryOp (Value *V)
 
static ConstantExprhasConstantExpr (Value *V)
 
static InstructionconvertExpression (ConstantExpr *CE, Instruction *InsertPt)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "break-constgeps"

Definition at line 65 of file BreakConstantExpr.cpp.

Function Documentation

◆ convertExpression()

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

Definition at line 162 of file BreakConstantExpr.cpp.

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

◆ hasConstantBinaryOrUnaryOp()

static ConstantExpr * hasConstantBinaryOrUnaryOp ( Value V)
static

Definition at line 112 of file BreakConstantExpr.cpp.

113{
114 if (ConstantExpr * CE = SVFUtil::dyn_cast<ConstantExpr>(V))
115 {
116 if (Instruction::isBinaryOp(CE->getOpcode()) || Instruction::isUnaryOp(CE->getOpcode()))
117 {
118 return CE;
119 }
120 else
121 {
122 for (u32_t index = 0; index < CE->getNumOperands(); ++index)
123 {
124 if (hasConstantBinaryOrUnaryOp (CE->getOperand(index)))
125 return CE;
126 }
127 }
128 }
129
130 return nullptr;
131}
static ConstantExpr * hasConstantBinaryOrUnaryOp(Value *V)
unsigned u32_t
Definition CommandLine.h:18
int index
Definition cJSON.h:170
llvm::ConstantExpr ConstantExpr
Definition BasicTypes.h:120

◆ hasConstantExpr()

static ConstantExpr * hasConstantExpr ( Value V)
static

Definition at line 136 of file BreakConstantExpr.cpp.

137{
139 {
140 return gep;
141 }
143 {
144 return buop;
145 }
146 else
147 {
148 return nullptr;
149 }
150}
static ConstantExpr * hasConstantGEP(Value *V)

◆ hasConstantGEP()

static ConstantExpr * hasConstantGEP ( Value V)
static

Definition at line 87 of file BreakConstantExpr.cpp.

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

◆ STATISTIC() [1/2]

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

◆ STATISTIC() [2/2]

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