Skip to content

Commit

Permalink
Check that no function->argumenttype mapping was passed where the fun…
Browse files Browse the repository at this point in the history
…ction does not exist in the module
  • Loading branch information
LPanosTT committed Jan 31, 2025
1 parent 1198166 commit 8c182ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/Dialect/TTIR/Transforms/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ class TTIRPopulateArgumentTypes
<< "\" argument count mismatch.\n";
signalPassFailure();
}
// Need to update/create the DictionaryAttr for each corresponding
// function argument.
for (uint32_t i = 0; i < func.getNumArguments(); i++) {
// The current argument may already have attributes, so we need to add
// the argument type to that DictonaryAttr rather than overwrite it.
std::optional<DictionaryAttr> currentArgAttrDict =
func.getArgAttrDict(i)
? std::make_optional(
Expand All @@ -125,6 +129,8 @@ class TTIRPopulateArgumentTypes
std::vector<NamedAttribute> newArgAttrs;
if (currentArgAttrDict.has_value()) {
for (NamedAttribute currentArgAttr : currentArgAttrDict.value()) {
// If this argument already has an argumnet type, this pass wil
// overwrite it. Log a warning.
if (currentArgAttr.getName() != "tt.argument_type") {
newArgAttrs.push_back(currentArgAttr);
} else {
Expand All @@ -143,6 +149,16 @@ class TTIRPopulateArgumentTypes
}
}
}

for (auto [funcName, argTypes] : argumentTypes) {
if (std::find(funcNames.begin(), funcNames.end(), funcName) ==
funcNames.end()) {
llvm::errs() << "Function: \"" << funcName
<< "\" was provided in the argument types map, however it "
"was not found in module!\n";
signalPassFailure();
}
}
}
};

Expand Down

0 comments on commit 8c182ba

Please sign in to comment.