diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -232,8 +232,16 @@ return false; } - return TargetInfo::initFeatureMap(Features, Diags, CPU, - (*ParseResult)->toFeatureVector()); + // RISCVISAInfo makes implications for ISA features + std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector(); + // Add non-ISA features like `relax` and `save-restore` back + for (std::string Feature : FeaturesVec) { + if (std::find(begin(ImpliedFeatures), end(ImpliedFeatures), Feature) == + end(ImpliedFeatures)) + ImpliedFeatures.push_back(Feature); + } + + return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures); } /// Return true if has this feature, need to sync with handleTargetFeatures.