[Mlir-commits] [llvm] [mlir] [NFC][TableGen] Use `Twine` for Name argument in CodeGenHelpers (PR #163581)
    Mehdi Amini 
    llvmlistbot at llvm.org
       
    Thu Oct 16 11:55:39 PDT 2025
    
    
  
================
@@ -13,17 +13,16 @@
 #ifndef LLVM_TABLEGEN_CODEGENHELPERS_H
 #define LLVM_TABLEGEN_CODEGENHELPERS_H
 
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/raw_ostream.h"
 #include <string>
 
 namespace llvm {
 // Simple RAII helper for emitting ifdef-undef-endif scope.
 class IfDefEmitter {
 public:
-  IfDefEmitter(raw_ostream &OS, StringRef Name) : Name(Name.str()), OS(OS) {
+  IfDefEmitter(raw_ostream &OS, const Twine &Name) : Name(Name.str()), OS(OS) {
----------------
joker-eph wrote:
I don't follow why doing this?
In general I believe we use Twine when the string is only conditionally used, because we save the time to serialize the string unnecessarily on the caller side.
Here this is on the contrary a pessimization: it'll serialize the string twice below!
https://github.com/llvm/llvm-project/pull/163581
    
    
More information about the Mlir-commits
mailing list