[llvm-branch-commits] [llvm] [BOLT] Support POSSIBLE_PIC_FIXED_BRANCH (PR #91667)
dcci wrote: Can we have @rafaelauler looking at this when he's back? https://github.com/llvm/llvm-project/pull/91667 ___ 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] [BOLT] Support POSSIBLE_PIC_FIXED_BRANCH (PR #91667)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/91667 >From dd4d0de42048c063d5e5095a0c2594c7cc578df5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 9 May 2024 19:35:26 -0700 Subject: [PATCH 1/2] Fix RISCVMCPlusBuilder Created using spr 1.3.4 --- bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp index 74f2f0aae91e66..020e62463ee2f4 100644 --- a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp +++ b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp @@ -177,13 +177,14 @@ class RISCVMCPlusBuilder : public MCPlusBuilder { MCInst , InstructionIterator Begin, InstructionIterator End, const unsigned PtrSize, MCInst *, unsigned , unsigned , int64_t , const MCExpr *, - MCInst *) const override { + MCInst *, MCInst *) const override { MemLocInstr = nullptr; BaseRegNum = 0; IndexRegNum = 0; DispValue = 0; DispExpr = nullptr; PCRelBaseOut = nullptr; +FixedEntryLoadInst = nullptr; // Check for the following long tail call sequence: // 1: auipc xi, %pcrel_hi(sym) >From 62391bb5aa01f2b77d4315d1e72a9924eec9ecc0 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Fri, 5 Jul 2024 14:54:51 -0700 Subject: [PATCH 2/2] Drop deregisterJumpTable Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 09a6ca1d68730c..f587d5a2cadd49 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -899,17 +899,9 @@ BinaryFunction::processIndirectBranch(MCInst , unsigned Size, TargetAddress = ArrayStart + *Value; -// Remove spurious JumpTable at EntryAddress caused by PIC reference from -// the load instruction. -JumpTable *JT = BC.getJumpTableContainingAddress(EntryAddress); -assert(JT && "Must have a jump table at fixed entry address"); -BC.deregisterJumpTable(EntryAddress); -JumpTables.erase(EntryAddress); -delete JT; - // Replace FixedEntryDispExpr used in target address calculation with outer // jump table reference. -JT = BC.getJumpTableContainingAddress(ArrayStart); +JumpTable *JT = BC.getJumpTableContainingAddress(ArrayStart); assert(JT && "Must have a containing jump table for PIC fixed branch"); BC.MIB->replaceMemOperandDisp(*FixedEntryLoadInstr, JT->getFirstLabel(), EntryAddress - ArrayStart, &*BC.Ctx); ___ 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] [llvm-objcopy] Support CREL (PR #97521)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/97521 >From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 3 Jul 2024 11:45:26 -0700 Subject: [PATCH 1/2] fix header Created using spr 1.3.5-bogner --- llvm/include/llvm/ADT/bit.h| 1 - llvm/include/llvm/MC/MCELFExtras.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h index 1c8bd46648256..c42b5e686bdc9 100644 --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h @@ -14,7 +14,6 @@ #ifndef LLVM_ADT_BIT_H #define LLVM_ADT_BIT_H -#include "llvm/ADT/bit.h" #include "llvm/Support/Compiler.h" #include #include diff --git a/llvm/include/llvm/MC/MCELFExtras.h b/llvm/include/llvm/MC/MCELFExtras.h index 0f0c10edca2cf..498d477fbedc4 100644 --- a/llvm/include/llvm/MC/MCELFExtras.h +++ b/llvm/include/llvm/MC/MCELFExtras.h @@ -10,6 +10,7 @@ #define LLVM_MC_MCELFEXTRAS_H #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/bit.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/raw_ostream.h" >From 799485c4797aa0a1dee207988076f628444b9bdd Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 5 Jul 2024 14:51:26 -0700 Subject: [PATCH 2/2] fix FileHeader: !FileHeader Created using spr 1.3.5-bogner --- llvm/test/tools/llvm-objcopy/ELF/crel.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/tools/llvm-objcopy/ELF/crel.test b/llvm/test/tools/llvm-objcopy/ELF/crel.test index 4c84b45d15559..daf4567d0c8a2 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/crel.test +++ b/llvm/test/tools/llvm-objcopy/ELF/crel.test @@ -23,7 +23,7 @@ # CHECK-NEXT: 0030 {{.*}} R_X86_64_64 0 --- !ELF -FileHeader: !FileHeader +FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_REL ___ 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] [llvm-objcopy] Support CREL (PR #97521)
MaskRay wrote: > Is it worth a test to show a user attempting to strip a symbol referenced by > a crel section? Similarly, a crel section that is associated with a section > that gets stripped? Perhaps not needed, but just a thought. This case is tested by `strip-reloc-symbol.test`. I've also duplicated some SHT_REL tests in reloc-error-remove-symtab.test https://github.com/llvm/llvm-project/pull/97521 ___ 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] [llvm-objcopy] Support CREL (PR #97521)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/97521 >From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 3 Jul 2024 11:45:26 -0700 Subject: [PATCH] fix header Created using spr 1.3.5-bogner --- llvm/include/llvm/ADT/bit.h| 1 - llvm/include/llvm/MC/MCELFExtras.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h index 1c8bd46648256..c42b5e686bdc9 100644 --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h @@ -14,7 +14,6 @@ #ifndef LLVM_ADT_BIT_H #define LLVM_ADT_BIT_H -#include "llvm/ADT/bit.h" #include "llvm/Support/Compiler.h" #include #include diff --git a/llvm/include/llvm/MC/MCELFExtras.h b/llvm/include/llvm/MC/MCELFExtras.h index 0f0c10edca2cf..498d477fbedc4 100644 --- a/llvm/include/llvm/MC/MCELFExtras.h +++ b/llvm/include/llvm/MC/MCELFExtras.h @@ -10,6 +10,7 @@ #define LLVM_MC_MCELFEXTRAS_H #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/bit.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/raw_ostream.h" ___ 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] [llvm-objcopy] Support CREL (PR #97521)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/97521 >From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 3 Jul 2024 11:45:26 -0700 Subject: [PATCH] fix header Created using spr 1.3.5-bogner --- llvm/include/llvm/ADT/bit.h| 1 - llvm/include/llvm/MC/MCELFExtras.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h index 1c8bd46648256e..c42b5e686bdc9c 100644 --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h @@ -14,7 +14,6 @@ #ifndef LLVM_ADT_BIT_H #define LLVM_ADT_BIT_H -#include "llvm/ADT/bit.h" #include "llvm/Support/Compiler.h" #include #include diff --git a/llvm/include/llvm/MC/MCELFExtras.h b/llvm/include/llvm/MC/MCELFExtras.h index 0f0c10edca2cfe..498d477fbedc4c 100644 --- a/llvm/include/llvm/MC/MCELFExtras.h +++ b/llvm/include/llvm/MC/MCELFExtras.h @@ -10,6 +10,7 @@ #define LLVM_MC_MCELFEXTRAS_H #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/bit.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/raw_ostream.h" ___ 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] [BOLT] Eliminate dead jump tables (PR #91666)
https://github.com/aaupov closed https://github.com/llvm/llvm-project/pull/91666 ___ 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] [BOLT] Support POSSIBLE_PIC_FIXED_BRANCH (PR #91667)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/91667 >From dd4d0de42048c063d5e5095a0c2594c7cc578df5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 9 May 2024 19:35:26 -0700 Subject: [PATCH] Fix RISCVMCPlusBuilder Created using spr 1.3.4 --- bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp index 74f2f0aae91e6..020e62463ee2f 100644 --- a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp +++ b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp @@ -177,13 +177,14 @@ class RISCVMCPlusBuilder : public MCPlusBuilder { MCInst , InstructionIterator Begin, InstructionIterator End, const unsigned PtrSize, MCInst *, unsigned , unsigned , int64_t , const MCExpr *, - MCInst *) const override { + MCInst *, MCInst *) const override { MemLocInstr = nullptr; BaseRegNum = 0; IndexRegNum = 0; DispValue = 0; DispExpr = nullptr; PCRelBaseOut = nullptr; +FixedEntryLoadInst = nullptr; // Check for the following long tail call sequence: // 1: auipc xi, %pcrel_hi(sym) ___ 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] [BOLT] Support POSSIBLE_PIC_FIXED_BRANCH (PR #91667)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/91667 >From dd4d0de42048c063d5e5095a0c2594c7cc578df5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 9 May 2024 19:35:26 -0700 Subject: [PATCH] Fix RISCVMCPlusBuilder Created using spr 1.3.4 --- bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp index 74f2f0aae91e6..020e62463ee2f 100644 --- a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp +++ b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp @@ -177,13 +177,14 @@ class RISCVMCPlusBuilder : public MCPlusBuilder { MCInst , InstructionIterator Begin, InstructionIterator End, const unsigned PtrSize, MCInst *, unsigned , unsigned , int64_t , const MCExpr *, - MCInst *) const override { + MCInst *, MCInst *) const override { MemLocInstr = nullptr; BaseRegNum = 0; IndexRegNum = 0; DispValue = 0; DispExpr = nullptr; PCRelBaseOut = nullptr; +FixedEntryLoadInst = nullptr; // Check for the following long tail call sequence: // 1: auipc xi, %pcrel_hi(sym) ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/97502 >From c6212e4b26b0f0d8abde323fa5fc04ecc6dd34fd Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 09:45:46 -0700 Subject: [PATCH 1/3] Changed profileMatches comment Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- bolt/lib/Profile/YAMLProfileReader.cpp| 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index a5bd3544bd999..627cebf5d9453 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -73,7 +73,7 @@ class YAMLProfileReader : public ProfileReaderBase { bool parseFunctionProfile(BinaryFunction , const yaml::bolt::BinaryFunctionProfile ); - /// Returns block cnt equality if IgnoreHash is true, otherwise, hash equality + /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , BinaryFunction ); diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index e8ce187367899..91628d950e9f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -333,6 +333,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { return Error::success(); } + bool YAMLProfileReader::profileMatches( const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { if (opts::IgnoreHash) >From 1f48f09228b54e410910c2186cf0c3a73400bfd3 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 10:26:27 -0700 Subject: [PATCH 2/3] Changing profileMatches BF param to const Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 627cebf5d9453..fe9f349de278d 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -75,7 +75,7 @@ class YAMLProfileReader : public ProfileReaderBase { /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , - BinaryFunction ); + const BinaryFunction ); /// Infer function profile from stale data (collected on older binaries). bool inferStaleProfile(BinaryFunction , >From 2b0a7b0870e722900b0538c8fb8d5e68329d0c73 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Fri, 5 Jul 2024 12:07:44 -0700 Subject: [PATCH 3/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 930bd37e14e13..54e6fa21c85d4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -335,7 +335,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { } bool YAMLProfileReader::profileMatches( -const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { +const yaml::bolt::BinaryFunctionProfile , const BinaryFunction ) { if (opts::IgnoreHash) return Profile.NumBasicBlocks == BF.size(); return Profile.Hash == static_cast(BF.getHash()); ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/97502 >From c6212e4b26b0f0d8abde323fa5fc04ecc6dd34fd Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 09:45:46 -0700 Subject: [PATCH 1/3] Changed profileMatches comment Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- bolt/lib/Profile/YAMLProfileReader.cpp| 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index a5bd3544bd999..627cebf5d9453 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -73,7 +73,7 @@ class YAMLProfileReader : public ProfileReaderBase { bool parseFunctionProfile(BinaryFunction , const yaml::bolt::BinaryFunctionProfile ); - /// Returns block cnt equality if IgnoreHash is true, otherwise, hash equality + /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , BinaryFunction ); diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index e8ce187367899..91628d950e9f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -333,6 +333,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { return Error::success(); } + bool YAMLProfileReader::profileMatches( const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { if (opts::IgnoreHash) >From 1f48f09228b54e410910c2186cf0c3a73400bfd3 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 10:26:27 -0700 Subject: [PATCH 2/3] Changing profileMatches BF param to const Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 627cebf5d9453..fe9f349de278d 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -75,7 +75,7 @@ class YAMLProfileReader : public ProfileReaderBase { /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , - BinaryFunction ); + const BinaryFunction ); /// Infer function profile from stale data (collected on older binaries). bool inferStaleProfile(BinaryFunction , >From 2b0a7b0870e722900b0538c8fb8d5e68329d0c73 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Fri, 5 Jul 2024 12:07:44 -0700 Subject: [PATCH 3/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 930bd37e14e13..54e6fa21c85d4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -335,7 +335,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { } bool YAMLProfileReader::profileMatches( -const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { +const yaml::bolt::BinaryFunctionProfile , const BinaryFunction ) { if (opts::IgnoreHash) return Profile.NumBasicBlocks == BF.size(); return Profile.Hash == static_cast(BF.getHash()); ___ 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-objdump] -r: support CREL (PR #97382)
@@ -1117,9 +1155,11 @@ void ELFObjectFile::getRelocationTypeName( template Expected ELFObjectFile::getRelocationAddend(DataRefImpl Rel) const { - if (getRelSection(Rel)->sh_type != ELF::SHT_RELA) -return createError("Section is not SHT_RELA"); - return (int64_t)getRela(Rel)->r_addend; + if (getRelSection(Rel)->sh_type == ELF::SHT_RELA) +return (int64_t)getRela(Rel)->r_addend; + if (getRelSection(Rel)->sh_type == ELF::SHT_CREL) +return (int64_t)getCrel(Rel).r_addend; + return createError("Section is not SHT_RELA"); MaskRay wrote: Error message adjusted. I think this line is dynamically unreachable. https://github.com/llvm/llvm-project/pull/97382 ___ 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-objdump] -r: support CREL (PR #97382)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/97382 ___ 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-objdump] -r: support CREL (PR #97382)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/97382 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -155,5 +155,51 @@ std::string hashBlockLoose(BinaryContext , const BinaryBasicBlock ) { return HashString; } +/// An even looser hash of a basic block to use with stale profile matching, +/// composed of the names of a block's called functions in lexicographic order. +std::string hashBlockCalls(BinaryContext , const BinaryBasicBlock ) { + // The hash is computed by creating a string of all lexicographically ordered + // called function names. + std::multiset FunctionNames; + for (const MCInst : BB) { +// Skip non-call instructions. +if (!BC.MIB->isCall(Instr)) + continue; +const MCSymbol *CallSymbol = BC.MIB->getTargetSymbol(Instr); +if (!CallSymbol) + continue; +FunctionNames.insert(std::string(CallSymbol->getName())); + } + + std::string HashString; + for (const std::string : FunctionNames) +HashString.append(FunctionName); + + return HashString; +} + +/// The same as the above function, but for profiled functions. dcci wrote: functions can be moved around the file, I wouldn't say "same as above" -- as above can change. https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -155,5 +155,51 @@ std::string hashBlockLoose(BinaryContext , const BinaryBasicBlock ) { return HashString; } +/// An even looser hash of a basic block to use with stale profile matching, dcci wrote: You can say: a looser version of $SOMETHING and make it more explicit. https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -35,6 +36,12 @@ std::string hashBlock(BinaryContext , const BinaryBasicBlock , std::string hashBlockLoose(BinaryContext , const BinaryBasicBlock ); +std::string hashBlockCalls(BinaryContext , const BinaryBasicBlock ); + +std::string +hashBlockCalls(const DenseMap , dcci wrote: how come here you're using pointers to strings rather than references? https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -414,31 +449,59 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType ) { /// matched to a jump in the binary, the count is recorded in CFG. size_t matchWeightsByHashes( BinaryContext , const BinaryFunction::BasicBlockOrderType , -const yaml::bolt::BinaryFunctionProfile , FlowFunction ) { +const yaml::bolt::BinaryFunctionProfile , FlowFunction , +HashFunction HashFunction, +const DenseMap ) { + assert(Func.Blocks.size() == BlockOrder.size() + 2); + std::vector CallHashes; std::vector Blocks; std::vector BlendedHashes; for (uint64_t I = 0; I < BlockOrder.size(); I++) { const BinaryBasicBlock *BB = BlockOrder[I]; assert(BB->getHash() != 0 && "empty hash of BinaryBasicBlock"); + +std::string CallHashStr = hashBlockCalls(BC, *BB); +if (CallHashStr.empty()) { + CallHashes.push_back(0); +} else if (HashFunction == HashFunction::StdHash) { + CallHashes.push_back(std::hash{}(CallHashStr)); +} else if (HashFunction == HashFunction::XXH3) { + CallHashes.push_back(llvm::xxh3_64bits(CallHashStr)); +} else { + llvm_unreachable("Unhandled HashFunction"); +} + Blocks.push_back([I + 1]); BlendedBlockHash BlendedHash(BB->getHash()); BlendedHashes.push_back(BlendedHash); LLVM_DEBUG(dbgs() << "BB with index " << I << " has hash = " << Twine::utohexstr(BB->getHash()) << "\n"); } StaleMatcher Matcher; - Matcher.init(Blocks, BlendedHashes); + Matcher.init(Blocks, BlendedHashes, CallHashes); // Index in yaml profile => corresponding (matched) block DenseMap MatchedBlocks; // Match blocks from the profile to the blocks in CFG for (const yaml::bolt::BinaryBasicBlockProfile : YamlBF.Blocks) { assert(YamlBB.Hash != 0 && "empty hash of BinaryBasicBlockProfile"); BlendedBlockHash YamlHash(YamlBB.Hash); -const FlowBlock *MatchedBlock = Matcher.matchBlock(YamlHash); -// Always match the entry block. + +const FlowBlock *MatchedBlock = nullptr; +std::string CallHashStr = hashBlockCalls(IdToFunctionName, YamlBB); +uint64_t CallHash = 0; +if (CallHashStr.empty()) { // Noop +} else if (HashFunction == HashFunction::StdHash) { + CallHash = std::hash{}(CallHashStr); +} else if (HashFunction == HashFunction::XXH3) { + CallHash = llvm::xxh3_64bits(CallHashStr); +} else { + llvm_unreachable("Unhandled HashFunction"); dcci wrote: you might want to add a more informative message. https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -414,31 +449,59 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType ) { /// matched to a jump in the binary, the count is recorded in CFG. size_t matchWeightsByHashes( BinaryContext , const BinaryFunction::BasicBlockOrderType , -const yaml::bolt::BinaryFunctionProfile , FlowFunction ) { +const yaml::bolt::BinaryFunctionProfile , FlowFunction , +HashFunction HashFunction, +const DenseMap ) { + assert(Func.Blocks.size() == BlockOrder.size() + 2); + std::vector CallHashes; std::vector Blocks; std::vector BlendedHashes; for (uint64_t I = 0; I < BlockOrder.size(); I++) { const BinaryBasicBlock *BB = BlockOrder[I]; assert(BB->getHash() != 0 && "empty hash of BinaryBasicBlock"); + +std::string CallHashStr = hashBlockCalls(BC, *BB); +if (CallHashStr.empty()) { + CallHashes.push_back(0); +} else if (HashFunction == HashFunction::StdHash) { + CallHashes.push_back(std::hash{}(CallHashStr)); +} else if (HashFunction == HashFunction::XXH3) { + CallHashes.push_back(llvm::xxh3_64bits(CallHashStr)); +} else { + llvm_unreachable("Unhandled HashFunction"); dcci wrote: maybe you can make this message slightly more verbose/explicative. https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -414,31 +449,59 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType ) { /// matched to a jump in the binary, the count is recorded in CFG. size_t matchWeightsByHashes( BinaryContext , const BinaryFunction::BasicBlockOrderType , -const yaml::bolt::BinaryFunctionProfile , FlowFunction ) { +const yaml::bolt::BinaryFunctionProfile , FlowFunction , +HashFunction HashFunction, +const DenseMap ) { + assert(Func.Blocks.size() == BlockOrder.size() + 2); + std::vector CallHashes; std::vector Blocks; std::vector BlendedHashes; for (uint64_t I = 0; I < BlockOrder.size(); I++) { const BinaryBasicBlock *BB = BlockOrder[I]; assert(BB->getHash() != 0 && "empty hash of BinaryBasicBlock"); + +std::string CallHashStr = hashBlockCalls(BC, *BB); +if (CallHashStr.empty()) { + CallHashes.push_back(0); +} else if (HashFunction == HashFunction::StdHash) { + CallHashes.push_back(std::hash{}(CallHashStr)); +} else if (HashFunction == HashFunction::XXH3) { dcci wrote: aren't these mutually exclusive? why do you need the `else` ? https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -414,31 +449,59 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType ) { /// matched to a jump in the binary, the count is recorded in CFG. size_t matchWeightsByHashes( BinaryContext , const BinaryFunction::BasicBlockOrderType , -const yaml::bolt::BinaryFunctionProfile , FlowFunction ) { +const yaml::bolt::BinaryFunctionProfile , FlowFunction , +HashFunction HashFunction, +const DenseMap ) { + assert(Func.Blocks.size() == BlockOrder.size() + 2); + std::vector CallHashes; std::vector Blocks; std::vector BlendedHashes; for (uint64_t I = 0; I < BlockOrder.size(); I++) { const BinaryBasicBlock *BB = BlockOrder[I]; assert(BB->getHash() != 0 && "empty hash of BinaryBasicBlock"); + +std::string CallHashStr = hashBlockCalls(BC, *BB); +if (CallHashStr.empty()) { + CallHashes.push_back(0); +} else if (HashFunction == HashFunction::StdHash) { + CallHashes.push_back(std::hash{}(CallHashStr)); +} else if (HashFunction == HashFunction::XXH3) { + CallHashes.push_back(llvm::xxh3_64bits(CallHashStr)); +} else { + llvm_unreachable("Unhandled HashFunction"); +} + Blocks.push_back([I + 1]); BlendedBlockHash BlendedHash(BB->getHash()); BlendedHashes.push_back(BlendedHash); LLVM_DEBUG(dbgs() << "BB with index " << I << " has hash = " << Twine::utohexstr(BB->getHash()) << "\n"); } StaleMatcher Matcher; - Matcher.init(Blocks, BlendedHashes); + Matcher.init(Blocks, BlendedHashes, CallHashes); // Index in yaml profile => corresponding (matched) block DenseMap MatchedBlocks; // Match blocks from the profile to the blocks in CFG for (const yaml::bolt::BinaryBasicBlockProfile : YamlBF.Blocks) { assert(YamlBB.Hash != 0 && "empty hash of BinaryBasicBlockProfile"); BlendedBlockHash YamlHash(YamlBB.Hash); -const FlowBlock *MatchedBlock = Matcher.matchBlock(YamlHash); -// Always match the entry block. + +const FlowBlock *MatchedBlock = nullptr; +std::string CallHashStr = hashBlockCalls(IdToFunctionName, YamlBB); +uint64_t CallHash = 0; +if (CallHashStr.empty()) { // Noop dcci wrote: ``` if (!CallHashStr.empty()) { if (...) } ``` maybe a better way of writing this https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/dcci edited https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -155,5 +155,51 @@ std::string hashBlockLoose(BinaryContext , const BinaryBasicBlock ) { return HashString; } +/// An even looser hash of a basic block to use with stale profile matching, +/// composed of the names of a block's called functions in lexicographic order. +std::string hashBlockCalls(BinaryContext , const BinaryBasicBlock ) { + // The hash is computed by creating a string of all lexicographically ordered + // called function names. + std::multiset FunctionNames; + for (const MCInst : BB) { +// Skip non-call instructions. +if (!BC.MIB->isCall(Instr)) + continue; +const MCSymbol *CallSymbol = BC.MIB->getTargetSymbol(Instr); +if (!CallSymbol) dcci wrote: is this something that can happen, or should it be an assertion? https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/dcci requested changes to this pull request. First round of comments https://github.com/llvm/llvm-project/pull/96596 ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/maksfb approved this pull request. https://github.com/llvm/llvm-project/pull/97502 ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/97502 >From c6212e4b26b0f0d8abde323fa5fc04ecc6dd34fd Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 09:45:46 -0700 Subject: [PATCH 1/3] Changed profileMatches comment Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- bolt/lib/Profile/YAMLProfileReader.cpp| 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index a5bd3544bd9992..627cebf5d9453a 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -73,7 +73,7 @@ class YAMLProfileReader : public ProfileReaderBase { bool parseFunctionProfile(BinaryFunction , const yaml::bolt::BinaryFunctionProfile ); - /// Returns block cnt equality if IgnoreHash is true, otherwise, hash equality + /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , BinaryFunction ); diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index e8ce187367899d..91628d950e9f4a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -333,6 +333,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { return Error::success(); } + bool YAMLProfileReader::profileMatches( const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { if (opts::IgnoreHash) >From 1f48f09228b54e410910c2186cf0c3a73400bfd3 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 10:26:27 -0700 Subject: [PATCH 2/3] Changing profileMatches BF param to const Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 627cebf5d9453a..fe9f349de278d4 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -75,7 +75,7 @@ class YAMLProfileReader : public ProfileReaderBase { /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , - BinaryFunction ); + const BinaryFunction ); /// Infer function profile from stale data (collected on older binaries). bool inferStaleProfile(BinaryFunction , >From 2b0a7b0870e722900b0538c8fb8d5e68329d0c73 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Fri, 5 Jul 2024 12:07:44 -0700 Subject: [PATCH 3/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 930bd37e14e138..54e6fa21c85d40 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -335,7 +335,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { } bool YAMLProfileReader::profileMatches( -const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { +const yaml::bolt::BinaryFunctionProfile , const BinaryFunction ) { if (opts::IgnoreHash) return Profile.NumBasicBlocks == BF.size(); return Profile.Hash == static_cast(BF.getHash()); ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/97502 >From c6212e4b26b0f0d8abde323fa5fc04ecc6dd34fd Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 09:45:46 -0700 Subject: [PATCH 1/3] Changed profileMatches comment Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- bolt/lib/Profile/YAMLProfileReader.cpp| 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index a5bd3544bd9992..627cebf5d9453a 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -73,7 +73,7 @@ class YAMLProfileReader : public ProfileReaderBase { bool parseFunctionProfile(BinaryFunction , const yaml::bolt::BinaryFunctionProfile ); - /// Returns block cnt equality if IgnoreHash is true, otherwise, hash equality + /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , BinaryFunction ); diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index e8ce187367899d..91628d950e9f4a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -333,6 +333,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { return Error::success(); } + bool YAMLProfileReader::profileMatches( const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { if (opts::IgnoreHash) >From 1f48f09228b54e410910c2186cf0c3a73400bfd3 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 10:26:27 -0700 Subject: [PATCH 2/3] Changing profileMatches BF param to const Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 627cebf5d9453a..fe9f349de278d4 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -75,7 +75,7 @@ class YAMLProfileReader : public ProfileReaderBase { /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , - BinaryFunction ); + const BinaryFunction ); /// Infer function profile from stale data (collected on older binaries). bool inferStaleProfile(BinaryFunction , >From 2b0a7b0870e722900b0538c8fb8d5e68329d0c73 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Fri, 5 Jul 2024 12:07:44 -0700 Subject: [PATCH 3/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 930bd37e14e138..54e6fa21c85d40 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -335,7 +335,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { } bool YAMLProfileReader::profileMatches( -const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { +const yaml::bolt::BinaryFunctionProfile , const BinaryFunction ) { if (opts::IgnoreHash) return Profile.NumBasicBlocks == BF.size(); return Profile.Hash == static_cast(BF.getHash()); ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/dcci approved this pull request. https://github.com/llvm/llvm-project/pull/97502 ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/97502 >From c6212e4b26b0f0d8abde323fa5fc04ecc6dd34fd Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 09:45:46 -0700 Subject: [PATCH 1/3] Changed profileMatches comment Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- bolt/lib/Profile/YAMLProfileReader.cpp| 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index a5bd3544bd9992..627cebf5d9453a 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -73,7 +73,7 @@ class YAMLProfileReader : public ProfileReaderBase { bool parseFunctionProfile(BinaryFunction , const yaml::bolt::BinaryFunctionProfile ); - /// Returns block cnt equality if IgnoreHash is true, otherwise, hash equality + /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , BinaryFunction ); diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index e8ce187367899d..91628d950e9f4a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -333,6 +333,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { return Error::success(); } + bool YAMLProfileReader::profileMatches( const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { if (opts::IgnoreHash) >From 1f48f09228b54e410910c2186cf0c3a73400bfd3 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 10:26:27 -0700 Subject: [PATCH 2/3] Changing profileMatches BF param to const Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 627cebf5d9453a..fe9f349de278d4 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -75,7 +75,7 @@ class YAMLProfileReader : public ProfileReaderBase { /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , - BinaryFunction ); + const BinaryFunction ); /// Infer function profile from stale data (collected on older binaries). bool inferStaleProfile(BinaryFunction , >From 2b0a7b0870e722900b0538c8fb8d5e68329d0c73 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Fri, 5 Jul 2024 12:07:44 -0700 Subject: [PATCH 3/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 930bd37e14e138..54e6fa21c85d40 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -335,7 +335,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { } bool YAMLProfileReader::profileMatches( -const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { +const yaml::bolt::BinaryFunctionProfile , const BinaryFunction ) { if (opts::IgnoreHash) return Profile.NumBasicBlocks == BF.size(); return Profile.Hash == static_cast(BF.getHash()); ___ 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] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/shawbyoung edited https://github.com/llvm/llvm-project/pull/96596 ___ 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] [libc] 07b53c6 - Revert "[libc] Fix readlink tests on 32-bit systems (#97850)"
Author: Mikhail R. Gadelha Date: 2024-07-05T15:30:24-03:00 New Revision: 07b53c66ac726d979d2640b7882082d6e053ccab URL: https://github.com/llvm/llvm-project/commit/07b53c66ac726d979d2640b7882082d6e053ccab DIFF: https://github.com/llvm/llvm-project/commit/07b53c66ac726d979d2640b7882082d6e053ccab.diff LOG: Revert "[libc] Fix readlink tests on 32-bit systems (#97850)" This reverts commit 0f1da49b4d854ce7c6572000da3fb6cb0a1245d2. Added: Modified: libc/test/src/unistd/CMakeLists.txt libc/test/src/unistd/readlink_test.cpp libc/test/src/unistd/readlinkat_test.cpp Removed: diff --git a/libc/test/src/unistd/CMakeLists.txt b/libc/test/src/unistd/CMakeLists.txt index f4f78b800987d..de3e8d9ccbb62 100644 --- a/libc/test/src/unistd/CMakeLists.txt +++ b/libc/test/src/unistd/CMakeLists.txt @@ -262,7 +262,6 @@ add_libc_unittest( libc.include.unistd libc.src.errno.errno libc.src.unistd.readlink -libc.src.string.string_utils libc.src.unistd.symlink libc.src.unistd.unlink libc.src.__support.CPP.string_view @@ -279,7 +278,6 @@ add_libc_unittest( libc.include.fcntl libc.include.unistd libc.src.errno.errno -libc.src.string.string_utils libc.src.unistd.readlinkat libc.src.unistd.symlink libc.src.unistd.unlink diff --git a/libc/test/src/unistd/readlink_test.cpp b/libc/test/src/unistd/readlink_test.cpp index 0760850d9bae1..20f3951349118 100644 --- a/libc/test/src/unistd/readlink_test.cpp +++ b/libc/test/src/unistd/readlink_test.cpp @@ -9,7 +9,6 @@ #include "src/__support/CPP/string_view.h" #include "src/errno/libc_errno.h" #include "src/unistd/readlink.h" -#include "src/string/string_utils.h" #include "src/unistd/symlink.h" #include "src/unistd/unlink.h" #include "test/UnitTest/ErrnoSetterMatcher.h" @@ -31,9 +30,8 @@ TEST(LlvmLibcReadlinkTest, CreateAndUnlink) { // 3. Cleanup the symlink created in step #1. ASSERT_THAT(LIBC_NAMESPACE::symlink(LINK_VAL, LINK), Succeeds(0)); - char buf[sizeof(FILENAME)]; - ssize_t len = LIBC_NAMESPACE::readlink( - LINK, buf, LIBC_NAMESPACE::internal::string_length(FILENAME)); + char buf[sizeof(LINK_VAL)]; + ssize_t len = LIBC_NAMESPACE::readlink(LINK, buf, sizeof(buf)); ASSERT_ERRNO_SUCCESS(); ASSERT_EQ(cpp::string_view(buf, len), cpp::string_view(LINK_VAL)); @@ -42,8 +40,7 @@ TEST(LlvmLibcReadlinkTest, CreateAndUnlink) { TEST(LlvmLibcReadlinkTest, ReadlinkInNonExistentPath) { using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails; - constexpr auto len = 8; - char buf[len]; - ASSERT_THAT(LIBC_NAMESPACE::readlink("non-existent-link", buf, len), + char buf[8]; + ASSERT_THAT(LIBC_NAMESPACE::readlink("non-existent-link", buf, sizeof(buf)), Fails(ENOENT)); } diff --git a/libc/test/src/unistd/readlinkat_test.cpp b/libc/test/src/unistd/readlinkat_test.cpp index 61e87731c9b9d..39d81d9ba544a 100644 --- a/libc/test/src/unistd/readlinkat_test.cpp +++ b/libc/test/src/unistd/readlinkat_test.cpp @@ -9,7 +9,6 @@ #include "src/__support/CPP/string_view.h" #include "src/errno/libc_errno.h" #include "src/unistd/readlinkat.h" -#include "src/string/string_utils.h" #include "src/unistd/symlink.h" #include "src/unistd/unlink.h" #include "test/UnitTest/ErrnoSetterMatcher.h" @@ -33,9 +32,8 @@ TEST(LlvmLibcReadlinkatTest, CreateAndUnlink) { // 3. Cleanup the symlink created in step #1. ASSERT_THAT(LIBC_NAMESPACE::symlink(LINK_VAL, LINK), Succeeds(0)); - char buf[sizeof(FILENAME)]; - ssize_t len = LIBC_NAMESPACE::readlinkat( - AT_FDCWD, LINK, buf, LIBC_NAMESPACE::internal::string_length(FILENAME)); + char buf[sizeof(LINK_VAL)]; + ssize_t len = LIBC_NAMESPACE::readlinkat(AT_FDCWD, LINK, buf, sizeof(buf)); ASSERT_ERRNO_SUCCESS(); ASSERT_EQ(cpp::string_view(buf, len), cpp::string_view(LINK_VAL)); @@ -44,9 +42,8 @@ TEST(LlvmLibcReadlinkatTest, CreateAndUnlink) { TEST(LlvmLibcReadlinkatTest, ReadlinkInNonExistentPath) { using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails; - constexpr auto len = 8; - char buf[len]; - ASSERT_THAT( - LIBC_NAMESPACE::readlinkat(AT_FDCWD, "non-existent-link", buf, len), - Fails(ENOENT)); + char buf[8]; + ASSERT_THAT(LIBC_NAMESPACE::readlinkat(AT_FDCWD, "non-existent-link", buf, + sizeof(buf)), + Fails(ENOENT)); } ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung edited https://github.com/llvm/llvm-project/pull/97502 ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/97502 >From c6212e4b26b0f0d8abde323fa5fc04ecc6dd34fd Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 09:45:46 -0700 Subject: [PATCH 1/2] Changed profileMatches comment Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- bolt/lib/Profile/YAMLProfileReader.cpp| 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index a5bd3544bd9992..627cebf5d9453a 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -73,7 +73,7 @@ class YAMLProfileReader : public ProfileReaderBase { bool parseFunctionProfile(BinaryFunction , const yaml::bolt::BinaryFunctionProfile ); - /// Returns block cnt equality if IgnoreHash is true, otherwise, hash equality + /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , BinaryFunction ); diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index e8ce187367899d..91628d950e9f4a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -333,6 +333,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { return Error::success(); } + bool YAMLProfileReader::profileMatches( const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { if (opts::IgnoreHash) >From 1f48f09228b54e410910c2186cf0c3a73400bfd3 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 10:26:27 -0700 Subject: [PATCH 2/2] Changing profileMatches BF param to const Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 627cebf5d9453a..fe9f349de278d4 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -75,7 +75,7 @@ class YAMLProfileReader : public ProfileReaderBase { /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , - BinaryFunction ); + const BinaryFunction ); /// Infer function profile from stale data (collected on older binaries). bool inferStaleProfile(BinaryFunction , ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/97502 >From c6212e4b26b0f0d8abde323fa5fc04ecc6dd34fd Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 09:45:46 -0700 Subject: [PATCH 1/2] Changed profileMatches comment Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- bolt/lib/Profile/YAMLProfileReader.cpp| 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index a5bd3544bd9992..627cebf5d9453a 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -73,7 +73,7 @@ class YAMLProfileReader : public ProfileReaderBase { bool parseFunctionProfile(BinaryFunction , const yaml::bolt::BinaryFunctionProfile ); - /// Returns block cnt equality if IgnoreHash is true, otherwise, hash equality + /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , BinaryFunction ); diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index e8ce187367899d..91628d950e9f4a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -333,6 +333,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext ) { return Error::success(); } + bool YAMLProfileReader::profileMatches( const yaml::bolt::BinaryFunctionProfile , BinaryFunction ) { if (opts::IgnoreHash) >From 1f48f09228b54e410910c2186cf0c3a73400bfd3 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Wed, 3 Jul 2024 10:26:27 -0700 Subject: [PATCH 2/2] Changing profileMatches BF param to const Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 627cebf5d9453a..fe9f349de278d4 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -75,7 +75,7 @@ class YAMLProfileReader : public ProfileReaderBase { /// Checks if a function profile matches a binary function. bool profileMatches(const yaml::bolt::BinaryFunctionProfile , - BinaryFunction ); + const BinaryFunction ); /// Infer function profile from stale data (collected on older binaries). bool inferStaleProfile(BinaryFunction , ___ 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] [BOLT][NFC] Refactor function matching (PR #97502)
https://github.com/shawbyoung edited https://github.com/llvm/llvm-project/pull/97502 ___ 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] [flang] [Flang][OpenMP] Add lowering support for DISTRIBUTE SIMD (PR #97819)
llvmbot wrote: @llvm/pr-subscribers-flang-fir-hlfir Author: Sergio Afonso (skatrak) Changes This patch adds support for lowering 'DISTRIBUTE SIMD' constructs to MLIR. Translation of `omp.distribute` operations to LLVM IR is still not supported, so its composition with `omp.simd` isn't either. --- Full diff: https://github.com/llvm/llvm-project/pull/97819.diff 4 Files Affected: - (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+37-1) - (added) flang/test/Lower/OpenMP/distribute-simd.f90 (+59) - (modified) flang/test/Lower/OpenMP/if-clause.f90 (+215-3) - (modified) flang/test/Lower/OpenMP/loop-compound.f90 (+40-5) ``diff diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index 50ff53a1cb0b3..95248900ffc23 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -1976,7 +1976,43 @@ static void genCompositeDistributeSimd( semantics::SemanticsContext , lower::pft::Evaluation , mlir::Location loc, const ConstructQueue , ConstructQueue::iterator item, DataSharingProcessor ) { - TODO(loc, "Composite DISTRIBUTE SIMD"); + lower::StatementContext stmtCtx; + + // Clause processing. + mlir::omp::DistributeClauseOps distributeClauseOps; + genDistributeClauses(converter, semaCtx, stmtCtx, item->clauses, loc, + distributeClauseOps); + + mlir::omp::SimdClauseOps simdClauseOps; + genSimdClauses(converter, semaCtx, item->clauses, loc, simdClauseOps); + + mlir::omp::LoopNestClauseOps loopNestClauseOps; + llvm::SmallVector iv; + genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc, + loopNestClauseOps, iv); + + // Operation creation. + // TODO: Populate entry block arguments with private variables. + auto distributeOp = genWrapperOp( + converter, loc, distributeClauseOps, /*blockArgTypes=*/{}); + + // TODO: Populate entry block arguments with reduction and private variables. + auto simdOp = genWrapperOp(converter, loc, simdClauseOps, +/*blockArgTypes=*/{}); + + // Construct wrapper entry block list and associated symbols. It is important + // that the symbol order and the block argument order match, so that the + // symbol-value bindings created are correct. + // TODO: Add omp.distribute private and omp.simd private and reduction args. + auto wrapperArgs = llvm::to_vector( + llvm::concat(distributeOp.getRegion().getArguments(), +simdOp.getRegion().getArguments())); + + assert(wrapperArgs.empty() && + "Block args for omp.simd and omp.distribute currently not expected"); + genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item, +loopNestClauseOps, iv, /*wrapperSyms=*/{}, wrapperArgs, +llvm::omp::Directive::OMPD_distribute_simd, dsp); } static void genCompositeDoSimd(lower::AbstractConverter , diff --git a/flang/test/Lower/OpenMP/distribute-simd.f90 b/flang/test/Lower/OpenMP/distribute-simd.f90 new file mode 100644 index 0..545037b7791b8 --- /dev/null +++ b/flang/test/Lower/OpenMP/distribute-simd.f90 @@ -0,0 +1,59 @@ +! This test checks lowering of OpenMP DISTRIBUTE SIMD composite constructs. + +! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s +! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s + +! CHECK-LABEL: func.func @_QPdistribute_simd_aligned( +subroutine distribute_simd_aligned(A) + use iso_c_binding + type(c_ptr) :: A + + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: aligned({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: aligned({{.*}}) + !$omp distribute simd aligned(A) + do index_ = 1, 10 +call c_test_call(A) + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_aligned + +! CHECK-LABEL: func.func @_QPdistribute_simd_safelen( +subroutine distribute_simd_safelen() + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: safelen({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: safelen({{.*}}) + !$omp distribute simd safelen(4) + do index_ = 1, 10 + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_safelen + +! CHECK-LABEL: func.func @_QPdistribute_simd_simdlen( +subroutine distribute_simd_simdlen() + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: simdlen({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: simdlen({{.*}}) + !$omp distribute simd simdlen(4) + do index_ = 1, 10 + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_simdlen diff --git a/flang/test/Lower/OpenMP/if-clause.f90 b/flang/test/Lower/OpenMP/if-clause.f90 index ea730b5f1d9db..f10a6b008cddf 100644 --- a/flang/test/Lower/OpenMP/if-clause.f90 +++ b/flang/test/Lower/OpenMP/if-clause.f90 @@ -11,18 +11,56 @@ program main ! TODO When they are supported, add
[llvm-branch-commits] [flang] [Flang][OpenMP] Add lowering support for DISTRIBUTE SIMD (PR #97819)
https://github.com/skatrak created https://github.com/llvm/llvm-project/pull/97819 This patch adds support for lowering 'DISTRIBUTE SIMD' constructs to MLIR. Translation of `omp.distribute` operations to LLVM IR is still not supported, so its composition with `omp.simd` isn't either. >From 4160feeb1daff9a287bb809ae89994632ce8f64a Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Fri, 5 Jul 2024 12:49:46 +0100 Subject: [PATCH] [Flang][OpenMP] Add lowering support for DISTRIBUTE SIMD This patch adds support for lowering 'DISTRIBUTE SIMD' constructs to MLIR. Translation of `omp.distribute` operations to LLVM IR is still not supported, so its composition with `omp.simd` isn't either. --- flang/lib/Lower/OpenMP/OpenMP.cpp | 38 +++- flang/test/Lower/OpenMP/distribute-simd.f90 | 59 ++ flang/test/Lower/OpenMP/if-clause.f90 | 218 +++- flang/test/Lower/OpenMP/loop-compound.f90 | 45 +++- 4 files changed, 351 insertions(+), 9 deletions(-) create mode 100644 flang/test/Lower/OpenMP/distribute-simd.f90 diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index 50ff53a1cb0b3..95248900ffc23 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -1976,7 +1976,43 @@ static void genCompositeDistributeSimd( semantics::SemanticsContext , lower::pft::Evaluation , mlir::Location loc, const ConstructQueue , ConstructQueue::iterator item, DataSharingProcessor ) { - TODO(loc, "Composite DISTRIBUTE SIMD"); + lower::StatementContext stmtCtx; + + // Clause processing. + mlir::omp::DistributeClauseOps distributeClauseOps; + genDistributeClauses(converter, semaCtx, stmtCtx, item->clauses, loc, + distributeClauseOps); + + mlir::omp::SimdClauseOps simdClauseOps; + genSimdClauses(converter, semaCtx, item->clauses, loc, simdClauseOps); + + mlir::omp::LoopNestClauseOps loopNestClauseOps; + llvm::SmallVector iv; + genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc, + loopNestClauseOps, iv); + + // Operation creation. + // TODO: Populate entry block arguments with private variables. + auto distributeOp = genWrapperOp( + converter, loc, distributeClauseOps, /*blockArgTypes=*/{}); + + // TODO: Populate entry block arguments with reduction and private variables. + auto simdOp = genWrapperOp(converter, loc, simdClauseOps, +/*blockArgTypes=*/{}); + + // Construct wrapper entry block list and associated symbols. It is important + // that the symbol order and the block argument order match, so that the + // symbol-value bindings created are correct. + // TODO: Add omp.distribute private and omp.simd private and reduction args. + auto wrapperArgs = llvm::to_vector( + llvm::concat(distributeOp.getRegion().getArguments(), +simdOp.getRegion().getArguments())); + + assert(wrapperArgs.empty() && + "Block args for omp.simd and omp.distribute currently not expected"); + genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item, +loopNestClauseOps, iv, /*wrapperSyms=*/{}, wrapperArgs, +llvm::omp::Directive::OMPD_distribute_simd, dsp); } static void genCompositeDoSimd(lower::AbstractConverter , diff --git a/flang/test/Lower/OpenMP/distribute-simd.f90 b/flang/test/Lower/OpenMP/distribute-simd.f90 new file mode 100644 index 0..545037b7791b8 --- /dev/null +++ b/flang/test/Lower/OpenMP/distribute-simd.f90 @@ -0,0 +1,59 @@ +! This test checks lowering of OpenMP DISTRIBUTE SIMD composite constructs. + +! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s +! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s + +! CHECK-LABEL: func.func @_QPdistribute_simd_aligned( +subroutine distribute_simd_aligned(A) + use iso_c_binding + type(c_ptr) :: A + + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: aligned({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: aligned({{.*}}) + !$omp distribute simd aligned(A) + do index_ = 1, 10 +call c_test_call(A) + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_aligned + +! CHECK-LABEL: func.func @_QPdistribute_simd_safelen( +subroutine distribute_simd_safelen() + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: safelen({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: safelen({{.*}}) + !$omp distribute simd safelen(4) + do index_ = 1, 10 + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_safelen + +! CHECK-LABEL: func.func @_QPdistribute_simd_simdlen( +subroutine distribute_simd_simdlen() + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: simdlen({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: simdlen({{.*}}) + !$omp distribute simd simdlen(4) + do
[llvm-branch-commits] [flang] [mlir] [Flang][OpenMP] Add lowering support for DO SIMD (PR #97718)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/97718 >From 27490fbac8e08ed6c11437ef28efd8298fb120b1 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Thu, 4 Jul 2024 12:56:43 +0100 Subject: [PATCH 1/3] [Flang][OpenMP] Add lowering support for DO SIMD This patch adds support for lowering 'DO SIMD' constructs to MLIR. SIMD information is now stored in an `omp.simd` loop wrapper, which is currently ignored by the OpenMP dialect to LLVM IR translation stage. The end result is that runtime behavior of compiled 'DO SIMD' constructs does not change after this patch, so 'DO SIMD' still runs like 'DO' (i.e. SIMD width = 1). However, all of the required information is now present in the resulting MLIR representation. To avoid confusion, the previous wsloop-simd.f90 lit test is renamed to wsloop-schedule.f90 and a new wsloop-simd.f90 test is created to check the addition of SIMD clauses to the `omp.simd` operation produced when a 'DO SIMD' construct is lowered to MLIR. --- flang/lib/Lower/OpenMP/OpenMP.cpp | 49 .../Lower/OpenMP/Todo/omp-do-simd-aligned.f90 | 16 .../Lower/OpenMP/Todo/omp-do-simd-linear.f90 | 2 +- .../Lower/OpenMP/Todo/omp-do-simd-safelen.f90 | 14 .../Lower/OpenMP/Todo/omp-do-simd-simdlen.f90 | 14 flang/test/Lower/OpenMP/if-clause.f90 | 31 flang/test/Lower/OpenMP/loop-compound.f90 | 3 + flang/test/Lower/OpenMP/wsloop-schedule.f90 | 37 ++ flang/test/Lower/OpenMP/wsloop-simd.f90 | 74 +++ .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 3 + 10 files changed, 153 insertions(+), 90 deletions(-) delete mode 100644 flang/test/Lower/OpenMP/Todo/omp-do-simd-aligned.f90 delete mode 100644 flang/test/Lower/OpenMP/Todo/omp-do-simd-safelen.f90 delete mode 100644 flang/test/Lower/OpenMP/Todo/omp-do-simd-simdlen.f90 create mode 100644 flang/test/Lower/OpenMP/wsloop-schedule.f90 diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index f29d3517bb39b..67bfdb150a7f2 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -1986,19 +1986,42 @@ static void genCompositeDoSimd(lower::AbstractConverter , const ConstructQueue , ConstructQueue::iterator item, DataSharingProcessor ) { - ClauseProcessor cp(converter, semaCtx, item->clauses); - cp.processTODO(loc, - llvm::omp::OMPD_do_simd); - // TODO: Add support for vectorization - add vectorization hints inside loop - // body. - // OpenMP standard does not specify the length of vector instructions. - // Currently we safely assume that for !$omp do simd pragma the SIMD length - // is equal to 1 (i.e. we generate standard workshare loop). - // When support for vectorization is enabled, then we need to add handling of - // if clause. Currently if clause can be skipped because we always assume - // SIMD length = 1. - genStandaloneDo(converter, symTable, semaCtx, eval, loc, queue, item, dsp); + lower::StatementContext stmtCtx; + + // Clause processing. + mlir::omp::WsloopClauseOps wsloopClauseOps; + llvm::SmallVector wsloopReductionSyms; + llvm::SmallVector wsloopReductionTypes; + genWsloopClauses(converter, semaCtx, stmtCtx, item->clauses, loc, + wsloopClauseOps, wsloopReductionTypes, wsloopReductionSyms); + + mlir::omp::SimdClauseOps simdClauseOps; + genSimdClauses(converter, semaCtx, item->clauses, loc, simdClauseOps); + + mlir::omp::LoopNestClauseOps loopNestClauseOps; + llvm::SmallVector iv; + genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc, + loopNestClauseOps, iv); + + // Operation creation. + auto wsloopOp = + genWsloopWrapperOp(converter, semaCtx, eval, loc, wsloopClauseOps, + wsloopReductionSyms, wsloopReductionTypes); + + auto simdOp = genSimdWrapperOp(converter, semaCtx, eval, loc, simdClauseOps); + + // Construct wrapper entry block list and associated symbols. It is important + // that the symbol and block argument order match, so that the symbol-value + // bindings created are correct. + // TODO: Add omp.wsloop private and omp.simd private and reduction args. + auto wrapperArgs = llvm::to_vector(llvm::concat( + wsloopOp.getRegion().getArguments(), simdOp.getRegion().getArguments())); + + assert(wsloopReductionSyms.size() == wrapperArgs.size() && + "Number of symbols and wrapper block arguments must match"); + genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item, +loopNestClauseOps, iv, wsloopReductionSyms, wrapperArgs, +llvm::omp::Directive::OMPD_do_simd, dsp); } static void genCompositeTaskloopSimd( diff --git a/flang/test/Lower/OpenMP/Todo/omp-do-simd-aligned.f90 b/flang/test/Lower/OpenMP/Todo/omp-do-simd-aligned.f90 deleted file
[llvm-branch-commits] [flang] [mlir] [Flang][OpenMP] Add lowering support for DO SIMD (PR #97718)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/97718 >From 27490fbac8e08ed6c11437ef28efd8298fb120b1 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Thu, 4 Jul 2024 12:56:43 +0100 Subject: [PATCH 1/2] [Flang][OpenMP] Add lowering support for DO SIMD This patch adds support for lowering 'DO SIMD' constructs to MLIR. SIMD information is now stored in an `omp.simd` loop wrapper, which is currently ignored by the OpenMP dialect to LLVM IR translation stage. The end result is that runtime behavior of compiled 'DO SIMD' constructs does not change after this patch, so 'DO SIMD' still runs like 'DO' (i.e. SIMD width = 1). However, all of the required information is now present in the resulting MLIR representation. To avoid confusion, the previous wsloop-simd.f90 lit test is renamed to wsloop-schedule.f90 and a new wsloop-simd.f90 test is created to check the addition of SIMD clauses to the `omp.simd` operation produced when a 'DO SIMD' construct is lowered to MLIR. --- flang/lib/Lower/OpenMP/OpenMP.cpp | 49 .../Lower/OpenMP/Todo/omp-do-simd-aligned.f90 | 16 .../Lower/OpenMP/Todo/omp-do-simd-linear.f90 | 2 +- .../Lower/OpenMP/Todo/omp-do-simd-safelen.f90 | 14 .../Lower/OpenMP/Todo/omp-do-simd-simdlen.f90 | 14 flang/test/Lower/OpenMP/if-clause.f90 | 31 flang/test/Lower/OpenMP/loop-compound.f90 | 3 + flang/test/Lower/OpenMP/wsloop-schedule.f90 | 37 ++ flang/test/Lower/OpenMP/wsloop-simd.f90 | 74 +++ .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 3 + 10 files changed, 153 insertions(+), 90 deletions(-) delete mode 100644 flang/test/Lower/OpenMP/Todo/omp-do-simd-aligned.f90 delete mode 100644 flang/test/Lower/OpenMP/Todo/omp-do-simd-safelen.f90 delete mode 100644 flang/test/Lower/OpenMP/Todo/omp-do-simd-simdlen.f90 create mode 100644 flang/test/Lower/OpenMP/wsloop-schedule.f90 diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index f29d3517bb39bc..67bfdb150a7f22 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -1986,19 +1986,42 @@ static void genCompositeDoSimd(lower::AbstractConverter , const ConstructQueue , ConstructQueue::iterator item, DataSharingProcessor ) { - ClauseProcessor cp(converter, semaCtx, item->clauses); - cp.processTODO(loc, - llvm::omp::OMPD_do_simd); - // TODO: Add support for vectorization - add vectorization hints inside loop - // body. - // OpenMP standard does not specify the length of vector instructions. - // Currently we safely assume that for !$omp do simd pragma the SIMD length - // is equal to 1 (i.e. we generate standard workshare loop). - // When support for vectorization is enabled, then we need to add handling of - // if clause. Currently if clause can be skipped because we always assume - // SIMD length = 1. - genStandaloneDo(converter, symTable, semaCtx, eval, loc, queue, item, dsp); + lower::StatementContext stmtCtx; + + // Clause processing. + mlir::omp::WsloopClauseOps wsloopClauseOps; + llvm::SmallVector wsloopReductionSyms; + llvm::SmallVector wsloopReductionTypes; + genWsloopClauses(converter, semaCtx, stmtCtx, item->clauses, loc, + wsloopClauseOps, wsloopReductionTypes, wsloopReductionSyms); + + mlir::omp::SimdClauseOps simdClauseOps; + genSimdClauses(converter, semaCtx, item->clauses, loc, simdClauseOps); + + mlir::omp::LoopNestClauseOps loopNestClauseOps; + llvm::SmallVector iv; + genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc, + loopNestClauseOps, iv); + + // Operation creation. + auto wsloopOp = + genWsloopWrapperOp(converter, semaCtx, eval, loc, wsloopClauseOps, + wsloopReductionSyms, wsloopReductionTypes); + + auto simdOp = genSimdWrapperOp(converter, semaCtx, eval, loc, simdClauseOps); + + // Construct wrapper entry block list and associated symbols. It is important + // that the symbol and block argument order match, so that the symbol-value + // bindings created are correct. + // TODO: Add omp.wsloop private and omp.simd private and reduction args. + auto wrapperArgs = llvm::to_vector(llvm::concat( + wsloopOp.getRegion().getArguments(), simdOp.getRegion().getArguments())); + + assert(wsloopReductionSyms.size() == wrapperArgs.size() && + "Number of symbols and wrapper block arguments must match"); + genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item, +loopNestClauseOps, iv, wsloopReductionSyms, wrapperArgs, +llvm::omp::Directive::OMPD_do_simd, dsp); } static void genCompositeTaskloopSimd( diff --git a/flang/test/Lower/OpenMP/Todo/omp-do-simd-aligned.f90 b/flang/test/Lower/OpenMP/Todo/omp-do-simd-aligned.f90 deleted file
[llvm-branch-commits] [CodeGen] Add dump() to MachineTraceMetrics.h (PR #97799)
https://github.com/RKSimon approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/97799 ___ 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] [CodeGen] Add dump() to MachineTraceMetrics.h (PR #97799)
https://github.com/dtcxzyw approved this pull request. https://github.com/llvm/llvm-project/pull/97799 ___ 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] [llvm-objcopy] Support CREL (PR #97521)
@@ -0,0 +1,140 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-objcopy --remove-section=.foo --strip-symbol=unused %t %t.out +# RUN: llvm-readelf -Sr %t.out | FileCheck %s + +# CHECK: [Nr] Name TypeAddress Off Size ES Flg Lk Inf Al +# CHECK-NEXT: [ 0] NULL 00 00 00 0 0 0 +# CHECK-NEXT: [ 1] .text PROGBITS {{.*}} 08 00 A 0 0 0 +# CHECK-NEXT: [ 2] .crel.textCREL {{.*}} 22 00 5 1 0 +# CHECK-NEXT: [ 3] nonalloc PROGBITS {{.*}} 30 00 0 0 0 +# CHECK-NEXT: [ 4] .crelnonalloc CREL {{.*}} 0b 00 5 3 0 + +# CHECK: Relocation section '.crel.text' at offset {{.*}} contains 4 entries: +# CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend +# CHECK-NEXT: 0001 {{.*}} R_X86_64_32 g1 + 1 +# CHECK-NEXT: 0002 {{.*}} R_X86_64_64 l1 + 2 +# CHECK-NEXT: {{.*}} R_X86_64_32S g1 - 1 +# CHECK-NEXT: 0004 {{.*}} R_X86_64_32S .text - 8000 +# CHECK-EMPTY: +# CHECK-NEXT: Relocation section '.crelnonalloc' at offset {{.*}} contains 3 entries: +# CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend +# CHECK-NEXT: 0010 {{.*}} R_X86_64_64 g1 + 1 +# CHECK-NEXT: 0020 {{.*}} R_X86_64_64 g2 + 2 +# CHECK-NEXT: 0030 {{.*}} R_X86_64_64 0 + +--- !ELF +FileHeader: !FileHeader jh7370 wrote: This line doesn't look right? https://github.com/llvm/llvm-project/pull/97521 ___ 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] [llvm-objcopy] Support CREL (PR #97521)
https://github.com/jh7370 commented: Is it worth a test to show a user attempting to strip a symbol referenced by a crel section? Similarly, a crel section that is associated with a section that gets stripped? Perhaps not needed, but just a thought. https://github.com/llvm/llvm-project/pull/97521 ___ 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] [llvm-objcopy] Support CREL (PR #97521)
https://github.com/jh7370 edited https://github.com/llvm/llvm-project/pull/97521 ___ 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] [llvm-objcopy] Support CREL (PR #97521)
@@ -0,0 +1,63 @@ +//===- MCELFExtras.h - Extra functions for ELF --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_MC_MCELFEXTRAS_H +#define LLVM_MC_MCELFEXTRAS_H + +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/bit.h" +#include "llvm/BinaryFormat/ELF.h" +#include "llvm/Support/LEB128.h" +#include "llvm/Support/raw_ostream.h" + +#include +#include + +namespace llvm::ELF { +// Encode relocations as CREL to OS. ToCrel is responsible for converting a +// const to a Elf_Crel jh7370 wrote: ```suggestion // const to a Elf_Crel. ``` Nit https://github.com/llvm/llvm-project/pull/97521 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -139,64 +262,59 @@ bool SLSHardeningInserter::hardenReturnsAndBRs(MachineModuleInfo , return Modified; } -static const unsigned NumPermittedRegs = 29; -static const struct ThunkNameAndReg { - const char* Name; - Register Reg; -} SLSBLRThunks[NumPermittedRegs] = { -{"__llvm_slsblr_thunk_x0", AArch64::X0}, -{"__llvm_slsblr_thunk_x1", AArch64::X1}, -{"__llvm_slsblr_thunk_x2", AArch64::X2}, -{"__llvm_slsblr_thunk_x3", AArch64::X3}, -{"__llvm_slsblr_thunk_x4", AArch64::X4}, -{"__llvm_slsblr_thunk_x5", AArch64::X5}, -{"__llvm_slsblr_thunk_x6", AArch64::X6}, -{"__llvm_slsblr_thunk_x7", AArch64::X7}, -{"__llvm_slsblr_thunk_x8", AArch64::X8}, -{"__llvm_slsblr_thunk_x9", AArch64::X9}, -{"__llvm_slsblr_thunk_x10", AArch64::X10}, -{"__llvm_slsblr_thunk_x11", AArch64::X11}, -{"__llvm_slsblr_thunk_x12", AArch64::X12}, -{"__llvm_slsblr_thunk_x13", AArch64::X13}, -{"__llvm_slsblr_thunk_x14", AArch64::X14}, -{"__llvm_slsblr_thunk_x15", AArch64::X15}, -// X16 and X17 are deliberately missing, as the mitigation requires those -// register to not be used in BLR. See comment in ConvertBLRToBL for more -// details. -{"__llvm_slsblr_thunk_x18", AArch64::X18}, -{"__llvm_slsblr_thunk_x19", AArch64::X19}, -{"__llvm_slsblr_thunk_x20", AArch64::X20}, -{"__llvm_slsblr_thunk_x21", AArch64::X21}, -{"__llvm_slsblr_thunk_x22", AArch64::X22}, -{"__llvm_slsblr_thunk_x23", AArch64::X23}, -{"__llvm_slsblr_thunk_x24", AArch64::X24}, -{"__llvm_slsblr_thunk_x25", AArch64::X25}, -{"__llvm_slsblr_thunk_x26", AArch64::X26}, -{"__llvm_slsblr_thunk_x27", AArch64::X27}, -{"__llvm_slsblr_thunk_x28", AArch64::X28}, -{"__llvm_slsblr_thunk_x29", AArch64::FP}, -// X30 is deliberately missing, for similar reasons as X16 and X17 are -// missing. -{"__llvm_slsblr_thunk_x31", AArch64::XZR}, -}; +// Currently, the longest possible thunk name is +// __llvm_slsblr_thunk_aa_xNN_xMM +// which is 31 characters (without the '\0' character). +static SmallString<32> createThunkName(const ThunkKind , Register Xn, + Register Xm) { + unsigned N = ThunksSet::indexOfXReg(Xn); + if (!Kind.HasXmOperand) +return formatv("{0}{1}x{2}", CommonNamePrefix, Kind.NameInfix, N); + + unsigned M = ThunksSet::indexOfXReg(Xm); + return formatv("{0}{1}x{2}_x{3}", CommonNamePrefix, Kind.NameInfix, N, M); +} -unsigned getThunkIndex(Register Reg) { - for (unsigned I = 0; I < NumPermittedRegs; ++I) -if (SLSBLRThunks[I].Reg == Reg) - return I; - llvm_unreachable("Unexpected register"); +static const ThunkKind (StringRef ThunkName, Register , kbeyls wrote: Again a very minor nitpick: I was a bit confused initially that the 3 results of this function are returned split between function return value (ThunkKind) and 2 pass-by-reference function arguments (Xn, Xm). Would it be better to either return all 3 of them through a function return value, or return all 3 of them through pass-by-reference function arguments? I'm just sharing it in case you think it's worthwhile to make such a change. https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -221,13 +339,19 @@ void SLSHardeningInserter::populateThunk(MachineFunction ) { // __llvm_slsblr_thunk_xN: // BR xN // barrierInsts kbeyls wrote: As part of reviewing this, I was wondering why the actual thunk content is ``` // __llvm_slsblr_thunk_{aa|ab|aaz|abz|}_xN_{xM}: // MOV X16, Xn // BR X16 | BRA{A|B} X16, Xm | BRA{A|B}Z X16 // barrierInsts ``` I had to use git blame to remind myself of why I changed this about 4 years ago, pointing to this commit: https://github.com/llvm/llvm-project/commit/d938ec4509c47d461377527fc2877ae14b91275c I think it would be useful to add an explanation similar to the one on that commit message to the comment here to explain why the `mov X16, Xn` is needed, as it is non-trivial. The explanation on the original commit message is: ``` A "BTI c" instruction only allows jumping/calling to using a BLR* instruction. However, the SLSBLR mitigation changes a BLR to a BR to implement the function call. Therefore, a "BTI c" check that passed before could trigger after the BLR->BR change done by the SLSBLR mitigation. However, if the register used in BR is X16 or X17, this trigger will not fire (see ArmARM for further details). ``` https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -221,13 +339,19 @@ void SLSHardeningInserter::populateThunk(MachineFunction ) { // __llvm_slsblr_thunk_xN: // BR xN // barrierInsts kbeyls wrote: Maybe something like ``` // __llvm_slsblr_thunk_{aa|ab|aaz|abz|}_xN_{xM}: // BR Xn | BRA{A|B} Xn, Xm | BRA{A|B}Z xN // barrierInsts ``` ? https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -68,6 +156,57 @@ struct SLSHardeningInserter : ThunkInserter { } // end anonymous namespace +const ThunkKind ThunkKind::BR = {ThunkBR, "", false, false, AArch64::BR}; +const ThunkKind ThunkKind::BRAA = {ThunkBRAA, "aa_", true, true, AArch64::BRAA}; +const ThunkKind ThunkKind::BRAB = {ThunkBRAB, "ab_", true, true, AArch64::BRAB}; +const ThunkKind ThunkKind::BRAAZ = {ThunkBRAAZ, "aaz_", false, true, +AArch64::BRAAZ}; +const ThunkKind ThunkKind::BRABZ = {ThunkBRABZ, "abz_", false, true, +AArch64::BRABZ}; + +static const ThunkKind *getThunkKind(unsigned OriginalOpcode) { kbeyls wrote: very minor comment: I thought I'd just share that if I would've written this function, I'd probably use std::optional rather than a "pointer to" return value. But this is very nit-picky, so if you think "pointer to" is better, let's leave it as is. https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -68,6 +156,57 @@ struct SLSHardeningInserter : ThunkInserter { } // end anonymous namespace +const ThunkKind ThunkKind::BR = {ThunkBR, "", false, false, AArch64::BR}; +const ThunkKind ThunkKind::BRAA = {ThunkBRAA, "aa_", true, true, AArch64::BRAA}; +const ThunkKind ThunkKind::BRAB = {ThunkBRAB, "ab_", true, true, AArch64::BRAB}; +const ThunkKind ThunkKind::BRAAZ = {ThunkBRAAZ, "aaz_", false, true, +AArch64::BRAAZ}; +const ThunkKind ThunkKind::BRABZ = {ThunkBRABZ, "abz_", false, true, +AArch64::BRABZ}; + +static const ThunkKind *getThunkKind(unsigned OriginalOpcode) { + switch (OriginalOpcode) { + case AArch64::BLR: + case AArch64::BLRNoIP: +return ::BR; + case AArch64::BLRAA: +return ::BRAA; + case AArch64::BLRAB: +return ::BRAB; + case AArch64::BLRAAZ: +return ::BRAAZ; + case AArch64::BLRABZ: +return ::BRABZ; + } + return nullptr; +} + +static bool isBLR(const MachineInstr ) { + return getThunkKind(MI.getOpcode()) != nullptr; +} + +unsigned ThunksSet::indexOfXReg(Register Reg) { + assert(AArch64::GPR64RegClass.contains(Reg)); + assert(Reg != AArch64::X16 && Reg != AArch64::X17 && Reg != AArch64::LR); + + // Most Xn registers have consequent ids, except for FP and XZR. kbeyls wrote: s/consequent/consecutive/? https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -221,13 +339,19 @@ void SLSHardeningInserter::populateThunk(MachineFunction ) { // __llvm_slsblr_thunk_xN: // BR xN // barrierInsts kbeyls wrote: I think it would be useful to update this comment to make it clear what the different kinds of thunk bodies are that are intended to be created here. https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -0,0 +1,210 @@ +# RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu \ +# RUN: -start-before aarch64-sls-hardening -o - %s \ +# RUN: -asm-verbose=0 \ +# RUN: | FileCheck %s \ +# RUN: --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 \ +# RUN: --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 \ +# RUN: --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 \ +# RUN: --implicit-check-not=__llvm_slsblr_thunk_abz_x5 + +# Pointer Authentication extension introduces more branch-with-link instructions kbeyls wrote: Maybe say "branch-with-link-to-register" as that's the name the ArmARM (Arm Architecture reference manual) uses for BLR* instructions. "branch-with-link" to me refers to the BL instruction. https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -274,40 +398,31 @@ void SLSHardeningInserter::convertBLRToBL( MachineInstr = *MBBI; assert(isBLR(BLR)); - unsigned BLOpcode; - Register Reg; - bool RegIsKilled; - switch (BLR.getOpcode()) { - case AArch64::BLR: - case AArch64::BLRNoIP: -BLOpcode = AArch64::BL; -Reg = BLR.getOperand(0).getReg(); -assert(Reg != AArch64::X16 && Reg != AArch64::X17 && Reg != AArch64::LR); -RegIsKilled = BLR.getOperand(0).isKill(); -break; - case AArch64::BLRAA: - case AArch64::BLRAB: - case AArch64::BLRAAZ: - case AArch64::BLRABZ: -llvm_unreachable("BLRA instructions cannot yet be produced by LLVM, " - "therefore there is no need to support them for now."); - default: -llvm_unreachable("unhandled BLR"); - } + const ThunkKind = *getThunkKind(BLR.getOpcode()); kbeyls wrote: In the 20-line-ish long comment above (which I cannot comment on directly in github), I think it would also be useful to indicate which branch instructions might be the authenticating ones. I think that might help the reader a bit better with more quickly understanding what the intended transform is. E.g. something like: ``` // Before: // |-| // | ...| // | instI | // | BLR{A|B|}{Z} xN{, xM} | // | instJ | // | ...| // |-| // // After: // |-| // | ...| // | instI | // | BL __llvm_slsblr_thunk_xN | // | instJ | // | ...| // |-| // // __llvm_slsblr_thunk_xN: // |-| // | BR{A|B|}{Z} xN{, xM} | // | barrierInsts | // |-| // ``` https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
https://github.com/kbeyls commented: Thank you, this mostly looks good to me. I've only added very minor comments; feel free to disagree with them. https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
https://github.com/kbeyls edited https://github.com/llvm/llvm-project/pull/97605 ___ 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] [AArch64][PAC] Support BLRA* instructions in SLS Hardening pass (PR #97605)
@@ -68,6 +156,57 @@ struct SLSHardeningInserter : ThunkInserter { } // end anonymous namespace +const ThunkKind ThunkKind::BR = {ThunkBR, "", false, false, AArch64::BR}; +const ThunkKind ThunkKind::BRAA = {ThunkBRAA, "aa_", true, true, AArch64::BRAA}; +const ThunkKind ThunkKind::BRAB = {ThunkBRAB, "ab_", true, true, AArch64::BRAB}; +const ThunkKind ThunkKind::BRAAZ = {ThunkBRAAZ, "aaz_", false, true, +AArch64::BRAAZ}; +const ThunkKind ThunkKind::BRABZ = {ThunkBRABZ, "abz_", false, true, +AArch64::BRABZ}; kbeyls wrote: very minor nitpick: These probably can go directly after the definition of `struct ThunkKind`? If so, it's easier to understand what all the "false" and "true"s mean here without having to scroll a lot to where `struct ThunkKind` is defined. https://github.com/llvm/llvm-project/pull/97605 ___ 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-objdump] -r: support CREL (PR #97382)
@@ -1117,9 +1155,11 @@ void ELFObjectFile::getRelocationTypeName( template Expected ELFObjectFile::getRelocationAddend(DataRefImpl Rel) const { - if (getRelSection(Rel)->sh_type != ELF::SHT_RELA) -return createError("Section is not SHT_RELA"); - return (int64_t)getRela(Rel)->r_addend; + if (getRelSection(Rel)->sh_type == ELF::SHT_RELA) +return (int64_t)getRela(Rel)->r_addend; + if (getRelSection(Rel)->sh_type == ELF::SHT_CREL) +return (int64_t)getCrel(Rel).r_addend; + return createError("Section is not SHT_RELA"); jh7370 wrote: I'm not sure this error quite makes sense anymore. Probably needs to say something about addends. https://github.com/llvm/llvm-project/pull/97382 ___ 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] [CodeGen] Add dump() to MachineTraceMetrics.h (PR #97799)
https://github.com/wangpc-pp created https://github.com/llvm/llvm-project/pull/97799 To enhance debugging. ___ 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] [RISCV] Support select optimization (PR #80124)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/80124 >From e3fb1fe7bdd4b7c24f9361c4d14dd1206fc8c067 Mon Sep 17 00:00:00 2001 From: wangpc Date: Sun, 18 Feb 2024 11:12:16 +0800 Subject: [PATCH 1/2] Move after addIRPasses Created using spr 1.3.4 --- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp index fdf1c023fff87..7a26e1956424c 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -450,15 +450,15 @@ void RISCVPassConfig::addIRPasses() { if (EnableLoopDataPrefetch) addPass(createLoopDataPrefetchPass()); -if (EnableSelectOpt && getOptLevel() == CodeGenOptLevel::Aggressive) - addPass(createSelectOptimizePass()); - addPass(createRISCVGatherScatterLoweringPass()); addPass(createInterleavedAccessPass()); addPass(createRISCVCodeGenPreparePass()); } TargetPassConfig::addIRPasses(); + + if (getOptLevel() == CodeGenOptLevel::Aggressive && EnableSelectOpt) +addPass(createSelectOptimizePass()); } bool RISCVPassConfig::addPreISel() { >From 5d5398596dc30c47c67572ec20137fb3f9434940 Mon Sep 17 00:00:00 2001 From: wangpc Date: Wed, 21 Feb 2024 21:21:28 +0800 Subject: [PATCH 2/2] Fix test Created using spr 1.3.4 --- llvm/test/CodeGen/RISCV/O3-pipeline.ll | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll index 62c1af52e6c20..8b52e3fe7b2f1 100644 --- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll @@ -34,15 +34,6 @@ ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Data Prefetch -; CHECK-NEXT: Post-Dominator Tree Construction -; CHECK-NEXT: Branch Probability Analysis -; CHECK-NEXT: Block Frequency Analysis -; CHECK-NEXT: Lazy Branch Probability Analysis -; CHECK-NEXT: Lazy Block Frequency Analysis -; CHECK-NEXT: Optimization Remark Emitter -; CHECK-NEXT: Optimize selects -; CHECK-NEXT: Dominator Tree Construction -; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: RISC-V gather/scatter lowering ; CHECK-NEXT: Interleaved Access Pass ; CHECK-NEXT: RISC-V CodeGenPrepare @@ -77,6 +68,15 @@ ; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: TLS Variable Hoist +; CHECK-NEXT: Post-Dominator Tree Construction +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Optimize selects +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: CodeGen Prepare ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Exception handling preparation ___ 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] [RISCV] Support select optimization (PR #80124)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/80124 >From e3fb1fe7bdd4b7c24f9361c4d14dd1206fc8c067 Mon Sep 17 00:00:00 2001 From: wangpc Date: Sun, 18 Feb 2024 11:12:16 +0800 Subject: [PATCH 1/2] Move after addIRPasses Created using spr 1.3.4 --- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp index fdf1c023fff878..7a26e1956424cb 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -450,15 +450,15 @@ void RISCVPassConfig::addIRPasses() { if (EnableLoopDataPrefetch) addPass(createLoopDataPrefetchPass()); -if (EnableSelectOpt && getOptLevel() == CodeGenOptLevel::Aggressive) - addPass(createSelectOptimizePass()); - addPass(createRISCVGatherScatterLoweringPass()); addPass(createInterleavedAccessPass()); addPass(createRISCVCodeGenPreparePass()); } TargetPassConfig::addIRPasses(); + + if (getOptLevel() == CodeGenOptLevel::Aggressive && EnableSelectOpt) +addPass(createSelectOptimizePass()); } bool RISCVPassConfig::addPreISel() { >From 5d5398596dc30c47c67572ec20137fb3f9434940 Mon Sep 17 00:00:00 2001 From: wangpc Date: Wed, 21 Feb 2024 21:21:28 +0800 Subject: [PATCH 2/2] Fix test Created using spr 1.3.4 --- llvm/test/CodeGen/RISCV/O3-pipeline.ll | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll index 62c1af52e6c20e..8b52e3fe7b2f15 100644 --- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll @@ -34,15 +34,6 @@ ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Data Prefetch -; CHECK-NEXT: Post-Dominator Tree Construction -; CHECK-NEXT: Branch Probability Analysis -; CHECK-NEXT: Block Frequency Analysis -; CHECK-NEXT: Lazy Branch Probability Analysis -; CHECK-NEXT: Lazy Block Frequency Analysis -; CHECK-NEXT: Optimization Remark Emitter -; CHECK-NEXT: Optimize selects -; CHECK-NEXT: Dominator Tree Construction -; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: RISC-V gather/scatter lowering ; CHECK-NEXT: Interleaved Access Pass ; CHECK-NEXT: RISC-V CodeGenPrepare @@ -77,6 +68,15 @@ ; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: TLS Variable Hoist +; CHECK-NEXT: Post-Dominator Tree Construction +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Optimize selects +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: CodeGen Prepare ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Exception handling preparation ___ 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] [Serialization] Code cleanups and polish 83233 (PR #83237)
ChuanqiXu9 wrote: Sorry for bothering, I tried a new manner to update the patch but it shows I should better : ( https://github.com/llvm/llvm-project/pull/83237 ___ 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] [libc] [lld] [lldb] [llvm] [Serialization] Introduce OnDiskHashTable for specializations (PR #83233)
https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/83233 error: too big or took too long to generate ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits