Skip to content

Commit 608e068

Browse files
committed
[Compile Time Values] Restrict the check for local variables to not apply to parameter value declarations
And remove some debug prints
1 parent 114af54 commit 608e068

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

lib/SILOptimizer/Mandatory/DiagnoseUnknownCompileTimeValues.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class DiagnoseUnknownCompileTimeValues : public SILModuleTransform {
176176

177177
void verifyLocal(DebugValueInst *DBI) {
178178
auto Decl = DBI->getDecl();
179-
if (!Decl || !Decl->isConstVal())
179+
if (!Decl || !isa<VarDecl>(Decl) || isa<ParamDecl>(Decl) || !Decl->isConstVal())
180180
return;
181181

182182
auto Value = ConstExprState.getConstantValue(DBI->getOperand());
@@ -186,8 +186,8 @@ class DiagnoseUnknownCompileTimeValues : public SILModuleTransform {
186186
LLVM_DEBUG(printSymbolicValueValue(Value, Allocator););
187187
if (!Value.isConstant()) {
188188
getModule()->getASTContext().Diags.diagnose(
189-
Decl->getStartLoc(),
190-
diag::require_const_arg_for_parameter);
189+
Decl->getParentInitializer()->getStartLoc(),
190+
diag::require_const_initializer_for_const);
191191
}
192192
}
193193

@@ -220,19 +220,6 @@ class DiagnoseUnknownCompileTimeValues : public SILModuleTransform {
220220
auto CalleeParameters = CalleeDecl->getParameters();
221221
auto ApplyArgRefs = Apply->getArguments();
222222

223-
// LLVM_DEBUG({
224-
// llvm::dbgs() << "\n-------------------------------------------\n";
225-
// llvm::dbgs() << "Apply: ";
226-
// Apply->dump();
227-
// llvm::dbgs() << CalleeDecl->getNameStr() << "\n";
228-
// llvm::dbgs() << "Apply Args: ";
229-
// llvm::dbgs() << ApplyArgRefs.size() << "\n";
230-
// llvm::dbgs() << "CalleeParameters: ";
231-
// llvm::dbgs() << CalleeParameters->size() << "\n";
232-
// llvm::dbgs() << "ArgumentOperandNumber: ";
233-
// llvm::dbgs() << Apply->getArgumentOperandNumber() << "\n";
234-
// });
235-
236223
// (AC) TODO: Needs work to correctly match params to args
237224
bool hasConst = false;
238225
for (size_t i = 0; i < CalleeParameters->size(); ++i)

0 commit comments

Comments
 (0)