[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 07:22:44 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(),
----------------
goussepi wrote:

Is c_str ok here ? would data() not work ?

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


More information about the llvm-commits mailing list