Fix MSAN failure on Function destruction
authorEvgenii Stepanov <eugenis@google.com>
Thu, 6 Feb 2020 23:07:20 +0000 (15:07 -0800)
committerEvgenii Stepanov <eugenis@google.com>
Thu, 6 Feb 2020 23:09:58 +0000 (15:09 -0800)
commit7dd2810907b87fbecb2ca7c111c2ad37bf1563e9
treea10b705ef22b80136e8ccc74a2935f66a2846338
parentac8a12c874cc7fb133f470549a2a31c59bb4243e
Fix MSAN failure on Function destruction

Summary:
When Function is destroyed, GlobalValue base class is destroyed, then
Value destructor would call use_empty, which ultimately attempts to
downcast 'this' to GlobalValue. This is UB, and is caught my MSAN as
accessing uninitialized memory.

Call materialized_use_empty, which doesn't call
assertModuleIsMaterializedImpl().

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74161

Patch by Antonio Maiorano.
llvm/lib/IR/Value.cpp