diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index 8ca8521f0b4cb..9c9318e2b66e4 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -1028,11 +1028,14 @@ void IRGenModule::constructInitialFnAttributes(llvm::AttrBuilder &Attrs, if (FuncOptMode == OptimizationMode::ForSize) Attrs.addAttribute(llvm::Attribute::MinSize); - auto triple = llvm::Triple(ClangOpts.Triple); - if (triple.getArchName() == "arm64e") { + if (IRGen.Opts.PointerAuth.ReturnAddresses) Attrs.addAttribute("ptrauth-returns"); + if (IRGen.Opts.PointerAuth.FunctionPointers) Attrs.addAttribute("ptrauth-calls"); - } + if (IRGen.Opts.PointerAuth.IndirectGotos) + Attrs.addAttribute("ptrauth-indirect-gotos"); + if (IRGen.Opts.PointerAuth.AuthTraps) + Attrs.addAttribute("ptrauth-auth-traps"); } llvm::AttributeList IRGenModule::constructInitialAttributes() { diff --git a/test/IRGen/ptrauth-functions.sil b/test/IRGen/ptrauth-functions.sil index 9606671228345..80f9e43227584 100644 --- a/test/IRGen/ptrauth-functions.sil +++ b/test/IRGen/ptrauth-functions.sil @@ -87,4 +87,4 @@ bb0(%0 : $T): sil_vtable F { } -// CHECK: #[[ATTRS]] = {{{.*}} "ptrauth-calls" "ptrauth-returns" +// CHECK: #[[ATTRS]] = {{{.*}} "ptrauth-auth-traps" "ptrauth-calls" "ptrauth-indirect-gotos" "ptrauth-returns"