Skip to content

Commit f06bc88

Browse files
committed
[PAC][Driver] Support pauthtest ABI for AArch64 Linux triples
When `pauthtest` is either passed as environment part of AArch64 Linux triple or passed via `-mabi=`, enable the following ptrauth flags: - `intrinsics`; - `calls`; - `returns`; - `auth-traps`; - `vtable-pointer-address-discrimination`; - `vtable-pointer-type-discrimination`; - `init-fini`. Some related stuff is still subject to change, and the ABI itself might be changed, so end users are not expected to use this and the ABI name has 'test' suffix. If `-mabi=pauthtest` option is used, it's normalized to effective triple. When the environment part of the effective triple is `pauthtest`, try to use `aarch64-linux-pauthtest` as multilib directory. The following is not supported: - combination of `pauthtest` ABI with any branch protection scheme except BTI; - explicit set of environment part of the triple to a value different from `pauthtest` in combination with `-mabi=pauthtest`; - usage on non-Linux OS.
1 parent a3dff30 commit f06bc88

File tree

19 files changed

+146
-52
lines changed

19 files changed

+146
-52
lines changed

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
204204
StringRef AArch64TargetInfo::getABI() const { return ABI; }
205205

206206
bool AArch64TargetInfo::setABI(const std::string &Name) {
207-
if (Name != "aapcs" && Name != "aapcs-soft" && Name != "darwinpcs")
207+
if (Name != "aapcs" && Name != "aapcs-soft" && Name != "darwinpcs" &&
208+
Name != "pauthtest")
208209
return false;
209210

210211
ABI = Name;
@@ -218,6 +219,12 @@ bool AArch64TargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
218219
Diags.Report(diag::err_target_unsupported_abi_with_fpu) << ABI;
219220
return false;
220221
}
222+
if (getTriple().getEnvironment() == llvm::Triple::PAuthTest &&
223+
getTriple().getOS() != llvm::Triple::Linux) {
224+
Diags.Report(diag::err_target_unsupported_abi_for_triple)
225+
<< getTriple().getEnvironmentName() << getTriple().getTriple();
226+
return false;
227+
}
221228
return true;
222229
}
223230

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
324324
case llvm::Triple::GNU:
325325
setABI("apcs-gnu");
326326
break;
327+
case llvm::Triple::PAuthTest:
328+
setABI("pauthtest");
329+
break;
327330
default:
328331
if (IsNetBSD)
329332
setABI("apcs-gnu");

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
147147
return createWindowsAArch64TargetCodeGenInfo(CGM, AArch64ABIKind::Win64);
148148
else if (Target.getABI() == "aapcs-soft")
149149
Kind = AArch64ABIKind::AAPCSSoft;
150+
else if (Target.getABI() == "pauthtest")
151+
Kind = AArch64ABIKind::PAuthTest;
150152

151153
return createAArch64TargetCodeGenInfo(CGM, Kind);
152154
}

clang/lib/CodeGen/TargetInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ enum class AArch64ABIKind {
437437
DarwinPCS,
438438
Win64,
439439
AAPCSSoft,
440+
PAuthTest,
440441
};
441442

442443
std::unique_ptr<TargetCodeGenInfo>

clang/lib/Driver/ToolChain.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,11 +1031,12 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args,
10311031
}
10321032
case llvm::Triple::aarch64: {
10331033
llvm::Triple Triple = getTriple();
1034+
tools::aarch64::setPAuthABIInTriple(getDriver(), Args, Triple);
10341035
if (!Triple.isOSBinFormatMachO())
1035-
return getTripleString();
1036+
return Triple.getTriple();
10361037

10371038
if (Triple.isArm64e())
1038-
return getTripleString();
1039+
return Triple.getTriple();
10391040

10401041
// FIXME: older versions of ld64 expect the "arm64" component in the actual
10411042
// triple string and query it to determine whether an LTO file can be

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,24 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
449449
if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
450450
Features.push_back("+no-bti-at-return-twice");
451451
}
452+
453+
void aarch64::setPAuthABIInTriple(const Driver &D, const ArgList &Args,
454+
llvm::Triple &Triple) {
455+
Arg *ABIArg = Args.getLastArg(options::OPT_mabi_EQ);
456+
bool HasPAuthABI =
457+
ABIArg ? (StringRef(ABIArg->getValue()) == "pauthtest") : false;
458+
459+
switch (Triple.getEnvironment()) {
460+
case llvm::Triple::UnknownEnvironment:
461+
if (HasPAuthABI)
462+
Triple.setEnvironment(llvm::Triple::PAuthTest);
463+
break;
464+
case llvm::Triple::PAuthTest:
465+
break;
466+
default:
467+
if (HasPAuthABI)
468+
D.Diag(diag::err_drv_unsupported_opt_for_target)
469+
<< ABIArg->getAsString(Args) << Triple.getTriple();
470+
break;
471+
}
472+
}

clang/lib/Driver/ToolChains/Arch/AArch64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ void getAArch64TargetFeatures(const Driver &D, const llvm::Triple &Triple,
2828
std::string getAArch64TargetCPU(const llvm::opt::ArgList &Args,
2929
const llvm::Triple &Triple, llvm::opt::Arg *&A);
3030

31+
void setPAuthABIInTriple(const Driver &D, const llvm::opt::ArgList &Args,
32+
llvm::Triple &triple);
33+
3134
} // end namespace aarch64
3235
} // end namespace target
3336
} // end namespace driver

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,8 +1487,7 @@ void AddUnalignedAccessWarning(ArgStringList &CmdArgs) {
14871487
// Each combination of options here forms a signing schema, and in most cases
14881488
// each signing schema is its own incompatible ABI. The default values of the
14891489
// options represent the default signing schema.
1490-
static void handlePAuthABIOption(const ArgList &DriverArgs,
1491-
ArgStringList &CC1Args) {
1490+
static void handlePAuthABI(const ArgList &DriverArgs, ArgStringList &CC1Args) {
14921491
if (!DriverArgs.hasArg(options::OPT_fptrauth_intrinsics,
14931492
options::OPT_fno_ptrauth_intrinsics))
14941493
CC1Args.push_back("-fptrauth-intrinsics");
@@ -1573,30 +1572,37 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
15731572
if (!isAArch64 && PBP.Key == "b_key")
15741573
D.Diag(diag::warn_unsupported_branch_protection)
15751574
<< "b-key" << A->getAsString(Args);
1576-
if (!isAArch64 && PBP.HasPauthABI)
1577-
D.Diag(diag::warn_unsupported_branch_protection)
1578-
<< "pauthabi" << A->getAsString(Args);
15791575
Scope = PBP.Scope;
15801576
Key = PBP.Key;
15811577
BranchProtectionPAuthLR = PBP.BranchProtectionPAuthLR;
15821578
IndirectBranches = PBP.BranchTargetEnforcement;
15831579
GuardedControlStack = PBP.GuardedControlStack;
1584-
if (isAArch64 && PBP.HasPauthABI)
1585-
handlePAuthABIOption(Args, CmdArgs);
15861580
}
15871581

15881582
CmdArgs.push_back(
15891583
Args.MakeArgString(Twine("-msign-return-address=") + Scope));
1590-
if (Scope != "none")
1584+
if (Scope != "none") {
1585+
if (Triple.getEnvironment() == llvm::Triple::PAuthTest)
1586+
D.Diag(diag::err_drv_unsupported_opt_for_target)
1587+
<< A->getAsString(Args) << Triple.getTriple();
15911588
CmdArgs.push_back(
15921589
Args.MakeArgString(Twine("-msign-return-address-key=") + Key));
1593-
if (BranchProtectionPAuthLR)
1590+
}
1591+
if (BranchProtectionPAuthLR) {
1592+
if (Triple.getEnvironment() == llvm::Triple::PAuthTest)
1593+
D.Diag(diag::err_drv_unsupported_opt_for_target)
1594+
<< A->getAsString(Args) << Triple.getTriple();
15941595
CmdArgs.push_back(
15951596
Args.MakeArgString(Twine("-mbranch-protection-pauth-lr")));
1597+
}
15961598
if (IndirectBranches)
15971599
CmdArgs.push_back("-mbranch-target-enforce");
1598-
if (GuardedControlStack)
1600+
if (GuardedControlStack) {
1601+
if (Triple.getEnvironment() == llvm::Triple::PAuthTest)
1602+
D.Diag(diag::err_drv_unsupported_opt_for_target)
1603+
<< A->getAsString(Args) << Triple.getTriple();
15991604
CmdArgs.push_back("-mguarded-control-stack");
1605+
}
16001606
}
16011607

16021608
void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
@@ -1740,6 +1746,8 @@ void RenderAArch64ABI(const llvm::Triple &Triple, const ArgList &Args,
17401746
ABIName = A->getValue();
17411747
else if (Triple.isOSDarwin())
17421748
ABIName = "darwinpcs";
1749+
else if (Triple.getEnvironment() == llvm::Triple::PAuthTest)
1750+
ABIName = "pauthtest";
17431751
else
17441752
ABIName = "aapcs";
17451753

@@ -1776,6 +1784,9 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
17761784
// Enable/disable return address signing and indirect branch targets.
17771785
CollectARMPACBTIOptions(getToolChain(), Args, CmdArgs, true /*isAArch64*/);
17781786

1787+
if (Triple.getEnvironment() == llvm::Triple::PAuthTest)
1788+
handlePAuthABI(Args, CmdArgs);
1789+
17791790
// Handle -msve_vector_bits=<bits>
17801791
if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
17811792
StringRef Val = A->getValue();

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ std::string Linux::getMultiarchTriple(const Driver &D,
8686
case llvm::Triple::aarch64:
8787
if (IsAndroid)
8888
return "aarch64-linux-android";
89+
if (hasEffectiveTriple() &&
90+
getEffectiveTriple().getEnvironment() == llvm::Triple::PAuthTest)
91+
return "aarch64-linux-pauthtest";
8992
return "aarch64-linux-gnu";
9093
case llvm::Triple::aarch64_be:
9194
return "aarch64_be-linux-gnu";

clang/test/Driver/Inputs/multilib_aarch64_linux_tree/usr/include/aarch64-linux-gnu/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/multilib_aarch64_linux_tree/usr/include/aarch64-linux-pauthtest/.keep

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %clang --target=aarch64-linux-pauthtest --sysroot=%S/Inputs/multilib_aarch64_linux_tree -### -c %s 2>&1 | FileCheck %s
2+
// RUN: %clang --target=aarch64-linux -mabi=pauthtest --sysroot=%S/Inputs/multilib_aarch64_linux_tree -### -c %s 2>&1 | FileCheck %s
3+
4+
// CHECK: "-internal-externc-isystem" "{{.*}}/usr/include/aarch64-linux-pauthtest"

clang/test/Driver/aarch64-ptrauth.c

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
// REQUIRES: aarch64-registered-target
2+
13
// RUN: %clang -### -c --target=aarch64 %s 2>&1 | FileCheck %s --check-prefix NONE
2-
// NONE: "-cc1"
4+
// NONE: "-cc1"
35
// NONE-NOT: "-fptrauth-
46

57
// RUN: %clang -### -c --target=aarch64 \
@@ -13,14 +15,21 @@
1315
// RUN: %s 2>&1 | FileCheck %s --check-prefix=ALL
1416
// ALL: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" "-fptrauth-returns" "-fptrauth-auth-traps" "-fptrauth-vtable-pointer-address-discrimination" "-fptrauth-vtable-pointer-type-discrimination" "-fptrauth-init-fini"
1517

16-
// RUN: %clang -### -c --target=aarch64 -mbranch-protection=pauthabi %s 2>&1 | \
17-
// RUN: FileCheck %s --check-prefix=PAUTHABI1
18-
// PAUTHABI1: "-cc1"{{.*}} "-fptrauth-intrinsics" "-fptrauth-calls" "-fptrauth-returns" "-fptrauth-auth-traps" "-fptrauth-vtable-pointer-address-discrimination" "-fptrauth-vtable-pointer-type-discrimination" "-fptrauth-init-fini"
18+
// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest %s 2>&1 | FileCheck %s --check-prefix=PAUTHABI1
19+
// RUN: %clang -### -c --target=aarch64-linux-pauthtest %s 2>&1 | FileCheck %s --check-prefix=PAUTHABI1
20+
// PAUTHABI1: "-cc1"{{.*}} "-triple" "aarch64-unknown-linux-pauthtest"
21+
// PAUTHABI1-SAME: "-target-abi" "pauthtest"
22+
// PAUTHABI1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" "-fptrauth-returns" "-fptrauth-auth-traps" "-fptrauth-vtable-pointer-address-discrimination" "-fptrauth-vtable-pointer-type-discrimination" "-fptrauth-init-fini"
1923

20-
// RUN: %clang -### -c --target=aarch64 -mbranch-protection=pauthabi -fno-ptrauth-intrinsics \
24+
// RUN: %clang -### -c --target=aarch64 -mabi=pauthtest -fno-ptrauth-intrinsics \
2125
// RUN: -fno-ptrauth-calls -fno-ptrauth-returns -fno-ptrauth-auth-traps \
2226
// RUN: -fno-ptrauth-vtable-pointer-address-discrimination -fno-ptrauth-vtable-pointer-type-discrimination \
2327
// RUN: -fno-ptrauth-init-fini %s 2>&1 | FileCheck %s --check-prefix=PAUTHABI2
28+
// RUN: %clang -### -c --target=aarch64-pauthtest -fno-ptrauth-intrinsics \
29+
// RUN: -fno-ptrauth-calls -fno-ptrauth-returns -fno-ptrauth-auth-traps \
30+
// RUN: -fno-ptrauth-vtable-pointer-address-discrimination -fno-ptrauth-vtable-pointer-type-discrimination \
31+
// RUN: -fno-ptrauth-init-fini %s 2>&1 | FileCheck %s --check-prefix=PAUTHABI2
32+
// PAUTHABI2: "-cc1"
2433
// PAUTHABI2-NOT: "-fptrauth-
2534

2635
// RUN: not %clang -### -c --target=x86_64 -fptrauth-intrinsics -fptrauth-calls -fptrauth-returns -fptrauth-auth-traps \
@@ -34,16 +43,50 @@
3443
// ERR1-NEXT: error: unsupported option '-fptrauth-vtable-pointer-type-discrimination' for target '{{.*}}'
3544
// ERR1-NEXT: error: unsupported option '-fptrauth-init-fini' for target '{{.*}}'
3645

37-
// RUN: not %clang -### -c --target=x86_64 -mbranch-protection=pauthabi %s 2>&1 | \
38-
// RUN: FileCheck %s --check-prefix=ERR2
39-
// ERR2: error: unsupported option '-mbranch-protection=' for target 'x86_64'
46+
//// Only support PAuth ABI for Linux as for now.
47+
// RUN: not %clang -c --target=aarch64-unknown -mabi=pauthtest %s 2>&1 | FileCheck %s --check-prefix=ERR2
48+
// RUN: not %clang -c --target=aarch64-unknown-pauthtest %s 2>&1 | FileCheck %s --check-prefix=ERR2
49+
// ERR2: error: ABI 'pauthtest' is not supported for 'aarch64-unknown-unknown-pauthtest'
4050

41-
// RUN: not %clang -### -c --target=aarch64 -mbranch-protection=pauthabi+pac-ret %s 2>&1 | \
42-
// RUN: FileCheck %s --check-prefix=ERR3
43-
// ERR3: error: unsupported argument 'pauthabi+pac-ret' to option '-mbranch-protection='
51+
//// PAuth ABI is encoded as environment part of the triple, so don't allow to explicitly set other environments.
52+
// RUN: not %clang -c --target=aarch64-linux-gnu -mabi=pauthtest %s 2>&1 | FileCheck %s --check-prefix=ERR3
53+
// ERR3: error: unsupported option '-mabi=pauthtest' for target 'aarch64-unknown-linux-gnu'
54+
// RUN: %clang -c --target=aarch64-linux-pauthtest -mabi=pauthtest %s
4455

45-
// RUN: not %clang -### -c --target=aarch64 -mbranch-protection=gcs+pauthabi %s 2>&1 | \
56+
//// The only branch protection option compatible with PAuthABI is BTI.
57+
// RUN: not %clang -### -c --target=aarch64-linux -mabi=pauthtest -mbranch-protection=pac-ret %s 2>&1 | \
58+
// RUN: FileCheck %s --check-prefix=ERR4
59+
// RUN: not %clang -### -c --target=aarch64-linux-pauthtest -mbranch-protection=pac-ret %s 2>&1 | \
4660
// RUN: FileCheck %s --check-prefix=ERR4
47-
// ERR4: error: unsupported argument 'pauthabi+gcs' to option '-mbranch-protection='
61+
// ERR4: error: unsupported option '-mbranch-protection=pac-ret' for target 'aarch64-unknown-linux-pauthtest'
62+
63+
// RUN: not %clang -### -c --target=aarch64-linux -mabi=pauthtest -mbranch-protection=gcs %s 2>&1 | \
64+
// RUN: FileCheck %s --check-prefix=ERR5
65+
// RUN: not %clang -### -c --target=aarch64-linux-pauthtest -mbranch-protection=gcs %s 2>&1 | \
66+
// RUN: FileCheck %s --check-prefix=ERR5
67+
// ERR5: error: unsupported option '-mbranch-protection=gcs' for target 'aarch64-unknown-linux-pauthtest'
68+
69+
// RUN: not %clang -### -c --target=aarch64-linux -mabi=pauthtest -mbranch-protection=standard %s 2>&1 | \
70+
// RUN: FileCheck %s --check-prefix=ERR6
71+
// RUN: not %clang -### -c --target=aarch64-linux-pauthtest -mbranch-protection=standard %s 2>&1 | \
72+
// RUN: FileCheck %s --check-prefix=ERR6
73+
// ERR6: error: unsupported option '-mbranch-protection=standard' for target 'aarch64-unknown-linux-pauthtest'
74+
75+
// RUN: not %clang -### -c --target=aarch64-linux -mabi=pauthtest -msign-return-address=all %s 2>&1 | \
76+
// RUN: FileCheck %s --check-prefix=ERR7
77+
// RUN: not %clang -### -c --target=aarch64-linux-pauthtest -msign-return-address=all %s 2>&1 | \
78+
// RUN: FileCheck %s --check-prefix=ERR7
79+
// ERR7: error: unsupported option '-msign-return-address=all' for target 'aarch64-unknown-linux-pauthtest'
80+
81+
// RUN: not %clang -### -c --target=aarch64-linux -mabi=pauthtest -msign-return-address=non-leaf %s 2>&1 | \
82+
// RUN: FileCheck %s --check-prefix=ERR8
83+
// RUN: not %clang -### -c --target=aarch64-linux-pauthtest -msign-return-address=non-leaf %s 2>&1 | \
84+
// RUN: FileCheck %s --check-prefix=ERR8
85+
// ERR8: error: unsupported option '-msign-return-address=non-leaf' for target 'aarch64-unknown-linux-pauthtest'
4886

49-
// RUN: %clang -### -c --target=aarch64 -mbranch-protection=bti+pauthabi %s 2>&1
87+
// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest -msign-return-address=none %s
88+
// RUN: %clang -### -c --target=aarch64-linux-pauthtest -msign-return-address=none %s
89+
// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest -mbranch-protection=bti %s
90+
// RUN: %clang -### -c --target=aarch64-linux-pauthtest -mbranch-protection=bti %s
91+
// RUN: %clang -### -c --target=aarch64-linux -mabi=pauthtest -mbranch-protection=none %s
92+
// RUN: %clang -### -c --target=aarch64-linux-pauthtest -mbranch-protection=none %s

llvm/include/llvm/TargetParser/ARMTargetParserCommon.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct ParsedBranchProtection {
4343
bool BranchTargetEnforcement;
4444
bool BranchProtectionPAuthLR;
4545
bool GuardedControlStack;
46-
bool HasPauthABI;
4746
};
4847

4948
bool parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class Triple {
266266
Cygnus,
267267
CoreCLR,
268268
Simulator, // Simulator variants of other systems, e.g., Apple's iOS
269-
MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
269+
MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
270270

271271
// Shader Stages
272272
// The order of these values matters, and must be kept in sync with the
@@ -290,7 +290,9 @@ class Triple {
290290
OpenCL,
291291
OpenHOS,
292292

293-
LastEnvironmentType = OpenHOS
293+
PAuthTest,
294+
295+
LastEnvironmentType = PAuthTest
294296
};
295297
enum ObjectFormatType {
296298
UnknownObjectFormat,

llvm/lib/TargetParser/ARMTargetParser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ StringRef ARM::computeDefaultTargetABI(const Triple &TT, StringRef CPU) {
562562
case Triple::EABIHF:
563563
case Triple::EABI:
564564
return "aapcs";
565+
case Triple::PAuthTest:
566+
return "pauthtest";
565567
default:
566568
if (TT.isOSNetBSD())
567569
return "apcs-gnu";

llvm/lib/TargetParser/ARMTargetParserCommon.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,13 @@ ARM::EndianKind ARM::parseArchEndian(StringRef Arch) {
134134
}
135135

136136
// Parse a branch protection specification, which has the form
137-
// standard | none | [bti,pac-ret[+b-key,+leaf,+pc]*,gcs,pauthabi]
138-
// Note: pauthabi is allowed with bti and disallowed with pac-ret and gcs.
139-
// Returns true on success, with individual elements of the
140-
// specification returned in `PBP`. Returns false in error, with `Err`
141-
// containing an erroneous part of the spec.
137+
// standard | none | [bti,pac-ret[+b-key,+leaf,+pc]*]
138+
// Returns true on success, with individual elements of the specification
139+
// returned in `PBP`. Returns false in error, with `Err` containing
140+
// an erroneous part of the spec.
142141
bool ARM::parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
143142
StringRef &Err, bool EnablePAuthLR) {
144-
PBP = {"none", "a_key", false, false, false, false};
143+
PBP = {"none", "a_key", false, false, false};
145144
if (Spec == "none")
146145
return true; // defaults are ok
147146

@@ -161,10 +160,6 @@ bool ARM::parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
161160
PBP.BranchTargetEnforcement = true;
162161
continue;
163162
}
164-
if (Opt == "pauthabi") {
165-
PBP.HasPauthABI = true;
166-
continue;
167-
}
168163
if (Opt == "pac-ret") {
169164
PBP.Scope = "non-leaf";
170165
for (; I + 1 != E; ++I) {
@@ -191,17 +186,5 @@ bool ARM::parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
191186
return false;
192187
}
193188

194-
if (!PBP.HasPauthABI)
195-
return true;
196-
197-
if (PBP.Scope != "none") {
198-
Err = "pauthabi+pac-ret";
199-
return false;
200-
}
201-
if (PBP.GuardedControlStack) {
202-
Err = "pauthabi+gcs";
203-
return false;
204-
}
205-
206189
return true;
207190
}

llvm/lib/TargetParser/Triple.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
347347
case OpenCL:
348348
return "opencl";
349349
case OpenHOS: return "ohos";
350+
case PAuthTest:
351+
return "pauthtest";
350352
}
351353

352354
llvm_unreachable("Invalid EnvironmentType!");
@@ -719,6 +721,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
719721
.StartsWith("amplification", Triple::Amplification)
720722
.StartsWith("opencl", Triple::OpenCL)
721723
.StartsWith("ohos", Triple::OpenHOS)
724+
.StartsWith("pauthtest", Triple::PAuthTest)
722725
.Default(Triple::UnknownEnvironment);
723726
}
724727

0 commit comments

Comments
 (0)