[all-commits] [llvm/llvm-project] 41d4aa: [SymbolRefAttr] Revise SymbolRefAttr to hold a Str...

Chris Lattner via All-commits all-commits at lists.llvm.org
Sun Aug 29 22:01:28 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 41d4aa7de68ed551010f27ff04ffc54e7616292a
      https://github.com/llvm/llvm-project/commit/41d4aa7de68ed551010f27ff04ffc54e7616292a
  Author: Chris Lattner <clattner at nondot.org>
  Date:   2021-08-29 (Sun, 29 Aug 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/GPU/GPUOps.td
    M mlir/include/mlir/IR/Builders.h
    M mlir/include/mlir/IR/BuiltinAttributes.h
    M mlir/include/mlir/IR/BuiltinAttributes.td
    M mlir/include/mlir/IR/OpBase.td
    M mlir/include/mlir/IR/SymbolInterfaces.td
    M mlir/include/mlir/IR/SymbolTable.h
    M mlir/lib/CAPI/IR/BuiltinAttributes.cpp
    M mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
    M mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
    M mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
    M mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
    M mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
    M mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
    M mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
    M mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    M mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
    M mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
    M mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/Builders.cpp
    M mlir/lib/IR/BuiltinAttributes.cpp
    M mlir/lib/IR/SymbolTable.cpp
    M mlir/lib/Rewrite/ByteCode.cpp
    M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    M mlir/test/lib/IR/TestSymbolUses.cpp
    M mlir/test/lib/Rewrite/TestPDLByteCode.cpp

  Log Message:
  -----------
  [SymbolRefAttr] Revise SymbolRefAttr to hold a StringAttr.

SymbolRefAttr is fundamentally a base string plus a sequence
of nested references.  Instead of storing the string data as
a copies StringRef, store it as an already-uniqued StringAttr.

This makes a lot of things simpler and more efficient because:
1) references to the symbol are already stored as StringAttr's:
   there is no need to copy the string data into MLIRContext
   multiple times.
2) This allows pointer comparisons instead of string
   comparisons (or redundant uniquing) within SymbolTable.cpp.
3) This allows SymbolTable to hold a DenseMap instead of a
   StringMap (which again copies the string data and slows
   lookup).

This is a moderately invasive patch, so I kept a lot of
compatibility APIs around.  It would be nice to explore changing
getName() to return a StringAttr for example (right now you have
to use getNameAttr()), and eliminate things like the StringRef
version of getSymbol.

Differential Revision: https://reviews.llvm.org/D108899




More information about the All-commits mailing list