Skip to content

Commit

Permalink
Revert r193251 : Use address-taken to disambiguate global variable an…
Browse files Browse the repository at this point in the history
…d indirect memops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193489 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Shuxin Yang committed Oct 27, 2013
1 parent 2d60c09 commit 69bd41d
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 72 deletions.
3 changes: 0 additions & 3 deletions docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions include/llvm/IR/GlobalVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -175,9 +174,6 @@ class GlobalVariable : public GlobalValue, public ilist_node<GlobalVariable> {
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);
Expand Down
11 changes: 0 additions & 11 deletions lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/AsmParser/LLLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(zeroinitializer);
KEYWORD(undef);
KEYWORD(null);
KEYWORD(notaddrtaken);
KEYWORD(to);
KEYWORD(tail);
KEYWORD(target);
Expand Down
4 changes: 1 addition & 3 deletions lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion lib/AsmParser/LLToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion lib/IR/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
3 changes: 0 additions & 3 deletions lib/IR/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
}


Expand Down
1 change: 0 additions & 1 deletion lib/Transforms/IPO/GlobalOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
29 changes: 0 additions & 29 deletions test/Analysis/BasicAA/noaddrtaken.ll

This file was deleted.

2 changes: 1 addition & 1 deletion test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/Transforms/GlobalOpt/atomic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion test/Transforms/GlobalOpt/globalsra-unknown-index.ll
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/Transforms/GlobalOpt/integer-bool.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/Transforms/GlobalOpt/unnamed-addr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 69bd41d

Please sign in to comment.