[llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 08:01:45 PST 2024


================
@@ -3430,7 +3430,12 @@ void FunctionStackPoisoner::processStaticAllocas() {
   SmallVector<ASanStackVariableDescription, 16> SVD;
   SVD.reserve(AllocaVec.size());
   for (AllocaInst *AI : AllocaVec) {
-    ASanStackVariableDescription D = {AI->getName().data(),
+    std::string Name = AI->getName().data();
+    if(AI->hasMetadata("OriginalName")){
+      MDTuple* tuple = dyn_cast<MDTuple>(AI->getMetadata("OriginalName"));
+      Name = dyn_cast<MDString>(tuple->getOperand(0))->getString();
+    }
+    ASanStackVariableDescription D = {Name.c_str(),
----------------
gbMattN wrote:

They are similar, but c_str is guaranteed to be null terminated, so I think it is preferable in situations like this

https://github.com/llvm/llvm-project/pull/119387


More information about the llvm-commits mailing list