[llvm] r222997 - [msan] Add compile-time checks for missing origins.

Nick Lewycky nlewycky at google.com
Tue Dec 2 21:48:19 PST 2014


Hey! I found that "Missing origin" assertion fires, and am currently
reducing a testcase. For now, I've reverted this in r223211 and will let
you know as soon as I have a testcase ready.

Nick

On 1 December 2014 at 01:53, Evgeniy Stepanov <eugeni.stepanov at gmail.com>
wrote:

> Author: eugenis
> Date: Mon Dec  1 03:53:51 2014
> New Revision: 222997
>
> URL: http://llvm.org/viewvc/llvm-project?rev=222997&view=rev
> Log:
> [msan] Add compile-time checks for missing origins.
>
> This change makes MemorySanitizer instrumentation a bit more strict
> about instructions that have no origin id assigned to them.
>
> This would have caught the bug that was fixed in r222918.
>
> No functional change.
>
> Modified:
>     llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
>
> Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=222997&r1=222996&r2=222997&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Mon Dec
> 1 03:53:51 2014
> @@ -921,6 +921,8 @@ struct MemorySanitizerVisitor : public I
>              Value *OriginPtr =
>                  getOriginPtrForArgument(&FArg, EntryIRB, ArgOffset);
>              setOrigin(A, EntryIRB.CreateLoad(OriginPtr));
> +          } else {
> +            setOrigin(A, getCleanOrigin());
>            }
>          }
>          ArgOffset += RoundUpToAlignment(Size, kShadowTLSAlignment);
> @@ -940,15 +942,13 @@ struct MemorySanitizerVisitor : public I
>    /// \brief Get the origin for a value.
>    Value *getOrigin(Value *V) {
>      if (!MS.TrackOrigins) return nullptr;
> -    if (isa<Instruction>(V) || isa<Argument>(V)) {
> -      Value *Origin = OriginMap[V];
> -      if (!Origin) {
> -        DEBUG(dbgs() << "NO ORIGIN: " << *V << "\n");
> -        Origin = getCleanOrigin();
> -      }
> -      return Origin;
> -    }
> -    return getCleanOrigin();
> +    if (!PropagateShadow) return getCleanOrigin();
> +    if (isa<Constant>(V)) return getCleanOrigin();
> +    assert((isa<Instruction>(V) || isa<Argument>(V)) &&
> +           "Unexpected value type in getOrigin()");
> +    Value *Origin = OriginMap[V];
> +    assert(Origin && "Missing origin");
> +    return Origin;
>    }
>
>    /// \brief Get the origin for i-th argument of the instruction I.
> @@ -1088,6 +1088,7 @@ struct MemorySanitizerVisitor : public I
>      IRB.CreateStore(getCleanShadow(&I), ShadowPtr);
>
>      setShadow(&I, getCleanShadow(&I));
> +    setOrigin(&I, getCleanOrigin());
>    }
>
>    void visitAtomicRMWInst(AtomicRMWInst &I) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141202/690e29fe/attachment.html>


More information about the llvm-commits mailing list