mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
Allow alias to point to an arbitrary ConstantExpr.
This patch changes GlobalAlias to point to an arbitrary ConstantExpr and it is up to MC (or the system assembler) to decide if that expression is valid or not. This reduces our ability to diagnose invalid uses and how early we can spot them, but it also lets us do things like @test5 = alias inttoptr(i32 sub (i32 ptrtoint (i32* @test2 to i32), i32 ptrtoint (i32* @bar to i32)) to i32*) An important implication of this patch is that the notion of aliased global doesn't exist any more. The alias has to encode the information needed to access it in its metadata (linkage, visibility, type, etc). Another consequence to notice is that getSection has to return a "const char *". It could return a NullTerminatedStringRef if there was such a thing, but when that was proposed the decision was to just uses "const char*" for that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210062 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1094,28 +1094,6 @@ uint64_t BitcodeReader::decodeSignRotatedValue(uint64_t V) {
|
||||
return 1ULL << 63;
|
||||
}
|
||||
|
||||
// FIXME: Delete this in LLVM 4.0 and just assert that the aliasee is a
|
||||
// GlobalObject.
|
||||
static GlobalObject &
|
||||
getGlobalObjectInExpr(const DenseMap<GlobalAlias *, Constant *> &Map,
|
||||
Constant &C) {
|
||||
auto *GO = dyn_cast<GlobalObject>(&C);
|
||||
if (GO)
|
||||
return *GO;
|
||||
|
||||
auto *GA = dyn_cast<GlobalAlias>(&C);
|
||||
if (GA)
|
||||
return getGlobalObjectInExpr(Map, *Map.find(GA)->second);
|
||||
|
||||
auto &CE = cast<ConstantExpr>(C);
|
||||
assert(CE.getOpcode() == Instruction::BitCast ||
|
||||
CE.getOpcode() == Instruction::GetElementPtr ||
|
||||
CE.getOpcode() == Instruction::AddrSpaceCast);
|
||||
if (CE.getOpcode() == Instruction::GetElementPtr)
|
||||
assert(cast<GEPOperator>(CE).hasAllZeroIndices());
|
||||
return getGlobalObjectInExpr(Map, *CE.getOperand(0));
|
||||
}
|
||||
|
||||
/// ResolveGlobalAndAliasInits - Resolve all of the initializers for global
|
||||
/// values and aliases that we can.
|
||||
error_code BitcodeReader::ResolveGlobalAndAliasInits() {
|
||||
@ -1141,30 +1119,19 @@ error_code BitcodeReader::ResolveGlobalAndAliasInits() {
|
||||
GlobalInitWorklist.pop_back();
|
||||
}
|
||||
|
||||
// FIXME: Delete this in LLVM 4.0
|
||||
// Older versions of llvm could write an alias pointing to another. We cannot
|
||||
// construct those aliases, so we first collect an alias to aliasee expression
|
||||
// and then compute the actual aliasee.
|
||||
DenseMap<GlobalAlias *, Constant *> AliasInit;
|
||||
|
||||
while (!AliasInitWorklist.empty()) {
|
||||
unsigned ValID = AliasInitWorklist.back().second;
|
||||
if (ValID >= ValueList.size()) {
|
||||
AliasInits.push_back(AliasInitWorklist.back());
|
||||
} else {
|
||||
if (Constant *C = dyn_cast_or_null<Constant>(ValueList[ValID]))
|
||||
AliasInit.insert(std::make_pair(AliasInitWorklist.back().first, C));
|
||||
AliasInitWorklist.back().first->setAliasee(C);
|
||||
else
|
||||
return Error(ExpectedConstant);
|
||||
}
|
||||
AliasInitWorklist.pop_back();
|
||||
}
|
||||
|
||||
for (auto &Pair : AliasInit) {
|
||||
auto &GO = getGlobalObjectInExpr(AliasInit, *Pair.second);
|
||||
Pair.first->setAliasee(&GO);
|
||||
}
|
||||
|
||||
while (!FunctionPrefixWorklist.empty()) {
|
||||
unsigned ValID = FunctionPrefixWorklist.back().second;
|
||||
if (ValID >= ValueList.size()) {
|
||||
|
Reference in New Issue
Block a user