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(P.first) || cast(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));