llvm-project/mlir/test
Sanjoy Das 86771d0b65 Introduce a ConditionallySpeculatable op interface
This patch takes the first step towards a more principled modeling of undefined behavior in MLIR as discussed in the following discourse threads:

 1. https://discourse.llvm.org/t/semantics-modeling-undefined-behavior-and-side-effects/4812
 2. https://discourse.llvm.org/t/rfc-mark-tensor-dim-and-memref-dim-as-side-effecting/65729

This patch in particular does the following:

 1. Introduces a ConditionallySpeculatable OpInterface that dynamically determines whether an Operation can be speculated.
 2. Re-defines `NoSideEffect` to allow undefined behavior, making it necessary but not sufficient for speculation.  Also renames it to `NoMemoryEffect`.
 3. Makes LICM respect the above semantics.
 4. Changes all ops tagged with `NoSideEffect` today to additionally implement ConditionallySpeculatable and mark themselves as always speculatable.  This combined trait is named `Pure`.  This makes this change NFC.

For out of tree dialects:

 1. Replace `NoSideEffect` with `Pure` if the operation does not have any memory effects, undefined behavior or infinite loops.
 2. Replace `NoSideEffect` with `NoSideEffect` otherwise.

The next steps in this process are (I'm proposing to do these in upcoming patches):

 1. Update operations like `tensor.dim`, `memref.dim`, `scf.for`, `affine.for` to implement a correct hook for `ConditionallySpeculatable`.  I'm also happy to update ops in other dialects if the respective dialect owners would like to and can give me some pointers.
 2. Update other passes that speculate operations to consult `ConditionallySpeculatable` in addition to `NoMemoryEffect`.  I could not find any other than LICM on a quick skim, but I could have missed some.
 3. Add some documentation / FAQs detailing the differences between side effects, undefined behavior, speculatabilty.

Reviewed By: rriddle, mehdi_amini

Differential Revision: https://reviews.llvm.org/D135505
2022-10-12 10:56:12 -07:00
..
Analysis [mlir][Linalg] NFC - Add bbarg pretty printing to linalg::generic 2022-10-05 00:59:42 -07:00
Bytecode [mlir:Bytecode] Add support for encoding resources 2022-09-13 11:39:19 -07:00
CAPI [mlir] add OperationType to the Transform dialect 2022-10-11 09:55:19 +00:00
Conversion [mlir] Fix bitwidth of memref-to-llvm constant. 2022-10-12 17:13:01 +03:00
Dialect [mlir][Linalg] Drop filter-based splitReduction 2022-10-12 07:27:35 -07:00
Examples [mlir][standalone] Specify python path when configuring 2022-09-20 15:43:39 -04:00
IR [mlir][NFC] Make 'printOp' public in AsmPrinter 2022-10-05 19:00:53 +00:00
Integration [mlir][sparse] Add MLIR interface for sparse tensor file input and output. 2022-10-11 16:25:13 -07:00
Interfaces [mlir][tensor][NFC] Rename linalg.init_tensor to tensor.empty 2022-10-04 17:25:35 +09:00
Pass [MLIR] Fix after 4b27825. 2022-09-28 10:15:41 +02:00
Rewrite (Reland) [mlir] Switch segment size attributes to DenseI32ArrayAttr 2022-08-12 19:44:52 -04:00
Target [mlir][llvm] Tablegen based operation import from LLVM IR. 2022-10-12 14:36:41 +03:00
Transforms Introduce a ConditionallySpeculatable op interface 2022-10-12 10:56:12 -07:00
Unit Resubmit "[MLIR] Remove unused config attributes from lit.site.cfg.py" 2022-09-03 09:02:37 +02:00
lib Introduce a ConditionallySpeculatable op interface 2022-10-12 10:56:12 -07:00
mlir-cpu-runner [mlir] Fix test failure with invalid piping syntax on old bash 2022-10-07 09:29:49 +09:00
mlir-linalg-ods-gen [mlir][linalg][NFC] Drop emitAccessorPrefix from Linalg dialect 2022-10-03 11:35:41 +09:00
mlir-lsp-server [mlir:LSP] Add a quickfix code action for inserting expected-* diagnostic checks 2022-07-20 15:43:59 -07:00
mlir-opt [mlir][spirv] Change dialect name from 'spv' to 'spirv' 2022-09-26 10:58:30 -04:00
mlir-pdll [mlir:PDLL] Actually run the integration tests 2022-09-01 12:37:18 -07:00
mlir-pdll-lsp-server [mlir:PDLL] Add support for inlay hints 2022-06-06 20:20:19 -07:00
mlir-reduce [mlir] Fix test failure with invalid piping syntax on old bash 2022-10-07 09:29:49 +09:00
mlir-spirv-cpu-runner Revert "[mlir][spirv] Change td def/class prefix from SPV to SPIRV" 2022-09-26 12:40:35 -04:00
mlir-tblgen Introduce a ConditionallySpeculatable op interface 2022-10-12 10:56:12 -07:00
mlir-translate [mlir][NFC] Update textual references of `func` to `func.func` in tool/runner tests 2022-04-20 22:17:30 -07:00
mlir-vulkan-runner Reland "[mlir][spirv] Change td def/class prefix from SPV to SPIRV" 2022-09-26 14:45:52 -04:00
python [mlir] switch the transform loop extension to use types 2022-10-11 09:55:23 +00:00
tblgen-lsp-server [TableGen:LSP] Resolve "go-to-def" on a let field to the base definition 2022-09-27 23:48:16 -07:00
APITest.h Adjust "end namespace" comment in MLIR to match new agree'd coding style 2021-12-08 06:05:26 +00:00
CMakeLists.txt [mlir] add OperationType to the Transform dialect 2022-10-11 09:55:19 +00:00
lit.cfg.py [mlir] add OperationType to the Transform dialect 2022-10-11 09:55:19 +00:00
lit.site.cfg.py.in [test][mlir] Restore used attributes deleted by D132726 2022-09-03 14:14:36 -07:00