// to represent relocations on supported targets. Expressions involving only
// constant addresses are constant folded instead.
switch (CE->getOpcode()) {
+ default:
+ break; // Error
case Instruction::AddrSpaceCast: {
const Constant *Op = CE->getOperand(0);
unsigned DstAS = CE->getType()->getPointerAddressSpace();
if (TM.isNoopAddrSpaceCast(SrcAS, DstAS))
return lowerConstant(Op);
- // Fallthrough to error.
- LLVM_FALLTHROUGH;
- }
- default: {
- // If the code isn't optimized, there may be outstanding folding
- // opportunities. Attempt to fold the expression using DataLayout as a
- // last resort before giving up.
- Constant *C = ConstantFoldConstant(CE, getDataLayout());
- if (C != CE)
- return lowerConstant(C);
-
- // Otherwise report the problem to the user.
- std::string S;
- raw_string_ostream OS(S);
- OS << "Unsupported expression in static initializer: ";
- CE->printAsOperand(OS, /*PrintType=*/false,
- !MF ? nullptr : MF->getFunction().getParent());
- report_fatal_error(Twine(OS.str()));
+ break; // Error
}
case Instruction::GetElementPtr: {
// Generate a symbolic expression for the byte address
return MCBinaryExpr::createAdd(LHS, RHS, Ctx);
}
}
+
+ // If the code isn't optimized, there may be outstanding folding
+ // opportunities. Attempt to fold the expression using DataLayout as a
+ // last resort before giving up.
+ Constant *C = ConstantFoldConstant(CE, getDataLayout());
+ if (C != CE)
+ return lowerConstant(C);
+
+ // Otherwise report the problem to the user.
+ std::string S;
+ raw_string_ostream OS(S);
+ OS << "Unsupported expression in static initializer: ";
+ CE->printAsOperand(OS, /*PrintType=*/false,
+ !MF ? nullptr : MF->getFunction().getParent());
+ report_fatal_error(Twine(OS.str()));
}
static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *C,