Skip to content

Commit a9e97b3

Browse files
committed
Add all the ptrauth IR attributes that Clang does.
A more modest fix for rdar://63289339 for the 5.3 release.
1 parent 8397013 commit a9e97b3

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
@@ -1028,11 +1028,14 @@ void IRGenModule::constructInitialFnAttributes(llvm::AttrBuilder &Attrs,
10281028
if (FuncOptMode == OptimizationMode::ForSize)
10291029
Attrs.addAttribute(llvm::Attribute::MinSize);
10301030

1031-
auto triple = llvm::Triple(ClangOpts.Triple);
1032-
if (triple.getArchName() == "arm64e") {
1031+
if (IRGen.Opts.PointerAuth.ReturnAddresses)
10331032
Attrs.addAttribute("ptrauth-returns");
1033+
if (IRGen.Opts.PointerAuth.FunctionPointers)
10341034
Attrs.addAttribute("ptrauth-calls");
1035-
}
1035+
if (IRGen.Opts.PointerAuth.IndirectGotos)
1036+
Attrs.addAttribute("ptrauth-indirect-gotos");
1037+
if (IRGen.Opts.PointerAuth.AuthTraps)
1038+
Attrs.addAttribute("ptrauth-auth-traps");
10361039
}
10371040

10381041
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)