aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-06 00:11:24 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-06 00:11:24 +0000
commit92a97a9166e359e195d949e63d7e24a4a33284cf (patch)
tree47fc373baf592033d473b376cc7a246697d5279b /lib/Bitcode
parent0985b3c81c4b56c4fb7104778df8e9ab21438d4b (diff)
downloadexternal_llvm-92a97a9166e359e195d949e63d7e24a4a33284cf.zip
external_llvm-92a97a9166e359e195d949e63d7e24a4a33284cf.tar.gz
external_llvm-92a97a9166e359e195d949e63d7e24a4a33284cf.tar.bz2
Revert "Include optional subclass flags, such as inbounds, nsw, etc., ...", this
breaks MiniSAT on x86_64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp56
1 files changed, 22 insertions, 34 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 05f7b52..9ed75ab 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -883,6 +883,19 @@ bool BitcodeReader::ResolveGlobalAndAliasInits() {
return false;
}
+static void SetOptimizationFlags(Value *V, uint64_t Flags) {
+ if (OverflowingBinaryOperator *OBO =
+ dyn_cast<OverflowingBinaryOperator>(V)) {
+ if (Flags & (1 << bitc::OBO_NO_SIGNED_WRAP))
+ OBO->setHasNoSignedWrap(true);
+ if (Flags & (1 << bitc::OBO_NO_UNSIGNED_WRAP))
+ OBO->setHasNoUnsignedWrap(true);
+ } else if (SDivOperator *Div = dyn_cast<SDivOperator>(V)) {
+ if (Flags & (1 << bitc::SDIV_EXACT))
+ Div->setIsExact(true);
+ }
+}
+
bool BitcodeReader::ParseConstants() {
if (Stream.EnterSubBlock(bitc::CONSTANTS_BLOCK_ID))
return Error("Malformed block record");
@@ -1034,22 +1047,10 @@ bool BitcodeReader::ParseConstants() {
} else {
Constant *LHS = ValueList.getConstantFwdRef(Record[1], CurTy);
Constant *RHS = ValueList.getConstantFwdRef(Record[2], CurTy);
- unsigned Flags = 0;
- if (Record.size() >= 4) {
- if (Opc == Instruction::Add ||
- Opc == Instruction::Sub ||
- Opc == Instruction::Mul) {
- if (Record[3] & (1 << bitc::OBO_NO_SIGNED_WRAP))
- Flags |= OverflowingBinaryOperator::NoSignedWrap;
- if (Record[3] & (1 << bitc::OBO_NO_UNSIGNED_WRAP))
- Flags |= OverflowingBinaryOperator::NoUnsignedWrap;
- } else if (Opc == Instruction::SDiv) {
- if (Record[3] & (1 << bitc::SDIV_EXACT))
- Flags |= SDivOperator::IsExact;
- }
- }
- V = ConstantExpr::get(Opc, LHS, RHS, Flags);
+ V = ConstantExpr::get(Opc, LHS, RHS);
}
+ if (Record.size() >= 4)
+ SetOptimizationFlags(V, Record[3]);
break;
}
case bitc::CST_CODE_CE_CAST: { // CE_CAST: [opcode, opty, opval]
@@ -1074,12 +1075,10 @@ bool BitcodeReader::ParseConstants() {
if (!ElTy) return Error("Invalid CE_GEP record");
Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], ElTy));
}
+ V = ConstantExpr::getGetElementPtr(Elts[0], &Elts[1],
+ Elts.size()-1);
if (BitCode == bitc::CST_CODE_CE_INBOUNDS_GEP)
- V = ConstantExpr::getInBoundsGetElementPtr(Elts[0], &Elts[1],
- Elts.size()-1);
- else
- V = ConstantExpr::getGetElementPtr(Elts[0], &Elts[1],
- Elts.size()-1);
+ cast<GEPOperator>(V)->setIsInBounds(true);
break;
}
case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#]
@@ -1611,19 +1610,8 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
int Opc = GetDecodedBinaryOpcode(Record[OpNum++], LHS->getType());
if (Opc == -1) return Error("Invalid BINOP record");
I = BinaryOperator::Create((Instruction::BinaryOps)Opc, LHS, RHS);
- if (OpNum < Record.size()) {
- if (Opc == Instruction::Add ||
- Opc == Instruction::Sub ||
- Opc == Instruction::Mul) {
- if (Record[3] & (1 << bitc::OBO_NO_SIGNED_WRAP))
- cast<BinaryOperator>(I)->setHasNoSignedWrap(true);
- if (Record[3] & (1 << bitc::OBO_NO_UNSIGNED_WRAP))
- cast<BinaryOperator>(I)->setHasNoUnsignedWrap(true);
- } else if (Opc == Instruction::SDiv) {
- if (Record[3] & (1 << bitc::SDIV_EXACT))
- cast<BinaryOperator>(I)->setIsExact(true);
- }
- }
+ if (OpNum < Record.size())
+ SetOptimizationFlags(I, Record[3]);
break;
}
case bitc::FUNC_CODE_INST_CAST: { // CAST: [opval, opty, destty, castopc]
@@ -1657,7 +1645,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
I = GetElementPtrInst::Create(BasePtr, GEPIdx.begin(), GEPIdx.end());
if (BitCode == bitc::FUNC_CODE_INST_INBOUNDS_GEP)
- cast<GetElementPtrInst>(I)->setIsInBounds(true);
+ cast<GEPOperator>(I)->setIsInBounds(true);
break;
}