llvm.org GIT mirror llvm / d96288a
add a new Instruction::mayReadFromMemory predicate, make Instruction::mayWriteToMemory stronger for invokes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50858 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
2 changed file(s) with 23 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
4949 ///
5050 bool mayWriteToMemory() const;
5151
52 /// mayReadFromMemory - Return true if this instruction may read memory.
53 ///
54 bool mayReadFromMemory() const;
55
5256 /// clone() - Create a copy of 'this' instruction that is identical in all
5357 /// ways except the following:
5458 /// * The instruction has no parent
218218 return false;
219219 }
220220
221
221 /// mayReadFromMemory - Return true if this instruction may read memory.
222 ///
223 bool Instruction::mayReadFromMemory() const {
224 switch (getOpcode()) {
225 default: return false;
226 case Instruction::Free:
227 case Instruction::Store:
228 case Instruction::VAArg:
229 return true;
230 case Instruction::Call:
231 return !cast(this)->doesNotAccessMemory();
232 case Instruction::Invoke:
233 return !cast(this)->doesNotAccessMemory();
234 case Instruction::Load:
235 return true;
236 }
237 }
222238
223239 /// mayWriteToMemory - Return true if this instruction may modify memory.
224240 ///
226242 switch (getOpcode()) {
227243 default: return false;
228244 case Instruction::Free:
229 case Instruction::Invoke:
230245 case Instruction::Store:
231246 case Instruction::VAArg:
232247 return true;
233248 case Instruction::Call:
234249 return !cast(this)->onlyReadsMemory();
250 case Instruction::Invoke:
251 return !cast(this)->onlyReadsMemory();
235252 case Instruction::Load:
236253 return cast(this)->isVolatile();
237254 }