1. Jul 29, 2022
    • sstwcw's avatar
      [clang-format] Handle Verilog attributes · 60e12068
      sstwcw authored
      Reviewed By: HazardyKnusperkeks, owenpan
      
      Differential Revision: https://reviews.llvm.org/D128709
      60e12068
    • sstwcw's avatar
      [clang-format] Handle Verilog case statements · c8871948
      sstwcw authored
      These statements are like switch statements in C, but without the 'case'
      keyword in labels.
      
      How labels are parsed.  In UnwrappedLineParser, the program tries to
      parse a statement every time it sees a colon.  In TokenAnnotator, a
      colon that isn't part of an expression is annotated as a label.
      
      The token type `TT_GotoLabelColon` is added.  We did not include Verilog
      in the name because we thought we would eventually have to fix the
      problem that case labels in C can't contain ternary conditional
      expressions and we would use that token type.
      
      The style is like below.  Labels are on separate lines and indented by
      default.  The linked style guide also has examples where labels and the
      corresponding statements are on the same lines.  They are not supported
      for now.
      
      https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md
      
      ```
      case (state_q)
        StIdle:
          state_d = StA;
        StA: begin
          state_d = StB;
        end
      endcase
      ```
      
      Differential Revision: https://reviews.llvm.org/D128714
      c8871948
    • sstwcw's avatar
      [clang-format] Handle Verilog user-defined primitives · b67ee18e
      sstwcw authored
      Differential Revision: https://reviews.llvm.org/D128713
      b67ee18e
    • sstwcw's avatar
      [clang-format] Handle Verilog modules · 6db0c18b
      sstwcw authored
      Now things inside hierarchies like modules and interfaces are
      indented.  When the module header spans multiple lines, all except the
      first line are indented as continuations.  We added the property
      `IsContinuation` to mark lines that should be indented this way.
      
      In order that the colons inside square brackets don't get labeled as
      `TT_ObjCMethodExpr`, we added a check to only use this type when the
      language is not Verilog.
      
      Differential Revision: https://reviews.llvm.org/D128712
      6db0c18b
    • sstwcw's avatar
      [clang-format] Handle Verilog blocks · 67480b36
      sstwcw authored
      Now stuff inside begin-end blocks get indented.
      
      Some tests are moved into FormatTestVerilog.Block from
      FormatTestVerilog.If because they have nothing to do with if statements.
      
      Reviewed By: HazardyKnusperkeks, owenpan
      
      Differential Revision: https://reviews.llvm.org/D128711
      67480b36
    • sstwcw's avatar
      [clang-format] Handle Verilog numbers and operators · f93182a8
      sstwcw authored
      Reviewed By: HazardyKnusperkeks
      
      Differential Revision: https://reviews.llvm.org/D126845
      f93182a8
    • Nico Weber's avatar
      [lld/mac] Add support for $ld$previous symbols with explicit symbol name · 241f0e8b
      Nico Weber authored
      A symbol `$ld$previous$/Another$1.2.3$1$3.0$14.0$_xxx$` means
      "pretend symbol `_xxx` is in dylib `/Another` with version `1.2.3`
      if the deployment target is between `3.0` and `14.0` and we're
      targeting platform `1` (ie macOS)".
      
      This means dylibs can now inject synthetic dylibs into the link, so
      DylibFile needs to grow a 3rd constructor.
      
      The only other interesting thing is that such an injected dylib
      counts as a use of the original dylib. This patch gets this mostly
      right (if _only_ `$ld$previous` symbols are used from a dylib,
      we don't add a dep on the dylib itself, matching ld64), but one case
      where we don't match ld64 yet is that ld64 even omits the original
      dylib when linking it with `-needed-l`. Lld currently still adds a load
      command for the original dylib in that case. (That's for a future
      patch.)
      
      Fixes #56074.
      
      Differential Revision: https://reviews.llvm.org/D130725
      241f0e8b
    • Changpeng Fang's avatar
      AMDGPU: Take care of "tied" operand when removeOperand · 2b731b30
      Changpeng Fang authored
      Summary:
        Flat scratch load of D16 type by default has tied vdst_in operand (with vdst). This should be taken
      care of at the time of "removeOperand" in eliminateFrameIndex. Otherwise we will hit an assert saying
      "Cannot move tied operands". This patch unties vdst_in before the move, and retie it with vdst afterwards.
      
      Reviewers:
        arsenm, foad
      
      Differential Revision: https://reviews.llvm.org/D130537
      2b731b30
    • Francis Visoiu Mistrih's avatar
      [Matrix] Refactor transpose distribution. NFC · bfd3883e
      Francis Visoiu Mistrih authored
      Use a function to distribute transposes. Preparation for future patches.
      bfd3883e
    • Vincent Lee's avatar
      [lld-macho] Allow linking with ABI compatible architectures · f030132c
      Vincent Lee authored
      Linking fails when targeting `x86_64-apple-darwin` for runtimes. The issue
      is that LLD strictly assumes the target architecture be present in the tbd
      files (which isn't always true). For example, when targeting `x86_64h`, it should
      work with `x86_64` because they are ABI compatible. This is also inline with what
      ld64 does.
      
      An environment variable (which ld64 also supports) is also added to preserve the
      existing behavior of strict architecture matching.
      
      Reviewed By: #lld-macho, int3
      
      Differential Revision: https://reviews.llvm.org/D130683
      f030132c
    • tlattner's avatar
    • V Donaldson's avatar
      [flang] Fix build failure · 05b3c900
      V Donaldson authored
      05b3c900
    • John Ericson's avatar
      [clang][lld][cmake] Simplify header dirs · cc56a502
      John Ericson authored
      We don't need to recompute the list LLVMConfig.cmake provides us.
      
      When LLVM is being built, the list is two elements long: generated headers and headers from source.
      
      When LLVM is already built,the list is one element long: the installed header directory containing both generated and hand-written sources.
      
      Reviewed By: sebastian-ne
      
      Differential Revision: https://reviews.llvm.org/D130553
      cc56a502
    • Slava Gurevich's avatar
      [LLDB] Fix missing return value in SBBreakpointLocation::GetQueueName() · 2e6b6522
      Slava Gurevich authored
      - Fix a typo in the function that never returns a significant value
      
      - Add unit tests for the getters/setters in SBBreakpointLocation
      
      - Verified the newly added unit test succeeds after the fix:
      llvm-lit -sv  lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
      
      Differential Revision: https://reviews.llvm.org/D130660
      2e6b6522
    • Shafik Yaghmour's avatar
      [Clang] Diagnose ill-formed constant expression when setting a non fixed enum... · b3645353
      Shafik Yaghmour authored
      [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values
      
      DR2338 clarified that it was undefined behavior to set the value outside the
      range of the enumerations values for an enum without a fixed underlying type.
      
      We should diagnose this with a constant expression context.
      
      Differential Revision: https://reviews.llvm.org/D130058
      b3645353
    • Felipe de Azevedo Piovezan's avatar
      [GlobalISel] Handle nullptr constants in dbg.value · 58526b2d
      Felipe de Azevedo Piovezan authored
      Currently, the LLVM IR -> MIR translator fails to translate dbg.values
      whose first argument is a null pointer. However, in other portions of
      the code, such pointers are always lowered to the constant zero, for
      example see IRTranslator::Translate(Constant, Register).
      
      This patch addresses the limitation by following the same approach of
      lowering null pointers to zero.
      
      A prior test was checking that null pointers were always lowered to
      $noreg; this test is changed to check for zero, and the previous
      behavior is now checked by introducing a dbg.value whose first argument
      is the address of a global variable.
      
      Differential Revision: https://reviews.llvm.org/D130721
      58526b2d
    • Jez Ng's avatar
      [lld-macho] `-exported_symbols` should hide symbols before LTO runs · 31760e81
      Jez Ng authored
      We were previously doing it after LTO, which did have the desired effect
      of having the un-exported symbols marked as private extern in the final
      output binary, but doing it before LTO creates more optimization
      opportunities.
      
      One observable difference is that LTO can now elide un-exported symbols
      entirely, so they may not even be present as private externs in the
      output.
      
      This is also what ld64 implements.
      
      Reviewed By: #lld-macho, thevinster
      
      Differential Revision: https://reviews.llvm.org/D130429
      31760e81
    • Felipe de Azevedo Piovezan's avatar
      [GlobalISel][nfc] Remove unnecessary cast · 0ef6809c
      Felipe de Azevedo Piovezan authored
      The getOperand method already returns a Constant when it is called on
      a ConstantExpression, as such the cast is not needed. To prevent a type
      mismatch between the different return statements of the lambda, the
      lambda return type is explicitly provided.
      
      Differential Revision: https://reviews.llvm.org/D130719
      0ef6809c
    • Jacques Pienaar's avatar
      [mlir] Introduce DefaultValuedOptionalAttr · af3ed4a2
      Jacques Pienaar authored
      Currently DefaultValuedAttr is confusingly actually default valued &
      optional but that was an artifact of development and longstanding TODO
      to address. Add new attribute that matches this behavior for cases where
      that is actually the desired behavior before addressing TODO (e.g., this
      is an incremental step to fixing DefaultValuedAttr).
      
      Differential Revision: https://reviews.llvm.org/D130679
      af3ed4a2
    • Anshil Gandhi's avatar
      [AMDGPU][Scheduler] Avoid initializing Register pressure tracker when tracking is disabled · 5c380564
      Anshil Gandhi authored
      When register pressure tracking is disabled, the scheduler attempts to load
      pressures at SReg_32 and VGPR_32. This causes an index out of bounds error.
      This patch fixes this issue by disabling the initialization of RPTracker
      when not needed. NFC
      
      Reviewed By: rampitec, kerbowa, arsenm
      
      Differential Revision: https://reviews.llvm.org/D129322
      5c380564
    • Denis Fatkulin's avatar
      [clang-format] Missing space between trailing return type 'auto' and left brace · 4977fd21
      Denis Fatkulin authored
      There's no a space symbol between  trailing return type `auto` and left brace `{`.
      
      The simpliest examles of code to reproduce the issue:
      
      ```
      []() -> auto {}
      ```
      
      and
      
      ```
      auto foo() -> auto {}
      ```
      
      Depends on D130299
      
      Reviewed By: HazardyKnusperkeks, curdeius, owenpan
      
      Differential Revision: https://reviews.llvm.org/D130417
      4977fd21
    • Markus Böck's avatar
      [mlir] Add Type::isa_and_nonnull · 2ec510f1
      Markus Böck authored
      2ec510f1
    • Greg Clayton's avatar
      Cache the value for absolute path in FileSpec. · dc0f452e
      Greg Clayton authored
      Checking if a path is absolute can be expensive and currently the result is not cached in the FileSpec object. This patch adds caching and also code to clear the cache if the file is modified.
      
      Differential Revision: https://reviews.llvm.org/D130396
      dc0f452e
    • Greg Clayton's avatar
      [NFC] Improve FileSpec internal APIs and usage in preparation for adding... · 529a3d87
      Greg Clayton authored
      [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.
      
      Resubmission of https://reviews.llvm.org/D130309 with the 2 patches that fixed the linux buildbot, and new windows fixes.
      
      The FileSpec APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossible to control all of the times the FileSpec object is modified so we can clear cached member variables like m_resolved and with an upcoming patch caching if the file is relative or absolute. This patch modifies the APIs of FileSpec so no one can modify the directory or filename instance variables directly by adding set accessors and by removing the get accessors that are non const.
      
      Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString:
      
      ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const;
      
      This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result.
      
      The patch:
      - Removes the non const GetDirectory() and GetFilename() get accessors
      - Adds set accessors to replace the above functions: SetDirectory() and SetFilename().
      - Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites
      - Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently.
      
      Differential Revision: https://reviews.llvm.org/D130549
      529a3d87
    • David Blaikie's avatar
      llvm-dwp: Include dwo name even when the input is a dwo · 6139626d
      David Blaikie authored
      This still only includes the dwo name if it's in the DW_AT_dwo_name
      attribute in the split unit - though it could be improved/modified to
      use the dwo name from the command line (if linking raw dwo files) or
      retrieved from the DW_AT_dwo_name in the executable (when using -e).
      
      It's useful in any case because you might have a large command line with
      many files and knowing exactly which dwo files are relevant will
      simplify debugging, but especially with '-e' when you didn't pass the
      dwo files explicitly in nthe first place it would be quite non-obvious
      where the duplicate units are coming from.
      6139626d
    • Mats Petersson's avatar
      [flang]Fix incorrect array type transformation · 7ae39114
      Mats Petersson authored
      When an array is defined with "unknown" size, such as fir.array<2x?x5xi32>,
      it should be converted to llvm.array<10 x i32>. The code so far has
      been converting it to llvm.ptr<i32>.
      
      Using a different function to check the if there starting are constant
      dimensions, rather than if ALL dimensions are constant, it now produces
      the correct array form.
      
      Some tests has been updated, so they are now checking the new behaviour
      rather than the old behaviour - so there's no need to add further tests
      for this particular scenario.
      
      This was originally found when compiling Spec 17 code, where an assert
      in a GepOP was hit. That is bug #56141, which this change fixes.
      
      Reviewed By: jeanPerier
      
      Differential Revision: https://reviews.llvm.org/D129196
      7ae39114
    • Daniele Vettorel's avatar
      Add `llvm-dwarfutil` to Bazel targets · e7c00485
      Daniele Vettorel authored
      Adds support for building the `llvm-dwarfutil` tool with Bazel
      
      Reviewed By: kuhar
      
      Differential Revision: https://reviews.llvm.org/D130720
      e7c00485
    • Adrian Kuegel's avatar
      [mlir][Complex] Change complex.number attribute type to ComplexType. · 23c3eb7c
      Adrian Kuegel authored
      It is more useful to use ComplexType as type of the attribute than to
      use the element type as attribute type. This means when using this
      attribute in complex::ConstantOp, we just need to check whether
      the types match.
      
      Reviewed By: pifon2a
      
      Differential Revision: https://reviews.llvm.org/D130703
      23c3eb7c
    • Ben Langmuir's avatar
      [clang][deps] Include canonical invocation in ContextHash · 02871701
      Ben Langmuir authored
      The "strict context hash" is insufficient to identify module
      dependencies during scanning, leading to different module build commands
      being produced for a single module, and non-deterministically choosing
      between them. This commit switches to hashing the canonicalized
      `CompilerInvocation` of the module. By hashing the invocation we are
      converting these from correctness issues to performance issues, and we
      can then incrementally improve our ability to canonicalize
      command-lines.
      
      This change can cause a regression in the number of modules needed. Of
      the 4 projects I tested, 3 had no regression, but 1, which was
      clang+llvm itself, had a 66% regression in number of modules (4%
      regression in total invocations). This is almost entirely due to
      differences between -W options across targets.  Of this, 25% of the
      additional modules are system modules, which we could avoid if we
      canonicalized -W options when -Wsystem-headers is not present --
      unfortunately this is non-trivial due to some warnings being enabled in
      system headers by default. The rest of the additional modules are mostly
      real differences in potential warnings, reflecting incorrect behaviour
      in the current scanner.
      
      There were also a couple of differences due to `-DFOO`
      `-fmodule-ignore-macro=FOO`, which I fixed here.
      
      Since the output paths for the module depend on its context hash, we
      hash the invocation before filling in outputs, and rely on the build
      system to always return the same output paths for a given module.
      
      Note: since the scanner itself uses an implicit modules build, there can
      still be non-determinism, but it will now present as different
      module+hashes rather than different command-lines for the same
      module+hash.
      
      Differential Revision: https://reviews.llvm.org/D129884
      02871701
    • Chris Bieneman's avatar
      [HLSL] Add RWBuffer default constructor · 66eabeb6
      Chris Bieneman authored
      This fills out the default constructor for RWBuffer to assign the
      handle with the result of __builtin_hlsl_create_handle which we can
      then treat as a pointer to the resource data through the mid-level of
      the compiler.
      
      Depends on D130016
      
      Differential Revision: https://reviews.llvm.org/D130017
      66eabeb6
    • Jon Chesterfield's avatar
      [openmp][amdgpu] Tear down amdgpu plugin accurately · ed0f2181
      Jon Chesterfield authored
      Moves DeviceInfo global to heap to accurately control lifetime.
      Moves calls from libomptarget to deinit_plugin later, plugins need to stay
      alive until very shortly before libomptarget is destructed.
      
      Leaving the deinit_plugin calls where initially inserted hits use after
      free from the dynamic_module.c offloading test (verified with valgrind
       that the new location is sound with respect to this)
      
      Reviewed By: tianshilei1992
      
      Differential Revision: https://reviews.llvm.org/D130714
      ed0f2181
    • Alexey Lapshin's avatar
      [Reland][Debuginfo][llvm-dwarfutil] Add check for unsupported debug sections. · e74197bc
      Alexey Lapshin authored
      Current DWARFLinker implementation does not support some debug sections
      (mainly DWARF v5 sections). This patch adds diagnostic for such sections.
      The warning would be displayed for critical(such that could not be removed)
      sections and the source file would be skipped. Other unsupported sections
      would be removed and warning message should be displayed. The zero exit
      status would be returned for both cases.
      
      Reviewed By: JDevlieghere
      
      Differential Revision: https://reviews.llvm.org/D123623
      e74197bc
    • Austin Kerbow's avatar
      0f93a45b
    • Fangrui Song's avatar
      [MC][test] Rename two --compress-debug-sections=zlib tests · 9f0d5330
      Fangrui Song authored
      To be clearer when zstd support is added.
      9f0d5330
    • River Riddle's avatar
      [mlir:SubElementsInterface] Add support for "skipping" when replacing attributes/types · 00a52c75
      River Riddle authored
      This is used to fix a bug in SymbolTable::replaceAllSymbolUses where we replace symbols that
      we shouldn't.
      
      Differential Revision: https://reviews.llvm.org/D130693
      00a52c75
    • Fangrui Song's avatar
      [llvm-objcopy] Support --{,de}compress-debug-sections for zstd · c26dc290
      Fangrui Song authored
      Also, add ELFCOMPRESS_ZSTD (2) from the approved generic-abi proposal:
      https://groups.google.com/g/generic-abi/c/satyPkuMisk
      ("Add new ch_type value: ELFCOMPRESS_ZSTD")
      
      Link: https://discourse.llvm.org/t/rfc-zstandard-as-a-second-compression-method-to-llvm/63399
      ("[RFC] Zstandard as a second compression method to LLVM")
      
      Differential Revision: https://reviews.llvm.org/D130458
      c26dc290
    • Austin Kerbow's avatar
      [AMDGPU] Add amdgcn_sched_group_barrier builtin · f5b21680
      Austin Kerbow authored
      This builtin allows the creation of custom scheduling pipelines on a per-region
      basis. Like the sched_barrier builtin this is intended to be used either for
      testing, in situations where the default scheduler heuristics cannot be
      improved, or in critical kernels where users are trying to get performance that
      is close to handwritten assembly. Obviously using these builtins will require
      extra work from the kernel writer to maintain the desired behavior.
      
      The builtin can be used to create groups of instructions called "scheduling
      groups" where ordering between the groups is enforced by the scheduler.
      __builtin_amdgcn_sched_group_barrier takes three parameters. The first parameter
      is a mask that determines the types of instructions that you would like to
      synchronize around and add to a scheduling group. These instructions will be
      selected from the bottom up starting from the sched_group_barrier's location
      during instruction scheduling. The second parameter is the number of matching
      instructions that will be associated with this sched_group_barrier. The third
      parameter is an identifier which is used to describe what other
      sched_group_barriers should be synchronized with. Note that multiple
      sched_group_barriers must be added in order for them to be useful since they
      only synchronize with other sched_group_barriers. Only "scheduling groups" with
      a matching third parameter will have any enforced ordering between them.
      
      As an example, the code below tries to create a pipeline of 1 VMEM_READ
      instruction followed by 1 VALU instruction followed by 5 MFMA instructions...
      // 1 VMEM_READ
      __builtin_amdgcn_sched_group_barrier(32, 1, 0)
      // 1 VALU
      __builtin_amdgcn_sched_group_barrier(2, 1, 0)
      // 5 MFMA
      __builtin_amdgcn_sched_group_barrier(8, 5, 0)
      // 1 VMEM_READ
      __builtin_amdgcn_sched_group_barrier(32, 1, 0)
      // 3 VALU
      __builtin_amdgcn_sched_group_barrier(2, 3, 0)
      // 2 VMEM_WRITE
      __builtin_amdgcn_sched_group_barrier(64, 2, 0)
      
      Reviewed By: jrbyrnes
      
      Differential Revision: https://reviews.llvm.org/D128158
      f5b21680
    • Sunho Kim's avatar
      [clang-repl] Support destructors of global objects. · c619d4f8
      Sunho Kim authored
      Supports destructors of global objects by properly calling jitdylib deinitialize which calls the global dtors of ir modules.
      
      This supersedes https://reviews.llvm.org/D127945. There was an issue when calling deinitialize on windows but it got fixed by https://reviews.llvm.org/D128037.
      
      Reviewed By: v.g.vassilev
      
      Differential Revision: https://reviews.llvm.org/D128589
      c619d4f8
    • Xing Xue's avatar
      [libc++][AIX] Use non-unique implementation for typeinfo comparison · aeb1c98f
      Xing Xue authored
      Summary:
      The AIX linker does not merge typeinfos when shared libraries are involved, which causes address comparison to fail although the types are the same. This patch changes to use the non-unique implementation for typeinfo comparison for AIX.
      
      Reviewed by: hubert.reinterpretcast, philnik, libc++
      
      Differential Revision: https://reviews.llvm.org/D130715
      aeb1c98f
    • Craig Topper's avatar
      [RISCV] Update lowerFROUND to use masked instructions. · 2750873d
      Craig Topper authored
      This avoids a vmerge at the end and avoids spurious fflags updates.
      This isn't used for constrained intrinsic so we technically don't have
      to worry about fflags, but it doesn't cost much to support it.
      
      To support I've extend our FCOPYSIGN_VL node to support a passthru
      operand. Similar to what was done for VRGATHER*_VL nodes.
      
      I plan to do a similar update for trunc, floor, and ceil.
      
      Reviewed By: reames, frasercrmck
      
      Differential Revision: https://reviews.llvm.org/D130659
      2750873d