[PATCH] D80249: CodeGen: Don't lazily construct MachineFunctionInfo

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 07:35:36 PST 2022


arsenm added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/MachineFunction.h:104
+  static Ty *create(BumpPtrAllocator &Allocator, const Function &F,
+                    const TargetSubtargetInfo *STI) {
+    return new (Allocator.Allocate<Ty>()) Ty(F, STI);
----------------
barannikov88 wrote:
> Should STI be also passed by reference (can it be null)?
getSubtargetImpl returns null by default, but not a whole lot of code bothers checking (e.g. the initial use when the function is constructed)


================
Comment at: llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp:39
+SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F,
+                                             const TargetSubtargetInfo *STI)
+  : AMDGPUMachineFunction(F, static_cast<const GCNSubtarget &>(*STI)),
----------------
barannikov88 wrote:
> Passing GCNSubtarget instead of TargetSubtargetInfo would save a cast :)
Fixed with more templates


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

https://reviews.llvm.org/D80249



More information about the llvm-commits mailing list