Fix most of PR10367.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 16 May 2014 19:35:39 +0000 (19:35 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 16 May 2014 19:35:39 +0000 (19:35 +0000)
commit27c076ae40ec65d1a9462d41f3709b305e641fa1
treee834e8217541ca69c12a38d44fb365e9720933de
parent33b37c7b12314d292c9074806f38aeaa6a707085
Fix most of PR10367.

This patch changes the design of GlobalAlias so that it doesn't take a
ConstantExpr anymore. It now points directly to a GlobalObject, but its type is
independent of the aliasee type.

To avoid changing all alias related tests in this patches, I kept the common
syntax

@foo = alias i32* @bar

to mean the same as now. The cases that used to use cast now use the more
general syntax

@foo = alias i16, i32* @bar.

Note that GlobalAlias now behaves a bit more like GlobalVariable. We
know that its type is always a pointer, so we omit the '*'.

For the bitcode, a nice surprise is that we were writing both identical types
already, so the format change is minimal. Auto upgrade is handled by looking
through the casts and no new fields are needed for now. New bitcode will
simply have different types for Alias and Aliasee.

One last interesting point in the patch is that replaceAllUsesWith becomes
smart enough to avoid putting a ConstantExpr in the aliasee. This seems better
than checking and updating every caller.

A followup patch will delete getAliasedGlobal now that it is redundant. Another
patch will add support for an explicit offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209007 91177308-0d34-0410-b5e6-96231b3b80d8
41 files changed:
include/llvm/IR/GlobalAlias.h
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/IR/AsmWriter.cpp
lib/IR/Core.cpp
lib/IR/Globals.cpp
lib/IR/Value.cpp
lib/IR/Verifier.cpp
lib/Linker/LinkModules.cpp
lib/Transforms/IPO/GlobalOpt.cpp
lib/Transforms/IPO/MergeFunctions.cpp
lib/Transforms/Utils/CloneModule.cpp
test/Assembler/2009-04-25-AliasGEP.ll [deleted file]
test/Assembler/addrspacecast-alias.ll
test/Assembler/alias-addrspace.ll [new file with mode: 0644]
test/Assembler/alias-to-alias.ll [new file with mode: 0644]
test/Assembler/alias-to-alias2.ll [new file with mode: 0644]
test/Assembler/alias-type.ll [new file with mode: 0644]
test/Bitcode/old-aliases.ll [new file with mode: 0644]
test/Bitcode/old-aliases.ll.bc [new file with mode: 0644]
test/CodeGen/ARM/aliases.ll
test/CodeGen/X86/aliases.ll
test/CodeGen/X86/dllexport-x86_64.ll
test/CodeGen/X86/dllexport.ll
test/Feature/alias2.ll [new file with mode: 0644]
test/Feature/aliases.ll
test/Linker/Inputs/PR8300.b.ll
test/Linker/Inputs/alias.ll [new file with mode: 0644]
test/Linker/Inputs/cycle.ll [new file with mode: 0644]
test/Linker/alias.ll [new file with mode: 0644]
test/Linker/cycle.ll [new file with mode: 0644]
test/Other/extract-alias.ll
test/Transforms/GlobalDCE/2009-01-05-DeadAliases.ll
test/Transforms/GlobalOpt/2009-02-15-BitcastAlias.ll
test/Transforms/GlobalOpt/alias-resolve.ll
test/Transforms/InstCombine/bitcast-alias-function.ll
test/Transforms/Internalize/2009-01-05-InternalizeAliases.ll
test/Verifier/aliasing-chain.ll [deleted file]
test/Verifier/bitcast-alias-address-space.ll [deleted file]
unittests/IR/ConstantsTest.cpp
unittests/Transforms/Utils/SpecialCaseList.cpp