[PATCH] D64414: Do not set ReadNone attribute on intrinsics with side effects
Momchil Velikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 06:32:26 PDT 2019
chill created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If an intrinsic is defined without outputs, but having side effects, it still can be removed completely from
the program. This patch make TableGen not set `Attribute::ReadNone` for intrinsics which
are declared with `IntrHasSideEffects`.
https://reviews.llvm.org/D64414
Files:
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/IntrinsicEmitter.cpp
Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===================================================================
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -685,7 +685,7 @@
}
if (!intrinsic.canThrow ||
- intrinsic.ModRef != CodeGenIntrinsic::ReadWriteMem ||
+ (intrinsic.ModRef != CodeGenIntrinsic::ReadWriteMem && !intrinsic.hasSideEffects) ||
intrinsic.isNoReturn || intrinsic.isCold || intrinsic.isNoDuplicate ||
intrinsic.isConvergent || intrinsic.isSpeculatable) {
OS << " const Attribute::AttrKind Atts[] = {";
@@ -727,6 +727,8 @@
switch (intrinsic.ModRef) {
case CodeGenIntrinsic::NoMem:
+ if (intrinsic.hasSideEffects)
+ break;
if (addComma)
OS << ",";
OS << "Attribute::ReadNone";
Index: llvm/utils/TableGen/CodeGenDAGPatterns.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -2779,7 +2779,7 @@
// chain.
if (Int.IS.RetVTs.empty())
Operator = getDAGPatterns().get_intrinsic_void_sdnode();
- else if (Int.ModRef != CodeGenIntrinsic::NoMem)
+ else if (Int.ModRef != CodeGenIntrinsic::NoMem || Int.hasSideEffects)
// Has side-effects, requires chain.
Operator = getDAGPatterns().get_intrinsic_w_chain_sdnode();
else // Otherwise, no chain.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64414.208663.patch
Type: text/x-patch
Size: 1478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190709/c69b9ff7/attachment.bin>
More information about the llvm-commits
mailing list