[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -172,6 +172,20 @@ def push_dynamic_library_lookup_path(config, new_path): # doesn't match config.compiler_rt_libdir then it means we might be testing the # compiler's own runtime libraries rather than the ones we just built. # Warn about about this and handle appropriately. +if config.test_standalone_build_libs: +if config.compiler_id == "Clang": +# Ensure that we use the just-built libraries when linking by overriding +# the Clang resource directory. However, this also means that we can no +# longer find the builtin headers from that path, so we explicitly add +# the builtin headers as an include path. +resource_dir, _ = get_path_from_clang( +shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=False +) +config.target_cflags += f" -nobuiltininc" +config.target_cflags += f" -I{config.compiler_rt_src_root}/include" +config.target_cflags += f" -idirafter {resource_dir}/include" +config.target_cflags += f" -resource-dir={config.compiler_rt_obj_root}" +config.target_cflags += f" -Wl,--rpath={config.compiler_rt_libdir}" delcypher wrote: The flags below create kind of a odd mix * Some external clang that has its own independent resource directory. * The external clang is being forced to use a different resource directory than what it was shipped with * The external clang is being forced to use a different set of headers than what it was shipped with I'm not sure that combination is guaranteed to work given that compiler-rt can be tightly coupled with clang. If I've read this code correctly the change you've made is on the common path (because `COMPILER_RT_TEST_STANDALONE_BUILD_LIBS` is `ON` by default) but AFAIK your change was never needed before because normally you would build compiler-rt with a just built clang which I think should mean there's no difference between what `-print-resource-dir` reports and `config.compiler_rt_obj_root`. Or have I misunderstood something? https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -172,6 +172,20 @@ def push_dynamic_library_lookup_path(config, new_path): # doesn't match config.compiler_rt_libdir then it means we might be testing the # compiler's own runtime libraries rather than the ones we just built. # Warn about about this and handle appropriately. +if config.test_standalone_build_libs: +if config.compiler_id == "Clang": +# Ensure that we use the just-built libraries when linking by overriding +# the Clang resource directory. However, this also means that we can no +# longer find the builtin headers from that path, so we explicitly add +# the builtin headers as an include path. delcypher wrote: Sorry. It's been a while since I looked at this code. If you use a different resource directory why can't the compiler use the header files in that resource directory? https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -571,6 +571,30 @@ string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}") string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}") set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS}) +option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS + "When set to ON and testing in a standalone build, test the runtime \ + libraries built by this standalone build rather than the runtime libraries \ + shipped with the compiler (used for testing). When set to OFF and testing \ + in a standalone build, test the runtime libraries shipped with the compiler \ + (used for testing). This option has no effect if the compiler and this \ + build are configured to use the same runtime library path." + ON) +if (COMPILER_RT_TEST_STANDALONE_BUILD_LIBS) + # Ensure that the unit tests can find the sanitizer headers prior to installation. + list(APPEND COMPILER_RT_UNITTEST_CFLAGS "-I${CMAKE_CURRENT_LIST_DIR}/include") + # Ensure that unit tests link against the just-built runtime libraries instead + # of the ones bundled with the compiler by overriding the resource directory. + # + if ("${COMPILER_RT_TEST_COMPILER_ID}" MATCHES "Clang") +list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-resource-dir=${CMAKE_CURRENT_BINARY_DIR}") + endif() + get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir) + list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-Wl,-rpath,${output_dir}") +endif() +message(WARNING "COMPILER_RT_UNITTEST_LINK_FLAGS=${COMPILER_RT_UNITTEST_LINK_FLAGS}, COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=${COMPILER_RT_TEST_STANDALONE_BUILD_LIBS} COMPILER_RT_TEST_COMPILER_ID=${COMPILER_RT_TEST_COMPILER_ID}") delcypher wrote: Is this left over from debugging? This warning message doesn't seem that helpful to a developer. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/delcypher commented: What is the `[𝘀𝗽𝗿] initial version` commit message about? https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -172,6 +172,20 @@ def push_dynamic_library_lookup_path(config, new_path): # doesn't match config.compiler_rt_libdir then it means we might be testing the # compiler's own runtime libraries rather than the ones we just built. # Warn about about this and handle appropriately. +if config.test_standalone_build_libs: +if config.compiler_id == "Clang": +# Ensure that we use the just-built libraries when linking by overriding +# the Clang resource directory. However, this also means that we can no +# longer find the builtin headers from that path, so we explicitly add +# the builtin headers as an include path. +resource_dir, _ = get_path_from_clang( +shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=False +) +config.target_cflags += f" -nobuiltininc" +config.target_cflags += f" -I{config.compiler_rt_src_root}/include" +config.target_cflags += f" -idirafter {resource_dir}/include" +config.target_cflags += f" -resource-dir={config.compiler_rt_obj_root}" +config.target_cflags += f" -Wl,--rpath={config.compiler_rt_libdir}" delcypher wrote: @arichardson To be clear. I'm not necessarily against your change but I'm a bit concerned about your change being on the default path given that it's not normally necessary. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [ARM] Update IsRestored for LR based on all returns (#82745) (PR #83129)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/83129 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [ARM] Update IsRestored for LR based on all returns (#82745) (PR #83129)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/83129 Backport 8779cf68e80dcc0b15e8034f39e6ce18b08352b6 749384c08e042739342c88b521c8ba5dac1b9276 Requested by: @P1119r1m >From ed453c4883cb38f86f4387a8d7989bcc3b8debe5 Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Fri, 23 Feb 2024 09:31:25 + Subject: [PATCH 1/2] Pre-commit test showing bug #80287 This test shows the bug where LR is used as a general-purpose register on a code path where it is not spilled to the stack. (cherry picked from commit 8779cf68e80dcc0b15e8034f39e6ce18b08352b6) --- llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll | 55 +++ 1 file changed, 55 insertions(+) create mode 100644 llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll diff --git a/llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll b/llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll new file mode 100644 index 00..883a812139ded1 --- /dev/null +++ b/llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll @@ -0,0 +1,55 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 +; RUN: llc -mtriple thumbv7a-none-eabi < %s | FileCheck %s + +@val0 = global i32 0, align 4 +@val1 = global i32 0, align 4 +@val2 = global i32 0, align 4 + +define i32 @foo(ptr %ctx) { +; CHECK-LABEL: foo: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT:cbz r0, .LBB0_2 +; CHECK-NEXT: @ %bb.1: @ %if.end +; CHECK-NEXT:movw r2, :lower16:val0 +; CHECK-NEXT:mov r1, r0 +; CHECK-NEXT:movs r0, #0 +; CHECK-NEXT:movw r12, :lower16:val2 +; CHECK-NEXT:movw r3, :lower16:val1 +; CHECK-NEXT:movt r2, :upper16:val0 +; CHECK-NEXT:add.w lr, r1, #4 +; CHECK-NEXT:movt r12, :upper16:val2 +; CHECK-NEXT:movt r3, :upper16:val1 +; CHECK-NEXT:stm.w lr, {r2, r3, r12} +; CHECK-NEXT:str r0, [r1, #16] +; CHECK-NEXT:bx lr +; CHECK-NEXT: .LBB0_2: @ %if.then +; CHECK-NEXT:.save {r7, lr} +; CHECK-NEXT:push {r7, lr} +; CHECK-NEXT:bl bar +; CHECK-NEXT:mov.w r0, #-1 +; CHECK-NEXT:pop {r7, pc} +entry: + %tobool.not = icmp eq ptr %ctx, null + br i1 %tobool.not, label %if.then, label %if.end + +if.then: ; preds = %entry + tail call void @bar() #2 + br label %return + +if.end: ; preds = %entry + %cmd_a = getelementptr inbounds i8, ptr %ctx, i32 4 + store ptr @val0, ptr %cmd_a, align 4 + %cmd_b = getelementptr inbounds i8, ptr %ctx, i32 8 + store ptr @val1, ptr %cmd_b, align 4 + %cmd_c = getelementptr inbounds i8, ptr %ctx, i32 12 + store ptr @val2, ptr %cmd_c, align 4 + %cmd_d = getelementptr inbounds i8, ptr %ctx, i32 16 + store ptr null, ptr %cmd_d, align 4 + br label %return + +return: ; preds = %if.end, %if.then + %retval.0 = phi i32 [ 0, %if.end ], [ -1, %if.then ] + ret i32 %retval.0 +} + +declare void @bar() >From 2673820806bf4db0ce495b88b2f93d1418e0a312 Mon Sep 17 00:00:00 2001 From: ostannard Date: Mon, 26 Feb 2024 12:23:25 + Subject: [PATCH 2/2] [ARM] Update IsRestored for LR based on all returns (#82745) PR #75527 fixed ARMFrameLowering to set the IsRestored flag for LR based on all of the return instructions in the function, not just one. However, there is also code in ARMLoadStoreOptimizer which changes return instructions, but it set IsRestored based on the one instruction it changed, not the whole function. The fix is to factor out the code added in #75527, and also call it from ARMLoadStoreOptimizer if it made a change to return instructions. Fixes #80287. (cherry picked from commit 749384c08e042739342c88b521c8ba5dac1b9276) --- llvm/lib/Target/ARM/ARMFrameLowering.cpp | 11 + llvm/lib/Target/ARM/ARMFrameLowering.h| 4 llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp | 23 --- llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll | 11 + 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp b/llvm/lib/Target/ARM/ARMFrameLowering.cpp index eeb7f64aa5810e..9b54dd4e4e618d 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp +++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp @@ -2781,10 +2781,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF, AFI->setLRIsSpilled(SavedRegs.test(ARM::LR)); } -void ARMFrameLowering::processFunctionBeforeFrameFinalized( -MachineFunction &MF, RegScavenger *RS) const { - TargetFrameLowering::processFunctionBeforeFrameFinalized(MF, RS); - +void ARMFrameLowering::updateLRRestored(MachineFunction &MF) { MachineFrameInfo &MFI = MF.getFrameInfo(); if (!MFI.isCalleeSavedInfoValid()) return; @@ -2808,6 +2805,12 @@ void ARMFrameLowering::processFunctionBeforeFrameFinalized( } } +void ARMFrameLowering::processFunctionBeforeFrameFinalized( +MachineFunction &MF, RegScavenger *RS) const { + TargetFrameLowering::processFunctionBeforeFrameFinalized(MF, RS); + upda
[llvm-branch-commits] [llvm] release/18.x: [ARM] Update IsRestored for LR based on all returns (#82745) (PR #83129)
llvmbot wrote: @fhahn What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/83129 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [ARM] Update IsRestored for LR based on all returns (#82745) (PR #83129)
llvmbot wrote: @llvm/pr-subscribers-backend-arm Author: None (llvmbot) Changes Backport 8779cf68e80dcc0b15e8034f39e6ce18b08352b6 749384c08e042739342c88b521c8ba5dac1b9276 Requested by: @P1119r1m --- Full diff: https://github.com/llvm/llvm-project/pull/83129.diff 4 Files Affected: - (modified) llvm/lib/Target/ARM/ARMFrameLowering.cpp (+7-4) - (modified) llvm/lib/Target/ARM/ARMFrameLowering.h (+4) - (modified) llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (+10-13) - (added) llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll (+56) ``diff diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp b/llvm/lib/Target/ARM/ARMFrameLowering.cpp index eeb7f64aa5810e..9b54dd4e4e618d 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp +++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp @@ -2781,10 +2781,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF, AFI->setLRIsSpilled(SavedRegs.test(ARM::LR)); } -void ARMFrameLowering::processFunctionBeforeFrameFinalized( -MachineFunction &MF, RegScavenger *RS) const { - TargetFrameLowering::processFunctionBeforeFrameFinalized(MF, RS); - +void ARMFrameLowering::updateLRRestored(MachineFunction &MF) { MachineFrameInfo &MFI = MF.getFrameInfo(); if (!MFI.isCalleeSavedInfoValid()) return; @@ -2808,6 +2805,12 @@ void ARMFrameLowering::processFunctionBeforeFrameFinalized( } } +void ARMFrameLowering::processFunctionBeforeFrameFinalized( +MachineFunction &MF, RegScavenger *RS) const { + TargetFrameLowering::processFunctionBeforeFrameFinalized(MF, RS); + updateLRRestored(MF); +} + void ARMFrameLowering::getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const { TargetFrameLowering::getCalleeSaves(MF, SavedRegs); diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.h b/llvm/lib/Target/ARM/ARMFrameLowering.h index 8d2b8beb9a58fb..3c7358d8cd53e2 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.h +++ b/llvm/lib/Target/ARM/ARMFrameLowering.h @@ -59,6 +59,10 @@ class ARMFrameLowering : public TargetFrameLowering { void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override; + /// Update the IsRestored flag on LR if it is spilled, based on the return + /// instructions. + static void updateLRRestored(MachineFunction &MF); + void processFunctionBeforeFrameFinalized( MachineFunction &MF, RegScavenger *RS = nullptr) const override; diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp index ed9d30c3c3ab90..6121055eb02176 100644 --- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -2062,17 +2062,6 @@ bool ARMLoadStoreOpt::MergeReturnIntoLDM(MachineBasicBlock &MBB) { MO.setReg(ARM::PC); PrevMI.copyImplicitOps(*MBB.getParent(), *MBBI); MBB.erase(MBBI); - // We now restore LR into PC so it is not live-out of the return block - // anymore: Clear the CSI Restored bit. - MachineFrameInfo &MFI = MBB.getParent()->getFrameInfo(); - // CSI should be fixed after PrologEpilog Insertion - assert(MFI.isCalleeSavedInfoValid() && "CSI should be valid"); - for (CalleeSavedInfo &Info : MFI.getCalleeSavedInfo()) { -if (Info.getReg() == ARM::LR) { - Info.setRestored(false); - break; -} - } return true; } } @@ -2120,14 +2109,22 @@ bool ARMLoadStoreOpt::runOnMachineFunction(MachineFunction &Fn) { isThumb2 = AFI->isThumb2Function(); isThumb1 = AFI->isThumbFunction() && !isThumb2; - bool Modified = false; + bool Modified = false, ModifiedLDMReturn = false; for (MachineBasicBlock &MBB : Fn) { Modified |= LoadStoreMultipleOpti(MBB); if (STI->hasV5TOps() && !AFI->shouldSignReturnAddress()) - Modified |= MergeReturnIntoLDM(MBB); + ModifiedLDMReturn |= MergeReturnIntoLDM(MBB); if (isThumb1) Modified |= CombineMovBx(MBB); } + Modified |= ModifiedLDMReturn; + + // If we merged a BX instruction into an LDM, we need to re-calculate whether + // LR is restored. This check needs to consider the whole function, not just + // the instruction(s) we changed, because there may be other BX returns which + // still need LR to be restored. + if (ModifiedLDMReturn) +ARMFrameLowering::updateLRRestored(Fn); Allocator.DestroyAll(); return Modified; diff --git a/llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll b/llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll new file mode 100644 index 00..9494880f990258 --- /dev/null +++ b/llvm/test/CodeGen/ARM/ldst-opt-lr-restored.ll @@ -0,0 +1,56 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 +; RUN: llc -mtriple thumbv7a-none-eabi < %s | FileCheck %s + +@val0 = global i32 0, align 4 +@val1 = global i32 0, align 4 +@val2 = global i32 0, align 4 + +define i32
[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Remove `SplitBlockRewrite` (PR #82777)
https://github.com/matthias-springer edited https://github.com/llvm/llvm-project/pull/82777 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/78432 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -571,6 +571,30 @@ string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}") string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}") set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS}) +option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS + "When set to ON and testing in a standalone build, test the runtime \ + libraries built by this standalone build rather than the runtime libraries \ + shipped with the compiler (used for testing). When set to OFF and testing \ + in a standalone build, test the runtime libraries shipped with the compiler \ + (used for testing). This option has no effect if the compiler and this \ + build are configured to use the same runtime library path." + ON) +if (COMPILER_RT_TEST_STANDALONE_BUILD_LIBS) + # Ensure that the unit tests can find the sanitizer headers prior to installation. + list(APPEND COMPILER_RT_UNITTEST_CFLAGS "-I${CMAKE_CURRENT_LIST_DIR}/include") + # Ensure that unit tests link against the just-built runtime libraries instead + # of the ones bundled with the compiler by overriding the resource directory. + # + if ("${COMPILER_RT_TEST_COMPILER_ID}" MATCHES "Clang") +list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-resource-dir=${CMAKE_CURRENT_BINARY_DIR}") + endif() + get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir) + list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-Wl,-rpath,${output_dir}") +endif() +message(WARNING "COMPILER_RT_UNITTEST_LINK_FLAGS=${COMPILER_RT_UNITTEST_LINK_FLAGS}, COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=${COMPILER_RT_TEST_STANDALONE_BUILD_LIBS} COMPILER_RT_TEST_COMPILER_ID=${COMPILER_RT_TEST_COMPILER_ID}") arichardson wrote: Yes, will remove! https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -172,6 +172,20 @@ def push_dynamic_library_lookup_path(config, new_path): # doesn't match config.compiler_rt_libdir then it means we might be testing the # compiler's own runtime libraries rather than the ones we just built. # Warn about about this and handle appropriately. +if config.test_standalone_build_libs: +if config.compiler_id == "Clang": +# Ensure that we use the just-built libraries when linking by overriding +# the Clang resource directory. However, this also means that we can no +# longer find the builtin headers from that path, so we explicitly add +# the builtin headers as an include path. arichardson wrote: I'm overriding the resource directory to point at the compiler-rt build directory. Unlike the clang install dir it won't contain the builtin headers (e.g. stdint.h, stddef.h, etc.). I could copy those files, but using this approach is less error prone. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)
aeubanks wrote: also, we should remove pipeline checks for "optsize" and move those checks into the passes themselves https://github.com/llvm/llvm-project/pull/83049 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -172,6 +172,20 @@ def push_dynamic_library_lookup_path(config, new_path): # doesn't match config.compiler_rt_libdir then it means we might be testing the # compiler's own runtime libraries rather than the ones we just built. # Warn about about this and handle appropriately. +if config.test_standalone_build_libs: +if config.compiler_id == "Clang": +# Ensure that we use the just-built libraries when linking by overriding +# the Clang resource directory. However, this also means that we can no +# longer find the builtin headers from that path, so we explicitly add +# the builtin headers as an include path. +resource_dir, _ = get_path_from_clang( +shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=False +) +config.target_cflags += f" -nobuiltininc" +config.target_cflags += f" -I{config.compiler_rt_src_root}/include" +config.target_cflags += f" -idirafter {resource_dir}/include" +config.target_cflags += f" -resource-dir={config.compiler_rt_obj_root}" +config.target_cflags += f" -Wl,--rpath={config.compiler_rt_libdir}" arichardson wrote: > The flags below create kind of a odd mix > > * Some external clang that has its own independent resource directory. In my case it is actually a clang built from the same monorepo commit hash, but it should also work with a system-provided clang. > * The external clang is being forced to use a different resource directory > than what it was shipped with The intention of this change is to test the libraries that we actually built just now rather than whatever happened to be installed to clang's resource directory. There is absolutely no guarantee that those match. > * The external clang is being forced to use a different set of headers than > what it was shipped with The whole point of this extra `-idirafter` is to make sure that the external clang uses its set of headers (the resource_dir variable points to the non-overriden directory). > > I'm not sure that combination is guaranteed to work given that compiler-rt > can be tightly coupled with clang. > > If I've read this code correctly the change you've made is on the common path > (because `COMPILER_RT_TEST_STANDALONE_BUILD_LIBS` is `ON` by default) but > AFAIK your change was never needed before because normally you would build > compiler-rt with a just built clang which I think should mean there's no > difference between what `-print-resource-dir` reports and > `config.compiler_rt_obj_root`. Or have I misunderstood something? The resource directories will only match if you build everything in on go (I believe with `LLVM_ENABLE_PROJECTS=clang;compiler-rt`). However, I am installing clang first and then building *only* compiler-rt (using the cmake invocation listed above), so the clang resource directory points to where clang was installed. I order to not affect the all-in-one build I will update the check to not add flags if the resource-dir matches the compiler_rt_objdir. Hopefully that addresses your concerns. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/arichardson edited https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/78432 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
@@ -0,0 +1,52 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "call.*(frexp|modf)" --version 4 +// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve -O3 -isystem %S/../Headers/Inputs/include -mllvm -vector-library=ArmPL -mllvm -force-vector-interleave=1 -mllvm -prefer-predicate-over-epilogue=predicate-dont-vectorize -emit-llvm -S -o - %s | FileCheck %s + +// REQUIRES: aarch64-registered-target + +/* +Testing vectorization of math functions that have the attribute write-only to +memory set. Given they have vectorized counterparts, they should be able to +vectorize. +*/ + +// The following define is required to access some math functions. +#define _GNU_SOURCE +#include + +// frexp/frexpf have no TLI mappings yet. + +// CHECK-LABEL: define dso_local void @frexp_f64( +// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK:[[CALL:%.*]] = tail call double @frexp(double noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR2:[0-9]+]] +// +void frexp_f64(double *in, double *out1, int *out2, int N) { + for (int i = 0; i < N; ++i) +*out1 = frexp(in[i], out2+i); +} + +// CHECK-LABEL: define dso_local void @frexp_f32( +// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK:[[CALL:%.*]] = tail call float @frexpf(float noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR2]] +// +void frexp_f32(float *in, float *out1, int *out2, int N) { + for (int i = 0; i < N; ++i) +*out1 = frexpf(in[i], out2+i); +} + +// CHECK-LABEL: define dso_local void @modf_f64( +// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK:[[CALL:%.*]] = tail call double @modf(double noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR3:[0-9]+]] +// +void modf_f64(double *in, double *out1, double *out2, int N) { + for (int i = 0; i < N; ++i) + out1[i] = modf(in[i], out2+i); +} + +// CHECK-LABEL: define dso_local void @modf_f32( +// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK:[[CALL:%.*]] = tail call float @modff(float noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR4:[0-9]+]] +// +void modf_f32(float *in, float *out1, float *out2, int N) { + for (int i = 0; i < N; ++i) + out1[i] = modff(in[i], out2+i); +} paschalis-mpeis wrote: This was converted to LLVM tests for LoopVectorizer, and also added LoopAccessAnalysis tests. Finally, the PR is stacked on top of #83143, which will re-introduce at least the modf/modff mappings https://github.com/llvm/llvm-project/pull/78432 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fixes naming inconsistency. (#83036) (PR #83156)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/83156 Backport b50bcc7ffb6ad6caa4c141a22915ab59f725b7ae Requested by: @mordante >From 7cab6b89b203ae604e8c3b31f964e0c1fe5884ea Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Tue, 27 Feb 2024 18:10:53 +0100 Subject: [PATCH] [libc++][modules] Fixes naming inconsistency. (#83036) The modules used is-standard-library and is-std-library. The latter is the name used in the SG15 proposal, Fixes: https://github.com/llvm/llvm-project/issues/82879 (cherry picked from commit b50bcc7ffb6ad6caa4c141a22915ab59f725b7ae) --- libcxx/modules/modules.json.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/modules/modules.json.in b/libcxx/modules/modules.json.in index ddc377f28f9194..759ac92d81f18e 100644 --- a/libcxx/modules/modules.json.in +++ b/libcxx/modules/modules.json.in @@ -5,7 +5,7 @@ { "logical-name": "std", "source-path": "@LIBCXX_MODULE_RELATIVE_PATH@/std.cppm", - "is-standard-library": true, + "is-std-library": true, "local-arguments": { "system-include-directories": [ "@LIBCXX_MODULE_RELATIVE_PATH@" ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fixes naming inconsistency. (#83036) (PR #83156)
llvmbot wrote: @ldionne What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/83156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fixes naming inconsistency. (#83036) (PR #83156)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/83156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] release/18.x: [llvm-shlib] Change libLLVM-$MAJOR.so symlink to point to versioned SO (#82660) (PR #83067)
https://github.com/llvmbot closed https://github.com/llvm/llvm-project/pull/83067 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] release/18.x: [llvm-shlib] Change libLLVM-$MAJOR.so symlink to point to versioned SO (#82660) (PR #83067)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/83067 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fixes naming inconsistency. (#83036) (PR #83156)
llvmbot wrote: @llvm/pr-subscribers-libcxx Author: None (llvmbot) Changes Backport b50bcc7ffb6ad6caa4c141a22915ab59f725b7ae Requested by: @mordante --- Full diff: https://github.com/llvm/llvm-project/pull/83156.diff 1 Files Affected: - (modified) libcxx/modules/modules.json.in (+1-1) ``diff diff --git a/libcxx/modules/modules.json.in b/libcxx/modules/modules.json.in index ddc377f28f9194..759ac92d81f18e 100644 --- a/libcxx/modules/modules.json.in +++ b/libcxx/modules/modules.json.in @@ -5,7 +5,7 @@ { "logical-name": "std", "source-path": "@LIBCXX_MODULE_RELATIVE_PATH@/std.cppm", - "is-standard-library": true, + "is-std-library": true, "local-arguments": { "system-include-directories": [ "@LIBCXX_MODULE_RELATIVE_PATH@" `` https://github.com/llvm/llvm-project/pull/83156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] release/18.x: [llvm-shlib] Change libLLVM-$MAJOR.so symlink to point to versioned SO (#82660) (PR #83067)
tstellar wrote: Merged: 4cc7a75aa6ac272a5774ef7ca3f6b2ad095425e3 https://github.com/llvm/llvm-project/pull/83067 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] [llvm] release/18.x: [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291) (PR #82870)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/82870 >From e2182a6b91f5001bd9b52e3b1fe6beac434e5fe5 Mon Sep 17 00:00:00 2001 From: yingopq <115543042+ying...@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:13:43 +0800 Subject: [PATCH] =?UTF-8?q?[Mips]=20Fix=20unable=20to=20handle=20inline=20?= =?UTF-8?q?assembly=20ends=20with=20compat-branch=20o=E2=80=A6=20(#77291)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …n MIPS Modify: Add a global variable 'CurForbiddenSlotAttr' to save current instruction's forbidden slot and whether set reorder. This is the judgment condition for whether to add nop. We would add a couple of '.set noreorder' and '.set reorder' to wrap the current instruction and the next instruction. Then we can get previous instruction`s forbidden slot attribute and whether set reorder by 'CurForbiddenSlotAttr'. If previous instruction has forbidden slot and .set reorder is active and current instruction is CTI. Then emit a NOP after it. Fix https://github.com/llvm/llvm-project/issues/61045. Because https://reviews.llvm.org/D158589 was 'Needs Review' state, not ending, so we commit pull request again. (cherry picked from commit 96abee5eef31274415681018553e1d4a16dc16c9) --- lld/test/ELF/mips-pc-relocs.s | 18 +++-- .../Target/Mips/AsmParser/MipsAsmParser.cpp | 78 ++- .../CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll | 71 + llvm/test/MC/Mips/forbidden-slot.s| 18 + llvm/test/MC/Mips/mips32r6/relocations.s | 22 +++--- llvm/test/MC/Mips/mips64r6/relocations.s | 26 +++ llvm/test/MC/Mips/relocation.s| 4 +- 7 files changed, 202 insertions(+), 35 deletions(-) create mode 100644 llvm/test/CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll create mode 100644 llvm/test/MC/Mips/forbidden-slot.s diff --git a/lld/test/ELF/mips-pc-relocs.s b/lld/test/ELF/mips-pc-relocs.s index 5e7dbed94ca7c4..7d23f9d7469a48 100644 --- a/lld/test/ELF/mips-pc-relocs.s +++ b/lld/test/ELF/mips-pc-relocs.s @@ -40,11 +40,13 @@ __start: # ^-- (0x20020-0x2)>>2 # CHECK-NEXT:20004: beqc$5, $6, 0x20020 # ^-- (0x20020-4-0x20004)>>2 -# CHECK-NEXT:20008: beqzc $9, 0x20020 -# ^-- (0x20020-4-0x20008)>>2 -# CHECK-NEXT:2000c: bc 0x20020 -# ^-- (0x20020-4-0x2000c)>>2 -# CHECK-NEXT:20010: aluipc $2, 0 -# ^-- %hi(0x20020-0x20010) -# CHECK-NEXT:20014: addiu $2, $2, 12 -# ^-- %lo(0x20020-0x20014) +# CHECK-NEXT:20008: nop +# CHECK-NEXT:2000c: beqzc $9, 0x20020 +# ^-- (0x20020-4-0x2000c)>>2 +# CHECK-NEXT:20010: nop +# CHECK-NEXT:20014: bc 0x20020 +# ^-- (0x20020-4-0x200014)>>2 +# CHECK-NEXT:20018: aluipc $2, 0 +# ^-- %hi(0x20020-0x20018) +# CHECK-NEXT:2001c: addiu $2, $2, 4 +# ^-- %lo(0x20020-0x2001c) diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 36aab383da68d2..9d6e8dc573a8d1 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -150,6 +150,7 @@ class MipsAsmParser : public MCTargetAsmParser { bool IsLittleEndian; bool IsPicEnabled; bool IsCpRestoreSet; + bool CurForbiddenSlotAttr; int CpRestoreOffset; unsigned GPReg; unsigned CpSaveLocation; @@ -552,6 +553,7 @@ class MipsAsmParser : public MCTargetAsmParser { CurrentFn = nullptr; +CurForbiddenSlotAttr = false; IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent(); IsCpRestoreSet = false; @@ -723,6 +725,16 @@ class MipsAsmParser : public MCTargetAsmParser { return getSTI().hasFeature(Mips::FeatureGINV); } + bool hasForbiddenSlot(const MCInstrDesc &MCID) const { +return !inMicroMipsMode() && (MCID.TSFlags & MipsII::HasForbiddenSlot); + } + + bool SafeInForbiddenSlot(const MCInstrDesc &MCID) const { +return !(MCID.TSFlags & MipsII::IsCTI); + } + + void onEndOfFile() override; + /// Warn if RegIndex is the same as the current AT. void warnIfRegIndexIsAT(unsigned RegIndex, SMLoc Loc); @@ -2307,7 +2319,41 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc, bool FillDelaySlot = MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder(); - if (FillDelaySlot) + + // Get previous instruction`s forbidden slot attribute and + // whether set reorder. + bool PrevForbiddenSlotAttr = CurForbiddenSlotAttr; + + // Flag represents we set reo
[llvm-branch-commits] [llvm] e2182a6 - [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291)
Author: yingopq Date: 2024-02-27T09:17:42-08:00 New Revision: e2182a6b91f5001bd9b52e3b1fe6beac434e5fe5 URL: https://github.com/llvm/llvm-project/commit/e2182a6b91f5001bd9b52e3b1fe6beac434e5fe5 DIFF: https://github.com/llvm/llvm-project/commit/e2182a6b91f5001bd9b52e3b1fe6beac434e5fe5.diff LOG: [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291) …n MIPS Modify: Add a global variable 'CurForbiddenSlotAttr' to save current instruction's forbidden slot and whether set reorder. This is the judgment condition for whether to add nop. We would add a couple of '.set noreorder' and '.set reorder' to wrap the current instruction and the next instruction. Then we can get previous instruction`s forbidden slot attribute and whether set reorder by 'CurForbiddenSlotAttr'. If previous instruction has forbidden slot and .set reorder is active and current instruction is CTI. Then emit a NOP after it. Fix https://github.com/llvm/llvm-project/issues/61045. Because https://reviews.llvm.org/D158589 was 'Needs Review' state, not ending, so we commit pull request again. (cherry picked from commit 96abee5eef31274415681018553e1d4a16dc16c9) Added: llvm/test/CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll llvm/test/MC/Mips/forbidden-slot.s Modified: lld/test/ELF/mips-pc-relocs.s llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp llvm/test/MC/Mips/mips32r6/relocations.s llvm/test/MC/Mips/mips64r6/relocations.s llvm/test/MC/Mips/relocation.s Removed: diff --git a/lld/test/ELF/mips-pc-relocs.s b/lld/test/ELF/mips-pc-relocs.s index 5e7dbed94ca7c4..7d23f9d7469a48 100644 --- a/lld/test/ELF/mips-pc-relocs.s +++ b/lld/test/ELF/mips-pc-relocs.s @@ -40,11 +40,13 @@ __start: # ^-- (0x20020-0x2)>>2 # CHECK-NEXT:20004: beqc$5, $6, 0x20020 # ^-- (0x20020-4-0x20004)>>2 -# CHECK-NEXT:20008: beqzc $9, 0x20020 -# ^-- (0x20020-4-0x20008)>>2 -# CHECK-NEXT:2000c: bc 0x20020 -# ^-- (0x20020-4-0x2000c)>>2 -# CHECK-NEXT:20010: aluipc $2, 0 -# ^-- %hi(0x20020-0x20010) -# CHECK-NEXT:20014: addiu $2, $2, 12 -# ^-- %lo(0x20020-0x20014) +# CHECK-NEXT:20008: nop +# CHECK-NEXT:2000c: beqzc $9, 0x20020 +# ^-- (0x20020-4-0x2000c)>>2 +# CHECK-NEXT:20010: nop +# CHECK-NEXT:20014: bc 0x20020 +# ^-- (0x20020-4-0x200014)>>2 +# CHECK-NEXT:20018: aluipc $2, 0 +# ^-- %hi(0x20020-0x20018) +# CHECK-NEXT:2001c: addiu $2, $2, 4 +# ^-- %lo(0x20020-0x2001c) diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 36aab383da68d2..9d6e8dc573a8d1 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -150,6 +150,7 @@ class MipsAsmParser : public MCTargetAsmParser { bool IsLittleEndian; bool IsPicEnabled; bool IsCpRestoreSet; + bool CurForbiddenSlotAttr; int CpRestoreOffset; unsigned GPReg; unsigned CpSaveLocation; @@ -552,6 +553,7 @@ class MipsAsmParser : public MCTargetAsmParser { CurrentFn = nullptr; +CurForbiddenSlotAttr = false; IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent(); IsCpRestoreSet = false; @@ -723,6 +725,16 @@ class MipsAsmParser : public MCTargetAsmParser { return getSTI().hasFeature(Mips::FeatureGINV); } + bool hasForbiddenSlot(const MCInstrDesc &MCID) const { +return !inMicroMipsMode() && (MCID.TSFlags & MipsII::HasForbiddenSlot); + } + + bool SafeInForbiddenSlot(const MCInstrDesc &MCID) const { +return !(MCID.TSFlags & MipsII::IsCTI); + } + + void onEndOfFile() override; + /// Warn if RegIndex is the same as the current AT. void warnIfRegIndexIsAT(unsigned RegIndex, SMLoc Loc); @@ -2307,7 +2319,41 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc, bool FillDelaySlot = MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder(); - if (FillDelaySlot) + + // Get previous instruction`s forbidden slot attribute and + // whether set reorder. + bool PrevForbiddenSlotAttr = CurForbiddenSlotAttr; + + // Flag represents we set reorder after nop. + bool SetReorderAfterNop = false; + + // If previous instruction has forbidden slot and .set reorder + // is active and current instruction is CTI. + // Then emit a NOP after it. + if (PrevForbiddenSlotAttr && !SafeInForbiddenSlot(MCID)) { +TOut.emitEmptyDelaySlot(false, IDLoc,
[llvm-branch-commits] [lld] [llvm] release/18.x: [Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291) (PR #82870)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/82870 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] release/18.x: MIPS: Fix asm constraints "f" and "r" for softfloat (#79116) (PR #83105)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/83105 >From 461274b81d8641eab64d494accddc81d7db8a09e Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Tue, 27 Feb 2024 14:08:36 +0800 Subject: [PATCH] MIPS: Fix asm constraints "f" and "r" for softfloat (#79116) This include 2 fixes: 1. Disallow 'f' for softfloat. 2. Allow 'r' for softfloat. Currently, 'f' is accpeted by clang, then LLVM meets an internal error. 'r' is rejected by LLVM by: couldn't allocate input reg for constraint 'r'. Fixes: #64241, #63632 - Co-authored-by: Fangrui Song (cherry picked from commit c88beb4112d5bbf07d76a615ab7f13ba2ba023e6) --- clang/lib/Basic/Targets/Mips.h| 4 +- .../CodeGen/Mips/inline-asm-constraints.c | 11 + clang/test/Sema/inline-asm-validate-mips.c| 9 llvm/lib/Target/Mips/MipsISelLowering.cpp | 10 ++-- .../Mips/inlineasm-constraints-softfloat.ll | 48 +++ 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 clang/test/CodeGen/Mips/inline-asm-constraints.c create mode 100644 clang/test/Sema/inline-asm-validate-mips.c create mode 100644 llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h index f46b95abfd75c7..23d4e1b598fa1e 100644 --- a/clang/lib/Basic/Targets/Mips.h +++ b/clang/lib/Basic/Targets/Mips.h @@ -237,12 +237,14 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo { case 'r': // CPU registers. case 'd': // Equivalent to "r" unless generating MIPS16 code. case 'y': // Equivalent to "r", backward compatibility only. -case 'f': // floating-point registers. case 'c': // $25 for indirect jumps case 'l': // lo register case 'x': // hilo register pair Info.setAllowsRegister(); return true; +case 'f': // floating-point registers. + Info.setAllowsRegister(); + return FloatABI != SoftFloat; case 'I': // Signed 16-bit constant case 'J': // Integer 0 case 'K': // Unsigned 16-bit constant diff --git a/clang/test/CodeGen/Mips/inline-asm-constraints.c b/clang/test/CodeGen/Mips/inline-asm-constraints.c new file mode 100644 index 00..88afe8735083b4 --- /dev/null +++ b/clang/test/CodeGen/Mips/inline-asm-constraints.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm -triple mips -target-feature +soft-float %s -o - | FileCheck %s --check-prefix=SOFT_FLOAT + +// SOFT_FLOAT: call void asm sideeffect "", "r,~{$1}"(float %1) +void read_float(float *p) { + __asm__("" ::"r"(*p)); +} + +// SOFT_FLOAT: call void asm sideeffect "", "r,~{$1}"(double %1) +void read_double(double *p) { + __asm__("" :: "r"(*p)); +} diff --git a/clang/test/Sema/inline-asm-validate-mips.c b/clang/test/Sema/inline-asm-validate-mips.c new file mode 100644 index 00..7da248fe417b5c --- /dev/null +++ b/clang/test/Sema/inline-asm-validate-mips.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple mips64 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple mips64 -target-feature +soft-float -fsyntax-only -verify=softfloat %s + +// expected-no-diagnostics + +void test_f(float p) { + float result = p; + __asm__("" :: "f"(result)); // softfloat-error{{invalid input constraint 'f' in asm}} +} diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index d431d3d91494f6..88b226eaaccfab 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -4128,14 +4128,18 @@ MipsTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, case 'd': // Address register. Same as 'r' unless generating MIPS16 code. case 'y': // Same as 'r'. Exists for compatibility. case 'r': - if (VT == MVT::i32 || VT == MVT::i16 || VT == MVT::i8 || VT == MVT::i1) { + if ((VT == MVT::i32 || VT == MVT::i16 || VT == MVT::i8 || + VT == MVT::i1) || + (VT == MVT::f32 && Subtarget.useSoftFloat())) { if (Subtarget.inMips16Mode()) return std::make_pair(0U, &Mips::CPU16RegsRegClass); return std::make_pair(0U, &Mips::GPR32RegClass); } - if (VT == MVT::i64 && !Subtarget.isGP64bit()) + if ((VT == MVT::i64 || (VT == MVT::f64 && Subtarget.useSoftFloat())) && + !Subtarget.isGP64bit()) return std::make_pair(0U, &Mips::GPR32RegClass); - if (VT == MVT::i64 && Subtarget.isGP64bit()) + if ((VT == MVT::i64 || (VT == MVT::f64 && Subtarget.useSoftFloat())) && + Subtarget.isGP64bit()) return std::make_pair(0U, &Mips::GPR64RegClass); // This will generate an error message return std::make_pair(0U, nullptr); diff --git a/llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll b/llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll new file mode 100644 index 00..705570f808ce00 --- /dev/null +++ b/llvm/test/CodeGen/Mips/inli
[llvm-branch-commits] [llvm] 461274b - MIPS: Fix asm constraints "f" and "r" for softfloat (#79116)
Author: YunQiang Su Date: 2024-02-27T09:18:54-08:00 New Revision: 461274b81d8641eab64d494accddc81d7db8a09e URL: https://github.com/llvm/llvm-project/commit/461274b81d8641eab64d494accddc81d7db8a09e DIFF: https://github.com/llvm/llvm-project/commit/461274b81d8641eab64d494accddc81d7db8a09e.diff LOG: MIPS: Fix asm constraints "f" and "r" for softfloat (#79116) This include 2 fixes: 1. Disallow 'f' for softfloat. 2. Allow 'r' for softfloat. Currently, 'f' is accpeted by clang, then LLVM meets an internal error. 'r' is rejected by LLVM by: couldn't allocate input reg for constraint 'r'. Fixes: #64241, #63632 - Co-authored-by: Fangrui Song (cherry picked from commit c88beb4112d5bbf07d76a615ab7f13ba2ba023e6) Added: clang/test/CodeGen/Mips/inline-asm-constraints.c clang/test/Sema/inline-asm-validate-mips.c llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll Modified: clang/lib/Basic/Targets/Mips.h llvm/lib/Target/Mips/MipsISelLowering.cpp Removed: diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h index f46b95abfd75c7..23d4e1b598fa1e 100644 --- a/clang/lib/Basic/Targets/Mips.h +++ b/clang/lib/Basic/Targets/Mips.h @@ -237,12 +237,14 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo { case 'r': // CPU registers. case 'd': // Equivalent to "r" unless generating MIPS16 code. case 'y': // Equivalent to "r", backward compatibility only. -case 'f': // floating-point registers. case 'c': // $25 for indirect jumps case 'l': // lo register case 'x': // hilo register pair Info.setAllowsRegister(); return true; +case 'f': // floating-point registers. + Info.setAllowsRegister(); + return FloatABI != SoftFloat; case 'I': // Signed 16-bit constant case 'J': // Integer 0 case 'K': // Unsigned 16-bit constant diff --git a/clang/test/CodeGen/Mips/inline-asm-constraints.c b/clang/test/CodeGen/Mips/inline-asm-constraints.c new file mode 100644 index 00..88afe8735083b4 --- /dev/null +++ b/clang/test/CodeGen/Mips/inline-asm-constraints.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm -triple mips -target-feature +soft-float %s -o - | FileCheck %s --check-prefix=SOFT_FLOAT + +// SOFT_FLOAT: call void asm sideeffect "", "r,~{$1}"(float %1) +void read_float(float *p) { + __asm__("" ::"r"(*p)); +} + +// SOFT_FLOAT: call void asm sideeffect "", "r,~{$1}"(double %1) +void read_double(double *p) { + __asm__("" :: "r"(*p)); +} diff --git a/clang/test/Sema/inline-asm-validate-mips.c b/clang/test/Sema/inline-asm-validate-mips.c new file mode 100644 index 00..7da248fe417b5c --- /dev/null +++ b/clang/test/Sema/inline-asm-validate-mips.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple mips64 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple mips64 -target-feature +soft-float -fsyntax-only -verify=softfloat %s + +// expected-no-diagnostics + +void test_f(float p) { + float result = p; + __asm__("" :: "f"(result)); // softfloat-error{{invalid input constraint 'f' in asm}} +} diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index d431d3d91494f6..88b226eaaccfab 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -4128,14 +4128,18 @@ MipsTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, case 'd': // Address register. Same as 'r' unless generating MIPS16 code. case 'y': // Same as 'r'. Exists for compatibility. case 'r': - if (VT == MVT::i32 || VT == MVT::i16 || VT == MVT::i8 || VT == MVT::i1) { + if ((VT == MVT::i32 || VT == MVT::i16 || VT == MVT::i8 || + VT == MVT::i1) || + (VT == MVT::f32 && Subtarget.useSoftFloat())) { if (Subtarget.inMips16Mode()) return std::make_pair(0U, &Mips::CPU16RegsRegClass); return std::make_pair(0U, &Mips::GPR32RegClass); } - if (VT == MVT::i64 && !Subtarget.isGP64bit()) + if ((VT == MVT::i64 || (VT == MVT::f64 && Subtarget.useSoftFloat())) && + !Subtarget.isGP64bit()) return std::make_pair(0U, &Mips::GPR32RegClass); - if (VT == MVT::i64 && Subtarget.isGP64bit()) + if ((VT == MVT::i64 || (VT == MVT::f64 && Subtarget.useSoftFloat())) && + Subtarget.isGP64bit()) return std::make_pair(0U, &Mips::GPR64RegClass); // This will generate an error message return std::make_pair(0U, nullptr); diff --git a/llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll b/llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll new file mode 100644 index 00..705570f808ce00 --- /dev/null +++ b/llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll @@ -0,0 +1,48 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_check
[llvm-branch-commits] [clang] [llvm] release/18.x: MIPS: Fix asm constraints "f" and "r" for softfloat (#79116) (PR #83105)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/83105 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
arichardson wrote: > What is the `[𝘀𝗽𝗿] initial version` commit message about? I'm trying to use getcord/spr for stacked pull requests and it appears this is what it does to the commit messages when uploading them. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
https://github.com/ldionne edited https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,53 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP +#define SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP + +/** + * @file Helper functions to create a @ref std::chrono::leap_second. + * + * Since the standard doesn't specify how a @ref std::chrono::leap_second is + * constructed this is implementation defined. To make the public API tests of + * the class generic this header defines helper functions to create the + * required object. + * + * @note This requires every standard library implementation to write their own + * helper function. Vendors are encouraged to create a pull request at + * https://github.com/llvm/llvm-project so their specific implementation can be + * part of this file. + */ + +#include "test_macros.h" + +#if TEST_STD_VER < 20 +# error "The format header requires at least C++20" +#endif + +#include + +#ifdef _LIBCPP_VERSION + +// In order to find this include the calling test needs to provide this path in +// the search path. Typically this looks like: +// REMOVE_THIS_PREFIX__ADDITIONAL_COMPILE_FLAGS(stdlib=libc++): -I %S/../../../../../../src/include +// where the number of `../` sequences depends on the subdirectory level of the +// test. +# include "tzdb/leap_second_private.h" // Header in the dylib + +inline constexpr std::chrono::leap_second +test_leap_second_create(const std::chrono::sys_seconds& date, const std::chrono::seconds& value) { + return std::chrono::leap_second{std::chrono::leap_second::__constructor_tag{}, date, value}; +} + +#else // _LIBCPP_VERSION +# error "Please create a vendor specific version of the test functions and file a review at https://reviews.llvm.org/"; ldionne wrote: This link is outdated now. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
https://github.com/ldionne requested changes to this pull request. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,53 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP +#define SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP + +/** + * @file Helper functions to create a @ref std::chrono::leap_second. ldionne wrote: This looks a bit odd since we don't use Doxygen anywhere in the codebase. I would remove the Doxygen style markup. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -35,5 +35,8 @@ int main(int, const char**) { assert(std::ranges::is_sorted(db.links)); assert(std::ranges::adjacent_find(db.links) == db.links.end()); // is unique? + assert(!db.leap_seconds.empty()); ldionne wrote: We seem to be missing a test that the `tzdb` struct has the right members with the right types. I think `libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.tzdb/tzdb.members.pass.cpp` needs to be updated. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,56 @@ +//===--===// +// +// 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 +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-incomplete-tzdb +// XFAIL: availability-tzdb-missing + +// + +// class leap_second +// { +// leap_second& operator=(const leap_second&) = default; +// +// ... +// }; + +#include +#include +#include + +// Add the include path required by test_chrono_leap_second.h when using libc++. +// ADDITIONAL_COMPILE_FLAGS(stdlib=libc++): -I %S/../../../../../src/include +#include "test_chrono_leap_second.h" + +constexpr bool test() { + std::chrono::leap_second a = + test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1}); + std::chrono::leap_second b = + test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{10}}, std::chrono::seconds{15}); + + // operator== only compares the date member. + assert(a.date() != b.date()); + assert(a.value() != b.value()); + + b = a; ldionne wrote: ```suggestion std::same_as decltype(auto) result = (b = a); assert(&result == &b); ``` Kinda pedantic, but we do it in several places and this ensures that we return the right type, and that we return `*this` from the operator. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,112 @@ +// -*- 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 +// +//===--===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_LEAP_SECOND_H +#define _LIBCPP___CHRONO_LEAP_SECOND_H + +#include +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) + +# include <__chrono/duration.h> +# include <__chrono/system_clock.h> +# include <__chrono/time_point.h> +# include <__compare/ordering.h> +# include <__compare/three_way_comparable.h> +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 + +namespace chrono { + +class leap_second { +public: + struct __constructor_tag; ldionne wrote: It would be nice to have a single tag type for private constructors -- we could define it library-wide and reuse it whenever we need one. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,51 @@ +//===--===// +// +// 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 +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-incomplete-tzdb +// XFAIL: availability-tzdb-missing + +// + +// class leap_second +// { +// leap_second(const leap_second&)= default; +// +// ... +// }; + +#include +#include +#include + +// Add the include path required by test_chrono_leap_second.h when using libc++. +// ADDITIONAL_COMPILE_FLAGS(stdlib=libc++): -I %S/../../../../../src/include +#include "test_chrono_leap_second.h" + +constexpr bool test() { + std::chrono::leap_second a = + test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1}); + std::chrono::leap_second b(a); ldionne wrote: ```suggestion std::chrono::leap_second b = a; ``` I think this would catch the case where the copy ctor is incorrectly marked as `explicit`. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -612,6 +643,16 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { std::ranges::sort(__tzdb.zones); std::ranges::sort(__tzdb.links); std::ranges::sort(__rules, {}, [](const auto& p) { return p.first; }); + + // There are two files with the leap second information + // - leapseconds as specified by zic + // - leap-seconds.list the source data + // The latter is much easier to parse, it seems Howard shares that + // opinion. + chrono::__parse_leap_seconds(__tzdb.leap_seconds, ifstream{__root / "leap-seconds.list"}); + // Note the input is sorted, but that does not seem to be are + // requirement, it is a requirement in the Standard. + std::ranges::sort(__tzdb.leap_seconds); ldionne wrote: ```suggestion // The Standard requires the leap seconds to be sorted. // leap-seconds.list usually provides them in sorted order, but that is not // guaranteed so we ensure it here. std::ranges::sort(__tzdb.leap_seconds); ``` https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,48 @@ +//===--===// +// +// 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 +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-incomplete-tzdb +// XFAIL: availability-tzdb-missing + +// + +// class leap_second; + +// constexpr sys_seconds date() const noexcept; + +#include +#include + +#include "test_macros.h" + +// Add the include path required by test_chrono_leap_second.h when using libc++. +// ADDITIONAL_COMPILE_FLAGS(stdlib=libc++): -I %S/../../../../../../src/include +#include "test_chrono_leap_second.h" + +constexpr bool test(const std::chrono::leap_second leap_second, std::chrono::sys_seconds expected) { + std::same_as auto date = leap_second.date(); + assert(date == expected); + static_assert(noexcept(leap_second.date())); + + return true; +} + +int main(int, const char**) { + const std::chrono::tzdb& tzdb = std::chrono::get_tzdb(); ldionne wrote: I think we have two tests here. First, we have a test with `test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1})` and we should test it both at runtime and at compile-time. Second, we have a test with the actual value obtained from `get_tzdb()` and we can only test it at runtime. ```c++ constexpr bool test() { auto leap_second = test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1}); std::same_as auto date = leap_second.date(); assert(date == std::chrono::sys_seconds{std::chrono::seconds{0}}); // etc.. } int main() { test(); static_assert(test()); // test with the real tzdb { const auto& tzdb = get_tzdb(); ... } } ``` This would apply to the other test files as well. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,53 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP +#define SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP + +/** + * @file Helper functions to create a @ref std::chrono::leap_second. + * + * Since the standard doesn't specify how a @ref std::chrono::leap_second is + * constructed this is implementation defined. To make the public API tests of + * the class generic this header defines helper functions to create the + * required object. + * + * @note This requires every standard library implementation to write their own + * helper function. Vendors are encouraged to create a pull request at + * https://github.com/llvm/llvm-project so their specific implementation can be + * part of this file. + */ + +#include "test_macros.h" + +#if TEST_STD_VER < 20 +# error "The format header requires at least C++20" +#endif + +#include + +#ifdef _LIBCPP_VERSION + +// In order to find this include the calling test needs to provide this path in +// the search path. Typically this looks like: +// REMOVE_THIS_PREFIX__ADDITIONAL_COMPILE_FLAGS(stdlib=libc++): -I %S/../../../../../../src/include ldionne wrote: ```suggestion // ADDITIONAL_COMPILE_FLAGS(stdlib=libc++): -I %S/../../../../../../src/include ``` This is not necessary to "escape" lit, since this is in a header. https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,112 @@ +// -*- 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 +// +//===--===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_LEAP_SECOND_H +#define _LIBCPP___CHRONO_LEAP_SECOND_H + +#include +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) + +# include <__chrono/duration.h> +# include <__chrono/system_clock.h> +# include <__chrono/time_point.h> +# include <__compare/ordering.h> +# include <__compare/three_way_comparable.h> +# include <__config> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 + +namespace chrono { + +class leap_second { +public: + struct __constructor_tag; + [[nodiscard]] + _LIBCPP_HIDE_FROM_ABI explicit constexpr leap_second(__constructor_tag&&, sys_seconds __date, seconds __value) + : __date_(__date), __value_(__value) {} + + _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&)= default; + _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default; + + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; } + + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; } + +private: + sys_seconds __date_; + seconds __value_; +}; + +_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const leap_second& __x, const leap_second& __y) { ldionne wrote: `inline`? https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)
@@ -0,0 +1,102 @@ +//===--===// +// +// 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 +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-incomplete-tzdb +// XFAIL: availability-tzdb-missing + +// + +// Tests the IANA database leap seconds parsing and operations. +// This is not part of the public tzdb interface. + +#include +#include +#include +#include +#include + +#include "assert_macros.h" +#include "concat_macros.h" +#include "filesystem_test_helper.h" +#include "test_tzdb.h" + +scoped_test_env env; +[[maybe_unused]] const std::filesystem::path dir = env.create_dir("zoneinfo"); +const std::filesystem::path tzdata = env.create_file("zoneinfo/tzdata.zi"); +const std::filesystem::path leap_seconds = env.create_file("zoneinfo/leap-seconds.list"); + +std::string_view std::chrono::__libcpp_tzdb_directory() { + static std::string result = dir.string(); + return result; +} + +void write(std::string_view input) { + static int version = 0; + + std::ofstream f{tzdata}; + f << "# version " << version++ << '\n'; + std::ofstream{leap_seconds}.write(input.data(), input.size()); +} + +static const std::chrono::tzdb& parse(std::string_view input) { + write(input); + return std::chrono::reload_tzdb(); +} + +static void test_exception(std::string_view input, [[maybe_unused]] std::string_view what) { + write(input); + + TEST_VALIDATE_EXCEPTION( + std::runtime_error, + [&]([[maybe_unused]] const std::runtime_error& e) { +TEST_LIBCPP_REQUIRE( +e.what() == what, +TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n')); + }, + TEST_IGNORE_NODISCARD std::chrono::reload_tzdb()); +} + +static void test_invalid() { + test_exception("0", "corrupt tzdb: expected a non-zero digit"); + + test_exception("1", "corrupt tzdb: expected whitespace"); + + test_exception("1 ", "corrupt tzdb: expected a non-zero digit"); +} + +static void test_leap_seconds() { + using namespace std::chrono; + + const tzdb& result = parse( + R"( +2272060800 10 # 1 Jan 1972 +2287785600 11 # 1 Jul 1972 +2303683200 12 # 1 Jan 1973 ldionne wrote: You could provide them unordered to test the sorting logic. Also, what about testing a date before 1970? https://github.com/llvm/llvm-project/pull/82113 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implements filebuf unbuffered. (PR #76629)
@@ -294,7 +318,10 @@ private: return nullptr; __om_ = __mode; + __try_set_unbuffered_mode(); ldionne wrote: Strange indentation. https://github.com/llvm/llvm-project/pull/76629 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implements filebuf unbuffered. (PR #76629)
@@ -276,6 +276,30 @@ private: state_type __st_; state_type __st_last_; ios_base::openmode __om_; + // Used to track the currently used mode and track whether the output should + // be unbuffered. + // [filebuf.virtuals]/12 + // If setbuf(0, 0) is called on a stream before any I/O has occurred on + // that stream, the stream becomes unbuffered. Otherwise the results are + // implementation-defined. + // This allows calling setbuf(0, 0) + // - before opening a file, + // - after opening a file, before + // - a read + // - a write + // - a seek. + // Note that opening a file with ios_base::ate does a seek operation. + // Normally underflow, overflow, and sync change this flag to + // ios_base::in, ios_base_out, or 0. + // + // The ios_base::trunc and ios_base::ate flags are used in the following way: + // - ios_base::trunc is set upon construction to indicate the unbuffered ldionne wrote: We should maybe introduce aptly-named values instead of reusing `trunc` and `ate`? https://github.com/llvm/llvm-project/pull/76629 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fixes naming inconsistency. (#83036) (PR #83156)
https://github.com/mathstuf approved this pull request. https://github.com/llvm/llvm-project/pull/83156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [compiler-rt] Build libfuzzer sources with the chosen C++ compiler (PR #83090)
https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/83090 >From 8d86b5ea7c696367173335997f5aab2d25a31ad0 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Mon, 26 Feb 2024 17:08:23 -0800 Subject: [PATCH] add missing part of diff Created using spr 1.3.4 --- compiler-rt/cmake/Modules/CompilerRTCompile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake index 8c804acb44ae4d..2bf115973a49b3 100644 --- a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake +++ b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake @@ -107,7 +107,7 @@ function(clang_compile object_file source) add_custom_command( OUTPUT ${object_file} -COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c +COMMAND ${compiler} ${compile_flags} -c -o "${object_file}" ${source_rpath} MAIN_DEPENDENCY ${source} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [compiler-rt] Build libfuzzer sources with the chosen C++ compiler (PR #83090)
https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/83090 >From 8d86b5ea7c696367173335997f5aab2d25a31ad0 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Mon, 26 Feb 2024 17:08:23 -0800 Subject: [PATCH] add missing part of diff Created using spr 1.3.4 --- compiler-rt/cmake/Modules/CompilerRTCompile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake index 8c804acb44ae4d..2bf115973a49b3 100644 --- a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake +++ b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake @@ -107,7 +107,7 @@ function(clang_compile object_file source) add_custom_command( OUTPUT ${object_file} -COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c +COMMAND ${compiler} ${compile_flags} -c -o "${object_file}" ${source_rpath} MAIN_DEPENDENCY ${source} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/arichardson edited https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -172,6 +172,20 @@ def push_dynamic_library_lookup_path(config, new_path): # doesn't match config.compiler_rt_libdir then it means we might be testing the # compiler's own runtime libraries rather than the ones we just built. # Warn about about this and handle appropriately. +if config.test_standalone_build_libs: +if config.compiler_id == "Clang": +# Ensure that we use the just-built libraries when linking by overriding +# the Clang resource directory. However, this also means that we can no +# longer find the builtin headers from that path, so we explicitly add +# the builtin headers as an include path. +resource_dir, _ = get_path_from_clang( +shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=False +) +config.target_cflags += f" -nobuiltininc" +config.target_cflags += f" -I{config.compiler_rt_src_root}/include" +config.target_cflags += f" -idirafter {resource_dir}/include" +config.target_cflags += f" -resource-dir={config.compiler_rt_obj_root}" +config.target_cflags += f" -Wl,--rpath={config.compiler_rt_libdir}" arichardson wrote: Logic has been updated now to only add these flags when using the non-LLVM_ENABLE_PROJECTS=clang;compiler-rt build. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -172,6 +172,20 @@ def push_dynamic_library_lookup_path(config, new_path): # doesn't match config.compiler_rt_libdir then it means we might be testing the # compiler's own runtime libraries rather than the ones we just built. # Warn about about this and handle appropriately. +if config.test_standalone_build_libs: +if config.compiler_id == "Clang": +# Ensure that we use the just-built libraries when linking by overriding +# the Clang resource directory. However, this also means that we can no +# longer find the builtin headers from that path, so we explicitly add +# the builtin headers as an include path. arichardson wrote: Clarified comment, should hopefully address this. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Backport ARM64EC variadic args fixes to LLVM 18 (PR #81800)
https://github.com/dpaoliello updated https://github.com/llvm/llvm-project/pull/81800 >From 10ed6a8e268c296901093f90bae4018faf90d27d Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 31 Jan 2024 02:32:15 + Subject: [PATCH 1/3] [AArch64] Fix variadic tail-calls on ARM64EC (#79774) ARM64EC varargs calls expect that x4 = sp at entry, special handling is needed to ensure this with tail calls since they occur after the epilogue and the x4 write happens before. I tried going through AArch64MachineFrameLowering for this, hoping to avoid creating the dummy object but this was the best I could do since the stack info that uses isn't populated at this stage, CreateFixedObject also explicitly forbids 0 sized objects. --- .../Target/AArch64/AArch64ISelLowering.cpp| 10 - llvm/test/CodeGen/AArch64/arm64ec-varargs.ll | 37 +++ llvm/test/CodeGen/AArch64/vararg-tallcall.ll | 8 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 0287856560e91a..196aa50cf4060b 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -8007,11 +8007,19 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI, } if (IsVarArg && Subtarget->isWindowsArm64EC()) { +SDValue ParamPtr = StackPtr; +if (IsTailCall) { + // Create a dummy object at the top of the stack that can be used to get + // the SP after the epilogue + int FI = MF.getFrameInfo().CreateFixedObject(1, FPDiff, true); + ParamPtr = DAG.getFrameIndex(FI, PtrVT); +} + // For vararg calls, the Arm64EC ABI requires values in x4 and x5 // describing the argument list. x4 contains the address of the // first stack parameter. x5 contains the size in bytes of all parameters // passed on the stack. -RegsToPass.emplace_back(AArch64::X4, StackPtr); +RegsToPass.emplace_back(AArch64::X4, ParamPtr); RegsToPass.emplace_back(AArch64::X5, DAG.getConstant(NumBytes, DL, MVT::i64)); } diff --git a/llvm/test/CodeGen/AArch64/arm64ec-varargs.ll b/llvm/test/CodeGen/AArch64/arm64ec-varargs.ll index dc16b3a1a0f270..844fc52ddade63 100644 --- a/llvm/test/CodeGen/AArch64/arm64ec-varargs.ll +++ b/llvm/test/CodeGen/AArch64/arm64ec-varargs.ll @@ -100,5 +100,42 @@ define void @varargs_many_argscalleer() nounwind { ret void } +define void @varargs_caller_tail() nounwind { +; CHECK-LABEL: varargs_caller_tail: +; CHECK:// %bb.0: +; CHECK-NEXT:sub sp, sp, #48 +; CHECK-NEXT:mov x4, sp +; CHECK-NEXT:add x8, sp, #16 +; CHECK-NEXT:mov x9, #4617315517961601024// =0x4014 +; CHECK-NEXT:mov x0, #4607182418800017408// =0x3ff0 +; CHECK-NEXT:mov w1, #2 // =0x2 +; CHECK-NEXT:mov x2, #4613937818241073152// =0x4008 +; CHECK-NEXT:mov w3, #4 // =0x4 +; CHECK-NEXT:mov w5, #16 // =0x10 +; CHECK-NEXT:stp xzr, x30, [sp, #24] // 8-byte Folded Spill +; CHECK-NEXT:stp x9, x8, [sp] +; CHECK-NEXT:str xzr, [sp, #16] +; CHECK-NEXT:.weak_anti_dep varargs_callee +; CHECK-NEXT:.set varargs_callee, "#varargs_callee"@WEAKREF +; CHECK-NEXT:.weak_anti_dep "#varargs_callee" +; CHECK-NEXT:.set "#varargs_callee", varargs_callee@WEAKREF +; CHECK-NEXT:bl "#varargs_callee" +; CHECK-NEXT:ldr x30, [sp, #32] // 8-byte Folded Reload +; CHECK-NEXT:add x4, sp, #48 +; CHECK-NEXT:mov x0, #4607182418800017408// =0x3ff0 +; CHECK-NEXT:mov w1, #4 // =0x4 +; CHECK-NEXT:mov w2, #3 // =0x3 +; CHECK-NEXT:mov w3, #2 // =0x2 +; CHECK-NEXT:mov x5, xzr +; CHECK-NEXT:add sp, sp, #48 +; CHECK-NEXT:.weak_anti_dep varargs_callee +; CHECK-NEXT:.set varargs_callee, "#varargs_callee"@WEAKREF +; CHECK-NEXT:.weak_anti_dep "#varargs_callee" +; CHECK-NEXT:.set "#varargs_callee", varargs_callee@WEAKREF +; CHECK-NEXT:b "#varargs_callee" + call void (double, ...) @varargs_callee(double 1.0, i32 2, double 3.0, i32 4, double 5.0, <2 x double> ) + tail call void (double, ...) @varargs_callee(double 1.0, i32 4, i32 3, i32 2) + ret void +} declare void @llvm.va_start(ptr) diff --git a/llvm/test/CodeGen/AArch64/vararg-tallcall.ll b/llvm/test/CodeGen/AArch64/vararg-tallcall.ll index 2d6db1642247d7..812837639196e6 100644 --- a/llvm/test/CodeGen/AArch64/vararg-tallcall.ll +++ b/llvm/test/CodeGen/AArch64/vararg-tallcall.ll @@ -1,5 +1,6 @@ ; RUN: llc -mtriple=aarch64-windows-msvc %s -o - | FileCheck %s
[llvm-branch-commits] [llvm] Backport ARM64EC variadic args fixes to LLVM 18 (PR #81800)
https://github.com/dpaoliello edited https://github.com/llvm/llvm-project/pull/81800 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
MaskRay wrote: > wants to merge 2 commits into > [users/arichardson/spr/main.compiler-rt-allow-running-tests-without-installing-first](https://github.com/llvm/llvm-project/tree/users/arichardson/spr/main.compiler-rt-allow-running-tests-without-installing-first) Note: since the base branch is not `main`, "Squash and merge" will not merge the patch to "main", but you can manually push it to `main` after approved. You can still click "Squash and merge" so that the PR shows "merged". https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/MaskRay approved this pull request. I have a regular clang build at /tmp/Rel. If I create a standalone compiler-rt build at /tmp/out/crt, I see that with this PR, clang invoked by llvm-lit will get `-resource-dir=/tmp/out/crt -Wl,-rpath,/tmp/out/crt/lib/linux`, which utilizes `include/sanitizer/*_interface.h` (used by certain asan tests) and runtime libraries. ``` #include #include "sanitizer/asan_interface.h" ``` https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
arichardson wrote: > > wants to merge 2 commits into > > [users/arichardson/spr/main.compiler-rt-allow-running-tests-without-installing-first](https://github.com/llvm/llvm-project/tree/users/arichardson/spr/main.compiler-rt-allow-running-tests-without-installing-first) > > Note: since the base branch is not `main`, "Squash and merge" will not merge > the patch to "main", but you can manually push it to `main` after approved. > You can still click "Squash and merge" so that the PR shows "merged". Thanks, trying to get my head around using spr, but I'm a bit scared of `spr land`, so I will probably edit the base branch of the PR in the web UI and land from there. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -168,10 +168,43 @@ def push_dynamic_library_lookup_path(config, new_path): r"/i386(?=-[^/]+$)", "/x86_64", config.compiler_rt_libdir ) + +# Check if the test compiler resource dir matches the local build directory +# (which happens with -DLLVM_ENABLE_PROJECTS=clang;compiler-rt) or if we are +# using an installed clang to test compiler-rt standalone. In the latter case +# we may need to override the resource dir to match the path of the just-built +# compiler-rt libraries. +test_cc_resource_dir, _ = get_path_from_clang( +shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=True +) +# Normalize the path for comparison +if test_cc_resource_dir is not None: +test_cc_resource_dir = os.path.realpath(test_cc_resource_dir) +if lit_config.debug: +lit_config.note(f"Resource dir for {config.clang} is {test_cc_resource_dir}") +local_build_resource_dir = os.path.realpath(config.compiler_rt_output_dir) +if test_cc_resource_dir != local_build_resource_dir: +if config.test_standalone_build_libs and config.compiler_id == "Clang": +if lit_config.debug: +lit_config.note(f'Overriding test compiler resource dir to use ' +f'libraries in "{config.compiler_rt_libdir}"') +# Ensure that we use the just-built static libraries when linking by +# overriding the Clang resource directory. Additionally, we want to use +# the builtin headers shipped with clang (e.g. stdint.h), so we +# explicitly add this as an include path (since the headers are not +# going to be in the current compiler-rt build directory). +# We also tell the linker to add an RPATH entry for the local library +# directory so that the just-built shared libraries are used. +config.target_cflags += f" -nobuiltininc" MaskRay wrote: Can `target_cflags` be made to a `list` instead of space-separate `str`? https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
@@ -168,10 +168,43 @@ def push_dynamic_library_lookup_path(config, new_path): r"/i386(?=-[^/]+$)", "/x86_64", config.compiler_rt_libdir ) + +# Check if the test compiler resource dir matches the local build directory +# (which happens with -DLLVM_ENABLE_PROJECTS=clang;compiler-rt) or if we are +# using an installed clang to test compiler-rt standalone. In the latter case +# we may need to override the resource dir to match the path of the just-built +# compiler-rt libraries. +test_cc_resource_dir, _ = get_path_from_clang( +shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=True +) +# Normalize the path for comparison +if test_cc_resource_dir is not None: +test_cc_resource_dir = os.path.realpath(test_cc_resource_dir) +if lit_config.debug: +lit_config.note(f"Resource dir for {config.clang} is {test_cc_resource_dir}") +local_build_resource_dir = os.path.realpath(config.compiler_rt_output_dir) +if test_cc_resource_dir != local_build_resource_dir: +if config.test_standalone_build_libs and config.compiler_id == "Clang": +if lit_config.debug: +lit_config.note(f'Overriding test compiler resource dir to use ' +f'libraries in "{config.compiler_rt_libdir}"') +# Ensure that we use the just-built static libraries when linking by +# overriding the Clang resource directory. Additionally, we want to use +# the builtin headers shipped with clang (e.g. stdint.h), so we +# explicitly add this as an include path (since the headers are not +# going to be in the current compiler-rt build directory). +# We also tell the linker to add an RPATH entry for the local library +# directory so that the just-built shared libraries are used. +config.target_cflags += f" -nobuiltininc" arichardson wrote: I agree that this would be cleaner, I will submit an independent cleanup PR. https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Remove pipeline checks for optsize for DFAJumpThreadingPass (PR #83188)
https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/83188 The pass itself checks whether to apply the optimization based on the minsize attribute, so there isn't much functional benefit to preventing the pass from being added. Gating the pass gets added to the pass pipeline complicates the interaction with -enable-dfa-jump-thread, as well. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/83049 >From fc2e672d474442ef83e90c7a41265d6433651b63 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Mon, 26 Feb 2024 21:42:24 + Subject: [PATCH 1/2] Refactor option names, and update test Created using spr 1.3.4 --- llvm/lib/Passes/PassBuilderPipelines.cpp| 4 ++-- llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp | 11 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index e48a31f79cc0c5..9f81ff1899ac5f 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -222,8 +222,8 @@ static cl::opt EnableDFAJumpThreading("enable-dfa-jump-thread", cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); -static cl::opt -OptSizeDFAJumpThreading("optsize-dfa-jump-thread", +extern cl::opt +OptSizeDFAJumpThreading("dfa-jump-thread-optsize", cl::desc("Enable DFA jump threading when optimizing for size"), cl::init(false), cl::Hidden); diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp index 9156d756310d14..ce5e823e531e0f 100644 --- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp @@ -110,11 +110,10 @@ static cl::opt cl::desc("Maximum cost accepted for the transformation"), cl::Hidden, cl::init(50)); -static cl::opt -IgnoreOptSize("dfa-jump-ignore-optsize", -cl::desc("Enable dfa jump threading, even when optimizing for size"), -cl::Hidden, cl::init(false)); - +static cl::opt DFAJumpThreadIgnoreOptSize( +"dfa-jump-ignore-optsize", +cl::desc("Enable dfa jump threading, even when optimizing for size"), +cl::Hidden, cl::init(false)); namespace { @@ -1250,7 +1249,7 @@ struct TransformDFA { bool DFAJumpThreading::run(Function &F) { LLVM_DEBUG(dbgs() << "\nDFA Jump threading: " << F.getName() << "\n"); - if (!IgnoreOptSize && F.hasOptSize()) { + if (!DFAJumpThreadIgnoreOptSize && F.hasOptSize()) { LLVM_DEBUG(dbgs() << "Skipping due to the 'minsize' attribute\n"); return false; } >From ffaa39b064da4d99e1834102ddbb38f0780e4ae7 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Mon, 26 Feb 2024 21:55:44 + Subject: [PATCH 2/2] Make variable static + rename Created using spr 1.3.4 --- llvm/lib/Passes/PassBuilderPipelines.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 9f81ff1899ac5f..a4db4614c6f830 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -222,8 +222,8 @@ static cl::opt EnableDFAJumpThreading("enable-dfa-jump-thread", cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); -extern cl::opt -OptSizeDFAJumpThreading("dfa-jump-thread-optsize", +static cl::opt +DFAJumpThreadingOptSize("dfa-jump-thread-optsize", cl::desc("Enable DFA jump threading when optimizing for size"), cl::init(false), cl::Hidden); @@ -723,7 +723,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level, // Re-consider control flow based optimizations after redundancy elimination, // redo DCE, etc. if (EnableDFAJumpThreading && - ((Level.getSizeLevel() == 0) || OptSizeDFAJumpThreading)) + ((Level.getSizeLevel() == 0) || DFAJumpThreadingOptSize)) FPM.addPass(DFAJumpThreadingPass()); FPM.addPass(JumpThreadingPass()); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/83049 >From fc2e672d474442ef83e90c7a41265d6433651b63 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Mon, 26 Feb 2024 21:42:24 + Subject: [PATCH 1/2] Refactor option names, and update test Created using spr 1.3.4 --- llvm/lib/Passes/PassBuilderPipelines.cpp| 4 ++-- llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp | 11 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index e48a31f79cc0c5..9f81ff1899ac5f 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -222,8 +222,8 @@ static cl::opt EnableDFAJumpThreading("enable-dfa-jump-thread", cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); -static cl::opt -OptSizeDFAJumpThreading("optsize-dfa-jump-thread", +extern cl::opt +OptSizeDFAJumpThreading("dfa-jump-thread-optsize", cl::desc("Enable DFA jump threading when optimizing for size"), cl::init(false), cl::Hidden); diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp index 9156d756310d14..ce5e823e531e0f 100644 --- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp @@ -110,11 +110,10 @@ static cl::opt cl::desc("Maximum cost accepted for the transformation"), cl::Hidden, cl::init(50)); -static cl::opt -IgnoreOptSize("dfa-jump-ignore-optsize", -cl::desc("Enable dfa jump threading, even when optimizing for size"), -cl::Hidden, cl::init(false)); - +static cl::opt DFAJumpThreadIgnoreOptSize( +"dfa-jump-ignore-optsize", +cl::desc("Enable dfa jump threading, even when optimizing for size"), +cl::Hidden, cl::init(false)); namespace { @@ -1250,7 +1249,7 @@ struct TransformDFA { bool DFAJumpThreading::run(Function &F) { LLVM_DEBUG(dbgs() << "\nDFA Jump threading: " << F.getName() << "\n"); - if (!IgnoreOptSize && F.hasOptSize()) { + if (!DFAJumpThreadIgnoreOptSize && F.hasOptSize()) { LLVM_DEBUG(dbgs() << "Skipping due to the 'minsize' attribute\n"); return false; } >From ffaa39b064da4d99e1834102ddbb38f0780e4ae7 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Mon, 26 Feb 2024 21:55:44 + Subject: [PATCH 2/2] Make variable static + rename Created using spr 1.3.4 --- llvm/lib/Passes/PassBuilderPipelines.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 9f81ff1899ac5f..a4db4614c6f830 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -222,8 +222,8 @@ static cl::opt EnableDFAJumpThreading("enable-dfa-jump-thread", cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); -extern cl::opt -OptSizeDFAJumpThreading("dfa-jump-thread-optsize", +static cl::opt +DFAJumpThreadingOptSize("dfa-jump-thread-optsize", cl::desc("Enable DFA jump threading when optimizing for size"), cl::init(false), cl::Hidden); @@ -723,7 +723,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level, // Re-consider control flow based optimizations after redundancy elimination, // redo DCE, etc. if (EnableDFAJumpThreading && - ((Level.getSizeLevel() == 0) || OptSizeDFAJumpThreading)) + ((Level.getSizeLevel() == 0) || DFAJumpThreadingOptSize)) FPM.addPass(DFAJumpThreadingPass()); FPM.addPass(JumpThreadingPass()); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)
ilovepi wrote: > also, we should remove pipeline checks for "optsize" and move those checks > into the passes themselves done in https://github.com/llvm/llvm-project/pull/83188 https://github.com/llvm/llvm-project/pull/83049 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)
https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/83088 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fixes naming inconsistency. (#83036) (PR #83156)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/83156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Remove pipeline checks for optsize for DFAJumpThreadingPass (PR #83188)
https://github.com/aeubanks approved this pull request. https://github.com/llvm/llvm-project/pull/83188 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: MIPS: fix emitDirectiveCpsetup on N32 (#80534) (PR #83198)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/83198 Backport 860b6edfa9b344fbf8c500c17158c8212ea87d1c Requested by: @brad0 >From 3e2247124ed20b20044d6f6e5afc065a7f6add61 Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Tue, 27 Feb 2024 05:08:58 +0800 Subject: [PATCH] MIPS: fix emitDirectiveCpsetup on N32 (#80534) In gas, .cpsetup may expand to one of two code sequences (one is related to `__gnu_local_gp`), depending on -mno-shared and -msym32. Since Clang doesn't support -mno-shared or -msym32, .cpsetup expands to one code sequence. The N32 condition incorrectly leads to the incorrect `__gnu_local_gp` code sequence. ``` : 0: ffbc0008sd gp,8(sp) 4: 3c1clui gp,0x0 4: R_MIPS_HI16 __gnu_local_gp 8: 279caddiu gp,gp,0 8: R_MIPS_LO16 __gnu_local_gp ``` Fixes: #52785 (cherry picked from commit 860b6edfa9b344fbf8c500c17158c8212ea87d1c) --- .../Mips/MCTargetDesc/MipsTargetStreamer.cpp | 12 +++-- llvm/test/MC/Mips/cpsetup.s | 47 ++- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index 27d7f0f261d100..adfcea73615831 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -1255,7 +1255,9 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo, emitRRI(Mips::SD, GPReg, Mips::SP, RegOrOffset, SMLoc(), &STI); } - if (getABI().IsN32()) { +#if 0 + // We haven't support -mabicalls -mno-shared yet. + if (-mno-shared) { MCSymbol *GPSym = MCA.getContext().getOrCreateSymbol("__gnu_local_gp"); const MipsMCExpr *HiExpr = MipsMCExpr::create( MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(GPSym, MCA.getContext()), @@ -1273,6 +1275,7 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo, return; } +#endif const MipsMCExpr *HiExpr = MipsMCExpr::createGpOff( MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(&Sym, MCA.getContext()), @@ -1288,8 +1291,11 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo, emitRRX(Mips::ADDiu, GPReg, GPReg, MCOperand::createExpr(LoExpr), SMLoc(), &STI); - // daddu $gp, $gp, $funcreg - emitRRR(Mips::DADDu, GPReg, GPReg, RegNo, SMLoc(), &STI); + // (d)addu $gp, $gp, $funcreg + if (getABI().IsN32()) +emitRRR(Mips::ADDu, GPReg, GPReg, RegNo, SMLoc(), &STI); + else +emitRRR(Mips::DADDu, GPReg, GPReg, RegNo, SMLoc(), &STI); } void MipsTargetELFStreamer::emitDirectiveCpreturn(unsigned SaveLocation, diff --git a/llvm/test/MC/Mips/cpsetup.s b/llvm/test/MC/Mips/cpsetup.s index 8e587aea3e7e69..4a027c6e796aea 100644 --- a/llvm/test/MC/Mips/cpsetup.s +++ b/llvm/test/MC/Mips/cpsetup.s @@ -4,8 +4,6 @@ # RUN: llvm-mc -triple mips-unknown-linux -target-abi o32 %s | \ # RUN: FileCheck -check-prefixes=ASM,ASM-O32 %s -# FIXME: Now we check .cpsetup expansion for `-mno-shared` case only. -#We also need to implement/check the `-mshared` case. # RUN: llvm-mc -triple mips64-unknown-linux -target-abi n32 -filetype=obj -o - %s | \ # RUN: llvm-objdump --no-print-imm-hex -d -r -z - | \ # RUN: FileCheck -check-prefixes=ALL,NXX,N32 %s @@ -35,11 +33,16 @@ t1: # NXX-NEXT: sd $gp, 8($sp) # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_HI16 # NXX-NEXT: addiu$gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_LO16 +# N32-NEXT: addu $gp, $gp, $25 # N64-NEXT: daddu$gp, $gp, $25 # ASM-NEXT: .cpsetup $25, 8, __cerror @@ -64,11 +67,16 @@ t2: # NXX-NEXT: move $2, $gp # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_HI16 # NXX-NEXT: addiu$gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_LO16 +# N32-NEXT: addu $gp, $gp, $25 # N64-NEXT: daddu$gp, $gp, $25 # ASM-NEXT: .cpsetup $25, $2, __cerror @@ -101,11 +109,16 @@ t3: # NXX-NEXT: move $2, $gp # NXX-NEXT: lui $gp, 0 -# N32-NEXT: {{^ *0+}}38: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: {{^ *0+}}40: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 .text +# N32-NEXT: {{^ *0+}}40: R_MIPS_GPREL16 .text +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_HI16 # NXX-NEXT: addiu$gp, $gp, 0 -# N32-NEXT: {{^ *0+}}3c: R
[llvm-branch-commits] [llvm] release/18.x: MIPS: fix emitDirectiveCpsetup on N32 (#80534) (PR #83198)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/83198 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: MIPS: fix emitDirectiveCpsetup on N32 (#80534) (PR #83198)
llvmbot wrote: @MaskRay What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/83198 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: MIPS: fix emitDirectiveCpsetup on N32 (#80534) (PR #83198)
llvmbot wrote: @llvm/pr-subscribers-mc Author: None (llvmbot) Changes Backport 860b6edfa9b344fbf8c500c17158c8212ea87d1c Requested by: @brad0 --- Full diff: https://github.com/llvm/llvm-project/pull/83198.diff 2 Files Affected: - (modified) llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (+9-3) - (modified) llvm/test/MC/Mips/cpsetup.s (+35-12) ``diff diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index 27d7f0f261d100..adfcea73615831 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -1255,7 +1255,9 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo, emitRRI(Mips::SD, GPReg, Mips::SP, RegOrOffset, SMLoc(), &STI); } - if (getABI().IsN32()) { +#if 0 + // We haven't support -mabicalls -mno-shared yet. + if (-mno-shared) { MCSymbol *GPSym = MCA.getContext().getOrCreateSymbol("__gnu_local_gp"); const MipsMCExpr *HiExpr = MipsMCExpr::create( MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(GPSym, MCA.getContext()), @@ -1273,6 +1275,7 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo, return; } +#endif const MipsMCExpr *HiExpr = MipsMCExpr::createGpOff( MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(&Sym, MCA.getContext()), @@ -1288,8 +1291,11 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo, emitRRX(Mips::ADDiu, GPReg, GPReg, MCOperand::createExpr(LoExpr), SMLoc(), &STI); - // daddu $gp, $gp, $funcreg - emitRRR(Mips::DADDu, GPReg, GPReg, RegNo, SMLoc(), &STI); + // (d)addu $gp, $gp, $funcreg + if (getABI().IsN32()) +emitRRR(Mips::ADDu, GPReg, GPReg, RegNo, SMLoc(), &STI); + else +emitRRR(Mips::DADDu, GPReg, GPReg, RegNo, SMLoc(), &STI); } void MipsTargetELFStreamer::emitDirectiveCpreturn(unsigned SaveLocation, diff --git a/llvm/test/MC/Mips/cpsetup.s b/llvm/test/MC/Mips/cpsetup.s index 8e587aea3e7e69..4a027c6e796aea 100644 --- a/llvm/test/MC/Mips/cpsetup.s +++ b/llvm/test/MC/Mips/cpsetup.s @@ -4,8 +4,6 @@ # RUN: llvm-mc -triple mips-unknown-linux -target-abi o32 %s | \ # RUN: FileCheck -check-prefixes=ASM,ASM-O32 %s -# FIXME: Now we check .cpsetup expansion for `-mno-shared` case only. -#We also need to implement/check the `-mshared` case. # RUN: llvm-mc -triple mips64-unknown-linux -target-abi n32 -filetype=obj -o - %s | \ # RUN: llvm-objdump --no-print-imm-hex -d -r -z - | \ # RUN: FileCheck -check-prefixes=ALL,NXX,N32 %s @@ -35,11 +33,16 @@ t1: # NXX-NEXT: sd $gp, 8($sp) # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_HI16 # NXX-NEXT: addiu$gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_LO16 +# N32-NEXT: addu $gp, $gp, $25 # N64-NEXT: daddu$gp, $gp, $25 # ASM-NEXT: .cpsetup $25, 8, __cerror @@ -64,11 +67,16 @@ t2: # NXX-NEXT: move $2, $gp # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_HI16 # NXX-NEXT: addiu$gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_LO16 +# N32-NEXT: addu $gp, $gp, $25 # N64-NEXT: daddu$gp, $gp, $25 # ASM-NEXT: .cpsetup $25, $2, __cerror @@ -101,11 +109,16 @@ t3: # NXX-NEXT: move $2, $gp # NXX-NEXT: lui $gp, 0 -# N32-NEXT: {{^ *0+}}38: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: {{^ *0+}}40: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 .text +# N32-NEXT: {{^ *0+}}40: R_MIPS_GPREL16 .text +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_HI16 # NXX-NEXT: addiu$gp, $gp, 0 -# N32-NEXT: {{^ *0+}}3c: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: {{^ *0+}}44: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 .text +# N32-NEXT: {{^ *0+}}44: R_MIPS_GPREL16 .text +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_LO16 +# N32-NEXT: addu $gp, $gp, $25 # N64-NEXT: daddu$gp, $gp, $25 # NXX-NEXT: nop # NXX-NEXT: sub $3, $3, $2 @@ -158,11 +171,16 @@ t5: # NXX-NEXT: sd $gp, 8($sp) # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_MIPS_HI16 # NXX-NEXT: addiu$gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror +# N32-NEXT: R_MIPS_GPREL16 __cerror +# N32-NEXT: R_MIPS_SUB +# N32-NEXT: R_M
[llvm-branch-commits] [compiler-rt] [compiler-rt] Build libfuzzer sources with the chosen C++ compiler (PR #83090)
https://github.com/aeubanks approved this pull request. seems reasonable https://github.com/llvm/llvm-project/pull/83090 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: MIPS: fix emitDirectiveCpsetup on N32 (#80534) (PR #83198)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/83198 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/83049 >From fc2e672d474442ef83e90c7a41265d6433651b63 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Mon, 26 Feb 2024 21:42:24 + Subject: [PATCH 1/3] Refactor option names, and update test Created using spr 1.3.4 --- llvm/lib/Passes/PassBuilderPipelines.cpp| 4 ++-- llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp | 11 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index e48a31f79cc0c5..9f81ff1899ac5f 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -222,8 +222,8 @@ static cl::opt EnableDFAJumpThreading("enable-dfa-jump-thread", cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); -static cl::opt -OptSizeDFAJumpThreading("optsize-dfa-jump-thread", +extern cl::opt +OptSizeDFAJumpThreading("dfa-jump-thread-optsize", cl::desc("Enable DFA jump threading when optimizing for size"), cl::init(false), cl::Hidden); diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp index 9156d756310d14..ce5e823e531e0f 100644 --- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp @@ -110,11 +110,10 @@ static cl::opt cl::desc("Maximum cost accepted for the transformation"), cl::Hidden, cl::init(50)); -static cl::opt -IgnoreOptSize("dfa-jump-ignore-optsize", -cl::desc("Enable dfa jump threading, even when optimizing for size"), -cl::Hidden, cl::init(false)); - +static cl::opt DFAJumpThreadIgnoreOptSize( +"dfa-jump-ignore-optsize", +cl::desc("Enable dfa jump threading, even when optimizing for size"), +cl::Hidden, cl::init(false)); namespace { @@ -1250,7 +1249,7 @@ struct TransformDFA { bool DFAJumpThreading::run(Function &F) { LLVM_DEBUG(dbgs() << "\nDFA Jump threading: " << F.getName() << "\n"); - if (!IgnoreOptSize && F.hasOptSize()) { + if (!DFAJumpThreadIgnoreOptSize && F.hasOptSize()) { LLVM_DEBUG(dbgs() << "Skipping due to the 'minsize' attribute\n"); return false; } >From ffaa39b064da4d99e1834102ddbb38f0780e4ae7 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Mon, 26 Feb 2024 21:55:44 + Subject: [PATCH 2/3] Make variable static + rename Created using spr 1.3.4 --- llvm/lib/Passes/PassBuilderPipelines.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 9f81ff1899ac5f..a4db4614c6f830 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -222,8 +222,8 @@ static cl::opt EnableDFAJumpThreading("enable-dfa-jump-thread", cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); -extern cl::opt -OptSizeDFAJumpThreading("dfa-jump-thread-optsize", +static cl::opt +DFAJumpThreadingOptSize("dfa-jump-thread-optsize", cl::desc("Enable DFA jump threading when optimizing for size"), cl::init(false), cl::Hidden); @@ -723,7 +723,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level, // Re-consider control flow based optimizations after redundancy elimination, // redo DCE, etc. if (EnableDFAJumpThreading && - ((Level.getSizeLevel() == 0) || OptSizeDFAJumpThreading)) + ((Level.getSizeLevel() == 0) || DFAJumpThreadingOptSize)) FPM.addPass(DFAJumpThreadingPass()); FPM.addPass(JumpThreadingPass()); >From 72ecbcc68501c976b3277b28edc6aeafff9f4dad Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Wed, 28 Feb 2024 00:22:40 + Subject: [PATCH 3/3] Fix missing match in test, due to a deleted line Created using spr 1.3.4 --- llvm/test/Transforms/DFAJumpThreading/negative.ll | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/test/Transforms/DFAJumpThreading/negative.ll b/llvm/test/Transforms/DFAJumpThreading/negative.ll index cce6cc887ff206..c822b6613f7334 100644 --- a/llvm/test/Transforms/DFAJumpThreading/negative.ll +++ b/llvm/test/Transforms/DFAJumpThreading/negative.ll @@ -188,6 +188,7 @@ define i32 @negative5(i32 %num) minsize { ; CHECK-NEXT:ret i32 0 ; ; IGNORESIZE-LABEL: define i32 @negative5( +; IGNORESIZE-SAME: i32 [[NUM:%.*]]) #[[ATTR0:[0-9]+]] { ; IGNORESIZE-NEXT: entry: ; IGNORESIZE-NEXT:br label [[FOR_BODY:%.*]] ; IGNORESIZE: for.body: ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 5800712 - Revert "[CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. …"
Author: Alexander Yermolovich Date: 2024-02-27T16:40:45-08:00 New Revision: 58007120dfbc69ccfdf04ae1eb71b30e3582b435 URL: https://github.com/llvm/llvm-project/commit/58007120dfbc69ccfdf04ae1eb71b30e3582b435 DIFF: https://github.com/llvm/llvm-project/commit/58007120dfbc69ccfdf04ae1eb71b30e3582b435.diff LOG: Revert "[CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. …" This reverts commit b3ae6c205e4afcf1a9f7d7204a659a27ca700237. Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/split-debug.c Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index dbfc729bba24c76..6e1b7e8657d0dc9 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,10 +4479,9 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (DebuggerTuning != llvm::DebuggerKind::LLDB && -(!PubnamesArg || - (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames +if (!PubnamesArg || +(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index a2a3dc023545034..968f33b4cc035c5 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -124,8 +124,3 @@ // G1_NOSPLIT: "-debug-info-kind=line-tables-only" // G1_NOSPLIT-NOT: "-split-dwarf-file" // G1_NOSPLIT-NOT: "-split-dwarf-output" - -/// Do not generate -ggnu-pubnames for -glldb -// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT - -// GLLDBSPLIT-NOT: "-ggnu-pubnames" ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits