[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
Mon Jul 15 09:25:34 PDT 2019
chill updated this revision to Diff 209887.
chill added a comment.
Added a regression test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64414/new/
https://reviews.llvm.org/D64414
Files:
llvm/test/TableGen/intrin-side-effects.td
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.
Index: llvm/test/TableGen/intrin-side-effects.td
===================================================================
--- /dev/null
+++ llvm/test/TableGen/intrin-side-effects.td
@@ -0,0 +1,39 @@
+// RUN: llvm-tblgen -gen-intrinsic-impl -I %p/../../include %s | FileCheck %s
+
+// Get the minimum blurb necessary to process ...
+include "llvm/CodeGen/ValueTypes.td"
+include "llvm/CodeGen/SDNodeProperties.td"
+
+class LLVMType<ValueType vt> {
+ ValueType VT = vt;
+ int isAny = 0;
+}
+
+def llvm_i32_ty : LLVMType<i32>;
+
+class IntrinsicProperty;
+def IntrNoMem : IntrinsicProperty;
+def IntrHasSideEffects : IntrinsicProperty;
+
+
+class Intrinsic<list<LLVMType> ret_types,
+ list<LLVMType> param_types = [],
+ list<IntrinsicProperty> intr_properties = [],
+ string name = "",
+ list<SDNodeProperty> sd_properties = []> : SDPatternOperator {
+ string LLVMName = name;
+ string TargetPrefix = "";
+ list<LLVMType> RetTypes = ret_types;
+ list<LLVMType> ParamTypes = param_types;
+ list<IntrinsicProperty> IntrProperties = intr_properties;
+ let Properties = sd_properties;
+
+ bit isTarget = 0;
+}
+
+// ... this intrinsic.
+def int_random_gen : Intrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrHasSideEffects]>;
+
+// CHECK: 1, // llvm.random.gen
+// CHECK: case 1:
+// CHECK-NEXT: Atts[] = {Attribute::NoUnwind}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64414.209887.patch
Type: text/x-patch
Size: 2866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190715/b695d61d/attachment.bin>
More information about the llvm-commits
mailing list