[all-commits] [llvm/llvm-project] df5c27: [flang][FIR] add FIR TBAA pass

Tom Eccles via All-commits all-commits at lists.llvm.org
Wed Oct 11 07:37:06 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: df5c27869c84ed6d6e61f03ac6e7a83e42d7dbd9
      https://github.com/llvm/llvm-project/commit/df5c27869c84ed6d6e61f03ac6e7a83e42d7dbd9
  Author: Tom Eccles <tom.eccles at arm.com>
  Date:   2023-10-11 (Wed, 11 Oct 2023)

  Changed paths:
    A flang/include/flang/Optimizer/Analysis/TBAAForest.h
    M flang/include/flang/Optimizer/Transforms/Passes.h
    M flang/include/flang/Optimizer/Transforms/Passes.td
    M flang/lib/Optimizer/Analysis/CMakeLists.txt
    A flang/lib/Optimizer/Analysis/TBAAForest.cpp
    A flang/lib/Optimizer/Transforms/AddAliasTags.cpp
    M flang/lib/Optimizer/Transforms/CMakeLists.txt
    A flang/test/Transforms/tbaa.fir
    A flang/test/Transforms/tbaa2.fir

  Log Message:
  -----------
  [flang][FIR] add FIR TBAA pass

See RFC at
https://discourse.llvm.org/t/rfc-propagate-fir-alias-analysis-information-using-tbaa/73755

This pass adds TBAA tags to all accesses to non-pointer/target dummy
arguments. These TBAA tags tell LLVM that these accesses cannot alias:
allowing better dead code elimination, hoisting out of loops, and
vectorization.

Each function has its own TBAA tree so that accesses between funtions
MayAlias after inlining.

I also included code for adding tags for local allocations and for
global variables. Enabling all three kinds of tag is known to produce a
miscompile and so these are disabled by default. But it isn't much
code and I thought it could be interesting to play with these later if
one is looking at a benchmark which looks like it would benefit from
more alias information. I'm open to removing this code too.

TBAA tags are also added separately by TBAABuilder during CodeGen.
TBAABuilder has to run during CodeGen because it adds tags to box
accesses, many of which are implicit in FIR. This pass cannot (easily)
run in CodeGen because fir::AliasAnalysis has difficulty tracing values
between blocks, and by the time CodeGen runs, structured control flow
has already been lowered.

Coming in follow up patches
  - Change CodeGen/TBAABuilder to use TBAAForest to add tags within the
    same per-function trees as are used here (delayed to a later patch
    to make it easier to revert)
  - Command line argument processing to actually enable the pass




More information about the All-commits mailing list