From 8b9304ff87d26e254d83a2352225667bb3867733 Mon Sep 17 00:00:00 2001 From: eastb233 Date: Thu, 28 Aug 2025 19:49:39 +0800 Subject: [PATCH] [NFC] Remove BUILD_FOR_OPENEULER macro for no-plt feature --- .../llvm/Analysis/TargetLibraryInfo.def | 8 -------- llvm/lib/CodeGen/DwarfEHPrepare.cpp | 2 -- llvm/lib/Target/AArch64/AArch64Subtarget.cpp | 19 ++++++------------- llvm/test/CodeGen/AArch64/fno-plt.c | 1 - llvm/test/CodeGen/AArch64/fno-plt.cpp | 1 - 5 files changed, 6 insertions(+), 25 deletions(-) diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.def b/llvm/include/llvm/Analysis/TargetLibraryInfo.def index b9146f53648a..bc69417bef53 100644 --- a/llvm/include/llvm/Analysis/TargetLibraryInfo.def +++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.def @@ -151,7 +151,6 @@ TLI_DEFINE_ENUM_INTERNAL(under_IO_putc) TLI_DEFINE_STRING_INTERNAL("_IO_putc") TLI_DEFINE_SIG_INTERNAL(Int, Int, Ptr) -#if defined(BUILD_FOR_OPENEULER) /// void _Unwind_Resume(_Unwind_Exception *); TLI_DEFINE_ENUM_INTERNAL(_Unwind_Resume) TLI_DEFINE_STRING_INTERNAL("_Unwind_Resume") @@ -161,7 +160,6 @@ TLI_DEFINE_SIG_INTERNAL(Void, Ptr) TLI_DEFINE_ENUM_INTERNAL(terminate) TLI_DEFINE_STRING_INTERNAL("_ZSt9terminatev") TLI_DEFINE_SIG_INTERNAL(Void) -#endif /// void operator delete[](void*); TLI_DEFINE_ENUM_INTERNAL(ZdaPv) @@ -478,24 +476,20 @@ TLI_DEFINE_ENUM_INTERNAL(cospif) TLI_DEFINE_STRING_INTERNAL("__cospif") TLI_DEFINE_SIG_INTERNAL(Flt, Flt) -#if defined(BUILD_FOR_OPENEULER) /// void * __cxa_allocate_exception(size_t thrown_size) TLI_DEFINE_ENUM_INTERNAL(__cxa_allocate_exception) TLI_DEFINE_STRING_INTERNAL("__cxa_allocate_exception") TLI_DEFINE_SIG_INTERNAL(Ptr, SizeT) -#endif /// int __cxa_atexit(void (*f)(void *), void *p, void *d); TLI_DEFINE_ENUM_INTERNAL(cxa_atexit) TLI_DEFINE_STRING_INTERNAL("__cxa_atexit") TLI_DEFINE_SIG_INTERNAL(Int, Ptr, Ptr, Ptr) -#if defined(BUILD_FOR_OPENEULER) /// void *__cxa_begin_catch(void *e) TLI_DEFINE_ENUM_INTERNAL(__cxa_begin_catch) TLI_DEFINE_STRING_INTERNAL("__cxa_begin_catch") TLI_DEFINE_SIG_INTERNAL(Ptr, Ptr) -#endif /// void __cxa_guard_abort(guard_t *guard); /// guard_t is int64_t in Itanium ABI or int32_t on ARM eabi. @@ -513,12 +507,10 @@ TLI_DEFINE_ENUM_INTERNAL(cxa_guard_release) TLI_DEFINE_STRING_INTERNAL("__cxa_guard_release") TLI_DEFINE_SIG_INTERNAL(Void, Ptr) -#if defined(BUILD_FOR_OPENEULER) /// void __cxa_throw(void *, void *, void (*)(void *)); TLI_DEFINE_ENUM_INTERNAL(cxa_throw) TLI_DEFINE_STRING_INTERNAL("__cxa_throw") TLI_DEFINE_SIG_INTERNAL(Void, Ptr, Ptr, Ptr) -#endif /// double __exp10_finite(double x); TLI_DEFINE_ENUM_INTERNAL(exp10_finite) diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp index d8882bd53ed6..158ed29e4043 100644 --- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp +++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp @@ -234,11 +234,9 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() { } RewindFunction = F.getParent()->getOrInsertFunction(RewindName, FTy); -#if defined(BUILD_FOR_OPENEULER) // If -fno-plt is enabled, add NonLazyBind for this library call. if (F.getParent()->getRtLibUseGOT()) (cast(RewindFunction.getCallee()))->addFnAttr(Attribute::NonLazyBind); -#endif // Create the basic block where the _Unwind_Resume call will live. if (ResumesLeft == 1) { diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp index 901dc2254c21..b91a87ad4dfa 100644 --- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp @@ -24,9 +24,7 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineScheduler.h" #include "llvm/IR/GlobalValue.h" -#if defined(BUILD_FOR_OPENEULER) #include "llvm/IR/Module.h" -#endif #include "llvm/TargetParser/AArch64TargetParser.h" using namespace llvm; @@ -443,20 +441,15 @@ unsigned AArch64Subtarget::classifyGlobalFunctionReference( // NonLazyBind goes via GOT unless we know it's available locally. auto *F = dyn_cast(GV); -#if defined(BUILD_FOR_OPENEULER) -// Check if NonLazyBind should go via GOT: -// 1. The target is not MachO, or MachO uses NonLazyBind. -// 2. The function's parent module requires GOT for runtime library calls. -// 3. The symbol is not assumed to be DSO-local. -// 4. The symbol does not have local linkage. + + // Check if NonLazyBind should go via GOT: + // 1. The target is not MachO, or MachO uses NonLazyBind. + // 2. The function's parent module requires GOT for runtime library calls. + // 3. The symbol is not assumed to be DSO-local. + // 4. The symbol does not have local linkage. if ((!isTargetMachO() || MachOUseNonLazyBind) && F && F->getParent()->getRtLibUseGOT() && !(TM.shouldAssumeDSOLocal(*GV->getParent(), GV) || GV->hasLocalLinkage())) -#else - if ((!isTargetMachO() || MachOUseNonLazyBind) && F && - F->hasFnAttribute(Attribute::NonLazyBind) && - !TM.shouldAssumeDSOLocal(*GV->getParent(), GV)) -#endif return AArch64II::MO_GOT; if (getTargetTriple().isOSWindows()) { diff --git a/llvm/test/CodeGen/AArch64/fno-plt.c b/llvm/test/CodeGen/AArch64/fno-plt.c index 4853cd33d7d1..81ed912ce927 100644 --- a/llvm/test/CodeGen/AArch64/fno-plt.c +++ b/llvm/test/CodeGen/AArch64/fno-plt.c @@ -1,4 +1,3 @@ -// REQUIRES: build_for_openeuler // RUN: clang %s -shared -fno-plt -O2 -fno-inline -fPIC -o noplt.so // RUN: llvm-objdump -d noplt.so | FileCheck %s --check-prefix=CHECK-NO-PLT diff --git a/llvm/test/CodeGen/AArch64/fno-plt.cpp b/llvm/test/CodeGen/AArch64/fno-plt.cpp index 619e5d1cc60e..c5a1f2f24b37 100644 --- a/llvm/test/CodeGen/AArch64/fno-plt.cpp +++ b/llvm/test/CodeGen/AArch64/fno-plt.cpp @@ -1,4 +1,3 @@ -// REQUIRES: build_for_openeuler // RUN: clang -x c++ %s -shared -fno-plt -O2 -fno-inline -fPIC -o noplt.so // RUN: llvm-objdump -d noplt.so | FileCheck %s --check-prefix=CHECK-NO-PLT -- Gitee