Don't commit addresses of aggregate values. This avoids problems with
authorDan Gohman <gohman@apple.com>
Mon, 7 Sep 2009 22:42:05 +0000 (22:42 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 7 Sep 2009 22:42:05 +0000 (22:42 +0000)
an aggregate store overlapping a different aggregate store, despite
the stores having distinct addresses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81164 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp

index 71eeb75310d3754e7e39ee84e2e65a94fc988ab4..86c5e2919483ce92b24001527cc2d9e1924d9be1 100644 (file)
@@ -2024,6 +2024,11 @@ static Constant *getVal(DenseMap<Value*, Constant*> &ComputedValues,
 /// we punt.  We basically just support direct accesses to globals and GEP's of
 /// globals.  This should be kept up to date with CommitValueTo.
 static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext &Context) {
+  // Conservatively, avoid aggregate types. This is because we don't
+  // want to worry about them partially overlapping other stores.
+  if (!cast<PointerType>(C->getType())->getElementType()->isSingleValueType())
+    return false;
+
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
     // Do not allow weak/linkonce/dllimport/dllexport linkage or
     // external globals.