mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-21 03:32:29 +00:00
Change the GlobalAlias constructor to look a bit more like GlobalVariable.
This is part of the fix for pr10367. A GlobalAlias always has a pointer type, so just have the constructor build the type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208983 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b95580a711
commit
ab67b30df6
include/llvm/IR
lib
AsmParser
Bitcode/Reader
IR
Linker
Transforms
unittests
@ -38,10 +38,11 @@ public:
|
||||
void *operator new(size_t s) {
|
||||
return User::operator new(s, 1);
|
||||
}
|
||||
/// GlobalAlias ctor - If a parent module is specified, the alias is
|
||||
/// automatically inserted into the end of the specified module's alias list.
|
||||
/// If a parent module is specified, the alias is automatically inserted into
|
||||
/// the end of the specified module's alias list.
|
||||
GlobalAlias(Type *Ty, LinkageTypes Linkage, const Twine &Name = "",
|
||||
Constant* Aliasee = nullptr, Module *Parent = nullptr);
|
||||
Constant* Aliasee = nullptr, Module *Parent = nullptr,
|
||||
unsigned AddressSpace = 0);
|
||||
|
||||
/// Provide fast operand accessors
|
||||
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
|
||||
|
@ -673,8 +673,10 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
|
||||
return Error(AliaseeLoc, "alias must have pointer type");
|
||||
|
||||
// Okay, create the alias but do not insert it into the module yet.
|
||||
std::unique_ptr<GlobalAlias> GA(new GlobalAlias(
|
||||
Aliasee->getType(), (GlobalValue::LinkageTypes)Linkage, Name, Aliasee));
|
||||
PointerType *PTy = cast<PointerType>(Aliasee->getType());
|
||||
std::unique_ptr<GlobalAlias> GA(
|
||||
new GlobalAlias(PTy->getElementType(), (GlobalValue::LinkageTypes)Linkage,
|
||||
Name, Aliasee, nullptr, PTy->getAddressSpace()));
|
||||
GA->setVisibility((GlobalValue::VisibilityTypes)Visibility);
|
||||
GA->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass);
|
||||
|
||||
|
@ -1966,8 +1966,10 @@ error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
if (!Ty->isPointerTy())
|
||||
return Error(InvalidTypeForValue);
|
||||
|
||||
GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]),
|
||||
"", nullptr, TheModule);
|
||||
auto *PTy = cast<PointerType>(Ty);
|
||||
GlobalAlias *NewGA =
|
||||
new GlobalAlias(PTy->getElementType(), GetDecodedLinkage(Record[2]),
|
||||
"", nullptr, TheModule, PTy->getAddressSpace());
|
||||
// Old bitcode files didn't have visibility field.
|
||||
// Local linkage must have default visibility.
|
||||
if (Record.size() > 3 && !NewGA->hasLocalLinkage())
|
||||
|
@ -1488,8 +1488,10 @@ void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit) {
|
||||
|
||||
LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
|
||||
const char *Name) {
|
||||
return wrap(new GlobalAlias(unwrap(Ty), GlobalValue::ExternalLinkage, Name,
|
||||
unwrap<Constant>(Aliasee), unwrap (M)));
|
||||
auto *PTy = cast<PointerType>(unwrap(Ty));
|
||||
return wrap(new GlobalAlias(
|
||||
PTy->getElementType(), GlobalValue::ExternalLinkage, Name,
|
||||
unwrap<Constant>(Aliasee), unwrap(M), PTy->getAddressSpace()));
|
||||
}
|
||||
|
||||
/*--.. Operations on functions .............................................--*/
|
||||
|
@ -213,15 +213,17 @@ void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
|
||||
// GlobalAlias Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
GlobalAlias::GlobalAlias(Type *Ty, LinkageTypes Link,
|
||||
const Twine &Name, Constant* aliasee,
|
||||
Module *ParentModule)
|
||||
: GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name) {
|
||||
GlobalAlias::GlobalAlias(Type *Ty, LinkageTypes Link, const Twine &Name,
|
||||
Constant *Aliasee, Module *ParentModule,
|
||||
unsigned AddressSpace)
|
||||
: GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalAliasVal,
|
||||
&Op<0>(), 1, Link, Name) {
|
||||
LeakDetector::addGarbageObject(this);
|
||||
|
||||
if (aliasee)
|
||||
assert(aliasee->getType() == Ty && "Alias and aliasee types should match!");
|
||||
Op<0>() = aliasee;
|
||||
if (Aliasee)
|
||||
assert(Aliasee->getType() == getType() &&
|
||||
"Alias and aliasee types should match!");
|
||||
Op<0>() = Aliasee;
|
||||
|
||||
if (ParentModule)
|
||||
ParentModule->getAliasList().push_back(this);
|
||||
|
@ -919,9 +919,10 @@ bool ModuleLinker::linkAliasProto(GlobalAlias *SGA) {
|
||||
|
||||
// If there is no linkage to be performed or we're linking from the source,
|
||||
// bring over SGA.
|
||||
GlobalAlias *NewDA = new GlobalAlias(TypeMap.get(SGA->getType()),
|
||||
SGA->getLinkage(), SGA->getName(),
|
||||
/*aliasee*/nullptr, DstM);
|
||||
auto *PTy = cast<PointerType>(TypeMap.get(SGA->getType()));
|
||||
GlobalAlias *NewDA =
|
||||
new GlobalAlias(PTy->getElementType(), SGA->getLinkage(), SGA->getName(),
|
||||
/*aliasee*/ nullptr, DstM, PTy->getAddressSpace());
|
||||
copyGVAttributes(NewDA, SGA);
|
||||
if (NewVisibility)
|
||||
NewDA->setVisibility(*NewVisibility);
|
||||
|
@ -1328,8 +1328,10 @@ void MergeFunctions::writeThunk(Function *F, Function *G) {
|
||||
// Replace G with an alias to F and delete G.
|
||||
void MergeFunctions::writeAlias(Function *F, Function *G) {
|
||||
Constant *BitcastF = ConstantExpr::getBitCast(F, G->getType());
|
||||
GlobalAlias *GA = new GlobalAlias(G->getType(), G->getLinkage(), "",
|
||||
BitcastF, G->getParent());
|
||||
PointerType *PTy = G->getType();
|
||||
GlobalAlias *GA =
|
||||
new GlobalAlias(PTy->getElementType(), G->getLinkage(), "", BitcastF,
|
||||
G->getParent(), PTy->getAddressSpace());
|
||||
F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
|
||||
GA->takeName(G);
|
||||
GA->setVisibility(G->getVisibility());
|
||||
|
@ -67,8 +67,10 @@ Module *llvm::CloneModule(const Module *M, ValueToValueMapTy &VMap) {
|
||||
// Loop over the aliases in the module
|
||||
for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
|
||||
I != E; ++I) {
|
||||
GlobalAlias *GA = new GlobalAlias(I->getType(), I->getLinkage(),
|
||||
I->getName(), nullptr, New);
|
||||
auto *PTy = cast<PointerType>(I->getType());
|
||||
auto *GA =
|
||||
new GlobalAlias(PTy->getElementType(), I->getLinkage(), I->getName(),
|
||||
nullptr, New, PTy->getAddressSpace());
|
||||
GA->copyAttributesFrom(I);
|
||||
VMap[I] = GA;
|
||||
}
|
||||
|
@ -52,9 +52,8 @@ TEST(VerifierTest, AliasUnnamedAddr) {
|
||||
GlobalVariable *Aliasee = new GlobalVariable(M, Ty, true,
|
||||
GlobalValue::ExternalLinkage,
|
||||
Init, "foo");
|
||||
GlobalAlias *GA = new GlobalAlias(Type::getInt8PtrTy(C),
|
||||
GlobalValue::ExternalLinkage,
|
||||
"bar", Aliasee, &M);
|
||||
auto *GA =
|
||||
new GlobalAlias(Ty, GlobalValue::ExternalLinkage, "bar", Aliasee, &M);
|
||||
GA->setUnnamedAddr(true);
|
||||
std::string Error;
|
||||
raw_string_ostream ErrorOS(Error);
|
||||
|
@ -35,8 +35,9 @@ protected:
|
||||
}
|
||||
|
||||
GlobalAlias *makeAlias(StringRef Name, GlobalValue *Aliasee) {
|
||||
return new GlobalAlias(Aliasee->getType(), GlobalValue::ExternalLinkage,
|
||||
Name, Aliasee, Aliasee->getParent());
|
||||
return new GlobalAlias(Aliasee->getType()->getElementType(),
|
||||
GlobalValue::ExternalLinkage, Name, Aliasee,
|
||||
Aliasee->getParent());
|
||||
}
|
||||
|
||||
SpecialCaseList *makeSpecialCaseList(StringRef List, std::string &Error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user