Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions lib/SILOptimizer/Mandatory/TFConstExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ namespace {
}

void setValue(SILValue value, SymbolicValue symVal) {
assert(!value->getType().isAddress() &&"addresses are tracked separately");
assert(!value->getType().isAddress() &&
"addresses are tracked separately");
calculatedValues.insert({ value, symVal });
}

Expand Down Expand Up @@ -396,7 +397,7 @@ SymbolicValue ConstExprFunctionState::computeConstantValue(SILValue value) {
if (fn)
return SymbolicValue::getFunction(fn, conf);

DEBUG(llvm::errs() << "ConstExpr Unresolved witness: " << *value << "\n");
DEBUG(llvm::dbgs() << "ConstExpr Unresolved witness: " << *value << "\n");
return SymbolicValue::getUnknown(value, UnknownReason::Default);
}

Expand All @@ -414,7 +415,7 @@ SymbolicValue ConstExprFunctionState::computeConstantValue(SILValue value) {
return calculatedValues[apply];
}

DEBUG(llvm::errs() << "ConstExpr Unknown simple: " << *value << "\n");
DEBUG(llvm::dbgs() << "ConstExpr Unknown simple: " << *value << "\n");

// Otherwise, we don't know how to handle this.
return SymbolicValue::getUnknown(value, UnknownReason::Default);
Expand Down Expand Up @@ -751,7 +752,7 @@ ConstExprFunctionState::computeConstantValueBuiltin(BuiltinInst *inst) {
}


DEBUG(llvm::errs() << "ConstExpr Unknown Builtin: " << *inst << "\n");
DEBUG(llvm::dbgs() << "ConstExpr Unknown Builtin: " << *inst << "\n");

// Otherwise, we don't know how to handle this builtin.
return unknownResult();
Expand All @@ -778,7 +779,7 @@ ConstExprFunctionState::computeOpaqueCallResult(ApplyInst *apply,
UnknownReason::Trap);
}

DEBUG(llvm::errs() << "ConstExpr Opaque Callee: " << *callee << "\n");
DEBUG(llvm::dbgs() << "ConstExpr Opaque Callee: " << *callee << "\n");
return SymbolicValue::getUnknown((SILInstruction*)apply,
UnknownReason::Default);
}
Expand Down Expand Up @@ -934,8 +935,8 @@ SymbolicValue ConstExprFunctionState::getConstantValue(SILValue value) {

// If this is the top-level lazy interpreter, output a debug trace.
if (!fn) {
DEBUG(llvm::errs() << "ConstExpr top level: "; value->dump());
DEBUG(llvm::errs() << " RESULT: "; result.dump());
DEBUG(llvm::dbgs() << "ConstExpr top level: "; value->dump());
DEBUG(llvm::dbgs() << " RESULT: "; result.dump());
}

return calculatedValues[value] = result;
Expand Down Expand Up @@ -1094,7 +1095,7 @@ ConstExprFunctionState::computeSingleStoreAddressValue(SILValue addr) {
}


DEBUG(llvm::errs() << "Unknown SingleStore ConstExpr user: "
DEBUG(llvm::dbgs() << "Unknown SingleStore ConstExpr user: "
<< *user << "\n");

// If this is some other user that we don't know about, then we should
Expand Down Expand Up @@ -1196,7 +1197,7 @@ AddressValue ConstExprFunctionState::computeAddressValue(SILValue addr) {
if (auto *bai = dyn_cast<BeginAccessInst>(addr))
return getAddressValue(bai->getOperand());

DEBUG(llvm::errs() << "ConstExpr Unknown simple addr: " << *addr << "\n");
DEBUG(llvm::dbgs() << "ConstExpr Unknown simple addr: " << *addr << "\n");

// Otherwise, we don't know how to handle this.
return getUnknownAddress(addr, UnknownReason::Default);
Expand Down Expand Up @@ -1297,20 +1298,20 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
auto result = getConstantValue(oneResultVal);
if (!result.isConstant())
return result;
DEBUG(llvm::errs() << " RESULT: "; result.dump());
DEBUG(llvm::dbgs() << " RESULT: "; result.dump());
} else {
auto result = getAddressValue(oneResultVal);
// If the address could not be resolved, puts the 'unknown' code into
// the referenced memory object.
auto memVal = memoryObjects[result.getObjectID()].first;
if (memVal.isUnknown())
return memVal;
DEBUG(llvm::errs() << " RESULT: "; result.dump());
DEBUG(llvm::dbgs() << " RESULT: "; result.dump());
}
return None;
}

DEBUG(llvm::errs() << "ConstExpr Unknown FS: " << *inst << "\n");
DEBUG(llvm::dbgs() << "ConstExpr Unknown FS: " << *inst << "\n");
// If this is an unknown instruction with no results then bail out.
return SymbolicValue::getUnknown(inst, UnknownReason::Default);
}
Expand Down Expand Up @@ -1338,10 +1339,10 @@ evaluateAndCacheCall(SILFunction &fn, SubstitutionMap substitutionMap,
unsigned nextBBArg = 0;
const auto &argList = fn.front().getArguments();

DEBUG(llvm::errs().changeColor(raw_ostream::SAVEDCOLOR, /*bold*/true)
DEBUG(llvm::dbgs().changeColor(raw_ostream::SAVEDCOLOR, /*bold*/true)
<< "\nConstExpr call fn: "
<< Demangle::demangleSymbolAsString(fn.getName());
llvm::errs().resetColor()
llvm::dbgs().resetColor()
<< "\n");

for (unsigned i = 0, e = conventions.getNumIndirectSILResults(); i != e; ++i)
Expand Down Expand Up @@ -1369,7 +1370,7 @@ evaluateAndCacheCall(SILFunction &fn, SubstitutionMap substitutionMap,

while (1) {
SILInstruction *inst = &*nextInst++;
DEBUG(llvm::errs() << "ConstExpr interpret: "; inst->dump());
DEBUG(llvm::dbgs() << "ConstExpr interpret: "; inst->dump());

// Make sure we haven't exceeded our interpreter iteration cap.
if (++numInstEvaluated > ConstExprLimit)
Expand Down Expand Up @@ -1411,7 +1412,7 @@ evaluateAndCacheCall(SILFunction &fn, SubstitutionMap substitutionMap,

// TODO: Handle caching of results.

DEBUG(llvm::errs() << "\n");
DEBUG(llvm::dbgs() << "\n");
return None;
}

Expand Down Expand Up @@ -1452,7 +1453,7 @@ evaluateAndCacheCall(SILFunction &fn, SubstitutionMap substitutionMap,
continue;
}

DEBUG(llvm::errs() << "ConstExpr: Unknown Terminator: " << *inst << "\n");
DEBUG(llvm::dbgs() << "ConstExpr: Unknown Terminator: " << *inst << "\n");

// TODO: Enum switches when we support enums?
return SymbolicValue::getUnknown(inst, UnknownReason::Default);
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Mandatory/TFDevicePartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class DevicePartitionerImpl
if (inst->getName().str() == "tf_tensor_to_i1")
return;

inst->print(llvm::errs());
inst->dump();
llvm_unreachable(
"DevicePartitionerImpl cannot mark this instruction yet\n");
}
Expand Down
2 changes: 0 additions & 2 deletions lib/SILOptimizer/Mandatory/TFDifferentiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ class ADContext {
ADContext::ADContext(SILModule &module, SILPassManager &passManager)
: module(module), passManager(passManager), typeConverter(module)
{
auto &ctx = getASTContext();

// Add local witness tables to the local map.
for (auto &wt : module.getWitnessTables())
witnessTables.insert({wt.getConformance(), &wt});
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Mandatory/TFLowerGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ void TFGraphLowering::visitTFOpInst(BuiltinInst *inst) {
}

if (!hasDevice) {
inst->print(llvm::errs());
inst->dump();
llvm_unreachable("The above tensor op has no device set");
}

Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Mandatory/TFPartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3218,7 +3218,7 @@ void TFFunctionPartition::balanceRetainReleaseCount(SILValue oldResult,
continue;
}

oldResult->print(llvm::errs());
oldResult->dump();
llvm_unreachable("Unhandled instruction type");
}

Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Mandatory/TFUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ static bool tryToRemoveArrayValue(SILValue value) {
}

// Otherwise we don't know what this is, conservatively bail out.
DEBUG(llvm::errs() << "Could not remove array because of: " << *user);
DEBUG(llvm::dbgs() << "Could not remove array because of: " << *user);
return false;
}
}
Expand Down