[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:12:07 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f9d6d46a8edfac7421a4b010eb216f793669bef1 01be0deaf6854ae1fd8f27ed9a3cb691be041d91 --extensions cpp -- llvm/lib/IR/ValueSymbolTable.cpp llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/IR/ValueSymbolTable.cpp b/llvm/lib/IR/ValueSymbolTable.cpp
index 8d1babfeca..81bb3f3c5a 100644
--- a/llvm/lib/IR/ValueSymbolTable.cpp
+++ b/llvm/lib/IR/ValueSymbolTable.cpp
@@ -123,10 +123,12 @@ ValueName *ValueSymbolTable::createValueName(StringRef Name, Value *V) {
   }
 
   // Otherwise, there is a naming conflict.  Rename this value.
-  // If we are renaming an instruction, ASan needs to know for it to serialize properly
-  if(auto* I = dyn_cast<Instruction>(V)){
-    MDString* trueNameMetadata = MDString::get(V->getContext(), Name);
-    llvm::MDTuple* tuple = llvm::MDTuple::get(V->getContext(), trueNameMetadata);
+  // If we are renaming an instruction, ASan needs to know for it to serialize
+  // properly
+  if (auto *I = dyn_cast<Instruction>(V)) {
+    MDString *trueNameMetadata = MDString::get(V->getContext(), Name);
+    llvm::MDTuple *tuple =
+        llvm::MDTuple::get(V->getContext(), trueNameMetadata);
     I->setMetadata("OriginalName", tuple);
   }
   SmallString<256> UniqueName(Name.begin(), Name.end());
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index d7e91097b3..c696cc3816 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -3431,8 +3431,8 @@ void FunctionStackPoisoner::processStaticAllocas() {
   SVD.reserve(AllocaVec.size());
   for (AllocaInst *AI : AllocaVec) {
     std::string Name = AI->getName().data();
-    if(AI->hasMetadata("OriginalName")){
-      MDTuple* tuple = dyn_cast<MDTuple>(AI->getMetadata("OriginalName"));
+    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(),

``````````

</details>


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


More information about the llvm-commits mailing list