1. [flang][fir] Add fir-opt tool (details)
  2. [flang][fir][NFC] Move FieldType to TableGen type definition (details)
  3. Revert "[flang][fir] Add fir-opt tool" (details)
  4. [FPEnv][ARM] Implement lowering of llvm.set.rounding (details)
  5. [test] Make ELF tests amenable to the order of non-local symbols (details)
  6. [LangRef] Update memory access ops to raise UB if ptrs are not well defined (details)
Commit df1eeaa7b404f7c5a96a812479f0ee2ce8354f6a by clementval
[flang][fir] Add fir-opt tool

This patch introduce the fir-opt tool. Similar to mlir-opt for FIR.
It will be used in following patches to test fir opt and round-trip.

Reviewed By: schweitz, mehdi_amini

Differential Revision:
The file was addedflang/tools/fir-opt/fir-opt.cpp
The file was modifiedflang/tools/CMakeLists.txt
The file was modifiedflang/test/Fir/fir-types.fir
The file was addedflang/tools/fir-opt/CMakeLists.txt
The file was modifiedflang/test/CMakeLists.txt
The file was modifiedflang/test/Fir/fir-ops.fir
Commit 8c1b63307f0696058bf4a9f7a54b012867f2457e by clementval
[flang][fir][NFC] Move FieldType to TableGen type definition

This patch is a follow up of D96422 and move ComplexType to TableGen.

Reviewed By: schweitz, mehdi_amini

Differential Revision:
The file was modifiedflang/include/flang/Optimizer/Dialect/
The file was modifiedflang/lib/Optimizer/Dialect/FIRType.cpp
The file was modifiedflang/include/flang/Optimizer/Dialect/
The file was modifiedflang/include/flang/Optimizer/Dialect/FIRType.h
Commit af186e93723837a507042acf1d7338e125706129 by clementval
Revert "[flang][fir] Add fir-opt tool"

This reverts commit df1eeaa7b404f7c5a96a812479f0ee2ce8354f6a.

Buildbot failure.
The file was removedflang/tools/fir-opt/CMakeLists.txt
The file was removedflang/tools/fir-opt/fir-opt.cpp
The file was modifiedflang/tools/CMakeLists.txt
The file was modifiedflang/test/Fir/fir-ops.fir
The file was modifiedflang/test/Fir/fir-types.fir
The file was modifiedflang/test/CMakeLists.txt
Commit 816053bc71751cac46aef085f57b7f305c7bbcd1 by sepavloff
[FPEnv][ARM] Implement lowering of llvm.set.rounding

Differential Revision:
The file was modifiedllvm/lib/Target/ARM/ARMISelLowering.cpp
The file was modifiedllvm/lib/Target/ARM/ARMISelLowering.h
The file was addedllvm/test/CodeGen/ARM/fpenv.ll
Commit 1f69355802ad446d95b4f71c421dd4100eb8aa77 by i
[test] Make ELF tests amenable to the order of non-local symbols
The file was modifiedlld/test/ELF/linkerscript/common-exclude.s
The file was modifiedlld/test/ELF/linkerscript/ehdr_start.s
The file was modifiedlld/test/ELF/aarch64-tls-ie.s
The file was modifiedlld/test/ELF/ppc64-error-missaligned-ds.s
The file was modifiedlld/test/ELF/edata-etext.s
The file was modifiedlld/test/ELF/combreloc.s
The file was modifiedllvm/test/MC/ELF/symver.s
The file was modifiedlld/test/ELF/global-offset-table-position-aarch64.s
The file was modifiedlld/test/ELF/gc-sections-shared.s
The file was modifiedlld/test/ELF/comdat-discarded-lazy.s
The file was modifiedlld/test/ELF/ehdr_start.s
The file was modifiedlld/test/ELF/linkerscript/common-assign.s
The file was modifiedlld/test/ELF/gnu-hash-table.s
The file was modifiedlld/test/ELF/symbol-ordering-file-warnings.s
The file was modifiedllvm/test/MC/ELF/undef.s
The file was modifiedlld/test/ELF/defsym.s
The file was modifiedlld/test/ELF/ppc64-error-missaligned-dq.s
The file was modifiedlld/test/ELF/common-gc.s
The file was modifiedlld/test/ELF/dynamic-list-glob.s
The file was modifiedlld/test/ELF/conflict-debug-variable2.s
The file was modifiedlld/test/ELF/undef-version-script.s
The file was modifiedlld/test/ELF/common-gc2.s
The file was modifiedlld/test/ELF/conflict-debug-variable.s
The file was modifiedlld/test/ELF/resolution.s
The file was modifiedlld/test/ELF/global-offset-table-position-i386.s
The file was modifiedlld/test/ELF/arm-gnu-ifunc.s
The file was modifiedlld/test/ELF/gnu-hash-table-rwsegment.s
The file was modifiedllvm/test/MC/ELF/weakref.s
The file was modifiedllvm/test/MC/ELF/type.s
Commit 1f6ec3d08f75dba6c93c291bd92552b807736eb3 by aqjune
[LangRef] Update memory access ops to raise UB if ptrs are not well defined

In the past, it was stated in D87994 that it is allowed to dereference a pointer that is partially undefined
if all of its possible representations fit into a dereferenceable range.
The motivation of the direction was to make a range analysis helpful for assuring dereferenceability.
Even if a range analysis concludes that its offset is within bounds, the offset could still be partially undefined; to utilize the range analysis, this relaxation was necessary. has more context about this.

However, this is currently blocking another optimization, which is annotating the noundef attribute for library functions' arguments. D95122 is the patch.
Currently, there are quite a few library functions which cannot have noundef attached to its pointer argument because it can be transformed from load/store.
For example, MemCpyOpt can convert stores into memset:

store p, i32 0
store (p+1), i32 0 // Since currently it is allowed for store to have partially undefined pointer..
memset(p, 0, 8)    // memset cannot guarantee that its ptr argument is noundef.

A bigger problem is that this makes unclear which library functions are allowed to have 'noundef' and which functions aren't (e.g., strlen).
This makes annotating noundef almost impossible for this kind of functions.

This patch proposes that all memory operations should have well-defined pointers.
For memset/memcpy, it is semantically equivalent to running a loop until the size is met (and branching on undef is UB), so the size is also updated to be well-defined.

Strictly speaking, this again violates the implication of dereferenceability from range analysis result.
However, I think this is okay for the following reasons:

1. It seems the existing analyses in the LLVM main repo does not have conflicting implementation with the new proposal.
`isDereferenceableAndAlignedPointer` works only when the GEP offset is constant, and `isDereferenceableAndAlignedInLoop` is also fine.

2. A possible miscompilation happens only when the source has a pointer with a *partially* undefined offset (it's okay with poison because there is no 'partially poison' value).
But, at least I'm not aware of a language using LLVM as backend that has a well-defined program while allowing partially undefined pointers.
There might be such a language that I'm not aware of, but improving the performance of the mainstream languages like C and Rust is more important IMHO.

Reviewed By: jdoerfert

Differential Revision:
The file was modifiedllvm/docs/LangRef.rst