summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
authorJohannes Doerfert <jdoerfert@anl.gov>2019-07-15 17:31:26 +0000
committerJohannes Doerfert <jdoerfert@anl.gov>2019-07-15 17:31:26 +0000
commit3dcd7996f1112e8f19f52a99ea7f2903572929dd (patch)
tree8bf19ac6effd46019f01053a2386562376b979be /llvm/lib/Transforms/IPO
parent8e7eee617a0915ca3153aed72da7c825f6263e25 (diff)
downloadbcm5719-llvm-3dcd7996f1112e8f19f52a99ea7f2903572929dd.tar.gz
bcm5719-llvm-3dcd7996f1112e8f19f52a99ea7f2903572929dd.zip
[FunctionAttrs] Remove readonly and writeonly assertion
There are scenarios where mutually recursive functions may cause the SCC to contain both read only and write only functions. This removes an assertion when adding read attributes which caused a crash with a the provided test case, and instead just doesn't add the attributes. Patch by Luke Lau <luke.lau@intel.com> Differential Revision: https://reviews.llvm.org/D60761 llvm-svn: 366090
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index cfae267c2f6..5ccd8bc4b0f 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -261,12 +261,15 @@ static bool addReadAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter) {
}
}
+ // If the SCC contains both functions that read and functions that write, then
+ // we cannot add readonly attributes.
+ if (ReadsMemory && WritesMemory)
+ return false;
+
// Success! Functions in this SCC do not access memory, or only read memory.
// Give them the appropriate attribute.
bool MadeChange = false;
- assert(!(ReadsMemory && WritesMemory) &&
- "Function marked read-only and write-only");
for (Function *F : SCCNodes) {
if (F->doesNotAccessMemory())
// Already perfect!
OpenPOWER on IntegriCloud