[PATCH] D141479: [RISCV] Generate march string from target features

Wang Pengcheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 20:19:36 PST 2023


pcwang-thead added inline comments.


================
Comment at: llvm/utils/TableGen/RISCVTargetDefEmitter.cpp:67
+      std::string EnumFeatures = getEnumFeatures(XLen);
+      std::string MArch = Rec.getValueAsString("DefaultMarch").str();
+
----------------
fpetrogalli wrote:
> You could use StringRef and then check MArch.empty() in line 70.
`getMArch()` returns `std::string`, if I change  type of `MArch ` from `std::string` to `StringRef`, it would be:
```
if (MArch.empty())
        MArch = StringRef(getMArch(XLen, Rec));
```
The string will be destroyed and cause errors like https://buildkite.com/llvm-project/premerge-checks/builds/130218.
So I think it is no bother to do that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141479/new/

https://reviews.llvm.org/D141479



More information about the llvm-commits mailing list