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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 05:57:46 PST 2025


================
@@ -3430,13 +3430,15 @@ void FunctionStackPoisoner::processStaticAllocas() {
   SmallVector<ASanStackVariableDescription, 16> SVD;
   SVD.reserve(AllocaVec.size());
   for (AllocaInst *AI : AllocaVec) {
-    ASanStackVariableDescription D = {AI->getName().data(),
-                                      ASan.getAllocaSizeInBytes(*AI),
-                                      0,
-                                      AI->getAlign().value(),
-                                      AI,
-                                      0,
-                                      0};
+    const char *Name = AI->getName().data();
+    if (AI->hasMetadata(LLVMContext::MD_unaltered_name)) {
+      MDTuple *tuple =
+          dyn_cast<MDTuple>(AI->getMetadata(LLVMContext::MD_unaltered_name));
+      Name = dyn_cast<MDString>(tuple->getOperand(0))->getString().data();
----------------
fhahn wrote:

Should those be casts? If the dyn_cast can return nullptr, you need to check the return value

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


More information about the llvm-commits mailing list