[PATCH] D9400: llvm.noalias - Use noalias intrinsics when inlining (and update them when cloning metadata)

Jeroen Dobbelaere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 16 10:08:11 PDT 2018


jeroen.dobbelaere added a comment.

Compare following testcases (which should have an equivalent result):

  void set_nnn(int* pA, int* pB, int* dummy) {
    int* lpA; lpA=pA;
    int* lpB; lpB=pB;
    int* ldummy; ldummy=dummy;
    *lpA=42;
    *lpB=43;
  
    *ldummy=99;
  }
   
  int test_rr_nnn(int* pA, int* pB, int* dummy) {
    int* __restrict lpA; lpA=pA;
    int* __restrict lpB; lpB=pB;
  
    set_nnn(lpA,lpB,dummy);
    return *lpA;
  }

versus:

  int test_rr_local(int* pA, int* pB, int* dummy) {
    int* __restrict lpA; lpA=pA;
    int* __restrict lpB; lpB=pB;
    int* ldummy; ldummy=dummy;
    { // inlined code:
      int* l2pA; l2pA=lpA;
      int* l2pB; l2pB=lpB;
      int* l2dummy; l2dummy=ldummy;
      *l2pA=42;
      *l2pB=43;
  
      *l2dummy=99;
    }
    return *lpA;
  }

After inlining, 'test_rr_nnn' will not contain !noalias references for the three store instructions that have been inlined.

While inlining, even when the callee does not have noalias args or noalias/scope metadata, it might be needed to add the information to the load/stores


https://reviews.llvm.org/D9400





More information about the llvm-commits mailing list