[PATCH] D47423: Simplify recursive launder.invariant.group and strip

Piotr Padlewski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 27 06:28:21 PDT 2018


Prazek created this revision.
Prazek added reviewers: rsmith, hfinkel, majnemer, amharc, kuhar.
Herald added a subscriber: hiraditya.

This patch is crucial for proving equality laundered/stripped
pointers. eg:

  bool foo(A *a) {
    return a == std::launder(a);
  }

Clang with -fstrict-vtable-pointers will emit something like:

  define dso_local zeroext i1 @_Z3fooP1A(%struct.A* %a) {
  entry:
    %c = bitcast %struct.A* %a to i8*
    %call = tail call i8* @llvm.launder.invariant.group.p0i8(i8* %c)
    %0 = bitcast %struct.A* %a to i8*
    %1 = tail call i8* @llvm.strip.invariant.group.p0i8(i8* %0)
    %2 = tail call i8* @llvm.strip.invariant.group.p0i8(i8* %call)
    %cmp = icmp eq i8* %1, %2
    ret i1 %cmp
  }

and because %2 can be replaced with @llvm.strip.invariant.group(%0)
and that %2 and %1 will produce the same value (because strip is readnone)
we can replace compare with true.


Repository:
  rL LLVM

https://reviews.llvm.org/D47423

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Analysis/ValueTracking/invariant.group.ll
  llvm/test/Transforms/InstCombine/invariant.group.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47423.148751.patch
Type: text/x-patch
Size: 6187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180527/3714eeb9/attachment.bin>


More information about the llvm-commits mailing list