[all-commits] [llvm/llvm-project] c4c8d0: [Clang] Fix incorrect handling of #pragma {GCC} un...

yronglin via All-commits all-commits at lists.llvm.org
Mon Apr 29 07:01:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c4c8d08b81e622529aaf0bfc3020d2b9e87267b3
      https://github.com/llvm/llvm-project/commit/c4c8d08b81e622529aaf0bfc3020d2b9e87267b3
  Author: yronglin <yronglin777 at gmail.com>
  Date:   2024-04-29 (Mon, 29 Apr 2024)

  Changed paths:
    M clang/lib/CodeGen/CGLoopInfo.cpp
    M clang/lib/Sema/SemaStmtAttr.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    A clang/test/AST/ast-dump-pragma-unroll.cpp
    M clang/test/CodeGenCXX/pragma-gcc-unroll.cpp
    M clang/test/CodeGenCXX/pragma-unroll.cpp
    M clang/test/Parser/pragma-unroll.cpp

  Log Message:
  -----------
  [Clang] Fix incorrect handling of #pragma {GCC} unroll N in dependent context (#90240)

PR https://github.com/llvm/llvm-project/pull/89567 fix the `#pragma
unroll N` crash issue in dependent context, but it's introduce an new
issue:

Since https://github.com/llvm/llvm-project/pull/89567, if `N` is value
dependent, 'option' and 'state' were ` (LoopHintAttr::Unroll,
LoopHintAttr::Enable)`. Therefor, clang's code generator generated
incorrect IR metadata.

For the situation `#pragma {GCC} unroll {0|1}`, before template
instantiation, this PR tweak the 'option' to `LoopHintAttr::UnrollCount`
and 'state' to `LoopHintAttr::Numeric`. During template instantiation
and if unroll count is 0 or 1 this PR tweak 'option' to
`LoopHintAttr::Unroll` and 'state' to `LoopHintAttr::Disable`. We don't
use `LoopHintAttr::UnrollCount` here because it's will emit an redundant
LLVM IR metadata `!{!"llvm.loop.unroll.count", i32 1}` when unroll count
is 1.

---------

Signed-off-by: yronglin <yronglin777 at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list