[clang] [llvm] [AMDGPU] Convert AMDGPUResourceUsageAnalysis pass from Module to MF pass (PR #102913)

Scott Linder via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 16 12:55:00 PDT 2024


================
@@ -0,0 +1,220 @@
+//===- AMDGPUMCResourceInfo.cpp --- MC Resource Info ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// \brief MC infrastructure to propagate the function level resource usage
+/// info.
+///
+//===----------------------------------------------------------------------===//
+
+#include "AMDGPUMCResourceInfo.h"
+#include "Utils/AMDGPUBaseInfo.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCSymbol.h"
+
+using namespace llvm;
+
+MCSymbol *MCResourceInfo::getSymbol(StringRef FuncName, ResourceInfoKind RIK) {
+  switch (RIK) {
----------------
slinder1 wrote:

Nit: the `OutContext.getOrCreateSymbol(FuncName + Suffix)`  bit seems like it might be worth factoring out to keep the case arms focused

```
auto GOCS = [this](StringRef Suffix) {
  return OutContext.getOrCreateSymbol(FuncName + Suffix);
};
switch (RIK) {
case RIK_NumAGPR: return GOCS(".num_agpr");
case RIK_NumSGPR: return GOCS(".num_sgpr");
// ...
}
```

https://github.com/llvm/llvm-project/pull/102913


More information about the cfe-commits mailing list