|
26 | 26 | #include <llvm/ADT/StringMap.h> |
27 | 27 | #include <llvm/Analysis/AliasAnalysis.h> |
28 | 28 | #include <llvm/Analysis/TargetLibraryInfo.h> |
| 29 | +#include "llvm/Demangle/Demangle.h" |
29 | 30 | #include <llvm/IR/IRBuilder.h> |
30 | 31 | #include <llvm/IR/InlineAsm.h> |
31 | 32 | #include <llvm/IR/Instructions.h> |
@@ -55,7 +56,8 @@ static inline bool isAllocationFunction(const llvm::StringRef name, |
55 | 56 | return true; |
56 | 57 | if (name == "__size_returning_new_experiment") |
57 | 58 | return true; |
58 | | - if (name == "__rust_alloc" || name == "__rust_alloc_zeroed") |
| 59 | + std::string demangledName = llvm::demangle(name.str()); |
| 60 | + if (demangledName == "__rustc::__rust_alloc" || demangledName == "__rustc::__rust_alloc_zeroed") |
59 | 61 | return true; |
60 | 62 | if (name == "julia.gc_alloc_obj" || name == "jl_gc_alloc_typed" || |
61 | 63 | name == "ijl_gc_alloc_typed") |
@@ -131,7 +133,8 @@ static inline bool isDeallocationFunction(const llvm::StringRef name, |
131 | 133 | return true; |
132 | 134 | if (name == "_mlir_memref_to_llvm_free") |
133 | 135 | return true; |
134 | | - if (name == "__rust_dealloc") |
| 136 | + std::string demangledName = llvm::demangle(name.str()); |
| 137 | + if (demangledName == "__rustc::__rust_dealloc") |
135 | 138 | return true; |
136 | 139 | if (name == "swift_release") |
137 | 140 | return true; |
@@ -207,7 +210,8 @@ static inline void zeroKnownAllocation(llvm::IRBuilder<> &bb, |
207 | 210 | assert(isAllocationFunction(funcName, TLI)); |
208 | 211 |
|
209 | 212 | // Don't re-zero an already-zero buffer |
210 | | - if (funcName == "calloc" || funcName == "__rust_alloc_zeroed") |
| 213 | + std::string demangledName = llvm::demangle(funcName.str()); |
| 214 | + if (funcName == "calloc" || demangledName == "__rustc::__rust_alloc_zeroed") |
211 | 215 | return; |
212 | 216 |
|
213 | 217 | Value *allocSize = argValues[0]; |
|
0 commit comments