Skip to content
Snippets Groups Projects
  1. May 11, 2017
  2. Mar 30, 2017
  3. Mar 26, 2017
    • Gor Nishanov's avatar
      [coroutines] Add codegen for await and yield expressions · bcaf7f2a
      Gor Nishanov authored
      Details:
      
      Emit suspend expression which roughly looks like:
      
      auto && x = CommonExpr();
      if (!x.await_ready()) {
         llvm_coro_save();
         x.await_suspend(...);     (*)
         llvm_coro_suspend(); (**)
      }
      x.await_resume();
      where the result of the entire expression is the result of x.await_resume()
      
      (*) If x.await_suspend return type is bool, it allows to veto a suspend:
      if (x.await_suspend(...))
         llvm_coro_suspend();
      (**) llvm_coro_suspend() encodes three possible continuations as a switch instruction:
      
      %where-to = call i8 @llvm.coro.suspend(...)
      switch i8 %where-to, label %coro.ret [ ; jump to epilogue to suspend
        i8 0, label %yield.ready   ; go here when resumed
        i8 1, label %yield.cleanup ; go here when destroyed
      ]
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298784 91177308-0d34-0410-b5e6-96231b3b80d8
      bcaf7f2a
  4. Dec 23, 2016
  5. Dec 20, 2016
  6. Dec 15, 2016
  7. Dec 14, 2016
  8. Dec 12, 2016
    • Richard Smith's avatar
      Add two new AST nodes to represent initialization of an array in terms of · 0601f898
      Richard Smith authored
      initialization of each array element:
      
       * ArrayInitLoopExpr is a prvalue of array type with two subexpressions:
         a common expression (an OpaqueValueExpr) that represents the up-front
         computation of the source of the initialization, and a subexpression
         representing a per-element initializer
       * ArrayInitIndexExpr is a prvalue of type size_t representing the current
         position in the loop
      
      This will be used to replace the creation of explicit index variables in lambda
      capture of arrays and copy/move construction of classes with array elements,
      and also C++17 structured bindings of arrays by value (which inexplicably allow
      copying an array by value, unlike all of C++'s other array declarations).
      
      No uses of these nodes are introduced by this change, however.
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289413 91177308-0d34-0410-b5e6-96231b3b80d8
      0601f898
  9. Dec 09, 2016
    • Yaxun Liu's avatar
      Add support for non-zero null pointer for C and OpenCL · b6215483
      Yaxun Liu authored
      In amdgcn target, null pointers in global, constant, and generic address space take value 0 but null pointers in private and local address space take value -1. Currently LLVM assumes all null pointers take value 0, which results in incorrectly translated IR. To workaround this issue, instead of emit null pointers in local and private address space, a null pointer in generic address space is emitted and casted to local and private address space.
      
      Tentative definition of global variables with non-zero initializer will have weak linkage instead of common linkage since common linkage requires zero initializer and does not have explicit section to hold the non-zero value.
      
      Virtual member functions getNullPointer and performAddrSpaceCast are added to TargetCodeGenInfo which by default returns ConstantPointerNull and emitting addrspacecast instruction. A virtual member function getNullPointerValue is added to TargetInfo which by default returns 0. Each target can override these virtual functions to get target specific null pointer and the null pointer value for specific address space, and perform specific translations for addrspacecast.
      
      Wrapper functions getNullPointer is added to CodegenModule and getTargetNullPointerValue is added to ASTContext to facilitate getting the target specific null pointers and their values.
      
      This change has no effect on other targets except amdgcn target. Other targets can provide support of non-zero null pointer in a similar way.
      
      This change only provides support for non-zero null pointer for C and OpenCL. Supporting for other languages will be added later incrementally.
      
      Differential Revision: https://reviews.llvm.org/D26196
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289252 91177308-0d34-0410-b5e6-96231b3b80d8
      b6215483
  10. Dec 07, 2016
  11. Jul 28, 2016
    • Yaxun Liu's avatar
      [OpenCL] Generate opaque type for sampler_t and function call for the initializer · 427517d1
      Yaxun Liu authored
      Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type.
      
      This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer.
      
      Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions.
      
      This patch is partially based on Alexey Sotkin's work in Khronos Clang (https://github.com/KhronosGroup/SPIR/commit/3d4eec61623502fc306e8c67c9868be2b136e42b).
      
      Differential Revision: https://reviews.llvm.org/D21567
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277024 91177308-0d34-0410-b5e6-96231b3b80d8
      427517d1
  12. Jun 28, 2016
    • Richard Smith's avatar
      P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991: · 5be817d9
      Richard Smith authored
      Replace inheriting constructors implementation with new approach, voted into
      C++ last year as a DR against C++11.
      
      Instead of synthesizing a set of derived class constructors for each inherited
      base class constructor, we make the constructors of the base class visible to
      constructor lookup in the derived class, using the normal rules for
      using-declarations.
      
      For constructors, UsingShadowDecl now has a ConstructorUsingShadowDecl derived
      class that tracks the requisite additional information. We create shadow
      constructors (not found by name lookup) in the derived class to model the
      actual initialization, and have a new expression node,
      CXXInheritedCtorInitExpr, to model the initialization of a base class from such
      a constructor. (This initialization is special because it performs real perfect
      forwarding of arguments.)
      
      In cases where argument forwarding is not possible (for inalloca calls,
      variadic calls, and calls with callee parameter cleanup), the shadow inheriting
      constructor is not emitted and instead we directly emit the initialization code
      into the caller of the inherited constructor.
      
      Note that this new model is not perfectly compatible with the old model in some
      corner cases. In particular:
       * if B inherits a private constructor from A, and C uses that constructor to
         construct a B, then we previously required that A befriends B and B
         befriends C, but the new rules require A to befriend C directly, and
       * if a derived class has its own constructors (and so its implicit default
         constructor is suppressed), it may still inherit a default constructor from
         a base class
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274049 91177308-0d34-0410-b5e6-96231b3b80d8
      5be817d9
  13. Mar 09, 2016
  14. Mar 08, 2016
  15. Feb 24, 2016
    • James Y Knight's avatar
      Default vaarg lowering should support indirect struct types. · 0b7e89b4
      James Y Knight authored
      Fixes PR11517 for SPARC.
      
      On most targets, clang lowers va_arg itself, eschewing the use of the
      llvm vaarg instruction. This is necessary (at least for now) as the type
      argument to the vaarg instruction cannot represent all the ABI
      information that is needed to support complex calling conventions.
      
      However, on targets with a simpler varrags ABIs, the LLVM instruction
      can work just fine, and clang can simply lower to it. Unfortunately,
      even on such targets, vaarg with a struct argument would fail, because
      the default lowering to vaarg was naive: it didn't take into account the
      ABI attribute computed by classifyArgumentType. In particular, for the
      DefaultABIInfo, structs are supposed to be passed indirectly and so
      llvm's vaarg instruction should be emitted with a pointer argument.
      
      Now, vaarg instruction emission is able to use computed ABIArgInfo for
      the provided argument type, which allows the default ABI support to work
      for structs too.
      
      I haven't touched the EmitVAArg implementation for PPC32_SVR4 or XCore,
      although I believe both are now redundant, and could be switched over to
      use the default implementation as well.
      
      Differential Revision: http://reviews.llvm.org/D16154
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261717 91177308-0d34-0410-b5e6-96231b3b80d8
      0b7e89b4
  16. Jan 13, 2016
  17. Nov 09, 2015
    • Tim Northover's avatar
      Atomics: support __c11_* calls on _Atomic struct types. · 6a3c4de2
      Tim Northover authored
      When a struct's size is not a power of 2, the corresponding _Atomic() type is
      promoted to the nearest. We already correctly handled normal C++ expressions of
      this form, but direct calls to the __c11_atomic_whatever builtins ended up
      performing dodgy operations on the smaller non-atomic types (e.g. memcpy too
      much). Later optimisations removed this as undefined behaviour.
      
      This patch converts EmitAtomicExpr to allocate its temporaries at the full
      atomic width, sidestepping the issue.
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252507 91177308-0d34-0410-b5e6-96231b3b80d8
      6a3c4de2
  18. Oct 20, 2015
  19. Sep 17, 2015
  20. Sep 08, 2015
    • John McCall's avatar
      Compute and preserve alignment more faithfully in IR-generation. · f4ddf94e
      John McCall authored
      Introduce an Address type to bundle a pointer value with an
      alignment.  Introduce APIs on CGBuilderTy to work with Address
      values.  Change core APIs on CGF/CGM to traffic in Address where
      appropriate.  Require alignments to be non-zero.  Update a ton
      of code to compute and propagate alignment information.
      
      As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
      helper function to CGF and made use of it in a number of places in
      the expression emitter.
      
      The end result is that we should now be significantly more correct
      when performing operations on objects that are locally known to
      be under-aligned.  Since alignment is not reliably tracked in the
      type system, there are inherent limits to this, but at least we
      are no longer confused by standard operations like derived-to-base
      conversions and array-to-pointer decay.  I've also fixed a large
      number of bugs where we were applying the complete-object alignment
      to a pointer instead of the non-virtual alignment, although most of
      these were hidden by the very conservative approach we took with
      member alignment.
      
      Also, because IRGen now reliably asserts on zero alignments, we
      should no longer be subject to an absurd but frustrating recurring
      bug where an incomplete type would report a zero alignment and then
      we'd naively do a alignmentAtOffset on it and emit code using an
      alignment equal to the largest power-of-two factor of the offset.
      
      We should also now be emitting much more aggressive alignment
      attributes in the presence of over-alignment.  In particular,
      field access now uses alignmentAtOffset instead of min.
      
      Several times in this patch, I had to change the existing
      code-generation pattern in order to more effectively use
      the Address APIs.  For the most part, this seems to be a strict
      improvement, like doing pointer arithmetic with GEPs instead of
      ptrtoint.  That said, I've tried very hard to not change semantics,
      but it is likely that I've failed in a few places, for which I
      apologize.
      
      ABIArgInfo now always carries the assumed alignment of indirect and
      indirect byval arguments.  In order to cut down on what was already
      a dauntingly large patch, I changed the code to never set align
      attributes in the IR on non-byval indirect arguments.  That is,
      we still generate code which assumes that indirect arguments have
      the given alignment, but we don't express this information to the
      backend except where it's semantically required (i.e. on byvals).
      This is likely a minor regression for those targets that did provide
      this information, but it'll be trivial to add it back in a later
      patch.
      
      I partially punted on applying this work to CGBuiltin.  Please
      do not add more uses of the CreateDefaultAligned{Load,Store}
      APIs; they will be going away eventually.
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246985 91177308-0d34-0410-b5e6-96231b3b80d8
      f4ddf94e
  21. Sep 04, 2015
  22. Jun 10, 2015
  23. Jun 08, 2015
  24. May 20, 2015
  25. Apr 29, 2015
  26. Apr 24, 2015
  27. Apr 06, 2015
  28. Feb 25, 2015
  29. Feb 14, 2015
  30. Feb 13, 2015
  31. Feb 09, 2015
Loading