[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 10 15:57:46 PST 2025
================
@@ -3391,6 +3391,29 @@ static void findStoresToUninstrumentedArgAllocas(
}
}
+StringRef getAllocaName(AllocaInst *AI) {
+ StringRef Name = AI->getName();
+
+ // Alloca could have been renamed for uniqueness. Its true name will have been
+ // recorded as an annotation.
+ if (AI->hasMetadata(LLVMContext::MD_annotation)) {
+ MDTuple *Annotation =
+ (MDTuple *)AI->getMetadata(LLVMContext::MD_annotation);
+ for (int i = 0; i < Annotation->getNumOperands(); i++) {
+ if (auto Tuple = dyn_cast<MDTuple>(Annotation->getOperand(i))) {
+ for (int i = 0; i < Tuple->getNumOperands(); i++) {
+ if (auto stringMetadata = dyn_cast<MDString>(Tuple->getOperand(i))) {
+ if (stringMetadata->getString() == "alloca_name_altered") {
+ Name = ((MDString *)Tuple->getOperand(i + 1).get())->getString();
----------------
vitalybuka wrote:
break or better return here
https://github.com/llvm/llvm-project/pull/119387
More information about the llvm-commits
mailing list