[AliasAnalysis] Initialize a member variable that may be used by unit test.

The unit tests in BasicAliasAnalysisTest use the alias analysis API
directly and do not call setAAResults to initalize AAR. This gives a
valgrind error "Conditional Jump depends on unitialized variable".

On most buildbots the variable is nullptr, but in some cases it can be
non nullptr leading to seemingly random failures.

These tests were disabled in r366986. With the initialization they can be
enabled again.

Fixes PR42719

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

llvm-svn: 367662
This commit is contained in:
Peter Smith 2019-08-02 08:05:14 +00:00
parent 044d8c486b
commit f5b91f2a0f
2 changed files with 3 additions and 6 deletions

View File

@ -949,7 +949,7 @@ template <typename DerivedT> class AAResultBase {
/// A pointer to the AAResults object that this AAResult is
/// aggregated within. May be null if not aggregated.
AAResults *AAR;
AAResults *AAR = nullptr;
/// Helper to dispatch calls back through the derived type.
DerivedT &derived() { return static_cast<DerivedT &>(*this); }

View File

@ -64,13 +64,10 @@ public:
: M("BasicAATest", C), B(C), DL(DLString), TLI(TLII), F(nullptr) {}
};
// FIXME: Both of these are disabled at the moment due to strange buildbot
// failures. Please see https://bugs.llvm.org/show_bug.cgi?id=42719
// Check that a function arg can't trivially alias a global when we're accessing
// >sizeof(global) bytes through that arg, unless the access size is just an
// upper-bound.
TEST_F(BasicAATest, DISABLED_AliasInstWithObjectOfImpreciseSize) {
TEST_F(BasicAATest, AliasInstWithObjectOfImpreciseSize) {
F = Function::Create(
FunctionType::get(B.getVoidTy(), {B.getInt32Ty()->getPointerTo()}, false),
GlobalValue::ExternalLinkage, "F", &M);
@ -104,7 +101,7 @@ TEST_F(BasicAATest, DISABLED_AliasInstWithObjectOfImpreciseSize) {
// Check that we fall back to MayAlias if we see an access of an entire object
// that's just an upper-bound.
TEST_F(BasicAATest, DISABLED_AliasInstWithFullObjectOfImpreciseSize) {
TEST_F(BasicAATest, AliasInstWithFullObjectOfImpreciseSize) {
F = Function::Create(
FunctionType::get(B.getVoidTy(), {B.getInt64Ty()}, false),
GlobalValue::ExternalLinkage, "F", &M);