[PATCH] D123260: [AArch64][AMDGPU][WebAssembly] Use static_cast instead of a reinterpret_cast to downcast in parseMachineFunctionInfo.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 14:54:15 PDT 2022
craig.topper created this revision.
craig.topper added reviewers: arsenm, tlively, paquette.
Herald added subscribers: hsmhsm, pmatos, asb, luke957, foad, StephenFan, ecnelises, kerbowa, luismarques, s.egerton, PkmX, sunfish, simoncook, hiraditya, kristof.beyls, jgravelle-google, arichardson, t-tye, sbc100, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, dschuff.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, aheejin, wdng.
Herald added a project: LLVM.
static_cast is a little safer here since the compiler will
ensure we're casting to a class derived from
yaml::MachineFunctionInfo.
I believe this first appeared on AMDGPU and was copied to the
other two targets.
Spotted when it was being copied to RISCV in D123178 <https://reviews.llvm.org/D123178>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123260
Files:
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -595,7 +595,7 @@
const yaml::MachineFunctionInfo &MFI, PerFunctionMIParsingState &PFS,
SMDiagnostic &Error, SMRange &SourceRange) const {
const auto &YamlMFI =
- reinterpret_cast<const yaml::WebAssemblyFunctionInfo &>(MFI);
+ static_cast<const yaml::WebAssemblyFunctionInfo &>(MFI);
MachineFunction &MF = PFS.MF;
MF.getInfo<WebAssemblyFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
return false;
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -1398,7 +1398,7 @@
const yaml::MachineFunctionInfo &MFI_, PerFunctionMIParsingState &PFS,
SMDiagnostic &Error, SMRange &SourceRange) const {
const yaml::SIMachineFunctionInfo &YamlMFI =
- reinterpret_cast<const yaml::SIMachineFunctionInfo &>(MFI_);
+ static_cast<const yaml::SIMachineFunctionInfo &>(MFI_);
MachineFunction &MF = PFS.MF;
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -810,7 +810,7 @@
const yaml::MachineFunctionInfo &MFI, PerFunctionMIParsingState &PFS,
SMDiagnostic &Error, SMRange &SourceRange) const {
const auto &YamlMFI =
- reinterpret_cast<const yaml::AArch64FunctionInfo &>(MFI);
+ static_cast<const yaml::AArch64FunctionInfo &>(MFI);
MachineFunction &MF = PFS.MF;
MF.getInfo<AArch64FunctionInfo>()->initializeBaseYamlFields(YamlMFI);
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123260.421019.patch
Type: text/x-patch
Size: 2005 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220406/5c5d9843/attachment.bin>
More information about the llvm-commits
mailing list