Revert r193251 : Use address-taken to disambiguate global variable and indirect memops.
authorShuxin Yang <shuxin.llvm@gmail.com>
Sun, 27 Oct 2013 03:08:44 +0000 (03:08 +0000)
committerShuxin Yang <shuxin.llvm@gmail.com>
Sun, 27 Oct 2013 03:08:44 +0000 (03:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193489 91177308-0d34-0410-b5e6-96231b3b80d8

18 files changed:
docs/LangRef.rst
include/llvm/IR/GlobalVariable.h
lib/Analysis/BasicAliasAnalysis.cpp
lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLParser.cpp
lib/AsmParser/LLToken.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/IR/AsmWriter.cpp
lib/IR/Globals.cpp
lib/Transforms/IPO/GlobalOpt.cpp
test/Analysis/BasicAA/noaddrtaken.ll [deleted file]
test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll
test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll
test/Transforms/GlobalOpt/atomic.ll
test/Transforms/GlobalOpt/globalsra-unknown-index.ll
test/Transforms/GlobalOpt/integer-bool.ll
test/Transforms/GlobalOpt/unnamed-addr.ll

index 1e2016bfbdd6ab6cc4be1cb0995067f9875930c6..b75c6b1b80f3d679d39b79fa4cb7a175bc45289b 100644 (file)
@@ -511,9 +511,6 @@ module, including those with external linkage or appearing in
 ``@llvm.used``. This assumption may be suppressed by marking the
 variable with ``externally_initialized``.
 
-If a global variable dose not have its address taken, it will be optionally
-flagged ``notaddrtaken``.
-
 An explicit alignment may be specified for a global, which must be a
 power of 2. If not present, or if the alignment is set to zero, the
 alignment of the global is set by the target to whatever it feels
index a5ab97db239bfa41dae6b8fb8c4162eb4cb22089..bfed50786ea0bf4395e8aa991d35909226ddb039 100644 (file)
@@ -48,7 +48,6 @@ class GlobalVariable : public GlobalValue, public ilist_node<GlobalVariable> {
                                                // can change from its initial
                                                // value before global
                                                // initializers are run?
-  bool notAddrTaken : 1;                       // Dose not have address taken.
 
 public:
   // allocate space for exactly one operand
@@ -175,9 +174,6 @@ public:
     isExternallyInitializedConstant = Val;
   }
 
-  void setAddressMaybeTaken(bool Val) { notAddrTaken = !Val; }
-  bool AddressMaybeTaken(void) const { return !notAddrTaken; }
-
   /// copyAttributesFrom - copy all additional attributes (those not needed to
   /// create a GlobalVariable) from the GlobalVariable Src to this one.
   void copyAttributesFrom(const GlobalValue *Src);
index 4e423a787c97b20a417e0c2534b1a9ce36d15529..bf929690ae779fbb9bf8f5fd108b6b7d93820099 100644 (file)
@@ -1238,17 +1238,6 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, uint64_t V1Size,
       return NoAlias;
     if (isEscapeSource(O2) && isNonEscapingLocalObject(O1))
       return NoAlias;
-
-    // If one object is a global variable without address taken, the other one
-    // is a different object, they will not alias because the global variable
-    // in question cannot be indirectly accessed.
-    if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(O1))
-      if (!GV->AddressMaybeTaken())
-        return NoAlias;
-
-    if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(O2))
-      if (!GV->AddressMaybeTaken())
-        return NoAlias;
   }
 
   // If the size of one access is larger than the entire object on the other
index 6d643b611c35e328dd8878fcef610e6f01947b18..99bff45792c65662c36609128d6536e07b74df24 100644 (file)
@@ -504,7 +504,6 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(zeroinitializer);
   KEYWORD(undef);
   KEYWORD(null);
-  KEYWORD(notaddrtaken);
   KEYWORD(to);
   KEYWORD(tail);
   KEYWORD(target);
index 9b5fb27a05673c76ac3fd86e5d96ea02f0d0fe4b..74c0ea4af529be744fbfc1c106495591e8821200 100644 (file)
@@ -704,7 +704,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
                            unsigned Linkage, bool HasLinkage,
                            unsigned Visibility) {
   unsigned AddrSpace;
-  bool IsConstant, UnnamedAddr, IsExternallyInitialized, notAddrTaken;
+  bool IsConstant, UnnamedAddr, IsExternallyInitialized;
   GlobalVariable::ThreadLocalMode TLM;
   LocTy UnnamedAddrLoc;
   LocTy IsExternallyInitializedLoc;
@@ -719,7 +719,6 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
                          IsExternallyInitialized,
                          &IsExternallyInitializedLoc) ||
       ParseGlobalType(IsConstant) ||
-      ParseOptionalToken(lltok::kw_notaddrtaken, notAddrTaken) ||
       ParseType(Ty, TyLoc))
     return true;
 
@@ -777,7 +776,6 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
   GV->setLinkage((GlobalValue::LinkageTypes)Linkage);
   GV->setVisibility((GlobalValue::VisibilityTypes)Visibility);
   GV->setExternallyInitialized(IsExternallyInitialized);
-  GV->setAddressMaybeTaken(!notAddrTaken);
   GV->setThreadLocalMode(TLM);
   GV->setUnnamedAddr(UnnamedAddr);
 
index 7832e816aa8805b1e7449e9235f42a1222a477ce..e1382fdb597523e797e5bf9954e61ab202b09b5b 100644 (file)
@@ -51,7 +51,6 @@ namespace lltok {
     kw_localdynamic, kw_initialexec, kw_localexec,
     kw_zeroinitializer,
     kw_undef, kw_null,
-    kw_notaddrtaken,
     kw_to,
     kw_tail,
     kw_target,
index 3fca4ab8e0ddb0d2a3a15930fb98b69bbfde0afc..e408cd1f981ef1e9605751ddcbb18fe8334df3b3 100644 (file)
@@ -1848,9 +1848,6 @@ bool BitcodeReader::ParseModule(bool Resume) {
         new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
                            TLM, AddressSpace, ExternallyInitialized);
       NewGV->setAlignment(Alignment);
-      if (Record.size() > 10)
-        NewGV->setAddressMaybeTaken(Record[10]);
-
       if (!Section.empty())
         NewGV->setSection(Section);
       NewGV->setVisibility(Visibility);
index 4f631b98859eb0f45827594cf39a5596aec16fee..b082ba6bfd274eb91688cb43342331d9e835c274 100644 (file)
@@ -616,13 +616,11 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
     Vals.push_back(GV->hasSection() ? SectionMap[GV->getSection()] : 0);
     if (GV->isThreadLocal() ||
         GV->getVisibility() != GlobalValue::DefaultVisibility ||
-        GV->hasUnnamedAddr() || GV->isExternallyInitialized() ||
-        !GV->AddressMaybeTaken()) {
+        GV->hasUnnamedAddr() || GV->isExternallyInitialized()) {
       Vals.push_back(getEncodedVisibility(GV));
       Vals.push_back(getEncodedThreadLocalMode(GV));
       Vals.push_back(GV->hasUnnamedAddr());
       Vals.push_back(GV->isExternallyInitialized());
-      Vals.push_back(GV->AddressMaybeTaken());
     } else {
       AbbrevToUse = SimpleGVarAbbrev;
     }
index dc337c16a604aa1e7d9c019e52ae40b080c008f1..6e3b853b3915d2efc741fc8f9cdaff71f504e0c3 100644 (file)
@@ -1459,7 +1459,6 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
   if (GV->hasUnnamedAddr()) Out << "unnamed_addr ";
   if (GV->isExternallyInitialized()) Out << "externally_initialized ";
   Out << (GV->isConstant() ? "constant " : "global ");
-  if (!GV->AddressMaybeTaken()) Out << "notaddrtaken ";
   TypePrinter.print(GV->getType()->getElementType(), Out);
 
   if (GV->hasInitializer()) {
index 8c28ec176f698a5562fe4857df42e89657bd3b12..da3b02a0fa6d62fb1253f2287b7a3822dd3b314b 100644 (file)
@@ -99,7 +99,6 @@ GlobalVariable::GlobalVariable(Type *Ty, bool constant, LinkageTypes Link,
   }
 
   LeakDetector::addGarbageObject(this);
-  setAddressMaybeTaken(true);
 }
 
 GlobalVariable::GlobalVariable(Module &M, Type *Ty, bool constant,
@@ -126,7 +125,6 @@ GlobalVariable::GlobalVariable(Module &M, Type *Ty, bool constant,
     Before->getParent()->getGlobalList().insert(Before, this);
   else
     M.getGlobalList().push_back(this);
-  setAddressMaybeTaken(true);
 }
 
 void GlobalVariable::setParent(Module *parent) {
@@ -187,7 +185,6 @@ void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
   GlobalValue::copyAttributesFrom(Src);
   const GlobalVariable *SrcVar = cast<GlobalVariable>(Src);
   setThreadLocal(SrcVar->isThreadLocal());
-  setAddressMaybeTaken(SrcVar->AddressMaybeTaken());
 }
 
 
index a259b4d392143bfab99788aa558c583c253f16ee..82a59ed562de71211237cb33f89a4018e07df96e 100644 (file)
@@ -1723,7 +1723,6 @@ bool GlobalOpt::ProcessGlobal(GlobalVariable *GV,
   if (GlobalStatus::analyzeGlobal(GV, GS))
     return false;
 
-  GV->setAddressMaybeTaken(false);
   if (!GS.IsCompared && !GV->hasUnnamedAddr()) {
     GV->setUnnamedAddr(true);
     NumUnnamed++;
diff --git a/test/Analysis/BasicAA/noaddrtaken.ll b/test/Analysis/BasicAA/noaddrtaken.ll
deleted file mode 100644 (file)
index 14aa45b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info 2>&1 | FileCheck %s
-
-; ModuleID = 'b.c'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.8.0"
-
-; CHECK: NoAlias:   i32* %p, i32* @xyz
-
-;@xyz = global i32 12, align 4
-@xyz = internal unnamed_addr global notaddrtaken i32 12, align 4
-
-; Function Attrs: nounwind ssp uwtable
-define i32 @foo(i32* nocapture %p, i32* nocapture %q) #0 {
-entry:
-  %0 = load i32* @xyz, align 4, !tbaa !0
-  %inc = add nsw i32 %0, 1
-  store i32 %inc, i32* @xyz, align 4, !tbaa !0
-  store i32 1, i32* %p, align 4, !tbaa !0
-  %1 = load i32* @xyz, align 4, !tbaa !0
-  store i32 %1, i32* %q, align 4, !tbaa !0
-  ret i32 undef
-}
-
-attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
-
-!0 = metadata !{metadata !1, metadata !1, i64 0}
-!1 = metadata !{metadata !"int", metadata !2, i64 0}
-!2 = metadata !{metadata !"omnipotent char", metadata !3, i64 0}
-!3 = metadata !{metadata !"Simple C/C++ TBAA"}
index 87f28897a2da059839fa17a80aa0b70f5a86b0f3..059af1cfeac8cc89f655422d2c9d04148ebad11d 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt < %s -globalopt -S | grep "@X = internal unnamed_addr global notaddrtaken i32"
+; RUN: opt < %s -globalopt -S | grep "@X = internal unnamed_addr global i32"
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
 target triple = "i386-apple-darwin7"
 @X = internal global i32* null         ; <i32**> [#uses=2]
index fd7b4dd601cc5a6957347409a4fb3e671a2dbcfb..b73f62ba148b74c4295f7a0080c1a2bb24e5b2b2 100644 (file)
@@ -8,7 +8,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
 target triple = "x86_64-apple-darwin10.0"
 
 @TOP = internal global i64* null                    ; <i64**> [#uses=2]
-; CHECK: @TOP = internal unnamed_addr global notaddrtaken i64* null
+; CHECK: @TOP = internal unnamed_addr global i64* null
 @channelColumns = internal global i64 0             ; <i64*> [#uses=2]
 
 ; Derived from @DescribeChannel() in yacr2
index d0fb9700dbb6843622cc38a6cb2d4b37e8141e86..ac05bfd68d9dc35c9b57410f3884d92f80ea17d9 100644 (file)
@@ -3,8 +3,8 @@
 @GV1 = internal global i64 1
 @GV2 = internal global i32 0
 
-; CHECK: @GV1 = internal unnamed_addr constant notaddrtaken i64 1
-; CHECK: @GV2 = internal unnamed_addr global notaddrtaken i32 0
+; CHECK: @GV1 = internal unnamed_addr constant i64 1
+; CHECK: @GV2 = internal unnamed_addr global i32 0
 
 define void @test1() {
 entry:
index a854d9476da98c72e785318e0c631f03869a8fd1..cc655e9a2d1db29c74034ebd1b0f247e1cfd93d9 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -globalopt -S > %t
-; RUN: grep "@Y = internal unnamed_addr global notaddrtaken \[3 x [%]struct.X\] zeroinitializer" %t
+; RUN: grep "@Y = internal unnamed_addr global \[3 x [%]struct.X\] zeroinitializer" %t
 ; RUN: grep load %t | count 6
 ; RUN: grep "add i32 [%]a, [%]b" %t | count 3
 
index a75614e7fa8ecea13626de49f1350972e74aa4f8..abf5fdd2ef3c910ae50fca3f7d3fd20276ebd6dc 100644 (file)
@@ -4,7 +4,7 @@
 @G = internal addrspace(1) global i32 0
 ; CHECK: @G
 ; CHECK: addrspace(1)
-; CHECK: global notaddrtaken i1 false
+; CHECK: global i1 false
 
 define void @set1() {
   store i32 0, i32 addrspace(1)* @G
index 7b049ec769dbd6d65848a4610ec8f55f8606052b..2ca91e50da2a7b4436b439940c5f4d7b9398774b 100644 (file)
@@ -6,10 +6,10 @@
 @d = internal constant [4 x i8] c"foo\00", align 1
 @e = linkonce_odr global i32 0
 
-; CHECK: @a = internal global notaddrtaken i32 0, align 4
+; CHECK: @a = internal global i32 0, align 4
 ; CHECK: @b = internal global i32 0, align 4
-; CHECK: @c = internal unnamed_addr global notaddrtaken i32 0, align 4
-; CHECK: @d = internal unnamed_addr constant notaddrtaken [4 x i8] c"foo\00", align 1
+; CHECK: @c = internal unnamed_addr global i32 0, align 4
+; CHECK: @d = internal unnamed_addr constant [4 x i8] c"foo\00", align 1
 ; CHECK: @e = linkonce_odr global i32 0
 
 define i32 @get_e() {