[llvm] [HWASan] Handle default attribute on personality function thunks. (PR #141917)
Daniel Kiss via llvm-commits
llvm-commits at lists.llvm.org
Thu May 29 02:04:53 PDT 2025
https://github.com/DanielKristofKiss created https://github.com/llvm/llvm-project/pull/141917
Function::createWithDefaultAttr deals with default attributes so no need to manually deal with them here.
>From fc1b69ccc835725c55c2834fda92de53ae87c57a Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Thu, 29 May 2025 10:59:04 +0200
Subject: [PATCH] [HWASan] Handle default attribute on personality function
thunks.
Function::createWithDefaultAttr deals with default attributes so no need to manually
deal with them here.
---
.../Instrumentation/HWAddressSanitizer.cpp | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index e81a725c62ead..e38ee68ce0451 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1842,16 +1842,11 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
Int32Ty, {Int32Ty, Int32Ty, Int64Ty, PtrTy, PtrTy}, false);
bool IsLocal = P.first && (!isa<GlobalValue>(P.first) ||
cast<GlobalValue>(P.first)->hasLocalLinkage());
- auto *ThunkFn = Function::Create(ThunkFnTy,
- IsLocal ? GlobalValue::InternalLinkage
- : GlobalValue::LinkOnceODRLinkage,
- ThunkName, &M);
- // TODO: think about other attributes as well.
- if (any_of(P.second, [](const Function *F) {
- return F->hasFnAttribute("branch-target-enforcement");
- })) {
- ThunkFn->addFnAttr("branch-target-enforcement");
- }
+ auto *ThunkFn = Function::createWithDefaultAttr(
+ ThunkFnTy,
+ IsLocal ? GlobalValue::InternalLinkage
+ : GlobalValue::LinkOnceODRLinkage,
+ M.getDataLayout().getProgramAddressSpace(), ThunkName, &M);
if (!IsLocal) {
ThunkFn->setVisibility(GlobalValue::HiddenVisibility);
ThunkFn->setComdat(M.getOrInsertComdat(ThunkName));
More information about the llvm-commits
mailing list