[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/101243 >From 61371af08b82e1229c34b43f56772813c2f74b1c Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 13:56:21 -0700 Subject: [PATCH 1/5] [cmake][llvm] Limit the number of Xcode schemes created by default CMake -GXcode would otherwise offer to create one scheme for each target, which ends up being a lot. For t push --forcenow, limit the default to the `check-*` LIT targets, plus `ALL_BUILD` and `install`. --- cmake/Modules/Xcode.cmake| 24 llvm/CMakeLists.txt | 4 llvm/cmake/modules/AddLLVM.cmake | 1 + 3 files changed, 29 insertions(+) create mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake new file mode 100644 index 0..466cf79eb8b00 --- /dev/null +++ b/cmake/Modules/Xcode.cmake @@ -0,0 +1,24 @@ +# When this is enabled, CMake will generate schemes for every target, but not +# all of them make sense to surface in the Xcode UI by default. +set(CMAKE_XCODE_GENERATE_SCHEME YES) + +# Enumerate all the targets in a directory. +macro(get_all_targets targets dir) + get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${sub_dirs}) +get_all_targets(${targets} ${subdir}) + endforeach() + get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${local_targets}) +endmacro() + +get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) + +# Turn off scheme generation by default for targets that do not have +# XCODE_GENERATE_SCHEME set. +foreach(target ${all_targets}) + get_target_property(value ${target} XCODE_GENERATE_SCHEME) + if("${value}" STREQUAL "value-NOTFOUND") +set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) + endif() +endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 12618966c4adf..501b9ea288053 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,3 +1423,7 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + include(Xcode) +endif() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 03f4e1f190fd9..f4f71b35ffa70 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2043,6 +2043,7 @@ function(add_lit_target target comment) # Tests should be excluded from "Build Solution". set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) + set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # Convert a target name like check-clang to a variable name like CLANG. >From 9b294dcb88c5aeb377454338773fabbaf58e41d6 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:36:56 -0700 Subject: [PATCH 2/5] take Jonas' suggestion --- cmake/Modules/Xcode.cmake | 24 llvm/CMakeLists.txt | 4 2 files changed, 28 deletions(-) delete mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake deleted file mode 100644 index 466cf79eb8b00..0 --- a/cmake/Modules/Xcode.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# When this is enabled, CMake will generate schemes for every target, but not -# all of them make sense to surface in the Xcode UI by default. -set(CMAKE_XCODE_GENERATE_SCHEME YES) - -# Enumerate all the targets in a directory. -macro(get_all_targets targets dir) - get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) - foreach(subdir ${sub_dirs}) -get_all_targets(${targets} ${subdir}) - endforeach() - get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) - list(APPEND ${targets} ${local_targets}) -endmacro() - -get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) - -# Turn off scheme generation by default for targets that do not have -# XCODE_GENERATE_SCHEME set. -foreach(target ${all_targets}) - get_target_property(value ${target} XCODE_GENERATE_SCHEME) - if("${value}" STREQUAL "value-NOTFOUND") -set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) - endif() -endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 501b9ea288053..12618966c4adf 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,7 +1423,3 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() - -if (XCODE) - include(Xcode) -endif() >From 834f4b1d7d7a062d6de08a3c285890c580097406 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:44:27 -0700 Subject: [PATCH 3/5] generate schemes for llvm_add_tool tools, too --- llvm/cmake/modules/AddLLVM.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f4f71b35ffa70..ac47e884ac229 100644 --- a/llvm/cmake/modules/AddLLVM.cm
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
jroelofs wrote: neat idea. that's doable. https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/101243 >From 61371af08b82e1229c34b43f56772813c2f74b1c Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 13:56:21 -0700 Subject: [PATCH 1/6] [cmake][llvm] Limit the number of Xcode schemes created by default CMake -GXcode would otherwise offer to create one scheme for each target, which ends up being a lot. For t push --forcenow, limit the default to the `check-*` LIT targets, plus `ALL_BUILD` and `install`. --- cmake/Modules/Xcode.cmake| 24 llvm/CMakeLists.txt | 4 llvm/cmake/modules/AddLLVM.cmake | 1 + 3 files changed, 29 insertions(+) create mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake new file mode 100644 index 0..466cf79eb8b00 --- /dev/null +++ b/cmake/Modules/Xcode.cmake @@ -0,0 +1,24 @@ +# When this is enabled, CMake will generate schemes for every target, but not +# all of them make sense to surface in the Xcode UI by default. +set(CMAKE_XCODE_GENERATE_SCHEME YES) + +# Enumerate all the targets in a directory. +macro(get_all_targets targets dir) + get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${sub_dirs}) +get_all_targets(${targets} ${subdir}) + endforeach() + get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${local_targets}) +endmacro() + +get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) + +# Turn off scheme generation by default for targets that do not have +# XCODE_GENERATE_SCHEME set. +foreach(target ${all_targets}) + get_target_property(value ${target} XCODE_GENERATE_SCHEME) + if("${value}" STREQUAL "value-NOTFOUND") +set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) + endif() +endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 12618966c4adf..501b9ea288053 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,3 +1423,7 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + include(Xcode) +endif() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 03f4e1f190fd9..f4f71b35ffa70 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2043,6 +2043,7 @@ function(add_lit_target target comment) # Tests should be excluded from "Build Solution". set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) + set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # Convert a target name like check-clang to a variable name like CLANG. >From 9b294dcb88c5aeb377454338773fabbaf58e41d6 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:36:56 -0700 Subject: [PATCH 2/6] take Jonas' suggestion --- cmake/Modules/Xcode.cmake | 24 llvm/CMakeLists.txt | 4 2 files changed, 28 deletions(-) delete mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake deleted file mode 100644 index 466cf79eb8b00..0 --- a/cmake/Modules/Xcode.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# When this is enabled, CMake will generate schemes for every target, but not -# all of them make sense to surface in the Xcode UI by default. -set(CMAKE_XCODE_GENERATE_SCHEME YES) - -# Enumerate all the targets in a directory. -macro(get_all_targets targets dir) - get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) - foreach(subdir ${sub_dirs}) -get_all_targets(${targets} ${subdir}) - endforeach() - get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) - list(APPEND ${targets} ${local_targets}) -endmacro() - -get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) - -# Turn off scheme generation by default for targets that do not have -# XCODE_GENERATE_SCHEME set. -foreach(target ${all_targets}) - get_target_property(value ${target} XCODE_GENERATE_SCHEME) - if("${value}" STREQUAL "value-NOTFOUND") -set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) - endif() -endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 501b9ea288053..12618966c4adf 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,7 +1423,3 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() - -if (XCODE) - include(Xcode) -endif() >From 834f4b1d7d7a062d6de08a3c285890c580097406 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:44:27 -0700 Subject: [PATCH 3/6] generate schemes for llvm_add_tool tools, too --- llvm/cmake/modules/AddLLVM.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f4f71b35ffa70..ac47e884ac229 100644 --- a/llvm/cmake/modules/AddLLVM.cm
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
@@ -1423,3 +1423,11 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + set(LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes") jroelofs wrote: Lists in CMake are semicolon-separated. I'll add an example in a comment. https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/101243 >From 61371af08b82e1229c34b43f56772813c2f74b1c Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 13:56:21 -0700 Subject: [PATCH 1/7] [cmake][llvm] Limit the number of Xcode schemes created by default CMake -GXcode would otherwise offer to create one scheme for each target, which ends up being a lot. For t push --forcenow, limit the default to the `check-*` LIT targets, plus `ALL_BUILD` and `install`. --- cmake/Modules/Xcode.cmake| 24 llvm/CMakeLists.txt | 4 llvm/cmake/modules/AddLLVM.cmake | 1 + 3 files changed, 29 insertions(+) create mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake new file mode 100644 index 0..466cf79eb8b00 --- /dev/null +++ b/cmake/Modules/Xcode.cmake @@ -0,0 +1,24 @@ +# When this is enabled, CMake will generate schemes for every target, but not +# all of them make sense to surface in the Xcode UI by default. +set(CMAKE_XCODE_GENERATE_SCHEME YES) + +# Enumerate all the targets in a directory. +macro(get_all_targets targets dir) + get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${sub_dirs}) +get_all_targets(${targets} ${subdir}) + endforeach() + get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${local_targets}) +endmacro() + +get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) + +# Turn off scheme generation by default for targets that do not have +# XCODE_GENERATE_SCHEME set. +foreach(target ${all_targets}) + get_target_property(value ${target} XCODE_GENERATE_SCHEME) + if("${value}" STREQUAL "value-NOTFOUND") +set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) + endif() +endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 12618966c4adf..501b9ea288053 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,3 +1423,7 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + include(Xcode) +endif() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 03f4e1f190fd9..f4f71b35ffa70 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2043,6 +2043,7 @@ function(add_lit_target target comment) # Tests should be excluded from "Build Solution". set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) + set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # Convert a target name like check-clang to a variable name like CLANG. >From 9b294dcb88c5aeb377454338773fabbaf58e41d6 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:36:56 -0700 Subject: [PATCH 2/7] take Jonas' suggestion --- cmake/Modules/Xcode.cmake | 24 llvm/CMakeLists.txt | 4 2 files changed, 28 deletions(-) delete mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake deleted file mode 100644 index 466cf79eb8b00..0 --- a/cmake/Modules/Xcode.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# When this is enabled, CMake will generate schemes for every target, but not -# all of them make sense to surface in the Xcode UI by default. -set(CMAKE_XCODE_GENERATE_SCHEME YES) - -# Enumerate all the targets in a directory. -macro(get_all_targets targets dir) - get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) - foreach(subdir ${sub_dirs}) -get_all_targets(${targets} ${subdir}) - endforeach() - get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) - list(APPEND ${targets} ${local_targets}) -endmacro() - -get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) - -# Turn off scheme generation by default for targets that do not have -# XCODE_GENERATE_SCHEME set. -foreach(target ${all_targets}) - get_target_property(value ${target} XCODE_GENERATE_SCHEME) - if("${value}" STREQUAL "value-NOTFOUND") -set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) - endif() -endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 501b9ea288053..12618966c4adf 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,7 +1423,3 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() - -if (XCODE) - include(Xcode) -endif() >From 834f4b1d7d7a062d6de08a3c285890c580097406 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:44:27 -0700 Subject: [PATCH 3/7] generate schemes for llvm_add_tool tools, too --- llvm/cmake/modules/AddLLVM.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f4f71b35ffa70..ac47e884ac229 100644 --- a/llvm/cmake/modules/AddLLVM.cm
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [lldb] [libcxxabi] [clang-tools-extra] [libcxx] [mlir] [libc] [llvm] [clang] [lld] [flang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[Lldb-commits] [libc] [lld] [libcxxabi] [clang-tools-extra] [llvm] [clang] [flang] [compiler-rt] [lldb] [libcxx] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[Lldb-commits] [compiler-rt] [lldb] [libc] [clang] [lld] [mlir] [llvm] [libcxxabi] [clang-tools-extra] [flang] [libcxx] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[Lldb-commits] [clang] [lld] [clang-tools-extra] [lldb] [libcxxabi] [mlir] [compiler-rt] [libc] [openmp] [llvm] [libcxx] [flang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[Lldb-commits] [clang] [flang] [llvm] [lld] [libcxxabi] [libc] [lldb] [openmp] [compiler-rt] [libcxx] [clang-tools-extra] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/10] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments
[Lldb-commits] [clang-tools-extra] [compiler-rt] [clang] [flang] [libc] [lld] [openmp] [mlir] [lldb] [libcxxabi] [llvm] [libcxx] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/10] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments
[Lldb-commits] [lld] [llvm] [mlir] [lldb] [flang] [clang] [openmp] [clang-tools-extra] [libcxx] [libcxxabi] [compiler-rt] [libc] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[Lldb-commits] [llvm] [clang-tools-extra] [libcxx] [flang] [lld] [openmp] [lldb] [libcxxabi] [compiler-rt] [mlir] [clang] [libc] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[Lldb-commits] [mlir] [openmp] [flang] [libc] [clang-tools-extra] [llvm] [lldb] [lld] [libcxxabi] [compiler-rt] [libcxx] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
jroelofs wrote: ping https://github.com/llvm/llvm-project/pull/73686 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [libcxx] [lldb] [libc] [openmp] [clang-tools-extra] [compiler-rt] [flang] [libcxxabi] [lld] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[Lldb-commits] [lldb] [libc] [mlir] [llvm] [clang] [lld] [compiler-rt] [flang] [openmp] [clang-tools-extra] [libcxxabi] [libcxx] [llvm] Support IFuncs on Darwin platforms (PR #73686)
@@ -2169,8 +2169,11 @@ void AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) { MCSymbol *LocalAlias = getSymbolPreferLocal(GI); if (LocalAlias != Name) OutStreamer->emitAssignment(LocalAlias, Expr); - } else if (TM.getTargetTriple().isOSBinFormatMachO() && - getIFuncMCSubtargetInfo()) { + +return; + } + + if (TM.getTargetTriple().isOSBinFormatMachO() && getIFuncMCSubtargetInfo()) { jroelofs wrote: oh, I see. sure. https://github.com/llvm/llvm-project/pull/73686 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [mlir] [compiler-rt] [clang] [lld] [lldb] [clang-tools-extra] [llvm] [libcxx] [openmp] [libcxxabi] [libc] [flang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[Lldb-commits] [flang] [libcxxabi] [libcxx] [clang-tools-extra] [llvm] [lld] [compiler-rt] [mlir] [openmp] [libc] [clang] [lldb] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[Lldb-commits] [lldb] [clang-tools-extra] [mlir] [lld] [libcxxabi] [libc] [libcxx] [compiler-rt] [openmp] [flang] [clang] [llvm] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73686 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [mlir] [lld] [libcxxabi] [libc] [libcxx] [compiler-rt] [openmp] [flang] [clang] [llvm] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/73687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [lldb] [llvm] [openmp] [libcxx] [mlir] [compiler-rt] [libcxxabi] [libc] [lld] [clang-tools-extra] [clang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [mlir] [lld] [libcxxabi] [libc] [libcxx] [compiler-rt] [openmp] [flang] [clang] [llvm] [clang] Function Multi Versioning supports IFunc lowerings on Darwin pl
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/73688 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [libcxxabi] [libc] [mlir] [lld] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [clang] [flang] [libcxx] [clang] Function Multi Versioning supports IFunc lowerings on Darwin pl
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73688 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [flang] [clang] [llvm] [lldb] [openmp] [mlir] [clang-tools-extra] [libc] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/74902 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [flang] [llvm] [clang-tools-extra] [lld] [clang] [libcxx] [lldb] [openmp] [libcxxabi] [mlir] [libc] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/73685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [libcxxabi] [libc] [mlir] [lld] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [clang] [flang] [libcxx] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [libc] [mlir] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [clang] [flang] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/74902 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [libcxxabi] [lldb] [openmp] [clang] [mlir] [lld] [llvm] [clang-tools-extra] [compiler-rt] [flang] [libc] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms
jroelofs wrote: Sorry about that... thanks! https://github.com/llvm/llvm-project/pull/73685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [llvm] [libcxxabi] [compiler-rt] [libc] [openmp] [mlir] [clang-tools-extra] [clang] [lldb] [libcxx] [flang] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms
jroelofs wrote: > BTW, when compiling the file I also get a bunch of warnings in this style: @mstorsjo maybe `unsigned long` is 32 bits on that platform... what's the target triple? https://github.com/llvm/llvm-project/pull/73685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lld] [libcxxabi] [llvm] [flang] [clang-tools-extra] [openmp] [compiler-rt] [lldb] [libc] [libcxx] [mlir] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms
jroelofs wrote: > this file suffers from a pretty deep ifdef nesting jungle, so I'm not sure if > that's the best solution I'll refactor, and put up a new PR. https://github.com/llvm/llvm-project/pull/73685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang-tools-extra] [clang] [flang] [compiler-rt] [lld] [libcxxabi] [libc] [lldb] [openmp] [mlir] [libcxx] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms
jroelofs wrote: https://github.com/llvm/llvm-project/pull/75635 https://github.com/llvm/llvm-project/pull/73685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [clang-tools-extra] [lld] [libcxx] [libcxxabi] [mlir] [flang] [clang] [openmp] [libc] [compiler-rt] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms
jroelofs wrote: Refactor here: https://github.com/llvm/llvm-project/pull/75635 https://github.com/llvm/llvm-project/pull/73685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libcxx] [flang] [clang] [lld] [lldb] [mlir] [llvm] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- 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 +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[Lldb-commits] [compiler-rt] [lldb] [llvm] [mlir] [lld] [flang] [clang] [libcxx] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- 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 +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[Lldb-commits] [compiler-rt] [libcxx] [flang] [clang] [lld] [lldb] [mlir] [llvm] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- 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 +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[Lldb-commits] [mlir] [llvm] [libcxx] [lld] [compiler-rt] [flang] [lldb] [clang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- 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 +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[Lldb-commits] [llvm] [lldb] [compiler-rt] [mlir] [libcxx] [clang] [flang] [lld] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/6] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- 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 +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[Lldb-commits] [lld] [compiler-rt] [llvm] [lldb] [flang] [mlir] [libcxx] [clang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/75635 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [libcxx] [flang] [llvm] [mlir] [clang] [lld] [compiler-rt] [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (PR #75636)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/75636 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [libcxx] [flang] [llvm] [mlir] [clang] [lld] [compiler-rt] [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (PR #75636)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/75636 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [llvm] [clang] [compiler-rt] [flang] [mlir] [lld] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: There were a few follow-ups to address that. Sorry. https://github.com/llvm/llvm-project/pull/75635 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [compiler-rt] [mlir] [llvm] [libcxx] [lldb] [lld] [flang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: * c88e74c26d5c - (31 minutes ago) fixup! fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs * a5a17e8fadd4 - (39 minutes ago) fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs * 256b214b6b0f - (66 minutes ago) [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636) - Jon Roelofs * 9237cfa65b6c - (68 minutes ago) [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs * b72e1609146e - (61 minutes ago) Revert "[builtins] Refactor cpu_model support to reduce #if nesting. NFCI" - Jon Roelofs * b8b40e2fb988 - (61 minutes ago) Revert "[builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636)" - Jon Roelofs * 17aa52017103 - (66 minutes ago) [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636) - Jon Roelofs * 025d048b1cac - (68 minutes ago) [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs https://github.com/llvm/llvm-project/pull/75635 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [compiler-rt] [clang] [llvm] [lld] [mlir] [flang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: @petrhosek oh, I see what the problem is. I'll add another follow-up shortly. Sorry for the noise. https://github.com/llvm/llvm-project/pull/75635 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [mlir] [lldb] [compiler-rt] [llvm] [lld] [libcxx] [clang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: More follow-ups in 85d5ed81b1df, and 52e7b6f5c520 https://github.com/llvm/llvm-project/pull/75635 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [lld] [lldb] [llvm] [clang] [flang] [mlir] [libcxx] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: I am surprised I haven't seen any complaints from buildbots about Andoid... anyway, thanks. 394e481a38c774f12c765fde7e9302d039a7cd94 https://github.com/llvm/llvm-project/pull/75635 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [lld] [libcxx] [clang] [lldb] [mlir] [llvm] [compiler-rt] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: @petrhosek I don't have a Fucshia sysroot to build this against, so I think it would help me a lot if you could grab the preprocessed version of the `cpu_model.c` before all these changes and stick it in a github gist... I feel a little bad for dragging this out in-tree. > These #if __has_include(...) conditionals would evaluate to false on Fuchsia > since we don't have those headers, but they have been moved in the refactored > version. In that case, if I'm reading it correctly, all of the `#if defined(__Fuchsia__)` support for both initializing the LSE atomics detection bool, and FMV in `cpu_model.c` are dead code, and we can drop those entries in the new `aarch64.c`. https://github.com/llvm/llvm-project/pull/75635 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE option(LLVM_EXTERNALIZE_DEBUGINFO "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) +option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS jroelofs wrote: The double negative is confusing. Maybe invert it, and make the name `LLVM_ENABLE_EXPORTED_SYMBOLS`? https://github.com/llvm/llvm-project/pull/87684 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE option(LLVM_EXTERNALIZE_DEBUGINFO "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) +option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS jroelofs wrote: Flags like this shouldn't have `DISABLE` in their name either. It's ambiguous/confusing whether `LLVM_DISABLE_THING=On` means THING=ON or THING=Off. https://github.com/llvm/llvm-project/pull/87684 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [AArch64] move extension information into tablgen (PR #90987)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/90987 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits