[llvm] 8e6b3cc - [SPIRV] Adapt itaniumDemangle change after itaniumDemangle

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 20:47:40 PDT 2023


Author: Fangrui Song
Date: 2023-05-04T20:47:34-07:00
New Revision: 8e6b3cc4aeedb864a983d849498c03b074570406

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

LOG: [SPIRV] Adapt itaniumDemangle change after itaniumDemangle

Added: 
    

Modified: 
    llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
    llvm/lib/Target/SPIRV/SPIRVUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp b/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
index 69681fd2a54ed..3a51e29dcf161 100644
--- a/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
@@ -171,9 +171,9 @@ void SPIRVRegularizer::visitCallInst(CallInst &CI) {
     return;
 
   auto MangledName = F->getName();
-  size_t n;
-  int status;
-  char *NameStr = itaniumDemangle(F->getName().data(), nullptr, &n, &status);
+  char *NameStr = itaniumDemangle(F->getName().data());
+  if (!NameStr)
+    return;
   StringRef DemangledName(NameStr);
 
   // TODO: add support for other builtins.

diff  --git a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp
index 514dc6497c470..f4f3cdce1ac3c 100644
--- a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp
@@ -293,16 +293,11 @@ std::string getOclOrSpirvBuiltinDemangledName(StringRef Name) {
     return std::string();
 
   // Try to use the itanium demangler.
-  size_t n;
-  int Status;
-  char *DemangledName = itaniumDemangle(Name.data(), nullptr, &n, &Status);
-
-  if (Status == demangle_success) {
+  if (char *DemangledName = itaniumDemangle(Name.data())) {
     std::string Result = DemangledName;
     free(DemangledName);
     return Result;
   }
-  free(DemangledName);
   // Otherwise use simple demangling to return the function name.
   if (IsNonMangledOCL || IsNonMangledSPIRV)
     return Name.str();


        


More information about the llvm-commits mailing list