Skip to content

Commit ca5954b

Browse files
macurtis-amdronlieb
authored andcommitted
Apply ptrauth changes and fix ARM build, tests
add back -fallow-half-arguments-and-returns for hipRuntime builds. ---------------------------------------------------------------------- Revert "[PAC][AArch64] Lower ptrauth constants in code (llvm#96879)" This reverts commit 88dd10c. ---------------------------------------------------------------------- [PAC][AArch64] Lower ptrauth constants in code (llvm#96879) This re-applies llvm#94241 after fixing buildbot failure, see https://lab.llvm.org/buildbot/#/builders/51/builds/570 According to standard, `constexpr` variables and `const` variables initialized with constant expressions can be used in lambdas w/o capturing - see https://en.cppreference.com/w/cpp/language/lambda. However, MSVC used on buildkite seems to ignore that rule and does not allow using such uncaptured variables in lambdas: we have "error C3493: 'Mask16' cannot be implicitly captured because no default capture mode has been specified" - see https://buildkite.com/llvm-project/github-pull-requests/builds/73238 Explicitly capturing such a variable, however, makes buildbot fail with "error: lambda capture 'Mask16' is not required to be captured for this use [-Werror,-Wunused-lambda-capture]" - see https://lab.llvm.org/buildbot/#/builders/51/builds/570. Fix both cases by using `0xffff` value directly instead of giving a name to it. Original PR description below. Depends on llvm#94240. Define the following pseudos for lowering ptrauth constants in code: - non-`extern_weak`: - no GOT load needed: `MOVaddrPAC` - similar to `MOVaddr`, with added PAC; - GOT load needed: `LOADgotPAC` - similar to `LOADgot`, with added PAC; - `extern_weak`: `LOADauthptrstatic` - similar to `LOADgot`, but use a special stub slot named `sym$auth_ptr$key$disc` filled by dynamic linker during relocation resolving instead of a GOT slot. --------- Co-authored-by: Ahmed Bougacha <[email protected]> (cherry picked from commit 1488fb4) ---------------------------------------------------------------------- [AArch64][PAC] Lower ptrauth constants in code for MachO. (llvm#97665) This also adds support for auth stubs on MachO using __DATA,__auth_ptr. Some of the machinery for auth stubs is already implemented; this generalizes that a bit to support MachO, and moves some of the shared logic into MMIImpls. In particular, this originally had an AuthStubInfo struct, but we no longer need it beyond a single MCExpr. So this provides variants of the symbol stub helper type declarations and functions for "expr stubs", where a stub points at an arbitrary MCExpr, rather than a simple MCSymbol (and a bit). (cherry picked from commit 5f1bb62) ---------------------------------------------------------------------- [AArch64][PAC] Sign block addresses used in indirectbr. (llvm#97647) Enabled in clang using: -fptrauth-indirect-gotos and at the IR level using function attribute: "ptrauth-indirect-gotos" Signing uses IA and a per-function integer discriminator. The discriminator isn't ABI-visible, and is currently: ptrauth_string_discriminator("<function_name> blockaddress") A sufficiently sophisticated frontend could benefit from per-indirectbr discrimination, which would need additional machinery, such as allowing "ptrauth" bundles on indirectbr. For our purposes, the simple scheme above is sufficient. This approach doesn't support subtracting label addresses and using the result as offsets, because each label address is signed. Pointer arithmetic on signed pointers corrupts the signature bits, and because label address expressions aren't typed beyond void*, we can't do anything reliably intelligent on the arithmetic exprs. Not signing addresses when used to form offsets would allow easily hijacking control flow by overwriting the offset. This diagnoses the basic cases (`&&lbl2 - &&lbl1`) in the frontend, while we evaluate either alternative implementations (e.g., lowering blockaddress to a bb number, and indirectbr to a checked jump-table), or better diagnostics (both at the frontend level and on unencodable IR constants). (cherry picked from commit b8721fa) ---------------------------------------------------------------------- [AArch64][PAC] Lower auth/resign into checked sequence. (llvm#79024) This introduces 3 hardening modes in the authentication step of auth/resign lowering: - unchecked, which uses the AUT instructions as-is - poison, which detects authentication failure (using an XPAC+CMP sequence), explicitly yielding the XPAC result rather than the AUT result, to avoid leaking - trap, which additionally traps on authentication failure, using BRK #0xC470 + key (IA C470, IB C471, DA C472, DB C473.) Not all modes are necessarily useful in all contexts, and there are more performant alternative lowerings in specific contexts (e.g., when I/D TBI enablement is a target ABI guarantee.) These will be implemented separately. This is controlled by the `ptrauth-auth-traps` function attributes, and can be overridden using `-aarch64-ptrauth-auth-checks=`. This also adds the FPAC extension, which we haven't needed before, to improve isel when we can rely on HW checking. (cherry picked from commit d7e8a74) ---------------------------------------------------------------------- [Clang][Arm] Convert -fallow-half-arguments-and-returns to a target option. NFC This cc1 option -fallow-half-arguments-and-returns allows __fp16 to be passed by argument and returned, without giving an error. It is currently always enabled for Arm and AArch64, by forcing the option in the driver. This means any cc1 tests (especially those needing arm_neon.h) need to specify the option too, to prevent the error from being emitted. This changes it to a target option instead, set to true for Arm and AArch64. This allows the option to be removed. Previously it was implied by -fnative_half_arguments_and_returns, which is set for certain languages like open_cl, renderscript and hlsl, so that option now too controls the errors. There were are few other non-arm uses of -fallow-half-arguments-and-returns but I believe they were unnecessary. The strictfp_builtins.c tests were converted from __fp16 to _Float16 to avoid the issues. Differential Revision: https://reviews.llvm.org/D133885 (cherry picked from commit 9ef11036505c0ae6cdb56ff49f39ab7abcded3cf) ---------------------------------------------------------------------- [clang] XFAIL a few tests due to 'noundef' etc Not all, but most of these are failing due to the presence of a 'noundef' call return attribute on some intrinsics. This is not present on upstream 'main' due to the AlwaysInliner pass being run. See commit 1a2e77c. ---------------------------------------------------------------------- [DebugInfo] Restore missing disabled ptrauth support See "[DebugInfo] Teach LLVM and LLDB about ptrauth in DWARF": commit a8c3d98 Author: Jonas Devlieghere <[email protected]> Date: Wed Jul 27 10:44:15 2022 -0700 ---------------------------------------------------------------------- Apply simple-do.ll test change from b46c085 ---------------------------------------------------------------------- Adjust ptrauth.s test for ptrauth_authentication_mode encoding ---------------------------------------------------------------------- Fix dwarf-eh-prepare-dbg.ll test: dwarfAddressSpace=>addressSpace ---------------------------------------------------------------------- Update some SLPVectorizer/AArch64 tests from upstream ---------------------------------------------------------------------- Regenerate assertions in arm_mult_q15.ll ---------------------------------------------------------------------- [AsmPrinter] Handle null extracted addr class ---------------------------------------------------------------------- [PowerPC] Account for custom LLVM moniker in aix tests ---------------------------------------------------------------------- [LoongArch] Add "Verify Heterogeneous Debug Preconditions" to pipeline test ---------------------------------------------------------------------- [JITLink][RISCV] Un-XFAIL ELF_pc_indirect.s ---------------------------------------------------------------------- Change-Id: Ie6ab500b2451b3ed070dfad0bc16d003e5e2fe10
1 parent e6f09b9 commit ca5954b

File tree

67 files changed

+298
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+298
-220
lines changed

clang/lib/Basic/TargetInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
5959
VLASupported = true;
6060
NoAsmVariants = false;
6161
HasLegalHalfType = false;
62+
HalfArgsAndReturns = false;
6263
HasFloat128 = false;
6364
HasIbm128 = false;
6465
HasFloat16 = false;

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
145145

146146
// All AArch64 implementations support ARMv8 FP, which makes half a legal type.
147147
HasLegalHalfType = true;
148+
HalfArgsAndReturns = true;
148149
HasFloat16 = true;
149150
HasStrictFP = true;
150151

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ bool ARMTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
607607
}
608608
}
609609

610+
HalfArgsAndReturns = true;
611+
610612
switch (ArchVersion) {
611613
case 6:
612614
if (ArchProfile == llvm::ARM::ProfileKind::M)

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,14 +1740,12 @@ void Clang::RenderTargetOptions(const llvm::Triple &EffectiveTriple,
17401740
case llvm::Triple::thumbeb:
17411741
// Use the effective triple, which takes into account the deployment target.
17421742
AddARMTargetArgs(EffectiveTriple, Args, CmdArgs, KernelOrKext);
1743-
CmdArgs.push_back("-fallow-half-arguments-and-returns");
17441743
break;
17451744

17461745
case llvm::Triple::aarch64:
17471746
case llvm::Triple::aarch64_32:
17481747
case llvm::Triple::aarch64_be:
17491748
AddAArch64TargetArgs(Args, CmdArgs);
1750-
CmdArgs.push_back("-fallow-half-arguments-and-returns");
17511749
break;
17521750

17531751
case llvm::Triple::loongarch32:

clang/lib/Sema/SemaType.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,8 @@ bool Sema::CheckFunctionReturnType(QualType T, SourceLocation Loc) {
25292529
}
25302530

25312531
// Functions cannot return half FP.
2532-
if (T->isHalfType() && !getLangOpts().HalfArgsAndReturns) {
2532+
if (T->isHalfType() && !getLangOpts().NativeHalfArgsAndReturns &&
2533+
!Context.getTargetInfo().allowHalfArgsAndReturns()) {
25332534
Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
25342535
FixItHint::CreateInsertion(Loc, "*");
25352536
return true;
@@ -2639,7 +2640,8 @@ QualType Sema::BuildFunctionType(QualType T,
26392640
if (ParamType->isVoidType()) {
26402641
Diag(Loc, diag::err_param_with_void_type);
26412642
Invalid = true;
2642-
} else if (ParamType->isHalfType() && !getLangOpts().HalfArgsAndReturns) {
2643+
} else if (ParamType->isHalfType() && !getLangOpts().NativeHalfArgsAndReturns &&
2644+
!Context.getTargetInfo().allowHalfArgsAndReturns()) {
26432645
// Disallow half FP arguments.
26442646
Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
26452647
FixItHint::CreateInsertion(Loc, "*");
@@ -4938,7 +4940,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
49384940
<< T << 0 /*pointer hint*/;
49394941
D.setInvalidType(true);
49404942
}
4941-
} else if (!S.getLangOpts().HalfArgsAndReturns) {
4943+
} else if (!S.getLangOpts().NativeHalfArgsAndReturns &&
4944+
!S.Context.getTargetInfo().allowHalfArgsAndReturns()) {
49424945
S.Diag(D.getIdentifierLoc(),
49434946
diag::err_parameters_retval_cannot_have_fp16_type) << 1;
49444947
D.setInvalidType(true);
@@ -5186,7 +5189,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
51865189
D.setInvalidType();
51875190
Param->setInvalidDecl();
51885191
}
5189-
} else if (!S.getLangOpts().HalfArgsAndReturns) {
5192+
} else if (!S.getLangOpts().NativeHalfArgsAndReturns &&
5193+
!S.Context.getTargetInfo().allowHalfArgsAndReturns()) {
51905194
S.Diag(Param->getLocation(),
51915195
diag::err_parameters_retval_cannot_have_fp16_type) << 0;
51925196
D.setInvalidType();

clang/test/CodeGen/PowerPC/builtins-ppc-fpconstrained.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
// RUN: -ffp-exception-behavior=strict -emit-llvm %s -o - | FileCheck \
66
// RUN: --check-prefix=CHECK-CONSTRAINED -vv %s
77
// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
8-
// RUN: -fallow-half-arguments-and-returns -S -o - %s | \
8+
// RUN: -S -o - %s | \
99
// RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK %s
1010
// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
11-
// RUN: -fallow-half-arguments-and-returns -S -ffp-exception-behavior=strict \
11+
// RUN: -S -ffp-exception-behavior=strict \
1212
// RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
1313
// RUN: --check-prefix=FIXME-CHECK %s
1414
// RUN: %clang_cc1 -triple powerpcspe -ffp-exception-behavior=strict \

clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// RUN: -ffp-exception-behavior=strict \
99
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
1010

11+
// XFAIL: *
12+
1113
#include <vecintrin.h>
1214

1315
volatile vector signed long long vsl;

clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// RUN: -O2 -fzvector -flax-vector-conversions=none \
77
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
88

9+
// XFAIL: *
10+
911
#include <vecintrin.h>
1012

1113
volatile vector signed char vsc;

clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// RUN: -ffp-exception-behavior=strict \
99
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
1010

11+
// XFAIL: *
12+
1113
#include <vecintrin.h>
1214

1315
volatile vector signed long long vsl;

clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// RUN: -O2 -fzvector -flax-vector-conversions=none \
77
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
88

9+
// XFAIL: *
10+
911
#include <vecintrin.h>
1012

1113
volatile vector signed char vsc;

0 commit comments

Comments
 (0)