| From b0343a38a5910e980bb031e4014655d77cd0c162 Mon Sep 17 00:00:00 2001 |
| From: Daniel Kiss <daniel.kiss@arm.com> |
| Date: Wed, 13 Apr 2022 09:31:25 +0200 |
| Subject: [PATCH] Support the min of module flags when linking, use for AArch64 |
| BTI/PAC-RET |
| |
| LTO objects might compiled with different `mbranch-protection` flags which will cause an error in the linker. |
| Such a setup is allowed in the normal build with this change that is possible. |
| |
| Reviewed By: pcc |
| |
| Differential Revision: https://reviews.llvm.org/D123493 |
| --- |
| clang/lib/CodeGen/CodeGenModule.cpp | 13 ++++-- |
| .../CodeGen/aarch64-sign-return-address.c | 46 +++++++++---------- |
| .../CodeGen/arm-branch-protection-attr-2.c | 28 +++++------ |
| .../arm-ignore-branch-protection-option.c | 2 +- |
| llvm/include/llvm/IR/Module.h | 5 +- |
| llvm/lib/IR/AutoUpgrade.cpp | 18 ++++++++ |
| llvm/lib/IR/Verifier.cpp | 7 +++ |
| llvm/lib/Linker/IRMover.cpp | 29 +++++++++++- |
| .../test/Bitcode/upgrade-branch-protection.ll | 16 +++++++ |
| .../AArch64/debug-info-sve-dbg-declare.mir | 8 ++-- |
| .../CodeGen/AArch64/live-debugvalues-sve.mir | 8 ++-- |
| llvm/test/CodeGen/AArch64/memsize-remarks.ll | 8 ++-- |
| .../AArch64/note-gnu-property-pac-bti-0.ll | 8 ++-- |
| .../AArch64/note-gnu-property-pac-bti-1.ll | 8 ++-- |
| .../AArch64/note-gnu-property-pac-bti-2.ll | 8 ++-- |
| .../AArch64/note-gnu-property-pac-bti-3.ll | 8 ++-- |
| .../AArch64/note-gnu-property-pac-bti-4.ll | 8 ++-- |
| .../AArch64/pacbti-llvm-generated-funcs-2.ll | 8 ++-- |
| .../CodeGen/AArch64/pacbti-module-attrs.ll | 8 ++-- |
| llvm/test/CodeGen/ARM/pacbti-module-attrs.ll | 6 +-- |
| llvm/test/CodeGen/ARM/setjmp-bti-basic.ll | 2 +- |
| llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll | 2 +- |
| .../LowOverheadLoops/skip-vpt-debug.mir | 6 +-- |
| .../bti-const-island-multiple-jump-tables.mir | 2 +- |
| llvm/test/CodeGen/Thumb2/bti-const-island.mir | 2 +- |
| llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll | 2 +- |
| .../CodeGen/Thumb2/bti-indirect-branches.ll | 2 +- |
| llvm/test/CodeGen/Thumb2/bti-jump-table.mir | 2 +- |
| llvm/test/CodeGen/Thumb2/bti-outliner-1.ll | 2 +- |
| llvm/test/CodeGen/Thumb2/bti-outliner-2.ll | 2 +- |
| .../CodeGen/Thumb2/bti-outliner-cost-1.ll | 2 +- |
| .../CodeGen/Thumb2/bti-outliner-cost-2.ll | 2 +- |
| .../test/CodeGen/Thumb2/bti-pac-replace-1.mir | 6 +-- |
| llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll | 6 +-- |
| llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll | 6 +-- |
| .../Thumb2/pacbti-m-indirect-tail-call.ll | 6 +-- |
| .../CodeGen/Thumb2/pacbti-m-outliner-1.ll | 6 +-- |
| .../CodeGen/Thumb2/pacbti-m-outliner-2.ll | 6 +-- |
| .../CodeGen/Thumb2/pacbti-m-outliner-3.ll | 6 +-- |
| .../CodeGen/Thumb2/pacbti-m-outliner-4.ll | 6 +-- |
| .../CodeGen/Thumb2/pacbti-m-outliner-5.ll | 6 +-- |
| .../test/CodeGen/Thumb2/pacbti-m-overalign.ll | 6 +-- |
| .../Thumb2/pacbti-m-unsupported-arch.ll | 6 +-- |
| .../test/CodeGen/Thumb2/pacbti-m-varargs-1.ll | 6 +-- |
| .../test/CodeGen/Thumb2/pacbti-m-varargs-2.ll | 6 +-- |
| llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll | 6 +-- |
| .../AArch64/debugline-endsequence.ll | 8 ++-- |
| .../debug-info-correlate-coverage.ll | 8 ++-- |
| .../InstrProfiling/debug-info-correlate.ll | 8 ++-- |
| llvm/test/LTO/AArch64/Inputs/foo.ll | 16 +++++++ |
| .../AArch64/link-branch-target-enforcement.ll | 38 +++++++++++++++ |
| llvm/test/LTO/AArch64/lit.local.cfg | 2 + |
| llvm/test/Verifier/module-flags-1.ll | 6 ++- |
| 56 files changed, 294 insertions(+), 160 deletions(-) |
| create mode 100644 llvm/test/Bitcode/upgrade-branch-protection.ll |
| create mode 100644 llvm/test/LTO/AArch64/Inputs/foo.ll |
| create mode 100644 llvm/test/LTO/AArch64/link-branch-target-enforcement.ll |
| create mode 100644 llvm/test/LTO/AArch64/lit.local.cfg |
| |
| diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp |
| index 4efcc8447d81..b251a4a7df3d 100644 |
| --- a/clang/lib/CodeGen/CodeGenModule.cpp |
| +++ b/clang/lib/CodeGen/CodeGenModule.cpp |
| @@ -729,7 +729,10 @@ void CodeGenModule::Release() { |
| // attributes, but we use module metadata to emit build attributes. This is |
| // needed for LTO, where the function attributes are inside bitcode |
| // serialised into a global variable by the time build attributes are |
| - // emitted, so we can't access them. |
| + // emitted, so we can't access them. LTO objects could be compiled with |
| + // different flags therefore module flags are set to "Min" behavior to achieve |
| + // the same end result of the normal build where e.g BTI is off if any object |
| + // doesn't support it. |
| if (Context.getTargetInfo().hasFeature("ptrauth") && |
| LangOpts.getSignReturnAddressScope() != |
| LangOptions::SignReturnAddressScopeKind::None) |
| @@ -743,16 +746,16 @@ void CodeGenModule::Release() { |
| Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb || |
| Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_32 || |
| Arch == llvm::Triple::aarch64_be) { |
| - getModule().addModuleFlag(llvm::Module::Error, "branch-target-enforcement", |
| + getModule().addModuleFlag(llvm::Module::Min, "branch-target-enforcement", |
| LangOpts.BranchTargetEnforcement); |
| |
| - getModule().addModuleFlag(llvm::Module::Error, "sign-return-address", |
| + getModule().addModuleFlag(llvm::Module::Min, "sign-return-address", |
| LangOpts.hasSignReturnAddress()); |
| |
| - getModule().addModuleFlag(llvm::Module::Error, "sign-return-address-all", |
| + getModule().addModuleFlag(llvm::Module::Min, "sign-return-address-all", |
| LangOpts.isSignReturnAddressScopeAll()); |
| |
| - getModule().addModuleFlag(llvm::Module::Error, |
| + getModule().addModuleFlag(llvm::Module::Min, |
| "sign-return-address-with-bkey", |
| !LangOpts.isSignReturnAddressWithAKey()); |
| } |
| diff --git a/clang/test/CodeGen/aarch64-sign-return-address.c b/clang/test/CodeGen/aarch64-sign-return-address.c |
| index 7dd7231e824a..9812238dcded 100644 |
| --- a/clang/test/CodeGen/aarch64-sign-return-address.c |
| +++ b/clang/test/CodeGen/aarch64-sign-return-address.c |
| @@ -19,28 +19,28 @@ |
| |
| // Check module attributes |
| |
| -// NONE: !{i32 1, !"branch-target-enforcement", i32 0} |
| -// ALL: !{i32 1, !"branch-target-enforcement", i32 0} |
| -// PART: !{i32 1, !"branch-target-enforcement", i32 0} |
| -// BTE: !{i32 1, !"branch-target-enforcement", i32 1} |
| -// B-KEY: !{i32 1, !"branch-target-enforcement", i32 0} |
| - |
| -// NONE: !{i32 1, !"sign-return-address", i32 0} |
| -// ALL: !{i32 1, !"sign-return-address", i32 1} |
| -// PART: !{i32 1, !"sign-return-address", i32 1} |
| -// BTE: !{i32 1, !"sign-return-address", i32 0} |
| -// B-KEY: !{i32 1, !"sign-return-address", i32 1} |
| - |
| -// NONE: !{i32 1, !"sign-return-address-all", i32 0} |
| -// ALL: !{i32 1, !"sign-return-address-all", i32 1} |
| -// PART: !{i32 1, !"sign-return-address-all", i32 0} |
| -// BTE: !{i32 1, !"sign-return-address-all", i32 0} |
| -// B-KEY: !{i32 1, !"sign-return-address-all", i32 0} |
| - |
| -// NONE: !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| -// ALL: !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| -// PART: !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| -// BTE: !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| -// B-KEY: !{i32 1, !"sign-return-address-with-bkey", i32 1} |
| +// NONE: !{i32 8, !"branch-target-enforcement", i32 0} |
| +// ALL: !{i32 8, !"branch-target-enforcement", i32 0} |
| +// PART: !{i32 8, !"branch-target-enforcement", i32 0} |
| +// BTE: !{i32 8, !"branch-target-enforcement", i32 1} |
| +// B-KEY: !{i32 8, !"branch-target-enforcement", i32 0} |
| + |
| +// NONE: !{i32 8, !"sign-return-address", i32 0} |
| +// ALL: !{i32 8, !"sign-return-address", i32 1} |
| +// PART: !{i32 8, !"sign-return-address", i32 1} |
| +// BTE: !{i32 8, !"sign-return-address", i32 0} |
| +// B-KEY: !{i32 8, !"sign-return-address", i32 1} |
| + |
| +// NONE: !{i32 8, !"sign-return-address-all", i32 0} |
| +// ALL: !{i32 8, !"sign-return-address-all", i32 1} |
| +// PART: !{i32 8, !"sign-return-address-all", i32 0} |
| +// BTE: !{i32 8, !"sign-return-address-all", i32 0} |
| +// B-KEY: !{i32 8, !"sign-return-address-all", i32 0} |
| + |
| +// NONE: !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| +// ALL: !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| +// PART: !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| +// BTE: !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| +// B-KEY: !{i32 8, !"sign-return-address-with-bkey", i32 1} |
| |
| void foo() {} |
| diff --git a/clang/test/CodeGen/arm-branch-protection-attr-2.c b/clang/test/CodeGen/arm-branch-protection-attr-2.c |
| index 18a15b8534b5..963059441d76 100644 |
| --- a/clang/test/CodeGen/arm-branch-protection-attr-2.c |
| +++ b/clang/test/CodeGen/arm-branch-protection-attr-2.c |
| @@ -15,19 +15,19 @@ |
| |
| // Check module attributes |
| |
| -// NONE: !{i32 1, !"branch-target-enforcement", i32 0} |
| -// PART: !{i32 1, !"branch-target-enforcement", i32 0} |
| -// ALL: !{i32 1, !"branch-target-enforcement", i32 0} |
| -// BTE: !{i32 1, !"branch-target-enforcement", i32 1} |
| - |
| -// NONE: !{i32 1, !"sign-return-address", i32 0} |
| -// PART: !{i32 1, !"sign-return-address", i32 1} |
| -// ALL: !{i32 1, !"sign-return-address", i32 1} |
| -// BTE: !{i32 1, !"sign-return-address", i32 0} |
| - |
| -// NONE: !{i32 1, !"sign-return-address-all", i32 0} |
| -// PART: !{i32 1, !"sign-return-address-all", i32 0} |
| -// ALL: !{i32 1, !"sign-return-address-all", i32 1} |
| -// BTE: !{i32 1, !"sign-return-address-all", i32 0} |
| +// NONE: !{i32 8, !"branch-target-enforcement", i32 0} |
| +// PART: !{i32 8, !"branch-target-enforcement", i32 0} |
| +// ALL: !{i32 8, !"branch-target-enforcement", i32 0} |
| +// BTE: !{i32 8, !"branch-target-enforcement", i32 1} |
| + |
| +// NONE: !{i32 8, !"sign-return-address", i32 0} |
| +// PART: !{i32 8, !"sign-return-address", i32 1} |
| +// ALL: !{i32 8, !"sign-return-address", i32 1} |
| +// BTE: !{i32 8, !"sign-return-address", i32 0} |
| + |
| +// NONE: !{i32 8, !"sign-return-address-all", i32 0} |
| +// PART: !{i32 8, !"sign-return-address-all", i32 0} |
| +// ALL: !{i32 8, !"sign-return-address-all", i32 1} |
| +// BTE: !{i32 8, !"sign-return-address-all", i32 0} |
| |
| void foo() {} |
| diff --git a/clang/test/Frontend/arm-ignore-branch-protection-option.c b/clang/test/Frontend/arm-ignore-branch-protection-option.c |
| index 9a7c0aca25d3..99a2accef3ae 100644 |
| --- a/clang/test/Frontend/arm-ignore-branch-protection-option.c |
| +++ b/clang/test/Frontend/arm-ignore-branch-protection-option.c |
| @@ -15,4 +15,4 @@ __attribute__((target("arch=cortex-m0"))) void f() {} |
| // CHECK-NOT: attributes { {{.*}} "branch-target-enforcement" |
| |
| /// Check that there are branch protection module attributes despite the warning. |
| -// CHECK: !{i32 1, !"branch-target-enforcement", i32 1} |
| +// CHECK: !{i32 8, !"branch-target-enforcement", i32 1} |
| diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h |
| index 0414adfaee4d..6cad37f4fe0e 100644 |
| --- a/llvm/include/llvm/IR/Module.h |
| +++ b/llvm/include/llvm/IR/Module.h |
| @@ -146,9 +146,12 @@ public: |
| /// Takes the max of the two values, which are required to be integers. |
| Max = 7, |
| |
| + /// Takes the min of the two values, which are required to be integers. |
| + Min = 8, |
| + |
| // Markers: |
| ModFlagBehaviorFirstVal = Error, |
| - ModFlagBehaviorLastVal = Max |
| + ModFlagBehaviorLastVal = Min |
| }; |
| |
| /// Checks if Metadata represents a valid ModFlagBehavior, and stores the |
| diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp |
| index a8547354f77c..b268fad8cd30 100644 |
| --- a/llvm/lib/IR/AutoUpgrade.cpp |
| +++ b/llvm/lib/IR/AutoUpgrade.cpp |
| @@ -4388,6 +4388,24 @@ bool llvm::UpgradeModuleFlags(Module &M) { |
| } |
| } |
| } |
| + |
| + // Upgrade branch protection and return address signing module flags. The |
| + // module flag behavior for these fields were Error and now they are Min. |
| + if (ID->getString() == "branch-target-enforcement" || |
| + ID->getString().startswith("sign-return-address")) { |
| + if (auto *Behavior = |
| + mdconst::dyn_extract_or_null<ConstantInt>(Op->getOperand(0))) { |
| + if (Behavior->getLimitedValue() == Module::Error) { |
| + Type *Int32Ty = Type::getInt32Ty(M.getContext()); |
| + Metadata *Ops[3] = { |
| + ConstantAsMetadata::get(ConstantInt::get(Int32Ty, Module::Min)), |
| + Op->getOperand(1), Op->getOperand(2)}; |
| + ModFlags->setOperand(I, MDNode::get(M.getContext(), Ops)); |
| + Changed = true; |
| + } |
| + } |
| + } |
| + |
| // Upgrade Objective-C Image Info Section. Removed the whitespce in the |
| // section name so that llvm-lto will not complain about mismatching |
| // module flags that is functionally the same. |
| diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp |
| index dc7b97982317..09d47954c05e 100644 |
| --- a/llvm/lib/IR/Verifier.cpp |
| +++ b/llvm/lib/IR/Verifier.cpp |
| @@ -1623,6 +1623,13 @@ Verifier::visitModuleFlag(const MDNode *Op, |
| // These behavior types accept any value. |
| break; |
| |
| + case Module::Min: { |
| + Assert(mdconst::dyn_extract_or_null<ConstantInt>(Op->getOperand(2)), |
| + "invalid value for 'min' module flag (expected constant integer)", |
| + Op->getOperand(2)); |
| + break; |
| + } |
| + |
| case Module::Max: { |
| Assert(mdconst::dyn_extract_or_null<ConstantInt>(Op->getOperand(2)), |
| "invalid value for 'max' module flag (expected constant integer)", |
| diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp |
| index 1a5363d44af8..05b71d1f3cb8 100644 |
| --- a/llvm/lib/Linker/IRMover.cpp |
| +++ b/llvm/lib/Linker/IRMover.cpp |
| @@ -12,6 +12,7 @@ |
| #include "llvm/ADT/SmallPtrSet.h" |
| #include "llvm/ADT/SmallString.h" |
| #include "llvm/ADT/Triple.h" |
| +#include "llvm/IR/AutoUpgrade.h" |
| #include "llvm/IR/Constants.h" |
| #include "llvm/IR/DebugInfoMetadata.h" |
| #include "llvm/IR/DiagnosticPrinter.h" |
| @@ -1256,6 +1257,9 @@ Error IRLinker::linkModuleFlagsMetadata() { |
| if (!SrcModFlags) |
| return Error::success(); |
| |
| + // Check for module flag for updates before do anything. |
| + UpgradeModuleFlags(*SrcM); |
| + |
| // If the destination module doesn't have module flags yet, then just copy |
| // over the source module's flags. |
| NamedMDNode *DstModFlags = DstM.getOrInsertModuleFlagsMetadata(); |
| @@ -1338,11 +1342,15 @@ Error IRLinker::linkModuleFlagsMetadata() { |
| |
| // Diagnose inconsistent merge behavior types. |
| if (SrcBehaviorValue != DstBehaviorValue) { |
| + bool MinAndWarn = (SrcBehaviorValue == Module::Min && |
| + DstBehaviorValue == Module::Warning) || |
| + (DstBehaviorValue == Module::Min && |
| + SrcBehaviorValue == Module::Warning); |
| bool MaxAndWarn = (SrcBehaviorValue == Module::Max && |
| DstBehaviorValue == Module::Warning) || |
| (DstBehaviorValue == Module::Max && |
| SrcBehaviorValue == Module::Warning); |
| - if (!MaxAndWarn) |
| + if (!(MaxAndWarn || MinAndWarn)) |
| return stringErr("linking module flags '" + ID->getString() + |
| "': IDs have conflicting behaviors in '" + |
| SrcM->getModuleIdentifier() + "' and '" + |
| @@ -1371,6 +1379,25 @@ Error IRLinker::linkModuleFlagsMetadata() { |
| emitWarning(Str); |
| } |
| |
| + // Choose the minimum if either source or destination request Min behavior. |
| + if (DstBehaviorValue == Module::Min || SrcBehaviorValue == Module::Min) { |
| + ConstantInt *DstValue = |
| + mdconst::extract<ConstantInt>(DstOp->getOperand(2)); |
| + ConstantInt *SrcValue = |
| + mdconst::extract<ConstantInt>(SrcOp->getOperand(2)); |
| + |
| + // The resulting flag should have a Min behavior, and contain the minimum |
| + // value from between the source and destination values. |
| + Metadata *FlagOps[] = { |
| + (DstBehaviorValue != Module::Min ? SrcOp : DstOp)->getOperand(0), ID, |
| + (SrcValue->getZExtValue() < DstValue->getZExtValue() ? SrcOp : DstOp) |
| + ->getOperand(2)}; |
| + MDNode *Flag = MDNode::get(DstM.getContext(), FlagOps); |
| + DstModFlags->setOperand(DstIndex, Flag); |
| + Flags[ID].first = Flag; |
| + continue; |
| + } |
| + |
| // Choose the maximum if either source or destination request Max behavior. |
| if (DstBehaviorValue == Module::Max || SrcBehaviorValue == Module::Max) { |
| ConstantInt *DstValue = |
| diff --git a/llvm/test/Bitcode/upgrade-branch-protection.ll b/llvm/test/Bitcode/upgrade-branch-protection.ll |
| new file mode 100644 |
| index 000000000000..1b33e3901198 |
| --- /dev/null |
| +++ b/llvm/test/Bitcode/upgrade-branch-protection.ll |
| @@ -0,0 +1,16 @@ |
| +;; Test that module flags "branch-target-enforcement" and "sign-return-address" can be upgraded to |
| +;; are upgraded from Error to Min. |
| + |
| +; RUN: llvm-as %s -o - | llvm-dis - | FileCheck %s |
| + |
| +!llvm.module.flags = !{!0, !1, !2, !3} |
| + |
| +!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 1, !"sign-return-address", i32 1} |
| +!2 = !{i32 1, !"sign-return-address-all", i32 1} |
| +!3 = !{i32 1, !"sign-return-address-with-bkey", i32 1} |
| + |
| +;CHECK: !0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +;CHECK: !1 = !{i32 8, !"sign-return-address", i32 1} |
| +;CHECK: !2 = !{i32 8, !"sign-return-address-all", i32 1} |
| +;CHECK: !3 = !{i32 8, !"sign-return-address-with-bkey", i32 1} |
| \ No newline at end of file |
| diff --git a/llvm/test/CodeGen/AArch64/debug-info-sve-dbg-declare.mir b/llvm/test/CodeGen/AArch64/debug-info-sve-dbg-declare.mir |
| index 81b3c6d9092c..22cff36afaf7 100644 |
| --- a/llvm/test/CodeGen/AArch64/debug-info-sve-dbg-declare.mir |
| +++ b/llvm/test/CodeGen/AArch64/debug-info-sve-dbg-declare.mir |
| @@ -89,10 +89,10 @@ |
| !3 = !{i32 7, !"Dwarf Version", i32 4} |
| !4 = !{i32 2, !"Debug Info Version", i32 3} |
| !5 = !{i32 1, !"wchar_size", i32 4} |
| - !6 = !{i32 1, !"branch-target-enforcement", i32 0} |
| - !7 = !{i32 1, !"sign-return-address", i32 0} |
| - !8 = !{i32 1, !"sign-return-address-all", i32 0} |
| - !9 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| + !6 = !{i32 8, !"branch-target-enforcement", i32 0} |
| + !7 = !{i32 8, !"sign-return-address", i32 0} |
| + !8 = !{i32 8, !"sign-return-address-all", i32 0} |
| + !9 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| !10 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git b19275ba870a06c5ef0428af6264ffd28c7cde9e)"} |
| !11 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !12, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| !12 = !DISubroutineType(types: !13) |
| diff --git a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir |
| index fed32002847a..8903ca2b865b 100644 |
| --- a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir |
| +++ b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir |
| @@ -69,10 +69,10 @@ |
| !3 = !{i32 7, !"Dwarf Version", i32 4} |
| !4 = !{i32 2, !"Debug Info Version", i32 3} |
| !5 = !{i32 1, !"wchar_size", i32 4} |
| - !6 = !{i32 1, !"branch-target-enforcement", i32 0} |
| - !7 = !{i32 1, !"sign-return-address", i32 0} |
| - !8 = !{i32 1, !"sign-return-address-all", i32 0} |
| - !9 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| + !6 = !{i32 8, !"branch-target-enforcement", i32 0} |
| + !7 = !{i32 8, !"sign-return-address", i32 0} |
| + !8 = !{i32 8, !"sign-return-address-all", i32 0} |
| + !9 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| !10 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git b19275ba870a06c5ef0428af6264ffd28c7cde9e)"} |
| !11 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !12, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !26) |
| !12 = !DISubroutineType(types: !13) |
| diff --git a/llvm/test/CodeGen/AArch64/memsize-remarks.ll b/llvm/test/CodeGen/AArch64/memsize-remarks.ll |
| index 2d9ef520d570..dffbf0438ac0 100644 |
| --- a/llvm/test/CodeGen/AArch64/memsize-remarks.ll |
| +++ b/llvm/test/CodeGen/AArch64/memsize-remarks.ll |
| @@ -328,10 +328,10 @@ attributes #4 = { nounwind } |
| !0 = !{i32 2, !"SDK Version", [2 x i32] [i32 12, i32 0]} |
| !1 = !{i32 2, !"Debug Info Version", i32 3} |
| !2 = !{i32 1, !"wchar_size", i32 4} |
| -!3 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!4 = !{i32 1, !"sign-return-address", i32 0} |
| -!5 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!6 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!3 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!4 = !{i32 8, !"sign-return-address", i32 0} |
| +!5 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!6 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| !7 = !{i32 7, !"PIC Level", i32 2} |
| !8 = !{i32 7, !"uwtable", i32 1} |
| !9 = !{i32 7, !"frame-pointer", i32 1} |
| diff --git a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll |
| index b64fda769df9..c4b80c426050 100644 |
| --- a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll |
| +++ b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll |
| @@ -8,10 +8,10 @@ attributes #0 = { "branch-target-enforcement"="true" } |
| |
| !llvm.module.flags = !{!0, !1, !2, !3} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!3 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!3 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| |
| ; Both attributes present in a file with no functions. |
| ; ASM: .word 3221225472 |
| diff --git a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll |
| index 4996d8e66f7f..c5995caba941 100644 |
| --- a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll |
| +++ b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll |
| @@ -10,10 +10,10 @@ entry: |
| |
| !llvm.module.flags = !{!0, !1, !2, !3} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| -!1 = !{i32 1, !"sign-return-address", i32 0} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!3 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"sign-return-address", i32 0} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!3 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| |
| ; BTI attribute present |
| ; ASM: .word 3221225472 |
| diff --git a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll |
| index f765aeb5c417..f0dd522e6adf 100644 |
| --- a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll |
| +++ b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll |
| @@ -10,10 +10,10 @@ entry: |
| |
| !llvm.module.flags = !{!0, !1, !2, !3} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!3 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!3 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| |
| ; PAC attribute present |
| ; ASM: .word 3221225472 |
| diff --git a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll |
| index f5ef65b7b903..4bf6532cbe27 100644 |
| --- a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll |
| +++ b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll |
| @@ -10,10 +10,10 @@ entry: |
| |
| !llvm.module.flags = !{!0, !1, !2, !3} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!3 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!3 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| |
| ; Both attribute present |
| ; ASM: .word 3221225472 |
| diff --git a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll |
| index 67ad5f07080b..fff698d2152a 100644 |
| --- a/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll |
| +++ b/llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll |
| @@ -17,10 +17,10 @@ attributes #1 = { "branch-target-enforcement"="true" } |
| |
| !llvm.module.flags = !{!0, !1, !2, !3} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 0} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!3 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 0} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!3 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| |
| ; Note is not emited if module has no properties |
| ; ASM-NOT: .note.gnu.property |
| \ No newline at end of file |
| diff --git a/llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll b/llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll |
| index e8c659380f7c..3cb4505041f3 100644 |
| --- a/llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll |
| +++ b/llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll |
| @@ -65,7 +65,7 @@ attributes #2 = { nofree noinline norecurse nounwind writeonly } |
| |
| !0 = !{i32 2, !"Debug Info Version", i32 3} |
| !1 = !{i32 1, !"wchar_size", i32 4} |
| -!2 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!3 = !{i32 1, !"sign-return-address", i32 1} |
| -!4 = !{i32 1, !"sign-return-address-all", i32 1} |
| -!5 = !{i32 1, !"sign-return-address-with-bkey", i32 1} |
| +!2 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!3 = !{i32 8, !"sign-return-address", i32 1} |
| +!4 = !{i32 8, !"sign-return-address-all", i32 1} |
| +!5 = !{i32 8, !"sign-return-address-with-bkey", i32 1} |
| diff --git a/llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll b/llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll |
| index 27287bd1895e..ae2fe567f845 100644 |
| --- a/llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll |
| +++ b/llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll |
| @@ -71,7 +71,7 @@ attributes #5 = { nounwind } |
| !llvm.module.flags = !{!0, !1, !2, !3, !4} |
| |
| !0 = !{i32 1, !"wchar_size", i32 4} |
| -!1 = !{i32 1, !"branch-target-enforcement", i32 1} |
| -!2 = !{i32 1, !"sign-return-address", i32 1} |
| -!3 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!4 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!1 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!2 = !{i32 8, !"sign-return-address", i32 1} |
| +!3 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| diff --git a/llvm/test/CodeGen/ARM/pacbti-module-attrs.ll b/llvm/test/CodeGen/ARM/pacbti-module-attrs.ll |
| index e0dda1c80ae3..a2ea83241afa 100644 |
| --- a/llvm/test/CodeGen/ARM/pacbti-module-attrs.ll |
| +++ b/llvm/test/CodeGen/ARM/pacbti-module-attrs.ll |
| @@ -16,6 +16,6 @@ entry: |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| diff --git a/llvm/test/CodeGen/ARM/setjmp-bti-basic.ll b/llvm/test/CodeGen/ARM/setjmp-bti-basic.ll |
| index e18f87d82e6c..4c10cd6ebcbe 100644 |
| --- a/llvm/test/CodeGen/ARM/setjmp-bti-basic.ll |
| +++ b/llvm/test/CodeGen/ARM/setjmp-bti-basic.ll |
| @@ -47,4 +47,4 @@ attributes #0 = { returns_twice } |
| |
| !llvm.module.flags = !{!0} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| diff --git a/llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll b/llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll |
| index 20fd1768d607..c168eb2cdd2d 100644 |
| --- a/llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll |
| +++ b/llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll |
| @@ -89,4 +89,4 @@ attributes #0 = { returns_twice } |
| |
| !llvm.module.flags = !{!0} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| diff --git a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/skip-vpt-debug.mir b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/skip-vpt-debug.mir |
| index 6d0688432a5a..1bfe8f9d289c 100644 |
| --- a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/skip-vpt-debug.mir |
| +++ b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/skip-vpt-debug.mir |
| @@ -93,9 +93,9 @@ |
| !6 = !{i32 1, !"static_rwdata", i32 1} |
| !7 = !{i32 1, !"enumsize_buildattr", i32 2} |
| !8 = !{i32 1, !"armlib_unavailable", i32 0} |
| - !9 = !{i32 1, !"branch-target-enforcement", i32 0} |
| - !10 = !{i32 1, !"sign-return-address", i32 0} |
| - !11 = !{i32 1, !"sign-return-address-all", i32 0} |
| + !9 = !{i32 8, !"branch-target-enforcement", i32 0} |
| + !10 = !{i32 8, !"sign-return-address", i32 0} |
| + !11 = !{i32 8, !"sign-return-address-all", i32 0} |
| !12 = !{!"Component: ARM Compiler 6.17.0.0 (permissive) Tool: armclang [00000000]"} |
| !13 = distinct !DISubprogram(name: "arm_max_no_idx_f32", scope: !1, file: !1, line: 5, type: !14, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !23) |
| !14 = !DISubroutineType(types: !15) |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-const-island-multiple-jump-tables.mir b/llvm/test/CodeGen/Thumb2/bti-const-island-multiple-jump-tables.mir |
| index e565d34cbade..8298ed792a03 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-const-island-multiple-jump-tables.mir |
| +++ b/llvm/test/CodeGen/Thumb2/bti-const-island-multiple-jump-tables.mir |
| @@ -126,7 +126,7 @@ |
| |
| !llvm.module.flags = !{!0} |
| |
| - !0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| + !0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| |
| ... |
| --- |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-const-island.mir b/llvm/test/CodeGen/Thumb2/bti-const-island.mir |
| index 52ee5c8b1d04..a861e1e3deb4 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-const-island.mir |
| +++ b/llvm/test/CodeGen/Thumb2/bti-const-island.mir |
| @@ -43,7 +43,7 @@ |
| } |
| |
| !llvm.module.flags = !{!0} |
| - !0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| + !0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| |
| ... |
| --- |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll b/llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll |
| index ce673fe0e23b..1c89e60bc6a5 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll |
| +++ b/llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll |
| @@ -19,4 +19,4 @@ entry: |
| } |
| |
| !llvm.module.flags = !{!1} |
| -!1 = !{i32 1, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"branch-target-enforcement", i32 1} |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll b/llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll |
| index f56e3b67b1d0..bfff648980d6 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll |
| +++ b/llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll |
| @@ -132,4 +132,4 @@ return: |
| } |
| |
| !llvm.module.flags = !{!1} |
| -!1 = !{i32 1, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"branch-target-enforcement", i32 1} |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-jump-table.mir b/llvm/test/CodeGen/Thumb2/bti-jump-table.mir |
| index 22f255b98472..22e7a7711de7 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-jump-table.mir |
| +++ b/llvm/test/CodeGen/Thumb2/bti-jump-table.mir |
| @@ -28,7 +28,7 @@ |
| } |
| |
| !llvm.module.flags = !{!0} |
| - !0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| + !0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| |
| ... |
| --- |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-outliner-1.ll b/llvm/test/CodeGen/Thumb2/bti-outliner-1.ll |
| index 7cccfac31076..03bdf454b855 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-outliner-1.ll |
| +++ b/llvm/test/CodeGen/Thumb2/bti-outliner-1.ll |
| @@ -133,4 +133,4 @@ attributes #2 = { minsize nofree norecurse nounwind optsize "branch-target-enfor |
| |
| !llvm.module.flags = !{!0} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-outliner-2.ll b/llvm/test/CodeGen/Thumb2/bti-outliner-2.ll |
| index b0d03d575bc5..f5d2d393040c 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-outliner-2.ll |
| +++ b/llvm/test/CodeGen/Thumb2/bti-outliner-2.ll |
| @@ -79,4 +79,4 @@ attributes #2 = { minsize nofree norecurse nounwind optsize "branch-target-enfor |
| |
| !llvm.module.flags = !{!0} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-outliner-cost-1.ll b/llvm/test/CodeGen/Thumb2/bti-outliner-cost-1.ll |
| index 3c800ad85a28..85358e694e20 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-outliner-cost-1.ll |
| +++ b/llvm/test/CodeGen/Thumb2/bti-outliner-cost-1.ll |
| @@ -64,4 +64,4 @@ attributes #0 = { minsize nofree norecurse nounwind optsize } |
| |
| !llvm.module.flags = !{!0} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll b/llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll |
| index 2cb6e2c5b5c1..376dc3a31068 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll |
| +++ b/llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll |
| @@ -48,4 +48,4 @@ attributes #0 = { minsize nofree norecurse nounwind optsize } |
| |
| !llvm.module.flags = !{!0} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir b/llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir |
| index 277679908aa4..609dc72e258f 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir |
| +++ b/llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir |
| @@ -15,9 +15,9 @@ |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| - !0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| - !1 = !{i32 1, !"sign-return-address", i32 1} |
| - !2 = !{i32 1, !"sign-return-address-all", i32 0} |
| + !0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| + !1 = !{i32 8, !"sign-return-address", i32 1} |
| + !2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| ... |
| --- |
| diff --git a/llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll b/llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll |
| index 630ae856560b..ee497433551f 100644 |
| --- a/llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll |
| +++ b/llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll |
| @@ -14,9 +14,9 @@ entry: |
| declare dso_local i32 @_Z1gi(i32) |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| ; Check the function starts with `pacbti` and correct unwind info is emitted |
| ; CHECK-LABEL: _Z1fi: |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll |
| index d4be44edbcec..0376d2164bd0 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll |
| @@ -97,9 +97,9 @@ attributes #1 = { "cmse_nonsecure_entry" "target-features"="+8msecext,+armv8-m.m |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| ; UNWIND-LABEL: FunctionAddress: 0x0 |
| ; UNWIND: 0x00 ; vsp = vsp + 4 |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll |
| index 1feb74cbfb82..98a5eb5b98aa 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll |
| @@ -32,6 +32,6 @@ attributes #0 = { nounwind } |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll |
| index 84983411e86c..ce22d4eb632b 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll |
| @@ -120,9 +120,9 @@ attributes #0 = { minsize nofree norecurse nounwind optsize uwtable} |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| ; UNWIND-LABEL: FunctionAddress: 0x0 |
| ; UNWIND: 0xB4 ; pop ra_auth_code |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-2.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-2.ll |
| index a346bb4391ad..b2c631ee3cbb 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-2.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-2.ll |
| @@ -84,6 +84,6 @@ attributes #0 = { minsize nofree norecurse nounwind optsize} |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll |
| index edbae593ee84..5e55c9aa15f5 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll |
| @@ -138,9 +138,9 @@ attributes #0 = { minsize noinline norecurse nounwind optsize readnone uwtable } |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| |
| ; UNWIND-LABEL: FunctionAddress: 0x4 |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll |
| index fa7337561ab8..b1768863b764 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll |
| @@ -172,9 +172,9 @@ attributes #2 = { noreturn } |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| |
| ; UNWIND-LABEL: FunctionAddress: 0x0 |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll |
| index b7a475ad6ab8..d1fdbee0cf29 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll |
| @@ -93,6 +93,6 @@ attributes #1 = { minsize nofree norecurse nounwind optsize "sign-return-address |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll |
| index 111f2de8a608..1f3626585209 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll |
| @@ -60,9 +60,9 @@ declare dso_local i32 @_Z1giPi(i32, i32*) local_unnamed_addr |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| ; UNWIND-LABEL: FunctionAddress: 0x0 |
| ; UNWIND: 0x97 ; vsp = r7 |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll |
| index 0af18a9f62ca..979292a5b1f2 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll |
| @@ -26,6 +26,6 @@ attributes #0 = { noinline nounwind } |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll |
| index 89a1e139a658..87c9e41acd6e 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll |
| @@ -72,6 +72,6 @@ attributes #1 = { nounwind } |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll |
| index ef0912ed68ac..e6069f6a1c90 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll |
| @@ -90,9 +90,9 @@ attributes #1 = { nounwind } |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| |
| ; UNWIND-LABEL: FunctionAddress |
| ; UNWIND: 0x01 ; vsp = vsp + 8 |
| diff --git a/llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll b/llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll |
| index b1881ee4d67c..898410de1520 100644 |
| --- a/llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll |
| +++ b/llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll |
| @@ -120,6 +120,6 @@ attributes #0 = { nounwind } |
| |
| !llvm.module.flags = !{!0, !1, !2} |
| |
| -!0 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!1 = !{i32 1, !"sign-return-address", i32 1} |
| -!2 = !{i32 1, !"sign-return-address-all", i32 0} |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| diff --git a/llvm/test/DebugInfo/AArch64/debugline-endsequence.ll b/llvm/test/DebugInfo/AArch64/debugline-endsequence.ll |
| index a6722788ec64..82b774366425 100644 |
| --- a/llvm/test/DebugInfo/AArch64/debugline-endsequence.ll |
| +++ b/llvm/test/DebugInfo/AArch64/debugline-endsequence.ll |
| @@ -46,10 +46,10 @@ define void @f4() !dbg !19 { |
| !7 = !{i32 7, !"Dwarf Version", i32 4} |
| !8 = !{i32 2, !"Debug Info Version", i32 3} |
| !9 = !{i32 1, !"wchar_size", i32 4} |
| -!10 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!11 = !{i32 1, !"sign-return-address", i32 0} |
| -!12 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!13 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!10 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!11 = !{i32 8, !"sign-return-address", i32 0} |
| +!12 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!13 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| !14 = !{i32 7, !"PIC Level", i32 2} |
| !15 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 1, type: !16, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| !16 = !DISubroutineType(types: !17) |
| diff --git a/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll b/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll |
| index f5d7a069c316..7ac788e0c861 100644 |
| --- a/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll |
| +++ b/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll |
| @@ -20,10 +20,10 @@ declare void @llvm.instrprof.cover(i8*, i64, i32, i32) |
| !2 = !{i32 7, !"Dwarf Version", i32 4} |
| !3 = !{i32 2, !"Debug Info Version", i32 3} |
| !4 = !{i32 1, !"wchar_size", i32 4} |
| -!5 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!6 = !{i32 1, !"sign-return-address", i32 0} |
| -!7 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!8 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!5 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!6 = !{i32 8, !"sign-return-address", i32 0} |
| +!7 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!8 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| !9 = !{i32 7, !"uwtable", i32 1} |
| !10 = !{i32 7, !"frame-pointer", i32 1} |
| !11 = !{!"clang version 14.0.0"} |
| diff --git a/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll b/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll |
| index 421bf96b6e73..64102ab4374f 100644 |
| --- a/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll |
| +++ b/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll |
| @@ -34,10 +34,10 @@ declare void @llvm.instrprof.increment(i8*, i64, i32, i32) |
| !2 = !{i32 7, !"Dwarf Version", i32 4} |
| !3 = !{i32 2, !"Debug Info Version", i32 3} |
| !4 = !{i32 1, !"wchar_size", i32 4} |
| -!5 = !{i32 1, !"branch-target-enforcement", i32 0} |
| -!6 = !{i32 1, !"sign-return-address", i32 0} |
| -!7 = !{i32 1, !"sign-return-address-all", i32 0} |
| -!8 = !{i32 1, !"sign-return-address-with-bkey", i32 0} |
| +!5 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!6 = !{i32 8, !"sign-return-address", i32 0} |
| +!7 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!8 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| !9 = !{i32 7, !"uwtable", i32 1} |
| !10 = !{i32 7, !"frame-pointer", i32 1} |
| !11 = !{!"clang version 14.0.0"} |
| diff --git a/llvm/test/LTO/AArch64/Inputs/foo.ll b/llvm/test/LTO/AArch64/Inputs/foo.ll |
| new file mode 100644 |
| index 000000000000..961b0d4e7997 |
| --- /dev/null |
| +++ b/llvm/test/LTO/AArch64/Inputs/foo.ll |
| @@ -0,0 +1,16 @@ |
| +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" |
| +target triple = "aarch64-unknown-linux-gnu" |
| + |
| +define dso_local i32 @foo() #0 { |
| +entry: |
| + ret i32 42 |
| +} |
| + |
| +attributes #0 = { noinline nounwind optnone uwtable } |
| + |
| +!llvm.module.flags = !{!0, !1, !2, !3} |
| + |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 1} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 1} |
| +!3 = !{i32 8, !"sign-return-address-with-bkey", i32 1} |
| diff --git a/llvm/test/LTO/AArch64/link-branch-target-enforcement.ll b/llvm/test/LTO/AArch64/link-branch-target-enforcement.ll |
| new file mode 100644 |
| index 000000000000..ccf8cf67ede6 |
| --- /dev/null |
| +++ b/llvm/test/LTO/AArch64/link-branch-target-enforcement.ll |
| @@ -0,0 +1,38 @@ |
| +; Testcase to check that module with different branch-target-enforcement can |
| +; be mixed. |
| +; |
| +; RUN: llvm-as %s -o %t1.bc |
| +; RUN: llvm-as %p/Inputs/foo.ll -o %t2.bc |
| +; RUN: llvm-lto -exported-symbol main \ |
| +; RUN: -exported-symbol foo \ |
| +; RUN: -filetype=obj \ |
| +; RUN: %t1.bc %t2.bc \ |
| +; RUN: -o %t1.exe 2>&1 | FileCheck --allow-empty %s |
| +; RUN: llvm-objdump -d %t1.exe | FileCheck --check-prefix=CHECK-DUMP %s |
| +; RUN: llvm-readelf -n %t1.exe | FileCheck --check-prefix=CHECK-PROP %s |
| + |
| +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" |
| +target triple = "aarch64-unknown-linux-gnu" |
| + |
| +declare i32 @foo(); |
| + |
| +define i32 @main() { |
| +entry: |
| + %add = call i32 @foo() |
| + ret i32 %add |
| +} |
| + |
| +!llvm.module.flags = !{!0, !1, !2, !3 } |
| +!0 = !{i32 8, !"branch-target-enforcement", i32 0} |
| +!1 = !{i32 8, !"sign-return-address", i32 1} |
| +!2 = !{i32 8, !"sign-return-address-all", i32 0} |
| +!3 = !{i32 8, !"sign-return-address-with-bkey", i32 0} |
| + |
| +; CHECK-NOT: linking module flags 'branch-target-enforcement': IDs have conflicting values in |
| +; CHECK-DUMP: <main>: |
| +; CHECK-DUMP: bl 0x8 <main+0x8> |
| +; CHECK-DUMP: <foo>: |
| + |
| +; `main` doesn't support BTI while `foo` does, so in the binary |
| +; we should see only PAC which is supported by both. |
| +; CHECK-PROP: Properties: aarch64 feature: PAC |
| \ No newline at end of file |
| diff --git a/llvm/test/LTO/AArch64/lit.local.cfg b/llvm/test/LTO/AArch64/lit.local.cfg |
| new file mode 100644 |
| index 000000000000..304f2436ece1 |
| --- /dev/null |
| +++ b/llvm/test/LTO/AArch64/lit.local.cfg |
| @@ -0,0 +1,2 @@ |
| +if not 'AArch64' in config.root.targets: |
| + config.unsupported = True |
| diff --git a/llvm/test/Verifier/module-flags-1.ll b/llvm/test/Verifier/module-flags-1.ll |
| index ff82c2845235..a3e50c59f18e 100644 |
| --- a/llvm/test/Verifier/module-flags-1.ll |
| +++ b/llvm/test/Verifier/module-flags-1.ll |
| @@ -45,6 +45,10 @@ |
| ; CHECK: invalid value for 'max' module flag (expected constant integer) |
| !19 = !{i32 7, !"max", !"max"} |
| |
| +; Check that any 'min' module flags are valid. |
| +; CHECK: invalid value for 'min' module flag (expected constant integer) |
| +!20 = !{i32 8, !"min", !"min"} |
| + |
| ; Check that any 'require' module flags are valid. |
| ; CHECK: invalid requirement on flag, flag is not present in module |
| !11 = !{i32 3, !"bar", !{!"no-such-flag", i32 52}} |
| @@ -58,4 +62,4 @@ |
| |
| !llvm.module.flags = !{ |
| !0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, |
| - !16, !17, !18, !19 } |
| + !16, !17, !18, !19, !20 } |
| -- |
| 2.35.1.1178.g4f1659d476-goog |
| |