[PATCH] D102348: [Instructions]: Calls marked with inaccessiblememonly attribute should be considered to not read/write memory
Ettore Tiotto via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 12 11:50:54 PDT 2021
etiotto created this revision.
etiotto added reviewers: Meinersbur, bmahjour, Whitney.
etiotto added a project: LLVM.
Herald added subscribers: dexonsmith, hiraditya.
etiotto requested review of this revision.
Herald added a subscriber: llvm-commits.
The documentations states that functions with the `inaccessiblememonly` only access memory that is not accessible by the module bering compiled:
inaccessiblememonly
This attribute indicates that the function may only access memory that is not accessible by the module being compiled. This is a weaker form of readnone. If the function reads or writes other memory, the behavior is undefined.
Therefore the `Instruction::mayReadFromMemory()` and `Instruction::mayWriteToMemory()` should report that such functions do not read not write memory in the module being compiled.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102348
Files:
llvm/lib/IR/Instruction.cpp
Index: llvm/lib/IR/Instruction.cpp
===================================================================
--- llvm/lib/IR/Instruction.cpp
+++ llvm/lib/IR/Instruction.cpp
@@ -553,8 +553,10 @@
return true;
case Instruction::Call:
case Instruction::Invoke:
- case Instruction::CallBr:
- return !cast<CallBase>(this)->doesNotReadMemory();
+ case Instruction::CallBr: {
+ const CallBase &CB = *cast<CallBase>(this);
+ return !CB.doesNotReadMemory() && !CB.onlyAccessesInaccessibleMemory();
+ }
case Instruction::Store:
return !cast<StoreInst>(this)->isUnordered();
}
@@ -573,8 +575,10 @@
return true;
case Instruction::Call:
case Instruction::Invoke:
- case Instruction::CallBr:
- return !cast<CallBase>(this)->onlyReadsMemory();
+ case Instruction::CallBr: {
+ const CallBase &CB = *cast<CallBase>(this);
+ return !CB.onlyReadsMemory() && !CB.onlyAccessesInaccessibleMemory();
+ }
case Instruction::Load:
return !cast<LoadInst>(this)->isUnordered();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102348.344891.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210512/b715995f/attachment.bin>
More information about the llvm-commits
mailing list