[llvm] [AMDGPU] Look up DefaultDepCtrEncoding instead of caching in global state (PR #227720)

Steffen Larsen via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 23:51:01 PDT 2026


================
@@ -1941,10 +1941,7 @@ static int encodeCustomOperand(const CustomOperandVal *Opr, int Size,
 namespace DepCtr {
 
 int getDefaultDepCtrEncoding(const MCSubtargetInfo &STI) {
-  static int Default = -1;
-  if (Default == -1)
-    Default = getDefaultCustomOperandEncoding(DepCtrInfo, DEP_CTR_SIZE, STI);
-  return Default;
+  return getDefaultCustomOperandEncoding(DepCtrInfo, DEP_CTR_SIZE, STI);
----------------
steffenlarsen wrote:

We can, though it requires the inclusion of the AMGPUAsmUtils header in AMDGPUBaseInfo, as `getDefaultCustomOperandEncoding` is `static` in the .cpp file and uses parts of it. That or we expose that function, but at that point I think it's better to just inline the definition, since the helper isn't used elsewhere.

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


More information about the llvm-commits mailing list