Skip to content

Commit 3e0b2b8

Browse files
authored
Merge pull request #31963 from rjmccall/ir-ptrauth-attributes-5.3
[5.3] Add all the ptrauth IR attributes that Clang does
2 parents 8ba8d95 + a9e97b3 commit 3e0b2b8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,11 +1054,14 @@ void IRGenModule::constructInitialFnAttributes(llvm::AttrBuilder &Attrs,
10541054
if (FuncOptMode == OptimizationMode::ForSize)
10551055
Attrs.addAttribute(llvm::Attribute::MinSize);
10561056

1057-
auto triple = llvm::Triple(ClangOpts.Triple);
1058-
if (triple.getArchName() == "arm64e") {
1057+
if (IRGen.Opts.PointerAuth.ReturnAddresses)
10591058
Attrs.addAttribute("ptrauth-returns");
1059+
if (IRGen.Opts.PointerAuth.FunctionPointers)
10601060
Attrs.addAttribute("ptrauth-calls");
1061-
}
1061+
if (IRGen.Opts.PointerAuth.IndirectGotos)
1062+
Attrs.addAttribute("ptrauth-indirect-gotos");
1063+
if (IRGen.Opts.PointerAuth.AuthTraps)
1064+
Attrs.addAttribute("ptrauth-auth-traps");
10621065
}
10631066

10641067
llvm::AttributeList IRGenModule::constructInitialAttributes() {

test/IRGen/ptrauth-functions.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ bb0(%0 : $T):
8787

8888
sil_vtable F {
8989
}
90-
// CHECK: #[[ATTRS]] = {{{.*}} "ptrauth-calls" "ptrauth-returns"
90+
// CHECK: #[[ATTRS]] = {{{.*}} "ptrauth-auth-traps" "ptrauth-calls" "ptrauth-indirect-gotos" "ptrauth-returns"

0 commit comments

Comments
 (0)