This is an archive of the discontinued LLVM Phabricator instance.

[WIP][OPENMP] Fix assertion error for using alignas with OpenMP directive
AbandonedPublic

Authored by cchen on May 26 2020, 2:50 PM.

Details

Reviewers
jdoerfert
ABataev
Summary

For the below case, Clang seems to regress (asserts) after https://github.com/llvm/llvm-project/commit/715f7a1bd058c64a39cc4773114dfb46ae8cc8a3

struct FOO
{
  static const int vec_align_bytes = 32;

  void foo()
  {
    alignas(vec_align_bytes) double a;
#pragma omp parallel // I've tried some other directives like master and target and all having same assertion failure
    a++;
  }

};

We can avoid the assertion failure by either removing alignas or
OpenMP directive in the above code. It is apparent the usage of alignas
is resonable so the issue might be stem from OpenMP code.
In addition, replacing OpenMP directive with some arbitrary Clang directive
can avoid the assertion failure.

Diff Detail

Event Timeline

cchen created this revision.May 26 2020, 2:50 PM
cchen added a comment.May 26 2020, 2:51 PM

Haven't added test yet since I'm not sure in which file should I add the test.

cchen added subscribers: dreachem, sandoval.

We can avoid the assertion failure by either removing alignas or OpenMP directive in the above code.

What OpenMP directive?

Haven't added test yet since I'm not sure in which file should I add the test.

Let's go with something like clang/test/OpenMP/sema_alignas.cpp so we can start discussing the test at least.

Haven't added test yet since I'm not sure in which file should I add the test.

Where is the directive?

cchen edited the summary of this revision. (Show Details)May 26 2020, 3:58 PM

Haven't added test yet since I'm not sure in which file should I add the test.

Where is the directive?

I just added it, sorry for my carelessness.

cchen updated this revision to Diff 266370.May 26 2020, 4:21 PM

Add test

Investigated the bug. Seems to me, the bug is not related to OpenMP. The following code crashes the compiler too:

struct FOO
{
  static const int vec_align_bytes = 32;

  void foo()
  {
    alignas(vec_align_bytes) double a;
    ;
  }

};

Seems to me, the bug is in Actions.ClassifyName which does not clean up the list of the possibly odr-used decls. Or in the code, which tries to parse the align argument Parser::ParseAlignArgument.

cchen abandoned this revision.Jun 2 2020, 1:57 PM