<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/95780>95780</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Problems with the VECTOR ALWAYS directive
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          psteinfeld
      </td>
    </tr>
</table>

<pre>
    These problems stem from the initial implementation in PR #93830.

When the directive appears in the execution part, the compiler emits an error message when the directive doesn't precede a DO loop.  This is different from the behavior of gfortran, nvfortran, and ifort.  None of these compilers even issue a warning.  As Peter suggested earlier, I would suggest that we issue a warning in this case.

Here's a small test that illustrates the situation.
```
program hello
  integer :: i = 1
  integer :: j = 1
  print *, 'hello'
!dir$ vector always
  print *, 'good bye'
end
```
gfortran, nvfortran, and ifort all compile this program without error.

Also, if the directive appears in the specification part, no message is emitted by the front end, but the error is caught during lowering and an internal error message is emitted.  In this case, I suggest that we do the same thing as the previous example -- emit a warning and otherwise ignore the directive.

Here's a program that illustrates this case:
```
program hello
  integer :: i = 1
!dir$ vector always
  integer :: j = 1
  print *, 'hello'
  print *, 'good bye'
end
```
Here's an excerpt from the log file if I compile the program above with flang-new:
```
error: loc("/local/home/psteinfeld/up/install/a.f90":1:1): loop directive must appear before a loop
LLVM ERROR: aborting
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /local/home/psteinfeld/up/install/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -resource-dir /local/home/psteinfeld/up/install/bin/.. -mframe-pointer=all -o /tmp/a-f06c9d.o -x f95-cpp-input a.f90
 #0 0x000055ea3d8cd9df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/psteinfeld/up/install/bin/flang-new+0x24409df)
 #1 0x000055ea3d8caf04 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fea70d5b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fea7020000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fea701df859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x000055ea3d304470 llvm::vfs::RedirectingFileSystem::create(llvm::ArrayRef<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, bool, llvm::vfs::FileSystem&) (.cold) VirtualFileSystem.cpp:0:0
 #6 0x000055ea3d85133e (/local/home/psteinfeld/up/install/bin/flang-new+0x23c433e)
 #7 0x000055ea3e11b7ea (/local/home/psteinfeld/up/install/bin/flang-new+0x2c8e7ea)
 #8 0x000055ea3e132f5e std::__detail::__variant::__gen_vtable_impl<true, std::__detail::__variant::_Multi_array<void (*)(Fortran::common::visitors<(anonymous namespace)::FirConverter::genFIR(Fortran::parser::CompilerDirective const&)::'lambda'(Fortran::parser::CompilerDirective::VectorAlways const&), (anonymous namespace)::FirConverter::genFIR(Fortran::parser::CompilerDirective const&)::'lambda0'(auto const&)>&&, std::variant<std::__cxx11::list<Fortran::parser::CompilerDirective::IgnoreTKR, std::allocator<Fortran::parser::CompilerDirective::IgnoreTKR>>, Fortran::parser::CompilerDirective::LoopCount, std::__cxx11::list<Fortran::parser::CompilerDirective::AssumeAligned, std::allocator<Fortran::parser::CompilerDirective::AssumeAligned>>, Fortran::parser::CompilerDirective::VectorAlways, std::__cxx11::list<Fortran::parser::CompilerDirective::NameValue, std::allocator<Fortran::parser::CompilerDirective::NameValue>>, Fortran::parser::CompilerDirective::Unrecognized> const&)>, std::tuple<std::variant<std::__cxx11::list<Fortran::parser::CompilerDirective::IgnoreTKR, std::allocator<Fortran::parser::CompilerDirective::IgnoreTKR>>, Fortran::parser::CompilerDirective::LoopCount, std::__cxx11::list<Fortran::parser::CompilerDirective::AssumeAligned, std::allocator<Fortran::parser::CompilerDirective::AssumeAligned>>, Fortran::parser::CompilerDirective::VectorAlways, std::__cxx11::list<Fortran::parser::CompilerDirective::NameValue, std::allocator<Fortran::parser::CompilerDirective::NameValue>>, Fortran::parser::CompilerDirective::Unrecognized> const&>, std::integer_sequence<unsigned long, 3ul>>::__visit_invoke(Fortran::common::visitors<(anonymous namespace)::FirConverter::genFIR(Fortran::parser::CompilerDirective const&)::'lambda'(Fortran::parser::CompilerDirective::VectorAlways const&), (anonymous namespace)::FirConverter::genFIR(Fortran::parser::CompilerDirective const&)::'lambda0'(auto const&)>&&, std::variant<std::__cxx11::list<Fortran::parser::CompilerDirective::IgnoreTKR, std::allocator<Fortran::parser::CompilerDirective::IgnoreTKR>>, Fortran::parser::CompilerDirective::LoopCount, std::__cxx11::list<Fortran::parser::CompilerDirective::AssumeAligned, std::allocator<Fortran::parser::CompilerDirective::AssumeAligned>>, Fortran::parser::CompilerDirective::VectorAlways, std::__cxx11::list<Fortran::parser::CompilerDirective::NameValue, std::allocator<Fortran::parser::CompilerDirective::NameValue>>, Fortran::parser::CompilerDirective::Unrecognized> const&) Bridge.cpp:0:0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWd1u2zoSfhrlZiBDpmRbuvCFm8Q4xfacBmm3B3tljKiRzJYitSRlO_v0C1K2Y6XNKZoWuwtsijoW_z7OzzfDEY3WikYRLaPZm2h2c4W922qz7KwjoWqS1VWpq4flxy1Zgs7oUlJrwTpqoTa6BbclEEo4gRJE20lqSTl0QisQCu7uIWJpkeZpMomSmyhZDX__3JIKSythiDuxI8CuIzTWr_IDdCDeB5gOjYvYdejluu2EJAPUCmcBFZAx2kBL1mJDsP8at9JkVcQWDjpDnCoChJv3ILXuJgAft8KCsFCJuiZDyj1qVdIWd0Ib0DU0tTbOoPJyqN1FA1UFwrcnAH9oRX6yC7Y6iWqBdqRAWNv7rfdolFDN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