Skip to content

Commit

Permalink
Workaround nvc++ codegen bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Nov 29, 2023
1 parent e4c3a59 commit f330769
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions interpreter/llvm-project/llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ static Option *getOptionPred(StringRef Name, size_t &Length,
// string.
while (OMI == OptionsMap.end() && Name.size() > 1) {
Name = Name.substr(0, Name.size() - 1); // Chop off the last character.
#ifdef __NVCOMPILER
nulls() << "asdf" << Name; // nvc++ workaround to prevent optimizer bug
#endif
OMI = OptionsMap.find(Name);
if (OMI != OptionsMap.end() && !Pred(OMI->getValue()))
OMI = OptionsMap.end();
Expand Down
17 changes: 15 additions & 2 deletions interpreter/llvm-project/llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ struct MatchableInfo {
/// suboperand index.
int findAsmOperand(StringRef N, int SubOpIdx) const {
auto I = find_if(AsmOperands, [&](const AsmOperand &Op) {
#ifdef __NVCOMPILER
nulls() << Op.SrcOpName << " " << N << "\n"; // nvc++ workaround to prevent optimizer bug
#endif
return Op.SrcOpName == N && Op.SubOpIdx == SubOpIdx;
});
return (I != AsmOperands.end()) ? I - AsmOperands.begin() : -1;
Expand All @@ -595,14 +598,24 @@ struct MatchableInfo {
/// This does not check the suboperand index.
int findAsmOperandNamed(StringRef N, int LastIdx = -1) const {
auto I = std::find_if(AsmOperands.begin() + LastIdx + 1, AsmOperands.end(),
[&](const AsmOperand &Op) { return Op.SrcOpName == N; });
[&](const AsmOperand &Op) {
#ifdef __NVCOMPILER
nulls() << Op.SrcOpName << " " << N << "\n"; // nvc++ workaround to prevent optimizer bug
#endif
return Op.SrcOpName == N;
});
return (I != AsmOperands.end()) ? I - AsmOperands.begin() : -1;
}

int findAsmOperandOriginallyNamed(StringRef N) const {
auto I =
find_if(AsmOperands,
[&](const AsmOperand &Op) { return Op.OrigSrcOpName == N; });
[&](const AsmOperand &Op) {
#ifdef __NVCOMPILER
nulls() << Op.OrigSrcOpName << " " << N << "\n"; // nvc++ workaround to prevent optimizer bug
#endif
return Op.OrigSrcOpName == N;
});
return (I != AsmOperands.end()) ? I - AsmOperands.begin() : -1;
}

Expand Down

0 comments on commit f330769

Please sign in to comment.