1. 23 Jan, 2023 1 commit
  2. 20 Jan, 2023 8 commits
  3. 19 Jan, 2023 1 commit
    • Silviu Baranga's avatar
      [Morello][SCEV] Fix expansion for add SCEV expressions. · d47174d8
      Silviu Baranga authored
      Check OpsAndLoops instead of Loops to find out the number
      of operands of the expression. This was causing an issue
      where we weren't doing the usual base/offset expansion.
      
      Additionally fix the logic in expandAddToGEP for capabilities.
      Just emit the ugly GEP to avoid the case where we would need
      multiple GEPs.
      
      Fixes #65
      d47174d8
  4. 09 Jan, 2023 1 commit
  5. 16 Dec, 2022 1 commit
    • Silviu Baranga's avatar
      [Morello] Update fault type for cap-fault-access · 5c65f3e3
      Silviu Baranga authored
      This is due to tightening of capability permissions returned by mmap.
      
      We should end up with a permissions fault everywhere, however
      at the moment the exact type of fault that we get depends on
      the environment. For now match all faults.
      5c65f3e3
  6. 12 Dec, 2022 1 commit
  7. 22 Nov, 2022 1 commit
  8. 04 Nov, 2022 1 commit
  9. 26 Oct, 2022 1 commit
    • Jessica Clarke's avatar
      [Morello] Use integer rather than capability branch to lower jump tables · 34f55f5a
      Jessica Clarke authored
      On Rainier, PCC bounds are not predicted, and only readable by ADR(P)
      once the branch has been resolved. This means that, if a jump table is
      in a tight loop, the backend fills up with ADR->BR->ADR->BR->... chains
      that result in large numbers of backend stalls. In particular, the state
      machine benchmark in CoreMark hits this, resulting in a 15% overhead
      (cycles) and around 3x the backend stalls that account for almost all
      this overhead. Using indirect integer branches, whilst sad that it has
      to be done to achieve competitive performance, should be just as safe,
      and reduces CoreMark's overhead to around 1% more cycles.
      34f55f5a
  10. 25 Oct, 2022 1 commit
    • Alex Richardson's avatar
      [ELF][Morello] Add basic support for LTO · a50d7610
      Alex Richardson authored
      When parsing bitcode files, ld.lld would previously hit an assertion due to
      a mismatched DataLayout. This patch adds minimal support for Morello LTO
      by inferring the target ABI from the morello-c64-plt flag. This flag
      is set automatically based on the ELF e_flags, so as long as the first
      input file is a purecap file, it should also work automatically when using
      a bare ld.lld invocation instead calling ld.lld via clang.
      
      This is lightly tested, but I have been able to build various projects
      with -flto=thin.
      a50d7610
  11. 11 Oct, 2022 1 commit
  12. 03 Oct, 2022 4 commits
    • Tom Stellard's avatar
      libcang: Add missing function to libclang.map · 1c2662b6
      Tom Stellard authored and Silviu Baranga's avatar Silviu Baranga committed
      This function is marked with CINDEX_LINKAGE, but was never added to the
      export list / linker script.
      
      Reviewed By: jrtc27
      
      Differential Revision: https://reviews.llvm.org/D106974
      
      (cherry picked from commit a4edb2b1ba0bda9042e87ca3f3e1b9f70598df9a)
      1c2662b6
    • Richard Smith's avatar
      PR45879: Fix assert when constant evaluating union assignment. · ec844a8e
      Richard Smith authored and Silviu Baranga's avatar Silviu Baranga committed
      Consider the form of the first operand of a class assignment not the
      second operand when implicitly starting the lifetimes of union members.
      Also add a missing check that the assignment call actually came from a
      syntactic assignment, not from a direct call to `operator=`.
      
      (cherry picked from commit 30baa5d2a450d5e302d8cba3fc7a26a59d4b7ae1)
      ec844a8e
    • Adrian Prantl's avatar
      [DwarfDebug] Refuse to emit DW_OP_LLVM_arg values wider than 64 bits · 78397683
      Adrian Prantl authored and Silviu Baranga's avatar Silviu Baranga committed
      DwarfExpression::addUnsignedConstant(const APInt &Value) only supports
      wider-than-64-bit values when it is used to emit a top-level DWARF
      expression representing the location of a variable. Before this change,
      it was possible to call addUnsignedConstant on >64 bit values within a
      subexpression when substituting DW_OP_LLVM_arg values.
      
      This can trigger an assertion failure (e.g. PR52584, PR52333) when it
      happens in a fragment (DW_OP_LLVM_fragment) expression, as
      addUnsignedConstant on >64 bit values splits the constant into separate
      DW_OP_pieces, which modifies DwarfExpression::OffsetInBits.
      
      This change papers over the assertion errors by bailing on overly wide
      DW_OP_LLVM_arg values. A more comprehensive fix might be to be to split
      wide values into pointer-sized fragments.
      
      [0] https://github.com/llvm/llvm-project/blob/e71fa03/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L799-L805
      
      Patch by Ricky Zhou!
      
      Differential Revision: https://reviews.llvm.org/D115343
      
      (cherry picked from commit c7c84b90879f0252c58894f70d2a19fc4c01cf64)
      78397683
    • Richard Smith's avatar
      An expression should only contain an unexpanded parameter pack if it · f4fce779
      Richard Smith authored and Silviu Baranga's avatar Silviu Baranga committed
      lexically contains a mention of the pack.
      
      Systematically distinguish between syntactic and semantic references to
      packs, especially when propagating dependence from a type into an
      expression. We should consult the type-as-written when computing
      syntactic dependence and should consult the semantic type when computing
      semantic dependence.
      
      Fixes #54402.
      
      (cherry picked from commit f1b0a4fc540f986372f09768c325d505b75b414d)
      f4fce779
  13. 30 Sep, 2022 1 commit
  14. 28 Sep, 2022 1 commit
    • Jessica Clarke's avatar
      [Morello] Work around RRLEN/RRMASK ISA quirk · d755e377
      Jessica Clarke authored
      For any representable length of the form (1 << 12) - 1) << (E + 3), i.e.
      the largest representable length for an exponent E, RRLEN and RRMASK as
      defined in Morello will incorrectly round the length up to the next
      representable one. On the surface this might not be an issue, as one
      might imagine it just results in a bit of redundant padding in edge
      cases, but it is in fact problematic for software written against the
      generic CHERI C interfaces. For example, a common way to assert that a
      length is representable is cheri_representable_length(x) == x, which is
      used in various places in CheriBSD, but this fails in the case that x is
      one of the special values. In particular, this has been seen to happen
      in the CheriBSD kernel's ELF image activator, since we round and align
      the start and end addresses for the mapped region to be representable
      and later assert this has been done, but very occasionally executables
      are produced that trip this up and panic the kernel. One could go add a
      workaround to every piece of software that requires the intrinsics to be
      exact, but this quickly becomes tedious and may not catch all such
      cases, leaving latent hard-to-trigger bugs on just Morello.
      
      Instead, make the Morello implementation of the intrinsics conform to
      the CHERI contract by expanding them to a multi-instruction sequence
      that detects potentially-problematic cases and fixes them to be what
      they should be. For efficiency, however, we leave DYNAMIC_STACKALLOC as
      padded more than needed; note that we already have a second SCBNDS for
      this case that takes the original unpadded length and so we will still
      get the tighter bounds on the capability, just a bit of padding after
      the top.
      
      For now the inexact LLVM intrinsics are not made available to Clang, but
      these should be added once a suitable name has been agreed upon (such as
      __builtin_morello_*_inexact to match the LLVM names chosen here, which
      should not be considered stable).
      d755e377
  15. 16 Sep, 2022 1 commit
    • Diana Picus's avatar
      [Morello][lldb] Read the ABI from ELF · f37aa851
      Diana Picus authored
      Distinguish between purecap and hybrid based on the existence of the
      EF_AARCH64_CHERI_PURECAP flag in the binary. This information is passed
      into the ArchSpec and used when determining the size of a pointer. Note
      that even with this patch we still don't have a fully consistent
      handling of pointers vs addresses in lldb, so certain things might still
      be broken. However, we can now enable one of the end-to-end tests for
      hybrid mode. It used to pass only for purecap because we were making an
      assumption about certain pointers being capabilities.
      f37aa851
  16. 15 Sep, 2022 1 commit
  17. 30 Aug, 2022 1 commit
  18. 26 Aug, 2022 3 commits
    • Alex Richardson's avatar
      [Morello] Update test after upstream cherry-pick · fafe622f
      Alex Richardson authored
      We now generate the expected relocation for a function instead of a
      relocation against section+offset. This ensures that compiling with
      -ffunction-sections no longer creates relocations without the LSB set.
      fafe622f
    • Alex Richardson's avatar
      Mark the $local function begin symbol as a function · 8524e56f
      Alex Richardson authored and Alex Richardson's avatar Alex Richardson committed
      While this does not matter for most targets, when building for Arm Morello,
      we have to mark the symbol as a function and add size information, so that
      LLD can correctly evaluate relocations against the local symbol.
      Since Morello is an out-of-tree target, I tried to reproduce this with
      in-tree backends and with the previous reviews applied this results in
      a noticeable difference when targeting Thumb.
      
      Background: Morello uses a method similar Thumb where the encoding mode is
      specified in the LSB of the symbol. If we don't mark the target as a
      function, the relocation will not have the LSB set and calls will end up
      using the wrong encoding mode (which will almost certainly crash).
      
      Reviewed By: MaskRay
      
      Differential Revision: https://reviews.llvm.org/D131429
      
      (cherry picked from commit 0483b008759b566984f040269b7a90210922a145)
      8524e56f
    • Alex Richardson's avatar
      [Morello] Baseline test for incorrect relocation with -ffunction-sections · e179980e
      Alex Richardson authored
      When calling a dso_local function, we end up creating a call against the
      .Lfoo$local label. This might be converted to a relocation against a
      section if there is such a matching one (which is a lot more likely with
      -ffunction-sections). LLD will later infer that a C64->A64 thunk is needed
      and generate an incorrect binary.
      e179980e
  19. 17 Aug, 2022 2 commits
  20. 27 Jul, 2022 1 commit
  21. 26 Jul, 2022 1 commit
  22. 22 Jul, 2022 2 commits
    • Silviu Baranga's avatar
      [Morello] Add a pass to change the way we are creating · 8646277e
      Silviu Baranga authored
      addresses for aliases in purecap.
      
      The motivation is that the global merge pass will replace
      globals with aliases to a merged global.
      
      The merged global address is produced by loading a capability
      from a pc-relative relocation (same as before).
      
      Safe loads/stores can use the merged global directly. Unsafe
      uses still need to produce the address of the global by doing
      a load from the capability table.
      8646277e
    • Silviu Baranga's avatar
      [Morello] Enable global merging for purecap. · 5f02f5b7
      Silviu Baranga authored
      For now this just does the merging, and for purecap we're
      replacing the old globals with the new aliases. This doesn't
      change codegen (we're still acccessing globals via loads),
      but it will enable future optimizations.
      
      Some notable changes to the globals merge pass:
        - We're attempting to pad globals to make capabilies to the
          emitted aliases representable. This doesn't do anything,
          since the maximum size of the merged global is 4096, but
          it's nice to have this in place.
        - We're replacing the old globals with aliases to the merged
          global. This keeps size information and we can consume it
          in future optimizations.
        - For purecap we merge BSS globals with non-BSS ones, which
          means globals that were in .bss now end up in .data. For
          purecap this is worth it as it's going to remove some
          loads/stores
      
      AArch64SandboxGlobalsOpt also now processes aliases as well.
      The metadata format for determining the index of the capability
      table for a global has changed since global aliases cannot
      attach metadata.
      5f02f5b7
  23. 21 Jul, 2022 3 commits
    • Diana Picus's avatar
      [Morello][lldb] Clean binaries in test runner · 94721dfc
      Diana Picus authored
      Sometimes the binaries might get left behind from a previous (possibly
      interrupted) run, which causes adb to error out when trying to upload
      them. This patch removes them if they already exist on the device, so we
      can test with up-to-date binaries.
      94721dfc
    • Diana Picus's avatar
      [Morello][lldb] Run end-to-end tests with 2 ABIs · 01fba3d7
      Diana Picus authored
      The end-to-end lldb tests used to be run only under the purecap ABI.
      This patch makes it possible to build and run a test both as purecap and
      as hybrid. It also enables most tests to be run for both ABIs. In order
      to do so, it sometimes adds `__capability` qualifiers to pointers (e.g.
      in order to trigger a capability fault even under the hybrid ABI).
      
      See the updates to the README for the low level details.
      01fba3d7
    • Diana Picus's avatar
      [Morello][lldb] Update comments. NFC · 69cb6a9d
      Diana Picus authored
      Mention that we can run the end-to-end tests either with an FVP model or
      a board.
      69cb6a9d
  24. 18 Jul, 2022 1 commit
    • Jessica Clarke's avatar
      [clang] Add support for legacy __sync builtins with capability types · aba2e084
      Jessica Clarke authored
      Whilst these are legacy and both GCC and Clang want code to migrate away
      from them, many open-source projects make use of them rather than the
      GNU __atomic/Clang __c11_atomic intrinsics or standard C(++)11 atomics.
      Add support for using them, with both overloaded and explicit forms.
      aba2e084