[llvm-branch-commits] [llvm] [LoongArch] Optimize vector bitreverse using scalar bitrev and vshuf4i (PR #118054)
https://github.com/SixWeining approved this pull request. https://github.com/llvm/llvm-project/pull/118054 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/19.x: [SCEV] Do not allow refinement in the rewriting of BEValue (#117152) (PR #118216)
llvmbot wrote: @llvm/pr-subscribers-llvm-analysis Author: Yingwei Zheng (dtcxzyw) Changes Backport https://github.com/llvm/llvm-project/commit/f7ef0721d60f85e1f699f8d1b83d4402ae19b122 --- Full diff: https://github.com/llvm/llvm-project/pull/118216.diff 5 Files Affected: - (modified) llvm/include/llvm/Analysis/ScalarEvolution.h (+6) - (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+34-13) - (added) llvm/test/Analysis/ScalarEvolution/pr117133.ll (+94) - (added) llvm/test/Transforms/IndVarSimplify/pr117133.ll (+44) - (modified) llvm/test/Transforms/LoopVectorize/trip-count-expansion-may-introduce-ub.ll (+6-4) ``diff diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index d9bfca763819f1..6d64154af59731 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -2132,6 +2132,12 @@ class ScalarEvolution { bool isGuaranteedToTransferExecutionTo(const Instruction *A, const Instruction *B); + /// Returns true if \p Op is guaranteed not to cause immediate UB. + bool isGuaranteedNotToCauseUB(const SCEV *Op); + + /// Returns true if \p Op is guaranteed to not be poison. + static bool isGuaranteedNotToBePoison(const SCEV *Op); + /// Return true if the SCEV corresponding to \p I is never poison. Proving /// this is more complex than proving that just \p I is never poison, since /// SCEV commons expressions across control flow, and you can have cases diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 412cfe73d3e559..cd272b34aab100 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -4217,7 +4217,7 @@ bool ScalarEvolution::canReuseInstruction( // Either the value can't be poison, or the S would also be poison if it // is. -if (PoisonVals.contains(V) || isGuaranteedNotToBePoison(V)) +if (PoisonVals.contains(V) || ::isGuaranteedNotToBePoison(V)) continue; auto *I = dyn_cast(V); @@ -4320,6 +4320,8 @@ ScalarEvolution::getSequentialMinMaxExpr(SCEVTypes Kind, } for (unsigned i = 1, e = Ops.size(); i != e; ++i) { +if (!isGuaranteedNotToCauseUB(Ops[i])) + continue; // We can replace %x umin_seq %y with %x umin %y if either: // * %y being poison implies %x is also poison. // * %x cannot be the saturating value (e.g. zero for umin). @@ -5936,18 +5938,22 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { // We can generalize this saying that i is the shifted value of BEValue // by one iteration: // PHI(f(0), f({1,+,1})) --> f({0,+,1}) -const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this); -const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false); -if (Shifted != getCouldNotCompute() && -Start != getCouldNotCompute()) { - const SCEV *StartVal = getSCEV(StartValueV); - if (Start == StartVal) { -// Okay, for the entire analysis of this edge we assumed the PHI -// to be symbolic. We now need to go back and purge all of the -// entries for the scalars that use the symbolic expression. -forgetMemoizedResults(SymbolicName); -insertValueToMap(PN, Shifted); -return Shifted; + +// Do not allow refinement in rewriting of BEValue. +if (isGuaranteedNotToCauseUB(BEValue)) { + const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this); + const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false); + if (Shifted != getCouldNotCompute() && Start != getCouldNotCompute() && + ::impliesPoison(BEValue, Start)) { +const SCEV *StartVal = getSCEV(StartValueV); +if (Start == StartVal) { + // Okay, for the entire analysis of this edge we assumed the PHI + // to be symbolic. We now need to go back and purge all of the + // entries for the scalars that use the symbolic expression. + forgetMemoizedResults(SymbolicName); + insertValueToMap(PN, Shifted); + return Shifted; +} } } } @@ -7319,6 +7325,21 @@ bool ScalarEvolution::isGuaranteedToTransferExecutionTo(const Instruction *A, return false; } +bool ScalarEvolution::isGuaranteedNotToBePoison(const SCEV *Op) { + SCEVPoisonCollector PC(/* LookThroughMaybePoisonBlocking */ true); + visitAll(Op, PC); + return PC.MaybePoison.empty(); +} + +bool ScalarEvolution::isGuaranteedNotToCauseUB(const SCEV *Op) { + return !SCEVExprContains(Op, [this](const SCEV *S) { +auto *UDiv = dyn_cast(S); +// The UDiv may be UB if the divisor is poison or zero. Unless the divisor +// is a non-zero constant, we have to assume the UDiv may be UB. +return UDiv && (!isKnownNonZero(UDiv->getOperand(1)) || +!isGuaranteedNotToBePoison(UDiv->getOperand(1))
[llvm-branch-commits] [llvm] release/19.x: [SCEV] Do not allow refinement in the rewriting of BEValue (#117152) (PR #118216)
https://github.com/dtcxzyw created https://github.com/llvm/llvm-project/pull/118216 Backport https://github.com/llvm/llvm-project/commit/f7ef0721d60f85e1f699f8d1b83d4402ae19b122 >From 6f08a0f1eb21de59f1c9cb2b8c86597d43e23b31 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Sun, 1 Dec 2024 22:18:46 +0800 Subject: [PATCH] release/19.x: [SCEV] Do not allow refinement in the rewriting of BEValue (#117152) --- llvm/include/llvm/Analysis/ScalarEvolution.h | 6 ++ llvm/lib/Analysis/ScalarEvolution.cpp | 47 +++--- .../test/Analysis/ScalarEvolution/pr117133.ll | 94 +++ .../Transforms/IndVarSimplify/pr117133.ll | 44 + .../trip-count-expansion-may-introduce-ub.ll | 10 +- 5 files changed, 184 insertions(+), 17 deletions(-) create mode 100644 llvm/test/Analysis/ScalarEvolution/pr117133.ll create mode 100644 llvm/test/Transforms/IndVarSimplify/pr117133.ll diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index d9bfca763819f1..6d64154af59731 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -2132,6 +2132,12 @@ class ScalarEvolution { bool isGuaranteedToTransferExecutionTo(const Instruction *A, const Instruction *B); + /// Returns true if \p Op is guaranteed not to cause immediate UB. + bool isGuaranteedNotToCauseUB(const SCEV *Op); + + /// Returns true if \p Op is guaranteed to not be poison. + static bool isGuaranteedNotToBePoison(const SCEV *Op); + /// Return true if the SCEV corresponding to \p I is never poison. Proving /// this is more complex than proving that just \p I is never poison, since /// SCEV commons expressions across control flow, and you can have cases diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 412cfe73d3e559..cd272b34aab100 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -4217,7 +4217,7 @@ bool ScalarEvolution::canReuseInstruction( // Either the value can't be poison, or the S would also be poison if it // is. -if (PoisonVals.contains(V) || isGuaranteedNotToBePoison(V)) +if (PoisonVals.contains(V) || ::isGuaranteedNotToBePoison(V)) continue; auto *I = dyn_cast(V); @@ -4320,6 +4320,8 @@ ScalarEvolution::getSequentialMinMaxExpr(SCEVTypes Kind, } for (unsigned i = 1, e = Ops.size(); i != e; ++i) { +if (!isGuaranteedNotToCauseUB(Ops[i])) + continue; // We can replace %x umin_seq %y with %x umin %y if either: // * %y being poison implies %x is also poison. // * %x cannot be the saturating value (e.g. zero for umin). @@ -5936,18 +5938,22 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { // We can generalize this saying that i is the shifted value of BEValue // by one iteration: // PHI(f(0), f({1,+,1})) --> f({0,+,1}) -const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this); -const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false); -if (Shifted != getCouldNotCompute() && -Start != getCouldNotCompute()) { - const SCEV *StartVal = getSCEV(StartValueV); - if (Start == StartVal) { -// Okay, for the entire analysis of this edge we assumed the PHI -// to be symbolic. We now need to go back and purge all of the -// entries for the scalars that use the symbolic expression. -forgetMemoizedResults(SymbolicName); -insertValueToMap(PN, Shifted); -return Shifted; + +// Do not allow refinement in rewriting of BEValue. +if (isGuaranteedNotToCauseUB(BEValue)) { + const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this); + const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false); + if (Shifted != getCouldNotCompute() && Start != getCouldNotCompute() && + ::impliesPoison(BEValue, Start)) { +const SCEV *StartVal = getSCEV(StartValueV); +if (Start == StartVal) { + // Okay, for the entire analysis of this edge we assumed the PHI + // to be symbolic. We now need to go back and purge all of the + // entries for the scalars that use the symbolic expression. + forgetMemoizedResults(SymbolicName); + insertValueToMap(PN, Shifted); + return Shifted; +} } } } @@ -7319,6 +7325,21 @@ bool ScalarEvolution::isGuaranteedToTransferExecutionTo(const Instruction *A, return false; } +bool ScalarEvolution::isGuaranteedNotToBePoison(const SCEV *Op) { + SCEVPoisonCollector PC(/* LookThroughMaybePoisonBlocking */ true); + visitAll(Op, PC); + return PC.MaybePoison.empty(); +} + +bool ScalarEvolution::isGuaranteedNotToCauseUB(const SCEV *Op) { + return !SCEVExprContains(Op, [this](const SCEV *S) { +auto *UDiv = dyn_cast(S); +// The UDiv ma
[llvm-branch-commits] [llvm] release/19.x: [SCEV] Do not allow refinement in the rewriting of BEValue (#117152) (PR #118216)
llvmbot wrote: @llvm/pr-subscribers-llvm-transforms Author: Yingwei Zheng (dtcxzyw) Changes Backport https://github.com/llvm/llvm-project/commit/f7ef0721d60f85e1f699f8d1b83d4402ae19b122 --- Full diff: https://github.com/llvm/llvm-project/pull/118216.diff 5 Files Affected: - (modified) llvm/include/llvm/Analysis/ScalarEvolution.h (+6) - (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+34-13) - (added) llvm/test/Analysis/ScalarEvolution/pr117133.ll (+94) - (added) llvm/test/Transforms/IndVarSimplify/pr117133.ll (+44) - (modified) llvm/test/Transforms/LoopVectorize/trip-count-expansion-may-introduce-ub.ll (+6-4) ``diff diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index d9bfca763819f1..6d64154af59731 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -2132,6 +2132,12 @@ class ScalarEvolution { bool isGuaranteedToTransferExecutionTo(const Instruction *A, const Instruction *B); + /// Returns true if \p Op is guaranteed not to cause immediate UB. + bool isGuaranteedNotToCauseUB(const SCEV *Op); + + /// Returns true if \p Op is guaranteed to not be poison. + static bool isGuaranteedNotToBePoison(const SCEV *Op); + /// Return true if the SCEV corresponding to \p I is never poison. Proving /// this is more complex than proving that just \p I is never poison, since /// SCEV commons expressions across control flow, and you can have cases diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 412cfe73d3e559..cd272b34aab100 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -4217,7 +4217,7 @@ bool ScalarEvolution::canReuseInstruction( // Either the value can't be poison, or the S would also be poison if it // is. -if (PoisonVals.contains(V) || isGuaranteedNotToBePoison(V)) +if (PoisonVals.contains(V) || ::isGuaranteedNotToBePoison(V)) continue; auto *I = dyn_cast(V); @@ -4320,6 +4320,8 @@ ScalarEvolution::getSequentialMinMaxExpr(SCEVTypes Kind, } for (unsigned i = 1, e = Ops.size(); i != e; ++i) { +if (!isGuaranteedNotToCauseUB(Ops[i])) + continue; // We can replace %x umin_seq %y with %x umin %y if either: // * %y being poison implies %x is also poison. // * %x cannot be the saturating value (e.g. zero for umin). @@ -5936,18 +5938,22 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { // We can generalize this saying that i is the shifted value of BEValue // by one iteration: // PHI(f(0), f({1,+,1})) --> f({0,+,1}) -const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this); -const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false); -if (Shifted != getCouldNotCompute() && -Start != getCouldNotCompute()) { - const SCEV *StartVal = getSCEV(StartValueV); - if (Start == StartVal) { -// Okay, for the entire analysis of this edge we assumed the PHI -// to be symbolic. We now need to go back and purge all of the -// entries for the scalars that use the symbolic expression. -forgetMemoizedResults(SymbolicName); -insertValueToMap(PN, Shifted); -return Shifted; + +// Do not allow refinement in rewriting of BEValue. +if (isGuaranteedNotToCauseUB(BEValue)) { + const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this); + const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false); + if (Shifted != getCouldNotCompute() && Start != getCouldNotCompute() && + ::impliesPoison(BEValue, Start)) { +const SCEV *StartVal = getSCEV(StartValueV); +if (Start == StartVal) { + // Okay, for the entire analysis of this edge we assumed the PHI + // to be symbolic. We now need to go back and purge all of the + // entries for the scalars that use the symbolic expression. + forgetMemoizedResults(SymbolicName); + insertValueToMap(PN, Shifted); + return Shifted; +} } } } @@ -7319,6 +7325,21 @@ bool ScalarEvolution::isGuaranteedToTransferExecutionTo(const Instruction *A, return false; } +bool ScalarEvolution::isGuaranteedNotToBePoison(const SCEV *Op) { + SCEVPoisonCollector PC(/* LookThroughMaybePoisonBlocking */ true); + visitAll(Op, PC); + return PC.MaybePoison.empty(); +} + +bool ScalarEvolution::isGuaranteedNotToCauseUB(const SCEV *Op) { + return !SCEVExprContains(Op, [this](const SCEV *S) { +auto *UDiv = dyn_cast(S); +// The UDiv may be UB if the divisor is poison or zero. Unless the divisor +// is a non-zero constant, we have to assume the UDiv may be UB. +return UDiv && (!isKnownNonZero(UDiv->getOperand(1)) || +!isGuaranteedNotToBePoison(UDiv->getOperand(1
[llvm-branch-commits] [lld] [PAC][lld][AArch64][ELF] Support signed TLSDESC (PR #113817)
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113817 >From a3cb7c88370a9aea7f276ebd39a548ff64abf6cc Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Fri, 25 Oct 2024 12:32:27 +0300 Subject: [PATCH 1/7] [PAC][lld][AArch64][ELF] Support signed TLSDESC Support `R_AARCH64_AUTH_TLSDESC_ADR_PAGE21`, `R_AARCH64_AUTH_TLSDESC_LD64_LO12` and `R_AARCH64_AUTH_TLSDESC_LD64_LO12` static TLSDESC relocations. --- lld/ELF/Arch/AArch64.cpp | 8 ++ lld/ELF/InputSection.cpp | 2 + lld/ELF/Relocations.cpp | 38 +++- lld/ELF/Relocations.h| 4 + lld/ELF/Symbols.h| 1 + lld/ELF/SyntheticSections.cpp| 5 + lld/test/ELF/aarch64-tlsdesc-pauth.s | 134 +++ 7 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 lld/test/ELF/aarch64-tlsdesc-pauth.s diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index fd85448e8b7a96..bbf3bf0f3dede5 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -157,9 +157,14 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, return R_AARCH64_AUTH; case R_AARCH64_TLSDESC_ADR_PAGE21: return R_AARCH64_TLSDESC_PAGE; + case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: +return R_AARCH64_AUTH_TLSDESC_PAGE; case R_AARCH64_TLSDESC_LD64_LO12: case R_AARCH64_TLSDESC_ADD_LO12: return R_TLSDESC; + case R_AARCH64_AUTH_TLSDESC_LD64_LO12: + case R_AARCH64_AUTH_TLSDESC_ADD_LO12: +return RelExpr::R_AARCH64_AUTH_TLSDESC; case R_AARCH64_TLSDESC_CALL: return R_TLSDESC_CALL; case R_AARCH64_TLSLE_ADD_TPREL_HI12: @@ -542,6 +547,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, case R_AARCH64_ADR_PREL_PG_HI21: case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: case R_AARCH64_TLSDESC_ADR_PAGE21: + case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: checkInt(ctx, loc, val, 33, rel); [[fallthrough]]; case R_AARCH64_ADR_PREL_PG_HI21_NC: @@ -592,6 +598,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: case R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC: case R_AARCH64_TLSDESC_LD64_LO12: + case R_AARCH64_AUTH_TLSDESC_LD64_LO12: checkAlignment(ctx, loc, val, 8, rel); write32Imm12(loc, getBits(val, 3, 11)); break; @@ -666,6 +673,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, break; case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: case R_AARCH64_TLSDESC_ADD_LO12: + case R_AARCH64_AUTH_TLSDESC_ADD_LO12: write32Imm12(loc, val); break; case R_AARCH64_TLSDESC: diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index ba7cdf106fe7cf..4ea6a3488af8c8 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -971,12 +971,14 @@ uint64_t InputSectionBase::getRelocTargetVA(Ctx &ctx, const Relocation &r, case R_SIZE: return r.sym->getSize() + a; case R_TLSDESC: + case RelExpr::R_AARCH64_AUTH_TLSDESC: return ctx.in.got->getTlsDescAddr(*r.sym) + a; case R_TLSDESC_PC: return ctx.in.got->getTlsDescAddr(*r.sym) + a - p; case R_TLSDESC_GOTPLT: return ctx.in.got->getTlsDescAddr(*r.sym) + a - ctx.in.gotPlt->getVA(); case R_AARCH64_TLSDESC_PAGE: + case R_AARCH64_AUTH_TLSDESC_PAGE: return getAArch64Page(ctx.in.got->getTlsDescAddr(*r.sym) + a) - getAArch64Page(p); case R_LOONGARCH_TLSDESC_PAGE_PC: diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 0a092737bd0e5f..262d2d74301c41 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -1341,6 +1341,36 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type, return 1; } + auto fatalBothAuthAndNonAuth = [&sym]() { +fatal("both AUTH and non-AUTH TLSDESC entries for '" + sym.getName() + + "' requested, but only one type of TLSDESC entry per symbol is " + "supported"); + }; + + // Do not optimize signed TLSDESC as described in pauthabielf64 to LE/IE. + // https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#general-restrictions + // > PAUTHELF64 only supports the descriptor based TLS (TLSDESC). + if (oneof( + expr)) { +assert(ctx.arg.emachine == EM_AARCH64); +if (!sym.hasFlag(NEEDS_TLSDESC)) + sym.setFlags(NEEDS_TLSDESC | NEEDS_TLSDESC_AUTH); +else if (!sym.hasFlag(NEEDS_TLSDESC_AUTH)) + fatalBothAuthAndNonAuth(); +sec->addReloc({expr, type, offset, addend, &sym}); +return 1; + } + + if (sym.hasFlag(NEEDS_TLSDESC_AUTH)) { +assert(ctx.arg.emachine == EM_AARCH64); +// TLSDESC_CALL hint relocation probably should not be emitted by compiler +// with signed TLSDESC enabled since it does not give any value, but leave a +// check against that just in case someone uses it. +if (expr != R_TLSDESC_CALL) + fatalBothAuthAndNonAuth(); +return 1; + } + bool isRISCV = ctx.arg.emachine
[llvm-branch-commits] [lld] [PAC][lld][AArch64][ELF] Support signed GOT with tiny code model (PR #113816)
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113816 >From ddbd738fcc401c79ed597ed5ea5086af7c83ae0c Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Fri, 25 Oct 2024 21:28:18 +0300 Subject: [PATCH 1/4] [PAC][lld][AArch64][ELF] Support signed GOT with tiny code model Support `R_AARCH64_AUTH_GOT_ADR_PREL_LO21` and `R_AARCH64_AUTH_GOT_LD_PREL19` GOT-generating relocations. --- lld/ELF/Arch/AArch64.cpp | 5 ++ lld/ELF/InputSection.cpp | 1 + lld/ELF/Relocations.cpp | 17 ++--- lld/ELF/Relocations.h| 1 + lld/test/ELF/aarch64-got-relocations-pauth.s | 73 5 files changed, 89 insertions(+), 8 deletions(-) diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index fd85448e8b7a96..04df28270943d9 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -205,6 +205,9 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, case R_AARCH64_AUTH_LD64_GOT_LO12_NC: case R_AARCH64_AUTH_GOT_ADD_LO12_NC: return R_AARCH64_AUTH_GOT; + case R_AARCH64_AUTH_GOT_LD_PREL19: + case R_AARCH64_AUTH_GOT_ADR_PREL_LO21: +return R_AARCH64_AUTH_GOT_PC; case R_AARCH64_LD64_GOTPAGE_LO15: return R_AARCH64_GOT_PAGE; case R_AARCH64_ADR_GOT_PAGE: @@ -548,6 +551,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, write32AArch64Addr(loc, val >> 12); break; case R_AARCH64_ADR_PREL_LO21: + case R_AARCH64_AUTH_GOT_ADR_PREL_LO21: checkInt(ctx, loc, val, 21, rel); write32AArch64Addr(loc, val); break; @@ -568,6 +572,7 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, case R_AARCH64_CONDBR19: case R_AARCH64_LD_PREL_LO19: case R_AARCH64_GOT_LD_PREL19: + case R_AARCH64_AUTH_GOT_LD_PREL19: checkAlignment(ctx, loc, val, 4, rel); checkInt(ctx, loc, val, 21, rel); writeMaskedBits32le(loc, (val & 0x1C) << 3, 0x1C << 3); diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index ba7cdf106fe7cf..92c75eae295a58 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -823,6 +823,7 @@ uint64_t InputSectionBase::getRelocTargetVA(Ctx &ctx, const Relocation &r, case R_AARCH64_GOT_PAGE: return r.sym->getGotVA(ctx) + a - getAArch64Page(ctx.in.got->getVA()); case R_GOT_PC: + case R_AARCH64_AUTH_GOT_PC: case R_RELAX_TLS_GD_TO_IE: return r.sym->getGotVA(ctx) + a - p; case R_GOTPLT_GOTREL: diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 0a092737bd0e5f..598d3b570044d7 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -210,11 +210,11 @@ static bool needsPlt(RelExpr expr) { } bool lld::elf::needsGot(RelExpr expr) { - return oneof( - expr); + return oneof(expr); } // True if this expression is of the form Sym - X, where X is a position in the @@ -988,8 +988,8 @@ bool RelocationScanner::isStaticLinkTimeConstant(RelExpr e, RelType type, R_GOTONLY_PC, R_GOTPLTONLY_PC, R_PLT_PC, R_PLT_GOTREL, R_PLT_GOTPLT, R_GOTPLT_GOTREL, R_GOTPLT_PC, R_PPC32_PLTREL, R_PPC64_CALL_PLT, R_PPC64_RELAX_TOC, R_RISCV_ADD, R_AARCH64_GOT_PAGE, -R_AARCH64_AUTH_GOT, R_LOONGARCH_PLT_PAGE_PC, R_LOONGARCH_GOT, -R_LOONGARCH_GOT_PAGE_PC>(e)) +R_AARCH64_AUTH_GOT, R_AARCH64_AUTH_GOT_PC, R_LOONGARCH_PLT_PAGE_PC, +R_LOONGARCH_GOT, R_LOONGARCH_GOT_PAGE_PC>(e)) return true; // These never do, except if the entire file is position dependent or if @@ -1104,7 +1104,8 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset, // Many LoongArch TLS relocs reuse the R_LOONGARCH_GOT type, in which // case the NEEDS_GOT flag shouldn't get set. bool needsGotAuth = - (expr == R_AARCH64_AUTH_GOT || expr == R_AARCH64_AUTH_GOT_PAGE_PC); + (expr == R_AARCH64_AUTH_GOT || expr == R_AARCH64_AUTH_GOT_PC || + expr == R_AARCH64_AUTH_GOT_PAGE_PC); uint16_t flags = sym.flags.load(std::memory_order_relaxed); if (!(flags & NEEDS_GOT)) { sym.setFlags(needsGotAuth ? (NEEDS_GOT | NEEDS_GOT_AUTH) : NEEDS_GOT); diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h index 506ed396ef033c..ac35259850e04b 100644 --- a/lld/ELF/Relocations.h +++ b/lld/ELF/Relocations.h @@ -94,6 +94,7 @@ enum RelExpr { R_AARCH64_AUTH_GOT_PAGE_PC, R_AARCH64_GOT_PAGE, R_AARCH64_AUTH_GOT, + R_AARCH64_AUTH_GOT_PC, R_AARCH64_PAGE_PC, R_AARCH64_RELAX_TLS_GD_TO_IE_PAGE_PC, R_AARCH64_TLSDESC_PAGE, diff --git a/lld/test/ELF/aarch64-got-relocations-pauth.s b/lld/test/ELF/aarch64-got-relocations-pauth.s index 1b01318bf36ab6..c03b00ca8fcef1 100644 --- a/lld/test/ELF/aarch64-got-relocations-pauth.s +++ b/lld/test/ELF/aarch64-got-relocations-pauth.s @@ -77,6 +77,79 @@ _start: adrp x1, :got_auth:zed add x1, x1, :got_auth_lo12:zed +#--- ok-tiny.s + +# RUN: llvm
[llvm-branch-commits] [clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)
llvmbot wrote: @llvm/pr-subscribers-backend-powerpc Author: Serge Pavlov (spavloff) Changes Previously the function 'trunc' in non-default floating-point environment was implemented with a special LLVM intrinsic 'experimental.constrained.trunc'. Introduction of floating-point operand bundles allows expressing the interaction with the FP environment using the same intrinsic as for the default mode. This changes removes 'llvm.experimental.constrained.trunc' and use 'llvm.trunc' in all cases. --- Patch is 138.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/118253.diff 66 Files Affected: - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+26-26) - (modified) clang/test/CodeGen/AArch64/neon-intrinsics-constrained.c (+1-1) - (modified) clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics-constrained.c (+3-1) - (modified) clang/test/CodeGen/PowerPC/builtins-ppc-fpconstrained.c (+4-2) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c (+3-1) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c (+2-1) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c (+4-2) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c (+6-4) - (modified) clang/test/CodeGen/arm64-vrnd-constrained.c (+3-1) - (modified) clang/test/CodeGen/constrained-math-builtins.c (+11-8) - (modified) llvm/include/llvm/CodeGen/SelectionDAGNodes.h (+1) - (modified) llvm/include/llvm/CodeGen/TargetLowering.h (+1) - (modified) llvm/include/llvm/IR/ConstrainedOps.def (+7-1) - (modified) llvm/include/llvm/IR/Function.h (+1-1) - (modified) llvm/include/llvm/IR/InstrTypes.h (+3) - (modified) llvm/include/llvm/IR/IntrinsicInst.h (+12) - (modified) llvm/include/llvm/IR/Intrinsics.h (+4-3) - (modified) llvm/include/llvm/IR/Intrinsics.td (-3) - (modified) llvm/lib/Analysis/ConstantFolding.cpp (+6-7) - (modified) llvm/lib/AsmParser/LLParser.cpp (+9) - (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) - (modified) llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp (+6) - (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp (+2) - (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (+3) - (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+1) - (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+16-3) - (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (+1-1) - (modified) llvm/lib/CodeGen/TargetLoweringBase.cpp (+2-1) - (modified) llvm/lib/IR/AutoUpgrade.cpp (+65-7) - (modified) llvm/lib/IR/Function.cpp (+2-2) - (modified) llvm/lib/IR/Instructions.cpp (+5) - (modified) llvm/lib/IR/IntrinsicInst.cpp (+31-1) - (modified) llvm/lib/IR/Intrinsics.cpp (+1-1) - (modified) llvm/lib/Transforms/Utils/Local.cpp (+3-4) - (modified) llvm/test/Assembler/fp-intrinsics-attr.ll (+5-7) - (modified) llvm/test/Bitcode/auto-upgrade-constrained.ll (+1-1) - (modified) llvm/test/CodeGen/AArch64/fp-intrinsics-fp16.ll (+1-2) - (modified) llvm/test/CodeGen/AArch64/fp-intrinsics-vector.ll (+3-6) - (modified) llvm/test/CodeGen/AArch64/fp-intrinsics.ll (+3-6) - (modified) llvm/test/CodeGen/ARM/fp-intrinsics.ll (+2-2) - (modified) llvm/test/CodeGen/PowerPC/fp-strict-round.ll (+4-17) - (modified) llvm/test/CodeGen/PowerPC/ppcf128-constrained-fp-intrinsics.ll (+1-4) - (modified) llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll (+4-17) - (modified) llvm/test/CodeGen/RISCV/double-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/RISCV/float-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/RISCV/rvv/fixed-vectors-ftrunc-constrained-sdnode.ll (+15-30) - (modified) llvm/test/CodeGen/RISCV/rvv/ftrunc-constrained-sdnode.ll (+15-30) - (modified) llvm/test/CodeGen/RISCV/zfh-half-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/RISCV/zfhmin-half-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/SystemZ/fp-strict-round-01.ll (+3-12) - (modified) llvm/test/CodeGen/SystemZ/fp-strict-round-02.ll (+3-12) - (modified) llvm/test/CodeGen/SystemZ/fp-strict-round-03.ll (+3-12) - (modified) llvm/test/CodeGen/SystemZ/vec-strict-round-01.ll (+2-8) - (modified) llvm/test/CodeGen/SystemZ/vec-strict-round-02.ll (+2-8) - (modified) llvm/test/CodeGen/SystemZ/vector-constrained-fp-intrinsics.ll (+4-17) - (modified) llvm/test/CodeGen/X86/fp-strict-scalar-round-fp16.ll (+2-4) - (modified) llvm/test/CodeGen/X86/fp-strict-scalar-round.ll (+2-6) - (modified) llvm/test/CodeGen/X86/fp128-libcalls-strict.ll (+1-2) - (modified) llvm/test/CodeGen/X86/fp80-strict-libcalls.ll (+1-2) - (modified) llvm/test/CodeGen/X86/vec-strict-256-fp16.ll (+1-3) - (modified) llvm/test/CodeGen/X86/vec-strict-256.ll (+2-6) - (modified) llvm/test/CodeGen/X86/vec-strict-512-fp16.ll (+1-2) - (modified) llvm/test/CodeGen/X86/vec-strict-512.ll (+2-4) - (modified) llvm/test/CodeGen/X86/vec-strict-round-128.ll (+2-6) -
[llvm-branch-commits] [clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-arm Author: Serge Pavlov (spavloff) Changes Previously the function 'trunc' in non-default floating-point environment was implemented with a special LLVM intrinsic 'experimental.constrained.trunc'. Introduction of floating-point operand bundles allows expressing the interaction with the FP environment using the same intrinsic as for the default mode. This changes removes 'llvm.experimental.constrained.trunc' and use 'llvm.trunc' in all cases. --- Patch is 138.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/118253.diff 66 Files Affected: - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+26-26) - (modified) clang/test/CodeGen/AArch64/neon-intrinsics-constrained.c (+1-1) - (modified) clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics-constrained.c (+3-1) - (modified) clang/test/CodeGen/PowerPC/builtins-ppc-fpconstrained.c (+4-2) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c (+3-1) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c (+2-1) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c (+4-2) - (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c (+6-4) - (modified) clang/test/CodeGen/arm64-vrnd-constrained.c (+3-1) - (modified) clang/test/CodeGen/constrained-math-builtins.c (+11-8) - (modified) llvm/include/llvm/CodeGen/SelectionDAGNodes.h (+1) - (modified) llvm/include/llvm/CodeGen/TargetLowering.h (+1) - (modified) llvm/include/llvm/IR/ConstrainedOps.def (+7-1) - (modified) llvm/include/llvm/IR/Function.h (+1-1) - (modified) llvm/include/llvm/IR/InstrTypes.h (+3) - (modified) llvm/include/llvm/IR/IntrinsicInst.h (+12) - (modified) llvm/include/llvm/IR/Intrinsics.h (+4-3) - (modified) llvm/include/llvm/IR/Intrinsics.td (-3) - (modified) llvm/lib/Analysis/ConstantFolding.cpp (+6-7) - (modified) llvm/lib/AsmParser/LLParser.cpp (+9) - (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) - (modified) llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp (+6) - (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp (+2) - (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (+3) - (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+1) - (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+16-3) - (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (+1-1) - (modified) llvm/lib/CodeGen/TargetLoweringBase.cpp (+2-1) - (modified) llvm/lib/IR/AutoUpgrade.cpp (+65-7) - (modified) llvm/lib/IR/Function.cpp (+2-2) - (modified) llvm/lib/IR/Instructions.cpp (+5) - (modified) llvm/lib/IR/IntrinsicInst.cpp (+31-1) - (modified) llvm/lib/IR/Intrinsics.cpp (+1-1) - (modified) llvm/lib/Transforms/Utils/Local.cpp (+3-4) - (modified) llvm/test/Assembler/fp-intrinsics-attr.ll (+5-7) - (modified) llvm/test/Bitcode/auto-upgrade-constrained.ll (+1-1) - (modified) llvm/test/CodeGen/AArch64/fp-intrinsics-fp16.ll (+1-2) - (modified) llvm/test/CodeGen/AArch64/fp-intrinsics-vector.ll (+3-6) - (modified) llvm/test/CodeGen/AArch64/fp-intrinsics.ll (+3-6) - (modified) llvm/test/CodeGen/ARM/fp-intrinsics.ll (+2-2) - (modified) llvm/test/CodeGen/PowerPC/fp-strict-round.ll (+4-17) - (modified) llvm/test/CodeGen/PowerPC/ppcf128-constrained-fp-intrinsics.ll (+1-4) - (modified) llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll (+4-17) - (modified) llvm/test/CodeGen/RISCV/double-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/RISCV/float-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/RISCV/rvv/fixed-vectors-ftrunc-constrained-sdnode.ll (+15-30) - (modified) llvm/test/CodeGen/RISCV/rvv/ftrunc-constrained-sdnode.ll (+15-30) - (modified) llvm/test/CodeGen/RISCV/zfh-half-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/RISCV/zfhmin-half-intrinsics-strict.ll (+1-3) - (modified) llvm/test/CodeGen/SystemZ/fp-strict-round-01.ll (+3-12) - (modified) llvm/test/CodeGen/SystemZ/fp-strict-round-02.ll (+3-12) - (modified) llvm/test/CodeGen/SystemZ/fp-strict-round-03.ll (+3-12) - (modified) llvm/test/CodeGen/SystemZ/vec-strict-round-01.ll (+2-8) - (modified) llvm/test/CodeGen/SystemZ/vec-strict-round-02.ll (+2-8) - (modified) llvm/test/CodeGen/SystemZ/vector-constrained-fp-intrinsics.ll (+4-17) - (modified) llvm/test/CodeGen/X86/fp-strict-scalar-round-fp16.ll (+2-4) - (modified) llvm/test/CodeGen/X86/fp-strict-scalar-round.ll (+2-6) - (modified) llvm/test/CodeGen/X86/fp128-libcalls-strict.ll (+1-2) - (modified) llvm/test/CodeGen/X86/fp80-strict-libcalls.ll (+1-2) - (modified) llvm/test/CodeGen/X86/vec-strict-256-fp16.ll (+1-3) - (modified) llvm/test/CodeGen/X86/vec-strict-256.ll (+2-6) - (modified) llvm/test/CodeGen/X86/vec-strict-512-fp16.ll (+1-2) - (modified) llvm/test/CodeGen/X86/vec-strict-512.ll (+2-4) - (modified) llvm/test/CodeGen/X86/vec-strict
[llvm-branch-commits] [clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)
graphite-app[bot] wrote: ## Your org has enabled the Graphite merge queue for merging into main Add the label “FP Bundles” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using [this link](https://app.graphite.dev/invite/github/llvm?ref=merge-queue-instructions-comment&prId=5670208668). https://github.com/llvm/llvm-project/pull/118253 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 868660b970ac1a6af74e418e75097e05759350e2 3da7fd198007d6c3698c025bfb96ea5fb0ccca34 --extensions cpp,c,h -- clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/AArch64/neon-intrinsics-constrained.c clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics-constrained.c clang/test/CodeGen/PowerPC/builtins-ppc-fpconstrained.c clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c clang/test/CodeGen/arm64-vrnd-constrained.c clang/test/CodeGen/constrained-math-builtins.c llvm/include/llvm/CodeGen/SelectionDAGNodes.h llvm/include/llvm/CodeGen/TargetLowering.h llvm/include/llvm/IR/Function.h llvm/include/llvm/IR/InstrTypes.h llvm/include/llvm/IR/IntrinsicInst.h llvm/include/llvm/IR/Intrinsics.h llvm/lib/Analysis/ConstantFolding.cpp llvm/lib/AsmParser/LLParser.cpp llvm/lib/CodeGen/ExpandVectorPredication.cpp llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h llvm/lib/CodeGen/TargetLoweringBase.cpp llvm/lib/IR/AutoUpgrade.cpp llvm/lib/IR/Function.cpp llvm/lib/IR/Instructions.cpp llvm/lib/IR/IntrinsicInst.cpp llvm/lib/IR/Intrinsics.cpp llvm/lib/Transforms/Utils/Local.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 52b2d3320c..13c9533a8b 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -20537,7 +20537,9 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID, CI = Intrinsic::experimental_constrained_nearbyint; break; case 1: ID = Intrinsic::round; CI = Intrinsic::experimental_constrained_round; break; - case 5: ID = Intrinsic::trunc; break; + case 5: +ID = Intrinsic::trunc; +break; case 6: ID = Intrinsic::ceil; CI = Intrinsic::experimental_constrained_ceil; break; case 7: ID = Intrinsic::floor; diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 6185e4c5a8..912cf4ce45 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -1215,7 +1215,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn, assert(Success && "cannot get intrinsic signature"); NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), NewID, - OverloadTys); + OverloadTys); } return true; } @@ -4956,44 +4956,43 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) { MTI->setSourceAlignment(Align->getMaybeAlignValue()); break; } -#define LEGACY_FUNCTION(NAME, A, R, I, D) \ - case Intrinsic::NAME: +#define LEGACY_FUNCTION(NAME, A, R, I, D) case Intrinsic::NAME: #include "llvm/IR/ConstrainedOps.def" - { -SmallVector Bundles; -unsigned NumMetadataArgs = 0; +{ + SmallVector Bundles; + unsigned NumMetadataArgs = 0; + + if (auto RM = getRoundingModeArg(*CI)) { +auto CurrentRM = CI->getRoundingMode(); +assert(!CurrentRM && "unexpected rounding bundle"); +Builder.createFPRoundingBundle(Bundles, RM); +++NumMetadataArgs; + } -if (auto RM = getRoundingModeArg(*CI)) { - auto CurrentRM = CI->getRoundingMode(); - assert(!CurrentRM && "unexpected rounding bundle"); - Builder.createFPRoundingBundle(Bundles, RM); - ++NumMetadataArgs; -} + if (auto EB = getExceptionBehaviorArg(*CI)) { +auto CurrentEB = CI->getExceptionBehavior(); +assert(!CurrentEB && "unexpected exception bundle"); +Builder.createFPExceptionBundle(Bundles, EB); +++NumMetadataArgs; + } -if (auto EB = getExceptionBehaviorArg(*CI)) { - auto CurrentEB = CI->getExceptionBehavior(); - assert(!CurrentEB && "unexpected exception bundle"); - Builder.createFPExceptionBundle(Bundles, EB); - ++NumMetadataArgs; -} + SmallVector Args(CI->args()); + Args.pop_back_n(NumMetadataArgs); + NewCall = Builder.CreateCall(NewFn, Args, Bundles, CI->getName()); + NewCall->copyMetadata(*CI); + AttributeList Attrs = CI->getAttributes(); + NewCall->setAttributes(Attrs); + if (isa(CI)) { +FastMathFlags FMF = CI->getFastMathFlags(); +