Skip to content

Commit

Permalink
Fix incorrect behaviour (#22)
Browse files Browse the repository at this point in the history
### Reported issue:
Passing `-debug-only=` doesn't work correctly, causes printout of MLIR lowering steps.

### Issue identified:
`-debug-only=` uses an internal object called `CurrentDebugType` to store all the debug string, e.g., given `-debug-only=foo`, then `foo` is stored in  `CurrentDebugType`. If `CurrentDebugType` is empty, then it behaves like `-debug`.
`InitLLVM` calls llvm_shutdown() on destruction, which cleans up ManagedStatic objects, including `CurrentDebugType`.
`InitLLVM` should be created at the scope of  `main`.

### Propose solution:
Remove the internal scope.

Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
  • Loading branch information
whitneywhtsang authored and etiotto committed Sep 6, 2022
1 parent 00f386f commit b7a7355
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions polygeist/tools/cgeist/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -664,31 +664,29 @@ int main(int argc, char **argv) {

std::vector<std::string> files;
std::vector<std::string> commands;
{
cl::list<std::string> inputFileName(cl::Positional, cl::OneOrMore,
cl::desc("<Specify input file>"),
cl::cat(toolOptions));

cl::list<std::string> inputCommandArgs(
"args", cl::Positional, cl::desc("<command arguments>"), cl::ZeroOrMore,
cl::PositionalEatsArgs);

int size = MLIRArgs.size();
const char **data = MLIRArgs.data();
InitLLVM y(size, data);
cl::ParseCommandLineOptions(size, data);
assert(inputFileName.size());
for (auto inp : inputFileName) {
std::ifstream inputFile(inp);
if (!inputFile.good()) {
outs() << "Not able to open file: " << inp << "\n";
return -1;
}
files.push_back(inp);
}
for (auto &cmd : inputCommandArgs) {
commands.push_back(cmd);
cl::list<std::string> inputFileName(cl::Positional, cl::OneOrMore,
cl::desc("<Specify input file>"),
cl::cat(toolOptions));

cl::list<std::string> inputCommandArgs(
"args", cl::Positional, cl::desc("<command arguments>"), cl::ZeroOrMore,
cl::PositionalEatsArgs);

int size = MLIRArgs.size();
const char **data = MLIRArgs.data();
InitLLVM y(size, data);
cl::ParseCommandLineOptions(size, data);
assert(inputFileName.size());
for (auto inp : inputFileName) {
std::ifstream inputFile(inp);
if (!inputFile.good()) {
outs() << "Not able to open file: " << inp << "\n";
return -1;
}
files.push_back(inp);
}
for (auto &cmd : inputCommandArgs) {
commands.push_back(cmd);
}

// Register and load MLIR Dialects.
Expand Down

0 comments on commit b7a7355

Please sign in to comment.