[llvm] dfe4d91 - GCStrategy: Use Twine properly for error message (#132760)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 8 07:57:32 PDT 2025


Author: Matt Arsenault
Date: 2025-04-08T21:57:29+07:00
New Revision: dfe4d9187c60c9888de3410ed3c2a98136a9cd8f

URL: https://github.com/llvm/llvm-project/commit/dfe4d9187c60c9888de3410ed3c2a98136a9cd8f
DIFF: https://github.com/llvm/llvm-project/commit/dfe4d9187c60c9888de3410ed3c2a98136a9cd8f.diff

LOG: GCStrategy: Use Twine properly for error message (#132760)

Added: 
    llvm/test/Transforms/RewriteStatepointsForGC/unsupported-gc-error.ll

Modified: 
    llvm/lib/IR/GCStrategy.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/GCStrategy.cpp b/llvm/lib/IR/GCStrategy.cpp
index c3e35bd58d13e..67f363d26b25f 100644
--- a/llvm/lib/IR/GCStrategy.cpp
+++ b/llvm/lib/IR/GCStrategy.cpp
@@ -41,10 +41,9 @@ std::unique_ptr<GCStrategy> llvm::getGCStrategy(const StringRef Name) {
     // be the builtin GCs if nothing else.  The most likely scenario here is
     // that we got here without running the initializers used by the Registry
     // itself and it's registration mechanism.
-    const std::string error =
-        std::string("unsupported GC: ") + Name.str() +
-        " (did you remember to link and initialize the library?)";
-    report_fatal_error(Twine(error));
+    report_fatal_error(
+        "unsupported GC: " + Name +
+        " (did you remember to link and initialize the library?)");
   } else
-    report_fatal_error(Twine(std::string("unsupported GC: ") + Name.str()));
+    report_fatal_error(Twine("unsupported GC: ") + Name);
 }

diff  --git a/llvm/test/Transforms/RewriteStatepointsForGC/unsupported-gc-error.ll b/llvm/test/Transforms/RewriteStatepointsForGC/unsupported-gc-error.ll
new file mode 100644
index 0000000000000..6a3c89098d2b8
--- /dev/null
+++ b/llvm/test/Transforms/RewriteStatepointsForGC/unsupported-gc-error.ll
@@ -0,0 +1,12 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: not --crash opt -disable-output -passes=rewrite-statepoints-for-gc %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: unsupported GC: unsupported-gc
+
+declare void @g()
+declare i32 @h()
+
+define ptr addrspace(1) @f0(ptr addrspace(1) %arg) gc "unsupported-gc" {
+  call void @g() [ "deopt"(i32 100) ]
+  ret ptr addrspace(1) %arg
+}


        


More information about the llvm-commits mailing list