mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
add support for undef values of opaque type, addressing PR541
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21701 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aba5ff5671
commit
9e60d8dbdc
@ -121,8 +121,8 @@ void SlotCalculator::processModule() {
|
|||||||
|
|
||||||
// Add all of the global variables to the value table...
|
// Add all of the global variables to the value table...
|
||||||
//
|
//
|
||||||
for (Module::const_global_iterator I = TheModule->global_begin(), E = TheModule->global_end();
|
for (Module::const_global_iterator I = TheModule->global_begin(),
|
||||||
I != E; ++I)
|
E = TheModule->global_end(); I != E; ++I)
|
||||||
getOrCreateSlot(I);
|
getOrCreateSlot(I);
|
||||||
|
|
||||||
// Scavenge the types out of the functions, then add the functions themselves
|
// Scavenge the types out of the functions, then add the functions themselves
|
||||||
@ -134,8 +134,8 @@ void SlotCalculator::processModule() {
|
|||||||
|
|
||||||
// Add all of the module level constants used as initializers
|
// Add all of the module level constants used as initializers
|
||||||
//
|
//
|
||||||
for (Module::const_global_iterator I = TheModule->global_begin(), E = TheModule->global_end();
|
for (Module::const_global_iterator I = TheModule->global_begin(),
|
||||||
I != E; ++I)
|
E = TheModule->global_end(); I != E; ++I)
|
||||||
if (I->hasInitializer())
|
if (I->hasInitializer())
|
||||||
getOrCreateSlot(I->getInitializer());
|
getOrCreateSlot(I->getInitializer());
|
||||||
|
|
||||||
@ -388,8 +388,8 @@ void SlotCalculator::purgeFunction() {
|
|||||||
SC_DEBUG("end purgeFunction!\n");
|
SC_DEBUG("end purgeFunction!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool hasNullValue(unsigned TyID) {
|
static inline bool hasNullValue(const Type *Ty) {
|
||||||
return TyID != Type::LabelTyID && TyID != Type::VoidTyID;
|
return Ty != Type::LabelTy && Ty != Type::VoidTy && !isa<OpaqueType>(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getOrCreateCompactionTableSlot - This method is used to build up the initial
|
/// getOrCreateCompactionTableSlot - This method is used to build up the initial
|
||||||
@ -413,7 +413,7 @@ unsigned SlotCalculator::getOrCreateCompactionTableSlot(const Value *V) {
|
|||||||
|
|
||||||
// Make sure to insert the null entry if the thing we are inserting is not a
|
// Make sure to insert the null entry if the thing we are inserting is not a
|
||||||
// null constant.
|
// null constant.
|
||||||
if (TyPlane.empty() && hasNullValue(V->getType()->getTypeID())) {
|
if (TyPlane.empty() && hasNullValue(V->getType())) {
|
||||||
Value *ZeroInitializer = Constant::getNullValue(V->getType());
|
Value *ZeroInitializer = Constant::getNullValue(V->getType());
|
||||||
if (V != ZeroInitializer) {
|
if (V != ZeroInitializer) {
|
||||||
TyPlane.push_back(ZeroInitializer);
|
TyPlane.push_back(ZeroInitializer);
|
||||||
@ -461,7 +461,8 @@ void SlotCalculator::buildCompactionTable(const Function *F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Next, include any types used by function arguments.
|
// Next, include any types used by function arguments.
|
||||||
for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
|
for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
|
||||||
|
I != E; ++I)
|
||||||
getOrCreateCompactionTableSlot(I->getType());
|
getOrCreateCompactionTableSlot(I->getType());
|
||||||
|
|
||||||
// Next, find all of the types and values that are referred to by the
|
// Next, find all of the types and values that are referred to by the
|
||||||
@ -829,7 +830,7 @@ int SlotCalculator::doInsertValue(const Value *D) {
|
|||||||
|
|
||||||
// If this is the first value to get inserted into the type plane, make sure
|
// If this is the first value to get inserted into the type plane, make sure
|
||||||
// to insert the implicit null value...
|
// to insert the implicit null value...
|
||||||
if (Table[Ty].empty() && hasNullValue(Ty)) {
|
if (Table[Ty].empty() && hasNullValue(Typ)) {
|
||||||
Value *ZeroInitializer = Constant::getNullValue(Typ);
|
Value *ZeroInitializer = Constant::getNullValue(Typ);
|
||||||
|
|
||||||
// If we are pushing zeroinit, it will be handled below.
|
// If we are pushing zeroinit, it will be handled below.
|
||||||
|
@ -843,8 +843,8 @@ void BytecodeWriter::outputConstantsInPlane(const std::vector<const Value*>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool hasNullValue(unsigned TyID) {
|
static inline bool hasNullValue(const Type *Ty) {
|
||||||
return TyID != Type::LabelTyID && TyID != Type::VoidTyID;
|
return Ty != Type::LabelTy && Ty != Type::VoidTy && !isa<OpaqueType>(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeWriter::outputConstants(bool isFunction) {
|
void BytecodeWriter::outputConstants(bool isFunction) {
|
||||||
@ -867,7 +867,7 @@ void BytecodeWriter::outputConstants(bool isFunction) {
|
|||||||
if (isFunction) // Don't re-emit module constants
|
if (isFunction) // Don't re-emit module constants
|
||||||
ValNo += Table.getModuleLevel(pno);
|
ValNo += Table.getModuleLevel(pno);
|
||||||
|
|
||||||
if (hasNullValue(pno)) {
|
if (hasNullValue(Plane[0]->getType())) {
|
||||||
// Skip zero initializer
|
// Skip zero initializer
|
||||||
if (ValNo == 0)
|
if (ValNo == 0)
|
||||||
ValNo = 1;
|
ValNo = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user