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

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 03:23:27 PDT 2019


peter.smith created this revision.
peter.smith added reviewers: asbirlea, george.burgess.iv, jyknight.

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.

In this particular case it looks like initializing to nullptr is sound as results should be standalone unless they've been explicitly aggregated.

These tests were disabled in r366986 as some unrelated changes to the unittests changed the memory allocation and caused the two tests to start failing. With the initialization they can be enabled again.

      

Fixes PR42719

I know very little about AA myself, there may be a way of rewriting the UnitTests so that it doesn't hit an unitialized variable, or a better fix, I'd need to hand over to an expert for that. I've picked some reviewers from the history of the file.


https://reviews.llvm.org/D65568

Files:
  include/llvm/Analysis/AliasAnalysis.h
  unittests/Analysis/BasicAliasAnalysisTest.cpp


Index: unittests/Analysis/BasicAliasAnalysisTest.cpp
===================================================================
--- unittests/Analysis/BasicAliasAnalysisTest.cpp
+++ unittests/Analysis/BasicAliasAnalysisTest.cpp
@@ -64,13 +64,10 @@
       : 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 @@
 
 // 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);
Index: include/llvm/Analysis/AliasAnalysis.h
===================================================================
--- include/llvm/Analysis/AliasAnalysis.h
+++ include/llvm/Analysis/AliasAnalysis.h
@@ -963,7 +963,7 @@
   /// top-level \c AAResults aggregation if one is registered, or to the
   /// current result if none are registered.
   class AAResultsProxy {
-    AAResults *AAR;
+    AAResults *AAR = nullptr;
     DerivedT &CurrentResult;
 
   public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65568.212771.patch
Type: text/x-patch
Size: 1792 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190801/72cb8b03/attachment.bin>


More information about the llvm-commits mailing list