From 5b3db45e8f4d2600c32e18b136a31457e31b7aed Mon Sep 17 00:00:00 2001 From: Piotr Padlewski Date: Mon, 2 Jul 2018 04:49:30 +0000 Subject: Implement strip.invariant.group Summary: This patch introduce new intrinsic - strip.invariant.group that was described in the RFC: Devirtualization v2 Reviewers: rsmith, hfinkel, nlopes, sanjoy, amharc, kuhar Subscribers: arsenm, nhaehnle, JDevlieghere, hiraditya, xbolva00, llvm-commits Differential Revision: https://reviews.llvm.org/D47103 Co-authored-by: Krzysztof Pszeniczny llvm-svn: 336073 --- llvm/lib/Analysis/ValueTracking.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Analysis/ValueTracking.cpp') diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 12002de..16a3c7c 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3404,8 +3404,9 @@ const Value *llvm::getArgumentAliasingToReturnedPointer(ImmutableCallSite CS) { } bool llvm::isIntrinsicReturningPointerAliasingArgumentWithoutCapturing( - ImmutableCallSite CS) { - return CS.getIntrinsicID() == Intrinsic::launder_invariant_group; + ImmutableCallSite CS) { + return CS.getIntrinsicID() == Intrinsic::launder_invariant_group || + CS.getIntrinsicID() == Intrinsic::strip_invariant_group; } /// \p PN defines a loop-variant pointer to an object. Check if the @@ -3454,13 +3455,15 @@ Value *llvm::GetUnderlyingObject(Value *V, const DataLayout &DL, return V; } else { if (auto CS = CallSite(V)) { - // Note: getArgumentAliasingToReturnedPointer keeps it in sync with - // CaptureTracking, which is needed for correctness. This is because - // some intrinsics like launder.invariant.group returns pointers that - // are aliasing it's argument, which is known to CaptureTracking. - // If AliasAnalysis does not use the same information, it could assume - // that pointer returned from launder does not alias it's argument - // because launder could not return it if the pointer was not captured. + // CaptureTracking can know about special capturing properties of some + // intrinsics like launder.invariant.group, that can't be expressed with + // the attributes, but have properties like returning aliasing pointer. + // Because some analysis may assume that nocaptured pointer is not + // returned from some special intrinsic (because function would have to + // be marked with returns attribute), it is crucial to use this function + // because it should be in sync with CaptureTracking. Not using it may + // cause weird miscompilations where 2 aliasing pointers are assumed to + // noalias. if (auto *RP = getArgumentAliasingToReturnedPointer(CS)) { V = RP; continue; -- cgit v1.1