Skip to content

Commit cd3f46f

Browse files
committed
[AutoDiff] NFC: Garden assertions.
Clarify `llvm_unreachable` after exhaustive switch is needed to silence MSVC C4715, so we don't accidentally remove it. Standardize some assertion messages.
1 parent 7fccbad commit cd3f46f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

include/swift/SILOptimizer/Differentiation/ADContext.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ ADContext::emitNondifferentiabilityError(SourceLoc loc,
357357
return diagnose(loc, diag::autodiff_when_differentiating_function_call);
358358
}
359359
}
360-
llvm_unreachable("invalid invoker");
360+
llvm_unreachable("Invalid invoker kind"); // silences MSVC C4715
361361
}
362362

363363
} // end namespace autodiff

lib/SILOptimizer/Differentiation/DifferentiationInvoker.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SourceLoc DifferentiationInvoker::getLocation() const {
3636
->getLocation()
3737
.getSourceLoc();
3838
}
39-
llvm_unreachable("invalid differentation invoker kind");
39+
llvm_unreachable("Invalid invoker kind"); // silences MSVC C4715
4040
}
4141

4242
void DifferentiationInvoker::print(llvm::raw_ostream &os) const {

lib/SILOptimizer/Differentiation/JVPCloner.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ SILValue JVPCloner::materializeTangentDirect(AdjointValue val,
222222
case AdjointValueKind::Concrete:
223223
return val.getConcreteValue();
224224
}
225-
llvm_unreachable("invalid value kind");
225+
llvm_unreachable("Invalid adjoint value kind"); // silences MSVC C4715
226226
}
227227

228228
SILValue JVPCloner::materializeTangent(AdjointValue val, SILLocation loc) {
@@ -245,7 +245,7 @@ void JVPCloner::setTangentBuffer(SILBasicBlock *origBB, SILValue originalBuffer,
245245
assert(originalBuffer->getType().isAddress());
246246
auto insertion =
247247
bufferMap.try_emplace({origBB, originalBuffer}, tangentBuffer);
248-
assert(insertion.second && "tangent buffer already exists.");
248+
assert(insertion.second && "Tangent buffer already exists");
249249
(void)insertion;
250250
}
251251

@@ -254,7 +254,7 @@ SILValue &JVPCloner::getTangentBuffer(SILBasicBlock *origBB,
254254
assert(originalBuffer->getType().isAddress());
255255
assert(originalBuffer->getFunction() == original);
256256
auto insertion = bufferMap.try_emplace({origBB, originalBuffer}, SILValue());
257-
assert(!insertion.second && "tangent buffer should already exist");
257+
assert(!insertion.second && "Tangent buffer should already exist");
258258
return insertion.first->getSecond();
259259
}
260260

0 commit comments

Comments
 (0)