mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Add support for undef and unreachable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17051 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -315,7 +315,7 @@ void AsmPrinter::printSingleConstantValue(const Constant* CV) {
|
||||
|
||||
if (const GlobalValue* GV = dyn_cast<GlobalValue>(CV)) {
|
||||
O << getID(GV) << "\n";
|
||||
} else if (isa<ConstantPointerNull>(CV)) {
|
||||
} else if (isa<ConstantPointerNull>(CV) || isa<UndefValue>(CV)) {
|
||||
// Null pointer value
|
||||
O << "0\n";
|
||||
} else if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV)) {
|
||||
@@ -482,7 +482,7 @@ std::string AsmPrinter::valToExprString(const Value* V,
|
||||
S += utostr(CI->getValue());
|
||||
else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
|
||||
S += ftostr(CFP->getValue());
|
||||
else if (isa<ConstantPointerNull>(CV))
|
||||
else if (isa<ConstantPointerNull>(CV) || isa<UndefValue>(CV))
|
||||
S += "0";
|
||||
else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV))
|
||||
S += ConstantExprToString(CE, target);
|
||||
@@ -750,7 +750,9 @@ void SparcV9AsmPrinter::printGlobalVariable(const GlobalVariable* GV) {
|
||||
if (GV->hasExternalLinkage())
|
||||
O << "\t.global\t" << getID(GV) << "\n";
|
||||
|
||||
if (GV->hasInitializer() && ! GV->getInitializer()->isNullValue()) {
|
||||
if (GV->hasInitializer() &&
|
||||
!(GV->getInitializer()->isNullValue() ||
|
||||
isa<UndefValue>(GV->getInitializer()))) {
|
||||
printConstant(GV->getInitializer(), getID(GV));
|
||||
} else {
|
||||
O << "\t.align\t" << TypeToAlignment(GV->getType()->getElementType(),
|
||||
@@ -769,7 +771,8 @@ void SparcV9AsmPrinter::emitGlobals(const Module &M) {
|
||||
assert(GI->hasInitializer());
|
||||
if (GI->isConstant())
|
||||
enterSection(ReadOnlyData); // read-only, initialized data
|
||||
else if (GI->getInitializer()->isNullValue())
|
||||
else if (GI->getInitializer()->isNullValue() ||
|
||||
isa<UndefValue>(GI->getInitializer()))
|
||||
enterSection(ZeroInitRWData); // read-write zero data
|
||||
else
|
||||
enterSection(InitRWData); // read-write non-zero data
|
||||
|
Reference in New Issue
Block a user