[PATCH] D106084: [DebugInfo] Switch to using constructor homing (-debug-info-kind=constructor) by default when debug info is enabled

2021-07-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Adrian said "Let's do it!" on the mailing list so LGTM for Darin.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106084/new/

https://reviews.llvm.org/D106084

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106130: [PowerPC] Implemented mtmsr, mfspr, mtspr Builtins

2021-07-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Herald added subscribers: steven.zhang, shchenz, kbarton, hiraditya, nemanjai.
Conanap requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Implemented builtins for mtmsr, mfspr, mtspr on PowerPC;
the patch is intended for XL Compatibility.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106130

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-64bit-only.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
===
--- llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
@@ -1,15 +1,20 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; NOTE: Had to manually modify the last test case (mtmsr) to allow the
+; NOTE: common check of mtmsr instead of 4 different check prefixes
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 < %s | FileCheck %s
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr7 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
-; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
 ; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-32BIT
 
 declare i32 @llvm.ppc.mftbu()
 declare i32 @llvm.ppc.mfmsr()
+declare void @llvm.ppc.mtmsr(i32)
+
+@ula = external local_unnamed_addr global i64, align 8
 
 define dso_local zeroext i32 @test_mftbu() {
 ; CHECK-LABEL: test_mftbu:
@@ -18,10 +23,10 @@
 ; CHECK-NEXT:clrldi 3, 3, 32
 ; CHECK-NEXT:blr
 ;
-; CHECK-AIX-LABEL: test_mftbu:
-; CHECK-AIX:   # %bb.0: # %entry
-; CHECK-AIX-NEXT:mftbu 3
-; CHECK-AIX-NEXT:blr
+; CHECK-32BIT-LABEL: test_mftbu:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mftbu 3
+; CHECK-32BIT-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.mftbu()
   ret i32 %0
@@ -34,13 +39,31 @@
 ; CHECK-NEXT:clrldi 3, 3, 32
 ; CHECK-NEXT:blr
 ;
-; CHECK-AIX-LABEL: test_mfmsr:
-; CHECK-AIX:   # %bb.0: # %entry
-; CHECK-AIX-NEXT:mfmsr 4
-; CHECK-AIX-NEXT:li 3, 0
-; CHECK-AIX-NEXT:blr
+; CHECK-32BIT-LABEL: test_mfmsr:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mfmsr 4
+; CHECK-32BIT-NEXT:li 3, 0
+; CHECK-32BIT-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.mfmsr()
   %conv = zext i32 %0 to i64
   ret i64 %conv
 }
+
+define dso_local void @test_mtmsr() {
+; CHECK-LABEL: test_mtmsr:
+; CHECK:mtmsr 3
+; CHECK-NEXT:blr
+;
+; CHECK-32BIT-LABEL: test_mtmsr:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:lwz 3, L..C0(2) # @ula
+; CHECK-32BIT-NEXT:lwz 3, 4(3)
+; CHECK-32BIT-NEXT:mtmsr 3, 0
+; CHECK-32BIT-NEXT:blr
+entry:
+  %0 = load i64, i64* @ula, align 8
+  %conv = trunc i64 %0 to i32
+  call void @llvm.ppc.mtmsr(i32 %conv)
+  ret void
+}
Index: llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
@@ -0,0 +1,123 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+
+declare i32 @llvm.ppc.mfspr.i32(i32 immarg)
+declare void @llvm.ppc.mtspr.i32(i32 immarg, i32)
+
+@ula = external dso_local global i32, align 4
+
+define dso_local i32 @test_mfxer() {
+; CHECK-LABEL: test_mfxer:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfxer 3
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 1)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mflr() {
+; CHECK-LABEL: test_mflr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 8
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 8)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfctr() {
+; CHECK-LABEL: test_mfctr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 9
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 9)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfppr() {
+; CHECK-LABEL: test_mfppr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 896
+; CHECK-NEXT: 

[PATCH] D106130: [PowerPC] Implemented mtmsr, mfspr, mtspr Builtins

2021-07-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 359236.
Conanap added a comment.

Added sema checking


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106130/new/

https://reviews.llvm.org/D106130

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-64bit-only.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
===
--- llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
@@ -1,15 +1,20 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; NOTE: Had to manually modify the last test case (mtmsr) to allow the
+; NOTE: common check of mtmsr instead of 4 different check prefixes
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 < %s | FileCheck %s
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr7 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
-; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
 ; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-32BIT
 
 declare i32 @llvm.ppc.mftbu()
 declare i32 @llvm.ppc.mfmsr()
+declare void @llvm.ppc.mtmsr(i32)
+
+@ula = external local_unnamed_addr global i64, align 8
 
 define dso_local zeroext i32 @test_mftbu() {
 ; CHECK-LABEL: test_mftbu:
@@ -18,10 +23,10 @@
 ; CHECK-NEXT:clrldi 3, 3, 32
 ; CHECK-NEXT:blr
 ;
-; CHECK-AIX-LABEL: test_mftbu:
-; CHECK-AIX:   # %bb.0: # %entry
-; CHECK-AIX-NEXT:mftbu 3
-; CHECK-AIX-NEXT:blr
+; CHECK-32BIT-LABEL: test_mftbu:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mftbu 3
+; CHECK-32BIT-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.mftbu()
   ret i32 %0
@@ -34,13 +39,31 @@
 ; CHECK-NEXT:clrldi 3, 3, 32
 ; CHECK-NEXT:blr
 ;
-; CHECK-AIX-LABEL: test_mfmsr:
-; CHECK-AIX:   # %bb.0: # %entry
-; CHECK-AIX-NEXT:mfmsr 4
-; CHECK-AIX-NEXT:li 3, 0
-; CHECK-AIX-NEXT:blr
+; CHECK-32BIT-LABEL: test_mfmsr:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mfmsr 4
+; CHECK-32BIT-NEXT:li 3, 0
+; CHECK-32BIT-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.mfmsr()
   %conv = zext i32 %0 to i64
   ret i64 %conv
 }
+
+define dso_local void @test_mtmsr() {
+; CHECK-LABEL: test_mtmsr:
+; CHECK:mtmsr 3
+; CHECK-NEXT:blr
+;
+; CHECK-32BIT-LABEL: test_mtmsr:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:lwz 3, L..C0(2) # @ula
+; CHECK-32BIT-NEXT:lwz 3, 4(3)
+; CHECK-32BIT-NEXT:mtmsr 3, 0
+; CHECK-32BIT-NEXT:blr
+entry:
+  %0 = load i64, i64* @ula, align 8
+  %conv = trunc i64 %0 to i32
+  call void @llvm.ppc.mtmsr(i32 %conv)
+  ret void
+}
Index: llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
@@ -0,0 +1,123 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+
+declare i32 @llvm.ppc.mfspr.i32(i32 immarg)
+declare void @llvm.ppc.mtspr.i32(i32 immarg, i32)
+
+@ula = external dso_local global i32, align 4
+
+define dso_local i32 @test_mfxer() {
+; CHECK-LABEL: test_mfxer:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfxer 3
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 1)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mflr() {
+; CHECK-LABEL: test_mflr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 8
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 8)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfctr() {
+; CHECK-LABEL: test_mfctr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 9
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 9)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfppr() {
+; CHECK-LABEL: test_mfppr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 896
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 896)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfppr32() {
+; CHECK-LABEL: test_mfppr32:
+

[clang-tools-extra] 8d051d8 - Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer"

2021-07-16 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2021-07-16T07:35:13Z
New Revision: 8d051d854619956de633047409149cdab1e3319a

URL: 
https://github.com/llvm/llvm-project/commit/8d051d854619956de633047409149cdab1e3319a
DIFF: 
https://github.com/llvm/llvm-project/commit/8d051d854619956de633047409149cdab1e3319a.diff

LOG: Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport 
to make it free of global initializer"

This reverts commit af9321739b20becf170e6bb5060b8d780e1dc8dd.
Still some specific config broken in some way that requires more
investigation.

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/indexer/IndexerMain.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
llvm/docs/CommandLine.rst
llvm/include/llvm/Support/ARMAttributeParser.h
llvm/include/llvm/Support/ARMBuildAttributes.h
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/RISCVAttributeParser.h
llvm/include/llvm/Support/RISCVAttributes.h
llvm/include/llvm/Support/ScopedPrinter.h
llvm/include/llvm/Support/WithColor.h
llvm/lib/Support/ARMBuildAttrs.cpp
llvm/lib/Support/CommandLine.cpp
llvm/lib/Support/Debug.cpp
llvm/lib/Support/DebugCounter.cpp
llvm/lib/Support/ELFAttributeParser.cpp
llvm/lib/Support/GraphWriter.cpp
llvm/lib/Support/RISCVAttributes.cpp
llvm/lib/Support/RandomNumberGenerator.cpp
llvm/lib/Support/Signals.cpp
llvm/lib/Support/Statistic.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Support/Timer.cpp
llvm/lib/Support/TypeSize.cpp
llvm/lib/Support/Windows/Signals.inc
llvm/lib/Support/WithColor.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/unittests/Support/ARMAttributeParser.cpp
llvm/unittests/Support/CommandLineTest.cpp
llvm/unittests/Support/RISCVAttributeParserTest.cpp

Removed: 
llvm/lib/Support/DebugOptions.h



diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 581dae7557295..49f16e72be92a 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -91,7 +91,7 @@ class Command {
   // By resetting the parser options, we lost the standard -help flag.
   llvm::cl::opt> Help{
   "help", llvm::cl::desc("Display available options"),
-  llvm::cl::ValueDisallowed, 
llvm::cl::cat(llvm::cl::getGeneralCategory())};
+  llvm::cl::ValueDisallowed, llvm::cl::cat(llvm::cl::GeneralCategory)};
   // FIXME: Allow commands to signal failure.
   virtual void run() = 0;
 

diff  --git a/clang-tools-extra/clangd/indexer/IndexerMain.cpp 
b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
index 54fcc1f28..fd8404be677a2 100644
--- a/clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -124,7 +124,7 @@ int main(int argc, const char **argv) {
   )";
 
   auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
-  argc, argv, llvm::cl::getGeneralCategory(), Overview);
+  argc, argv, llvm::cl::GeneralCategory, Overview);
 
   if (!Executor) {
 llvm::errs() << llvm::toString(Executor.takeError()) << "\n";

diff  --git a/clang/tools/clang-refactor/ClangRefactor.cpp 
b/clang/tools/clang-refactor/ClangRefactor.cpp
index eacd00a601dbe..01edad43164fb 100644
--- a/clang/tools/clang-refactor/ClangRefactor.cpp
+++ b/clang/tools/clang-refactor/ClangRefactor.cpp
@@ -38,11 +38,11 @@ namespace opts {
 static cl::OptionCategory CommonRefactorOptions("Refactoring options");
 
 static cl::opt Verbose("v", cl::desc("Use verbose output"),
- cl::cat(cl::getGeneralCategory()),
+ cl::cat(cl::GeneralCategory),
  cl::sub(*cl::AllSubCommands));
 
 static cl::opt Inplace("i", cl::desc("Inplace edit s"),
- cl::cat(cl::getGeneralCategory()),
+ cl::cat(cl::GeneralCategory),
  cl::sub(*cl::AllSubCommands));
 
 } // end namespace opts
@@ -613,7 +613,7 @@ int main(int argc, const char **argv) {
   ClangRefactorTool RefactorTool;
 
   auto ExpectedParser = CommonOptionsParser::create(
-  argc, argv, cl::getGeneralCategory(), cl::ZeroOrMore,
+  argc, argv, cl::GeneralCategory, cl::ZeroOrMore,
   "Clang-based refactoring tool for C, C++ and Objective-C");
   if (!ExpectedParser) {
 llvm::errs() << ExpectedParser.takeError();

diff  --git a/llvm/docs/CommandLine.rst b/llvm/docs/CommandLine.rst
index fef7e39ad86d2..e549d49bd90f5 100644
--- a/llvm/docs/Comm

[clang-tools-extra] 7637457 - Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2021-07-16T07:38:16Z
New Revision: 76374573ce829b083b95b74937a11e9b91f8f45f

URL: 
https://github.com/llvm/llvm-project/commit/76374573ce829b083b95b74937a11e9b91f8f45f
DIFF: 
https://github.com/llvm/llvm-project/commit/76374573ce829b083b95b74937a11e9b91f8f45f.diff

LOG: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make 
it free of global initializer

We can build it with -Werror=global-constructors now. This helps
in situation where libSupport is embedded as a shared library,
potential with dlopen/dlclose scenario, and when command-line
parsing or other facilities may not be involved. Avoiding the
implicit construction of these cl::opt can avoid double-registration
issues and other kind of behavior.

Reviewed By: lattner, jpienaar

Differential Revision: https://reviews.llvm.org/D105959

Added: 
llvm/lib/Support/DebugOptions.h

Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/indexer/IndexerMain.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
llvm/docs/CommandLine.rst
llvm/include/llvm/Support/ARMAttributeParser.h
llvm/include/llvm/Support/ARMBuildAttributes.h
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/RISCVAttributeParser.h
llvm/include/llvm/Support/RISCVAttributes.h
llvm/include/llvm/Support/ScopedPrinter.h
llvm/include/llvm/Support/WithColor.h
llvm/lib/Support/ARMBuildAttrs.cpp
llvm/lib/Support/CommandLine.cpp
llvm/lib/Support/Debug.cpp
llvm/lib/Support/DebugCounter.cpp
llvm/lib/Support/ELFAttributeParser.cpp
llvm/lib/Support/GraphWriter.cpp
llvm/lib/Support/RISCVAttributes.cpp
llvm/lib/Support/RandomNumberGenerator.cpp
llvm/lib/Support/Signals.cpp
llvm/lib/Support/Statistic.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Support/Timer.cpp
llvm/lib/Support/TypeSize.cpp
llvm/lib/Support/Windows/Signals.inc
llvm/lib/Support/WithColor.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/unittests/Support/ARMAttributeParser.cpp
llvm/unittests/Support/CommandLineTest.cpp
llvm/unittests/Support/RISCVAttributeParserTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 49f16e72be92a..581dae7557295 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -91,7 +91,7 @@ class Command {
   // By resetting the parser options, we lost the standard -help flag.
   llvm::cl::opt> Help{
   "help", llvm::cl::desc("Display available options"),
-  llvm::cl::ValueDisallowed, llvm::cl::cat(llvm::cl::GeneralCategory)};
+  llvm::cl::ValueDisallowed, 
llvm::cl::cat(llvm::cl::getGeneralCategory())};
   // FIXME: Allow commands to signal failure.
   virtual void run() = 0;
 

diff  --git a/clang-tools-extra/clangd/indexer/IndexerMain.cpp 
b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
index fd8404be677a2..54fcc1f28 100644
--- a/clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -124,7 +124,7 @@ int main(int argc, const char **argv) {
   )";
 
   auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
-  argc, argv, llvm::cl::GeneralCategory, Overview);
+  argc, argv, llvm::cl::getGeneralCategory(), Overview);
 
   if (!Executor) {
 llvm::errs() << llvm::toString(Executor.takeError()) << "\n";

diff  --git a/clang/tools/clang-refactor/ClangRefactor.cpp 
b/clang/tools/clang-refactor/ClangRefactor.cpp
index 01edad43164fb..eacd00a601dbe 100644
--- a/clang/tools/clang-refactor/ClangRefactor.cpp
+++ b/clang/tools/clang-refactor/ClangRefactor.cpp
@@ -38,11 +38,11 @@ namespace opts {
 static cl::OptionCategory CommonRefactorOptions("Refactoring options");
 
 static cl::opt Verbose("v", cl::desc("Use verbose output"),
- cl::cat(cl::GeneralCategory),
+ cl::cat(cl::getGeneralCategory()),
  cl::sub(*cl::AllSubCommands));
 
 static cl::opt Inplace("i", cl::desc("Inplace edit s"),
- cl::cat(cl::GeneralCategory),
+ cl::cat(cl::getGeneralCategory()),
  cl::sub(*cl::AllSubCommands));
 
 } // end namespace opts
@@ -613,7 +613,7 @@ int main(int argc, const char **argv) {
   ClangRefactorTool RefactorTool;
 
   auto ExpectedParser = CommonOptionsParser::create(
-  argc, argv, cl::GeneralCategory, cl::ZeroOrMore,
+  argc, argv, cl::getGeneralCategor

[clang] 918bda1 - [analyzer] Do not assume that all pointers have the same bitwidth as void*

2021-07-16 Thread via cfe-commits

Author: Vince Bridgers
Date: 2021-07-16T03:22:57-05:00
New Revision: 918bda1241202d0480c6d94ec8f72c483d77a06c

URL: 
https://github.com/llvm/llvm-project/commit/918bda1241202d0480c6d94ec8f72c483d77a06c
DIFF: 
https://github.com/llvm/llvm-project/commit/918bda1241202d0480c6d94ec8f72c483d77a06c.diff

LOG: [analyzer] Do not assume that all pointers have the same bitwidth as void*

This change addresses this assertion that occurs in a downstream
compiler with a custom target.

```APInt.h:1151: bool llvm::APInt::operator==(const llvm::APInt &) const: 
Assertion `BitWidth == RHS.BitWidth && "Comparison requires equal bit 
widths"'```

No covering test case is susbmitted with this change since this crash
cannot be reproduced using any upstream supported target. The test case
that exposes this issue is as simple as:

```lang=c++
  void test(int * p) {
int * q = p-1;
if (q) {}
if (q) {} // crash
(void)q;
  }
```

The custom target that exposes this problem supports two address spaces,
16-bit `char`s, and a `_Bool` type that maps to 16-bits. There are no upstream
supported targets with similar attributes.

The assertion appears to be happening as a result of evaluating the
`SymIntExpr` `(reg_$0) != 0U` in `VisitSymIntExpr` located in
`SimpleSValBuilder.cpp`. The `LHS` is evaluated to `32b` and the `RHS` is
evaluated to `16b`. This eventually leads to the assertion in `APInt.h`.

While this change addresses the crash and passes LITs, two follow-ups
are required:
  1) The remainder of `getZeroWithPtrWidth()` and `getIntWithPtrWidth()`
 should be cleaned up following this model to prevent future
 confusion.
  2) We're not sure why references are found along with the modified
 code path, that should not be the case. A more principled
 fix may be found after some further comprehension of why this
 is the case.

Acks: Thanks to @steakhal and @martong for the discussions leading to this
fix.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D105974

Added: 
clang/test/Analysis/solver-sym-simplification-ptr-bool.cl

Modified: 
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index b7ca8e8ca9cd..a5e99ce72d6b 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -712,9 +712,23 @@ SVal SValBuilder::evalCastSubKind(loc::MemRegionVal V, 
QualType CastTy,
   // symbols to use, only content metadata.
   return nonloc::SymbolVal(SymMgr.getExtentSymbol(FTR));
 
-if (const SymbolicRegion *SymR = R->getSymbolicBase())
-  return makeNonLoc(SymR->getSymbol(), BO_NE,
-BasicVals.getZeroWithPtrWidth(), CastTy);
+if (const SymbolicRegion *SymR = R->getSymbolicBase()) {
+  SymbolRef Sym = SymR->getSymbol();
+  QualType Ty = Sym->getType();
+  // This change is needed for architectures with varying
+  // pointer widths. See the amdgcn opencl reproducer with
+  // this change as an example: solver-sym-simplification-ptr-bool.cl
+  // FIXME: We could encounter a reference here,
+  //try returning a concrete 'true' since it might
+  //be easier on the solver.
+  // FIXME: Cleanup remainder of `getZeroWithPtrWidth ()`
+  //and `getIntWithPtrWidth()` functions to prevent future
+  //confusion
+  const llvm::APSInt &Zero = Ty->isReferenceType()
+ ? BasicVals.getZeroWithPtrWidth()
+ : BasicVals.getZeroWithTypeSize(Ty);
+  return makeNonLoc(Sym, BO_NE, Zero, CastTy);
+}
 // Non-symbolic memory regions are always true.
 return makeTruthVal(true, CastTy);
   }

diff  --git a/clang/test/Analysis/solver-sym-simplification-ptr-bool.cl 
b/clang/test/Analysis/solver-sym-simplification-ptr-bool.cl
new file mode 100644
index ..be8edbf51eba
--- /dev/null
+++ b/clang/test/Analysis/solver-sym-simplification-ptr-bool.cl
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze 
-analyzer-checker=core %s
+
+// expected-no-diagnostics
+
+// This test case covers an issue found in the static analyzer
+// solver where pointer sizes were assumed. Pointer sizes may vary on other
+// architectures. This issue was originally discovered on a downstream,
+// custom target, this assert occurs on the custom target and this one
+// without the fix, and is fixed with this change.
+//
+// The assertion appears to be happening as a result of evaluating the
+// SymIntExpr (reg_$0) != 0U in VisitSymIntExpr located in
+// SimpleSValBuilder.cpp. The LHS is evaluated to 32b and the RHS is
+// evaluated to 16b. This eventually leads to the assertion in APInt.h.
+//
+// APInt.h:1151: bool llvm::APInt::operator=

[PATCH] D105974: [analyzer] Do not assume that all pointers have the same bitwidth as void*

2021-07-16 Thread Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG918bda124120: [analyzer] Do not assume that all pointers 
have the same bitwidth as void* (authored by vabridgers, committed by einvbri 
).

Changed prior to commit:
  https://reviews.llvm.org/D105974?vs=359163&id=359246#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105974/new/

https://reviews.llvm.org/D105974

Files:
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/solver-sym-simplification-ptr-bool.cl


Index: clang/test/Analysis/solver-sym-simplification-ptr-bool.cl
===
--- /dev/null
+++ clang/test/Analysis/solver-sym-simplification-ptr-bool.cl
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze 
-analyzer-checker=core %s
+
+// expected-no-diagnostics
+
+// This test case covers an issue found in the static analyzer
+// solver where pointer sizes were assumed. Pointer sizes may vary on other
+// architectures. This issue was originally discovered on a downstream,
+// custom target, this assert occurs on the custom target and this one
+// without the fix, and is fixed with this change.
+//
+// The assertion appears to be happening as a result of evaluating the
+// SymIntExpr (reg_$0) != 0U in VisitSymIntExpr located in
+// SimpleSValBuilder.cpp. The LHS is evaluated to 32b and the RHS is
+// evaluated to 16b. This eventually leads to the assertion in APInt.h.
+//
+// APInt.h:1151: bool llvm::APInt::operator==(const llvm::APInt &) const: 
Assertion `BitWidth == RHS.BitWidth && "Comparison requires equal bit widths"'
+// 
+void test1(__attribute__((address_space(256))) int * p) {
+  __attribute__((address_space(256))) int * q = p-1;
+  if (q) {}
+  if (q) {}
+  (void)q;
+}
+ 
+void test2(__attribute__((address_space(256))) int * p) {
+  __attribute__((address_space(256))) int * q = p-1;
+  q && q; 
+  q && q; 
+  (void)q;
+} 
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -712,9 +712,23 @@
   // symbols to use, only content metadata.
   return nonloc::SymbolVal(SymMgr.getExtentSymbol(FTR));
 
-if (const SymbolicRegion *SymR = R->getSymbolicBase())
-  return makeNonLoc(SymR->getSymbol(), BO_NE,
-BasicVals.getZeroWithPtrWidth(), CastTy);
+if (const SymbolicRegion *SymR = R->getSymbolicBase()) {
+  SymbolRef Sym = SymR->getSymbol();
+  QualType Ty = Sym->getType();
+  // This change is needed for architectures with varying
+  // pointer widths. See the amdgcn opencl reproducer with
+  // this change as an example: solver-sym-simplification-ptr-bool.cl
+  // FIXME: We could encounter a reference here,
+  //try returning a concrete 'true' since it might
+  //be easier on the solver.
+  // FIXME: Cleanup remainder of `getZeroWithPtrWidth ()`
+  //and `getIntWithPtrWidth()` functions to prevent future
+  //confusion
+  const llvm::APSInt &Zero = Ty->isReferenceType()
+ ? BasicVals.getZeroWithPtrWidth()
+ : BasicVals.getZeroWithTypeSize(Ty);
+  return makeNonLoc(Sym, BO_NE, Zero, CastTy);
+}
 // Non-symbolic memory regions are always true.
 return makeTruthVal(true, CastTy);
   }


Index: clang/test/Analysis/solver-sym-simplification-ptr-bool.cl
===
--- /dev/null
+++ clang/test/Analysis/solver-sym-simplification-ptr-bool.cl
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze -analyzer-checker=core %s
+
+// expected-no-diagnostics
+
+// This test case covers an issue found in the static analyzer
+// solver where pointer sizes were assumed. Pointer sizes may vary on other
+// architectures. This issue was originally discovered on a downstream,
+// custom target, this assert occurs on the custom target and this one
+// without the fix, and is fixed with this change.
+//
+// The assertion appears to be happening as a result of evaluating the
+// SymIntExpr (reg_$0) != 0U in VisitSymIntExpr located in
+// SimpleSValBuilder.cpp. The LHS is evaluated to 32b and the RHS is
+// evaluated to 16b. This eventually leads to the assertion in APInt.h.
+//
+// APInt.h:1151: bool llvm::APInt::operator==(const llvm::APInt &) const: Assertion `BitWidth == RHS.BitWidth && "Comparison requires equal bit widths"'
+// 
+void test1(__attribute__((address_space(256))) int * p) {
+  __attribute__((address_space(256))) int * q = p-1;
+  if (q) {}
+  if (q) {}
+  (void)q;
+}
+ 
+void test2(__attribute__((address_

[PATCH] D105491: [clang] Use i64 for the !srcloc metadata on asm IR nodes.

2021-07-16 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

@dexonsmith I don't think they need upgraded. Most of the places I can see 
referencing `!srcloc` are copying it around and will preserve the i32 type. 
Cases which actually read the value are already reading it as 64 bit via 
`getZExtValue` and have been updated here, e.g. `MachineInstr::emitError`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105491/new/

https://reviews.llvm.org/D105491

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer added inline comments.



Comment at: llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h:32
+  Triple TargetTriple = {});
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
   static bool isRequired() { return true; }

vitalybuka wrote:
> fmayer wrote:
> > vitalybuka wrote:
> > > fmayer wrote:
> > > > vitalybuka wrote:
> > > > > Why not from M.getTargetTriple() ?
> > > > Mostly for consistency with the legacy pass. Either way is fine for me 
> > > > though, what do you prefer?
> > > I don't know if will cause any issues, but usually most passes get triple 
> > > from the module.
> > > I prefer we stay consistent with the rest of the code if possible.
> > > 
> > I'll leave it as is, for consistency within this file, as we need to do it 
> > this way for the new pass manager.
> That's what I don't like, passing Triple from BackendUtil.cpp
> I've updated the patch. You can download it with "arc patch D105703"
OK, no strong feelings but now we addRequire the pass even if we don't need it, 
so there isn't much point turning it off anymore, no?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-07-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1223-1225
+template <>
+RangeSet SymbolicRangeInferrer::VisitBinaryOperator(Range LHS, Range 
RHS,
+   QualType T) {

I think it should be a specialization for another `VisitBinaryOperator`.
In the switch, you can see that we give range sets for `LHS` and `RHS`, so how 
does it work?
There is a function in between (also `VisitBinaryOperator`) that creates simple 
ranges out of range sets and ask to visit binary operator for those.  You can 
specialize it instead since we can simply check for empty intersection of range 
sets.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1241
+  // In all other cases, the resulting range cannot be deduced.
+  return RangeFactory.getEmptySet();
+}

Empty range set means "This situation is IMPOSSIBLE".  Is that what you want 
here?



Comment at: clang/test/Analysis/constant-folding.c:470-504
+  // Checks when ranges are not overlapping
+  if (a <= 10 && b >= 20) {
+clang_analyzer_eval((a != b) != 0); // expected-warning{{TRUE}}
+  }
+
+  if (c <= INT_MIN + 10 && d >= INT_MAX - 10) {
+clang_analyzer_eval((c != d) == 0); // expected-warning{{FALSE}}

Did you try it in debugger, do we get inside of your function?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106102/new/

https://reviews.llvm.org/D106102

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 359256.
Topotuna added a comment.

Patch made compatible with changes to D105988 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105987/new/

https://reviews.llvm.org/D105987

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -3,27 +3,46 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 
 void foo(){
 
 global int* ptr1 = NULL;
 
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__global void *'}}
+#endif
 global int* ptr2 = (global void*)0;
 
 constant int* ptr3 = NULL;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing 
'__constant int *__private' with an expression of type '__global void *' 
changes address space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__constant int 
*__private' with an rvalue of type '__global void *'}}
+#else
+// expected-error@+2{{initializing '__constant int *__private' with an 
expression of type '__global void *' changes address space of pointer}}
+#endif
+constant int* ptr4 = (global void*)0;
 
 #ifdef CL20
 // Accept explicitly pointer to generic address space in OpenCL v2.0.
 global int* ptr5 = (generic void*)0;
 #endif
 
-global int* ptr6 = (local void*)0; // expected-error{{initializing '__global 
int *__private' with an expression of type '__local void *' changes address 
space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__local void *'}}
+#else
+// expected-error@+2{{initializing '__global int *__private' with an 
expression of type '__local void *' changes address space of pointer}}
+#endif
+global int* ptr6 = (local void*)0;
 
 bool cmp = ptr1 == NULL;
 
-cmp = ptr1 == (local void*)0; // expected-error{{comparison between  
('__global int *' and '__local void *') which are pointers to non-overlapping 
address spaces}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{comparison of distinct pointer types ('__global int *' 
and '__local void *')}}
+#else
+// expected-error@+2{{comparison between  ('__global int *' and '__local void 
*') which are pointers to non-overlapping address spaces}}
+#endif
+cmp = ptr1 == (local void*)0;
 
 cmp = ptr3 == NULL;
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,11 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
+#if defined(__OPENCL_CPP_VERSION__)
+#define NULL nullptr
+#elif defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
+#endif
 
 /**
  * Value of maximum non-infinite single-precision floating-point


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -3,27 +3,46 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header -verify %s
 
 void foo(){
 
 global int* ptr1 = NULL;
 
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int *__private' with an rvalue of type '__global void *'}}
+#endif
 global int* ptr2 = (global void*)0;
 
 constant int* ptr3 = NULL;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__constant int *__private' with an rvalue of type '__global void *'}}
+#else
+// expected-error@+2{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
+#endif
+constant int* ptr4 = (global void*)0;
 
 #ifdef CL20
 // Accept explicitly pointer to generic address space i

[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/test/SemaOpenCL/null_literal.cl:13
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__global void *'}}
+#endif

Anastasia wrote:
> hmm, you should not get those errors though https://godbolt.org/z/qvr7x11TM
The `expected-error` here refers to line 15 which displays an error: 
https://godbolt.org/z/zYzGedzv4


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105987/new/

https://reviews.llvm.org/D105987

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105946: [PowerPC] Store, load, move from and to registers related builtins

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

Taking this off the review queue until `lharx/lbarx` are changed to emit inline 
asm in line with `lwarx/ldarx`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105946/new/

https://reviews.llvm.org/D105946

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-16 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 359258.
pmatos added a comment.

Remove hunks touching LLTs accidentally added before


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104797/new/

https://reviews.llvm.org/D104797

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+%extern = type opaque
+%externref = type %extern addrspace(10)*
+
+define void @store_extern(%externref %ref) {
+  store %extern unde

[PATCH] D105946: [PowerPC] Store, load, move from and to registers related builtins

2021-07-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 359259.
Conanap added a comment.

Updated lharx and lbarx to inline asm implementation, implemented stfiw.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105946/new/

https://reviews.llvm.org/D105946

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  clang/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.c
  clang/test/CodeGen/builtins-ppc-xlcompat-prefetch.c
  clang/test/CodeGen/builtins-ppc-xlcompat-stfiw.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-stfiw.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX64
+
+declare void @llvm.ppc.dcbtstt(i8*)
+declare void @llvm.ppc.dcbtt(i8*)
+
+@vpa = external local_unnamed_addr global i8*, align 8
+
+define dso_local void @test_dcbtstt() {
+; CHECK-LABEL: test_dcbtstt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addis 3, 2, .LC0@toc@ha
+; CHECK-NEXT:ld 3, .LC0@toc@l(3)
+; CHECK-NEXT:ld 3, 0(3)
+; CHECK-NEXT:dcbtstt 0, 3
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_dcbtstt:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
+; CHECK-AIX-NEXT:lwz 3, 0(3)
+; CHECK-AIX-NEXT:dcbtstt 0, 3
+; CHECK-AIX-NEXT:blr
+;
+; CHECK-AIX64-LABEL: test_dcbtstt:
+; CHECK-AIX64:   # %bb.0: # %entry
+; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
+; CHECK-AIX64-NEXT:ld 3, 0(3)
+; CHECK-AIX64-NEXT:dcbtstt 0, 3
+; CHECK-AIX64-NEXT:blr
+entry:
+  %0 = load i8*, i8** @vpa, align 8
+  tail call void @llvm.ppc.dcbtstt(i8* %0)
+  ret void
+}
+
+
+define dso_local void @test_dcbtt() {
+; CHECK-LABEL: test_dcbtt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addis 3, 2, .LC0@toc@ha
+; CHECK-NEXT:ld 3, .LC0@toc@l(3)
+; CHECK-NEXT:ld 3, 0(3)
+; CHECK-NEXT:dcbtt 0, 3
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_dcbtt:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
+; CHECK-AIX-NEXT:lwz 3, 0(3)
+; CHECK-AIX-NEXT:dcbtt 0, 3
+; CHECK-AIX-NEXT:blr
+;
+; CHECK-AIX64-LABEL: test_dcbtt:
+; CHECK-AIX64:   # %bb.0: # %entry
+; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
+; CHECK-AIX64-NEXT:ld 3, 0(3)
+; CHECK-AIX64-NEXT:dcbtt 0, 3
+; CHECK-AIX64-NEXT:blr
+entry:
+  %0 = load i8*, i8** @vpa, align 8
+  tail call void @llvm.ppc.dcbtt(i8* %0)
+  ret void
+}
Index: llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-32BIT
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+
+declare i32 @llvm.ppc.mftbu()
+declare i32 @llvm.ppc.mfmsr()
+
+define dso_local zeroext i32 @test_mftbu() {
+; CHECK-LABEL: test_mftbu:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mftbu 3
+; CHECK-NEXT:clrldi 3, 3, 32
+; CHECK-NEXT:blr
+;
+; CHECK-32BIT-LABEL: test_mftbu:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mftbu 3
+; CHECK-32BIT-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.mftbu()
+  ret i32 %0
+}
+
+define dso_local i64 @test_mfmsr() {
+; CHECK-LABEL: test_mfmsr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfmsr 3
+; CHECK-NEXT:  

[PATCH] D105495: [clang] Make negative getLocWithOffset widening-safe.

2021-07-16 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

I'm not a huge fan of this as an API; it is not obvious what the function and 
parameters do without reading the comment or implementation (e.g. whether 
`Offset` is ignored if `NegOffset` is given, and what it means to pass offsets 
to both). It moves the subtraction logic from the call site, where it is 
meaningful, to inside the function where it is not. I also think it's the 
caller's responsibility to make sure what they pass in is correctly signed. 
I've put suggestions for how each call site could be updated without casting 
while keeping `getLocWithOffset` unchanged.




Comment at: clang/lib/AST/SelectorLocationsKind.cpp:41
 ++Len;
-  return ArgLoc.getLocWithOffset(-Len);
 }

These are probably fine as they were



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:236
 if (Loc.isMacroID())
-  return Loc.getLocWithOffset(-SM.getFileOffset(Loc));
+  return Loc.getLocWithOffset(0, SM.getFileOffset(Loc));
 return SM.getLocForStartOfFile(SM.getFileID(Loc));

Seems like getFileOffset should now return ui64.



Comment at: clang/lib/Format/FormatTokenLexer.cpp:835
   SourceLocation WhitespaceStart =
-  FormatTok->Tok.getLocation().getLocWithOffset(-TrailingWhitespace);
+  FormatTok->Tok.getLocation().getLocWithOffset(0, TrailingWhitespace);
   FormatTok->IsFirst = IsFirstToken;

This probably would need a cast; widening `TrailingWhitespace` seems overkill.



Comment at: clang/lib/Lex/Lexer.cpp:530
   // Create a lexer starting at the beginning of this token.
-  SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
+  SourceLocation LexerStartLoc = Loc.getLocWithOffset(0, LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,

ditto `getDecomposedLoc`



Comment at: clang/lib/Lex/Lexer.cpp:568-570
   std::pair FileLocInfo = SM.getDecomposedLoc(FileLoc);
   std::pair BeginFileLocInfo =
   SM.getDecomposedLoc(BeginFileLoc);

Shouldn't the return type of `getDecomposedLoc` need updating at some stage? If 
so that would take care of this case



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:174-179
   unsigned Offset = SMLoc.getPointer() - LBuf->getBufferStart();
 
   // Figure out which token that offset points into.
   const unsigned *TokOffsetPtr = llvm::lower_bound(AsmTokOffsets, Offset);
   unsigned TokIndex = TokOffsetPtr - AsmTokOffsets.begin();
   unsigned TokOffset = *TokOffsetPtr;





Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:1073-1074
   // Compute the column number of the end.
   unsigned EndColNo = SM.getExpansionColumnNumber(InstantiationEnd);
   unsigned OldEndColNo = EndColNo;
 




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105495/new/

https://reviews.llvm.org/D105495

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer updated this revision to Diff 359263.
fmayer added a comment.

update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-stack-safety-analysis-asm.c
  clang/test/CodeGen/hwasan-stack-safety-analysis.c
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -109,6 +110,11 @@
cl::desc("instrument stack (allocas)"),
cl::Hidden, cl::init(true));
 
+static cl::opt
+ClUseStackSafety("hwasan-use-stack-safety", cl::Hidden, cl::init(true),
+ cl::Hidden, cl::desc("Use Stack Safety analysis results"),
+ cl::Optional);
+
 static cl::opt ClUARRetagToZero(
 "hwasan-uar-retag-to-zero",
 cl::desc("Clear alloca tags before returning from the function to allow "
@@ -210,13 +216,22 @@
 #pragma GCC poison ClInstrumentWithCalls
 }
 
+bool shouldUseStackSafetyAnalysis(const Triple &TargetTriple,
+  bool DisableOptimization) {
+  auto StackSafety = ClUseStackSafety.getNumOccurrences()
+ ? ClUseStackSafety
+ : !DisableOptimization;
+  return shouldInstrumentStack(TargetTriple) && StackSafety;
+// No one should use the option directly.
+#pragma GCC poison ClUseStackSafety
+}
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
 class HWAddressSanitizer {
 public:
-  explicit HWAddressSanitizer(Module &M, bool CompileKernel = false,
-  bool Recover = false)
-  : M(M) {
+  explicit HWAddressSanitizer(Module &M, bool CompileKernel, bool Recover,
+  const StackSafetyGlobalInfo *SSI)
+  : M(M), SSI(SSI) {
 this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
 this->CompileKernel = ClEnableKhwasan.getNumOccurrences() > 0
   ? ClEnableKhwasan
@@ -225,6 +240,8 @@
 initializeModule();
   }
 
+  void setSSI(const StackSafetyGlobalInfo *S) { SSI = S; }
+
   bool sanitizeFunction(Function &F);
   void initializeModule();
   void createHwasanCtorComdat();
@@ -277,6 +294,7 @@
 private:
   LLVMContext *C;
   Module &M;
+  const StackSafetyGlobalInfo *SSI;
   Triple TargetTriple;
   FunctionCallee HWAsanMemmove, HWAsanMemcpy, HWAsanMemset;
   FunctionCallee HWAsanHandleVfork;
@@ -347,7 +365,8 @@
   static char ID;
 
   explicit HWAddressSanitizerLegacyPass(bool CompileKernel = false,
-bool Recover = false)
+bool Recover = false,
+bool DisableOptimization = false)
   : FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover) {
 initializeHWAddressSanitizerLegacyPassPass(
 *PassRegistry::getPassRegistry());
@@ -356,11 +375,19 @@
   StringRef getPassName() const override { return "HWAddressSanitizer"; }
 
   bool doInitialization(Module &M) override {
-HWASan = std::make_unique(M, CompileKernel, Recover);
+HWASan = std::make_unique(M, CompileKernel, Recover,
+  /*SSI=*/nullptr);
 return true;
   }
 
   bool runOnFunction(Function &F) override {
+if (shouldUseStackSafetyAnalysis(Triple(F.getParent()->getTargetTriple()),
+ DisableOptimization)) {
+  // We cannot call getAnalysis in doInitialization, that would cause a
+  // crash as the required analyses are not initialized yet.
+  HWASan->setSSI(
+  &getAnalysis().getResult());
+}
 return HWASan->sanitizeFunction(F);
   }
 
@@ -369,10 +396,15 @@
 return false;
   }
 
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
+AU.addRequired();
+  }
+
 private:
   std::unique_ptr HWASan;
   bool CompileKernel;
   bool Recover;
+  bool DisableOptimization;
 };
 
 } // end anonymous namespace
@@ -388,18 +420,26 @@
 "HWAddressSanitizer: detect memory bugs using tagged addressing.", false,
 false)
 
-FunctionPass *llvm::createHWAddressSanitizerLegacyPassPass(bool CompileKernel,
-   bool Recover) {
+FunctionPass *
+llvm::createHWA

[PATCH] D106136: [Analyzer][solver] Fix equivalence class invariant violation in removeDeadBindings

2021-07-16 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: vsavchenko, NoQ, steakhal.
Herald added subscribers: manas, ASDenysPetrov, gamesh411, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is an invariant in the range based solver for equivalence classes.
We don't store class->member associations for trivial classes in the
state (`ClassMembers`). This means any SymbolSet stored in ClassMembers
must have at least two members. This invariant is violated in
removeDeadBindings, because we remove a class from `ClassMembers` only
once it became empty.

Fixing this invariant violation implies that we must prepare for element
removals from an equivalence class. An element removal might result in
downgrading a non-trivial class to trivial, also the representative
symbol might be changed. If the representative symbol has changed then
we have to re-key constraints and the disequality info.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106136

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/equivalence-classes-and-remove-dead.c

Index: clang/test/Analysis/equivalence-classes-and-remove-dead.c
===
--- /dev/null
+++ clang/test/Analysis/equivalence-classes-and-remove-dead.c
@@ -0,0 +1,64 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   2>&1 | FileCheck %s
+
+void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
+void clang_analyzer_printState();
+
+void testIntersection(int a, int b, int c) {
+  if (a < 42 && b > 15 && c >= 25 && c <= 30) {
+if (a != b)
+  return;
+
+clang_analyzer_eval(a > 15);  // expected-warning{{TRUE}}
+clang_analyzer_eval(b < 42);  // expected-warning{{TRUE}}
+clang_analyzer_eval(a <= 30); // expected-warning{{UNKNOWN}}
+
+clang_analyzer_printState(); // At this point a, b, c are alive
+// CHECK:  "constraints": [
+// CHECK-NEXT:   { "symbol": "reg_$0", "range": "{ [16, 41] }" },
+// CHECK-NEXT:   { "symbol": "reg_$1", "range": "{ [16, 41] }" },
+// CHECK-NEXT:   { "symbol": "reg_$2", "range": "{ [25, 30] }" },
+// CHECK-NEXT:   { "symbol": "(reg_$0) != (reg_$1)", "range": "{ [0, 0] }" }
+// CHECK-NEXT: ],
+// CHECK-NEXT: "equivalence_classes": [
+// CHECK-NEXT:   [ "reg_$0", "reg_$1" ]
+// CHECK-NEXT: ],
+// CHECK-NEXT: "disequality_info": null,
+
+if (c == b) {
+  // Also, it should be noted that c is dead at this point, but the
+  // constraint initially associated with c is still around.
+  clang_analyzer_printState(); // a, b are alive
+  // CHECK:  "constraints": [
+  // CHECK-NEXT:   { "symbol": "reg_$0", "range": "{ [25, 30] }" },
+  // CHECK-NEXT:   { "symbol": "reg_$1", "range": "{ [25, 30] }" },
+  // CHECK-NEXT:   { "symbol": "(reg_$0) != (reg_$1)", "range": "{ [0, 0] }" }
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "equivalence_classes": [
+  // CHECK-NEXT:   [ "reg_$0", "reg_$1" ]
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "disequality_info": null,
+  clang_analyzer_eval(a >= 25 && a <= 30); // expected-warning{{TRUE}}
+
+  clang_analyzer_printState(); // only b is alive
+  // CHECK:   "constraints": [
+  // CHECK-NEXT:{ "symbol": "reg_$1", "range": "{ [25, 30] }" }
+  // CHECK-NEXT:  ],
+  // CHECK-NEXT:  "equivalence_classes": null,
+  // CHECK-NEXT:  "disequality_info": null,
+  clang_analyzer_eval(b >= 25 && b <= 30); // expected-warning{{TRUE}}
+
+  clang_analyzer_printState(); // all died
+  // CHECK:   "constraints": null,
+  // CHECK-NEXT:  "equivalence_classes": null,
+  // CHECK-NEXT:  "disequality_info": null,
+}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -592,6 +592,16 @@
   RangeSet::Factory &F,
   ProgramStateRef State);
 
+  /// Associate new members to the class. This may result in changing the
+  /// representative symbol or downgrading from non-trivial to trivial.
+  LLVM_NODISCARD ProgramStateRef setNewMembers(SymbolSet NewMembers,
+   ProgramStateRef State);
+
+  // Remove an already empty class amongs the constraints and the disequali

[PATCH] D106136: [Analyzer][solver] Fix equivalence class invariant violation in removeDeadBindings

2021-07-16 Thread Gabor Marton via Phabricator via cfe-commits
martong added a subscriber: vabridgers.
martong added a comment.

Note1: This issue is not related to and does not fix 
https://bugs.llvm.org/show_bug.cgi?id=51109
Note2: I am about to measure any performance penalty induced by the extra 
bookkeeping we must do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106136/new/

https://reviews.llvm.org/D106136

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105498: [clang] Remove assumption about SourceLocation alignment.

2021-07-16 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: clang/lib/AST/DeclObjC.cpp:880-882
-  unsigned Size = sizeof(ParmVarDecl *) * NumParams +
-  sizeof(SourceLocation) * SelLocs.size();
   ParamsAndSelLocs = C.Allocate(Size);

Since we know the number of parameters and number of sellocs when we do the 
allocation, is there a reason we can't we split it into two separate 
allocations and reduce the complexity?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105498/new/

https://reviews.llvm.org/D105498

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106136: [Analyzer][solver] Fix equivalence class invariant violation in removeDeadBindings

2021-07-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Thanks for working on it, but it is a quite large change that I don't get the 
motivation for (it doesn't even fix the recently found bug).

Summary explains what the patch does, but for why it is done, it talks about an 
invariant that is not specified anywhere in the code.

When I was implementing it, trivial class is a symbol that was never ever equal 
to anything else.  The moment we make merge something into it, it stops being 
trivial, forever!  Representative is an implementation detail and shouldn't be 
required to represent the actual information.  What I'm saying is that 
representative can be long gone, but the class can still hold.  If we use 
representative symbol for something other than its pointer or type after it's 
gone, the mistake is using representative in the first place, not the 
motivation to make it more complex and change representatives.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106136/new/

https://reviews.llvm.org/D106136

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106137: [flang][driver] Add support for Frontend Plugins

2021-07-16 Thread Stuart Ellis via Phabricator via cfe-commits
stuartellis created this revision.
Herald added subscribers: dang, mgorny.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
stuartellis requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Introducing a plugin API and a simple HelloWorld Plugin example.
This patch adds the `-load` and `-plugin` flags to frontend driver and
the code around using custom frontend actions from within a plugin
shared library object.

It also adds to the Driver-help test to check the help option with the
updated driver flags.

Additionally, the patch creates a plugin-example test to check the
HelloWorld plugin example runs correctly. As part of this, a new CMake
flag (FLANG_BUILD_EXAMPLES) is added to allow the example to be built
and for the test to run.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106137

Files:
  clang/include/clang/Driver/Options.td
  flang/CMakeLists.txt
  flang/examples/CMakeLists.txt
  flang/examples/HelloWorld/CMakeLists.txt
  flang/examples/HelloWorld/HelloWorldPlugin.cpp
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/include/flang/Frontend/FrontendPluginRegistry.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendAction.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/CMakeLists.txt
  flang/test/Driver/driver-help.f90
  flang/test/Driver/plugin-example.f90
  flang/test/lit.cfg.py
  flang/test/lit.site.cfg.py.in
  flang/tools/flang-driver/CMakeLists.txt

Index: flang/tools/flang-driver/CMakeLists.txt
===
--- flang/tools/flang-driver/CMakeLists.txt
+++ flang/tools/flang-driver/CMakeLists.txt
@@ -27,4 +27,6 @@
   clangBasic
 )
 
+export_executable_symbols_for_plugins(flang-new)
+
 install(TARGETS flang-new DESTINATION bin)
Index: flang/test/lit.site.cfg.py.in
===
--- flang/test/lit.site.cfg.py.in
+++ flang/test/lit.site.cfg.py.in
@@ -3,6 +3,8 @@
 import sys
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_shlib_dir = path(r"@SHLIBDIR@")
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.flang_obj_root = "@FLANG_BINARY_DIR@"
 config.flang_src_dir = "@FLANG_SOURCE_DIR@"
@@ -10,8 +12,10 @@
 config.flang_intrinsic_modules_dir = "@FLANG_INTRINSIC_MODULES_DIR@"
 config.flang_llvm_tools_dir = "@CMAKE_BINARY_DIR@/bin"
 config.flang_lib_dir = "@CMAKE_BINARY_DIR@/lib"
+config.flang_examples = @FLANG_BUILD_EXAMPLES@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.flang_standalone_build = @FLANG_STANDALONE_BUILD@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 config.cc = "@CMAKE_C_COMPILER@"
 
 # Control the regression test for flang-new driver
@@ -24,6 +28,7 @@
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.flang_tools_dir = config.flang_tools_dir % lit_config.params
+config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
 key, = e.args
Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -30,6 +30,8 @@
'.CUF', '.f18', '.F18', '.fir', '.f03', '.F03', '.f08', '.F08']
 
 config.substitutions.append(('%PATH%', config.environment['PATH']))
+config.substitutions.append(('%llvmshlibdir', config.llvm_shlib_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
 
 llvm_config.use_default_substitutions()
 
@@ -45,6 +47,14 @@
 else:
   config.available_features.add('old-flang-driver')
 
+# If the flang examples are built, add examples to the config
+if config.flang_examples:
+config.available_features.add('examples')
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
+
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)
 
Index: flang/test/Driver/plugin-example.f90
===
--- /dev/null
+++ flang/test/Driver/plugin-example.f90
@@ -0,0 +1,7 @@
+! Check that loading and running the Hello World plugin example results in the correct print statement
+! This requires that the examples are built (FLANG_BUILD_EXAMPLES=ON)
+
+! REQUIRES: new-flang-driver, plugins, examples
+
+! RUN: %flang_fc1 -load %llvmshlibdir/flangHelloWorldPlugin%pluginext -plugin -hello-world %s 2>&1 | FileCheck %s
+! CHECK: Hello World from your new plugin
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -109,11 +109,13 @@
 ! HELP-FC1-NEXT: -help  

[PATCH] D98709: [clang-tidy] New feature --skip-headers, (tested as default)

2021-07-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 359271.
chh retitled this revision from "[clang-tidy] Add --skip-headers, part 1" to 
"[clang-tidy] New feature --skip-headers, (tested as default)".
chh edited the summary of this revision.
chh added a comment.

sync with latest source, update more tests to test skip-headers as default


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98709/new/

https://reviews.llvm.org/D98709

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  
clang-tools-extra/test/clang-tidy/checkers/abseil-upgrade-duration-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -1202,6 +1202,8 @@
   if (!DeclNode) {
 return true;
   }
+  if (Options.Filter && Options.Filter->skipDecl(DeclNode))
+return true;
 
   bool ScopedTraversal =
   TraversingASTNodeNotSpelledInSource || DeclNode->isImplicit();
@@ -1454,5 +1456,8 @@
   return llvm::None;
 }
 
+// Out of line key method.
+MatchFinder::MatchFinderOptions::DeclFilter::~DeclFilter() = default;
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -133,11 +133,19 @@
   /// Per bucket timing information.
   llvm::StringMap &Records;
 };
+struct DeclFilter {
+  virtual bool skipDecl(Decl *) = 0;
+  virtual bool skipLocation(SourceLocation) = 0;
+  virtual ~DeclFilter();
+};
 
 /// Enables per-check timers.
 ///
 /// It prints a report after match.
 llvm::Optional CheckProfiling;
+
+/// Check if a Decl should be skipped.
+std::shared_ptr Filter;
   };
 
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
Index: clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cp

[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Uday Bondhugula via Phabricator via cfe-commits
bondhugula added a comment.

This is a really welcome change! Multiple registration issues were really an 
inconvenience - I had no clue this was the pattern to use to fix it. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 359191.
mehdi_amini marked 7 inline comments as done.
mehdi_amini added a comment.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added projects: clang, clang-tools-extra.

Address comment and fix build errors


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/ARMAttributeParser.h
  llvm/include/llvm/Support/ARMBuildAttributes.h
  llvm/include/llvm/Support/CommandLine.h
  llvm/include/llvm/Support/RISCVAttributeParser.h
  llvm/include/llvm/Support/RISCVAttributes.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/include/llvm/Support/WithColor.h
  llvm/lib/Support/ARMBuildAttrs.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Support/Debug.cpp
  llvm/lib/Support/DebugCounter.cpp
  llvm/lib/Support/DebugOptions.h
  llvm/lib/Support/ELFAttributeParser.cpp
  llvm/lib/Support/GraphWriter.cpp
  llvm/lib/Support/RISCVAttributes.cpp
  llvm/lib/Support/RandomNumberGenerator.cpp
  llvm/lib/Support/Signals.cpp
  llvm/lib/Support/Statistic.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/TypeSize.cpp
  llvm/lib/Support/WithColor.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/unittests/Support/ARMAttributeParser.cpp
  llvm/unittests/Support/CommandLineTest.cpp
  llvm/unittests/Support/RISCVAttributeParserTest.cpp

Index: llvm/unittests/Support/RISCVAttributeParserTest.cpp
===
--- llvm/unittests/Support/RISCVAttributeParserTest.cpp
+++ llvm/unittests/Support/RISCVAttributeParserTest.cpp
@@ -49,7 +49,7 @@
 }
 
 static bool testTagString(unsigned Tag, const char *name) {
-  return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::RISCVAttributeTags)
+  return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::getRISCVAttributeTags())
  .str() == name;
 }
 
Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -110,7 +110,7 @@
   ASSERT_NE(Retrieved->Categories.end(),
 find_if(Retrieved->Categories,
 [&](const llvm::cl::OptionCategory *Cat) {
-  return Cat == &cl::GeneralCategory;
+  return Cat == &cl::getGeneralCategory();
 }))
   << "Incorrect default option category.";
 
@@ -152,10 +152,10 @@
 
 TEST(CommandLineTest, UseMultipleCategories) {
   StackOption TestOption2("test-option2", cl::cat(TestCategory),
-   cl::cat(cl::GeneralCategory),
-   cl::cat(cl::GeneralCategory));
+   cl::cat(cl::getGeneralCategory()),
+   cl::cat(cl::getGeneralCategory()));
 
-  // Make sure cl::GeneralCategory wasn't added twice.
+  // Make sure cl::getGeneralCategory() wasn't added twice.
   ASSERT_EQ(TestOption2.Categories.size(), 2U);
 
   ASSERT_NE(TestOption2.Categories.end(),
@@ -166,9 +166,9 @@
   << "Failed to assign Option Category.";
   ASSERT_NE(TestOption2.Categories.end(),
 find_if(TestOption2.Categories,
- [&](const llvm::cl::OptionCategory *Cat) {
-   return Cat == &cl::GeneralCategory;
- }))
+[&](const llvm::cl::OptionCategory *Cat) {
+  return Cat == &cl::getGeneralCategory();
+}))
   << "Failed to assign General Category.";
 
   cl::OptionCategory AnotherCategory("Additional test Options", "Description");
@@ -176,9 +176,9 @@
   cl::cat(AnotherCategory));
   ASSERT_EQ(TestOption.Categories.end(),
 find_if(TestOption.Categories,
- [&](const llvm::cl::OptionCategory *Cat) {
-   return Cat == &cl::GeneralCategory;
- }))
+[&](const llvm::cl::OptionCategory *Cat) {
+  return Cat == &cl::getGeneralCategory();
+}))
   << "Failed to remove General Category.";
   ASSERT_NE(TestOption.Categories.end(),
 find_if(TestOption.Categories,
Index: llvm/unittests/Support/ARMAttributeParser.cpp
===
--- llvm/unittests/Support/ARMAttributeParser.cpp
+++ llvm/unit

[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 359196.
mehdi_amini added a comment.

Fix windows build


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/ARMAttributeParser.h
  llvm/include/llvm/Support/ARMBuildAttributes.h
  llvm/include/llvm/Support/CommandLine.h
  llvm/include/llvm/Support/RISCVAttributeParser.h
  llvm/include/llvm/Support/RISCVAttributes.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/include/llvm/Support/WithColor.h
  llvm/lib/Support/ARMBuildAttrs.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Support/Debug.cpp
  llvm/lib/Support/DebugCounter.cpp
  llvm/lib/Support/DebugOptions.h
  llvm/lib/Support/ELFAttributeParser.cpp
  llvm/lib/Support/GraphWriter.cpp
  llvm/lib/Support/RISCVAttributes.cpp
  llvm/lib/Support/RandomNumberGenerator.cpp
  llvm/lib/Support/Signals.cpp
  llvm/lib/Support/Statistic.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/TypeSize.cpp
  llvm/lib/Support/Windows/Signals.inc
  llvm/lib/Support/WithColor.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/unittests/Support/ARMAttributeParser.cpp
  llvm/unittests/Support/CommandLineTest.cpp
  llvm/unittests/Support/RISCVAttributeParserTest.cpp

Index: llvm/unittests/Support/RISCVAttributeParserTest.cpp
===
--- llvm/unittests/Support/RISCVAttributeParserTest.cpp
+++ llvm/unittests/Support/RISCVAttributeParserTest.cpp
@@ -49,7 +49,7 @@
 }
 
 static bool testTagString(unsigned Tag, const char *name) {
-  return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::RISCVAttributeTags)
+  return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::getRISCVAttributeTags())
  .str() == name;
 }
 
Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -110,7 +110,7 @@
   ASSERT_NE(Retrieved->Categories.end(),
 find_if(Retrieved->Categories,
 [&](const llvm::cl::OptionCategory *Cat) {
-  return Cat == &cl::GeneralCategory;
+  return Cat == &cl::getGeneralCategory();
 }))
   << "Incorrect default option category.";
 
@@ -152,10 +152,10 @@
 
 TEST(CommandLineTest, UseMultipleCategories) {
   StackOption TestOption2("test-option2", cl::cat(TestCategory),
-   cl::cat(cl::GeneralCategory),
-   cl::cat(cl::GeneralCategory));
+   cl::cat(cl::getGeneralCategory()),
+   cl::cat(cl::getGeneralCategory()));
 
-  // Make sure cl::GeneralCategory wasn't added twice.
+  // Make sure cl::getGeneralCategory() wasn't added twice.
   ASSERT_EQ(TestOption2.Categories.size(), 2U);
 
   ASSERT_NE(TestOption2.Categories.end(),
@@ -166,9 +166,9 @@
   << "Failed to assign Option Category.";
   ASSERT_NE(TestOption2.Categories.end(),
 find_if(TestOption2.Categories,
- [&](const llvm::cl::OptionCategory *Cat) {
-   return Cat == &cl::GeneralCategory;
- }))
+[&](const llvm::cl::OptionCategory *Cat) {
+  return Cat == &cl::getGeneralCategory();
+}))
   << "Failed to assign General Category.";
 
   cl::OptionCategory AnotherCategory("Additional test Options", "Description");
@@ -176,9 +176,9 @@
   cl::cat(AnotherCategory));
   ASSERT_EQ(TestOption.Categories.end(),
 find_if(TestOption.Categories,
- [&](const llvm::cl::OptionCategory *Cat) {
-   return Cat == &cl::GeneralCategory;
- }))
+[&](const llvm::cl::OptionCategory *Cat) {
+  return Cat == &cl::getGeneralCategory();
+}))
   << "Failed to remove General Category.";
   ASSERT_NE(TestOption.Categories.end(),
 find_if(TestOption.Categories,
Index: llvm/unittests/Support/ARMAttributeParser.cpp
===
--- llvm/unittests/Support/ARMAttributeParser.cpp
+++ llvm/unittests/Support/ARMAttributeParser.cpp
@@ -48,7 +48,7 @@
 }
 
 bool testTagString(unsigned Tag, const char *name) {
-  return ELFAttrs::attrTypeAsS

[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D105959#2882099 , @bondhugula 
wrote:

> This is a really welcome change! Multiple registration issues were really an 
> inconvenience - I had no clue this was the pattern to use to fix it. Thanks!

To be fair: we can do it transparently only for libSupport, as it contains the 
entry point for command line parsing it can explicitly trigger the registration 
of the options for itself. Other libraries in LLVM don't have this luxury...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Mehdi AMINI via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42f588f39c5c: Use ManagedStatic and lazy initialization of 
cl::opt in libSupport to make it… (authored by mehdi_amini).

Changed prior to commit:
  https://reviews.llvm.org/D105959?vs=359196&id=359201#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/ARMAttributeParser.h
  llvm/include/llvm/Support/ARMBuildAttributes.h
  llvm/include/llvm/Support/CommandLine.h
  llvm/include/llvm/Support/RISCVAttributeParser.h
  llvm/include/llvm/Support/RISCVAttributes.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/include/llvm/Support/WithColor.h
  llvm/lib/Support/ARMBuildAttrs.cpp
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Support/Debug.cpp
  llvm/lib/Support/DebugCounter.cpp
  llvm/lib/Support/DebugOptions.h
  llvm/lib/Support/ELFAttributeParser.cpp
  llvm/lib/Support/GraphWriter.cpp
  llvm/lib/Support/RISCVAttributes.cpp
  llvm/lib/Support/RandomNumberGenerator.cpp
  llvm/lib/Support/Signals.cpp
  llvm/lib/Support/Statistic.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/TypeSize.cpp
  llvm/lib/Support/Windows/Signals.inc
  llvm/lib/Support/WithColor.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/unittests/Support/ARMAttributeParser.cpp
  llvm/unittests/Support/CommandLineTest.cpp
  llvm/unittests/Support/RISCVAttributeParserTest.cpp

Index: llvm/unittests/Support/RISCVAttributeParserTest.cpp
===
--- llvm/unittests/Support/RISCVAttributeParserTest.cpp
+++ llvm/unittests/Support/RISCVAttributeParserTest.cpp
@@ -49,7 +49,7 @@
 }
 
 static bool testTagString(unsigned Tag, const char *name) {
-  return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::RISCVAttributeTags)
+  return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::getRISCVAttributeTags())
  .str() == name;
 }
 
Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -110,7 +110,7 @@
   ASSERT_NE(Retrieved->Categories.end(),
 find_if(Retrieved->Categories,
 [&](const llvm::cl::OptionCategory *Cat) {
-  return Cat == &cl::GeneralCategory;
+  return Cat == &cl::getGeneralCategory();
 }))
   << "Incorrect default option category.";
 
@@ -152,10 +152,10 @@
 
 TEST(CommandLineTest, UseMultipleCategories) {
   StackOption TestOption2("test-option2", cl::cat(TestCategory),
-   cl::cat(cl::GeneralCategory),
-   cl::cat(cl::GeneralCategory));
+   cl::cat(cl::getGeneralCategory()),
+   cl::cat(cl::getGeneralCategory()));
 
-  // Make sure cl::GeneralCategory wasn't added twice.
+  // Make sure cl::getGeneralCategory() wasn't added twice.
   ASSERT_EQ(TestOption2.Categories.size(), 2U);
 
   ASSERT_NE(TestOption2.Categories.end(),
@@ -166,9 +166,9 @@
   << "Failed to assign Option Category.";
   ASSERT_NE(TestOption2.Categories.end(),
 find_if(TestOption2.Categories,
- [&](const llvm::cl::OptionCategory *Cat) {
-   return Cat == &cl::GeneralCategory;
- }))
+[&](const llvm::cl::OptionCategory *Cat) {
+  return Cat == &cl::getGeneralCategory();
+}))
   << "Failed to assign General Category.";
 
   cl::OptionCategory AnotherCategory("Additional test Options", "Description");
@@ -176,9 +176,9 @@
   cl::cat(AnotherCategory));
   ASSERT_EQ(TestOption.Categories.end(),
 find_if(TestOption.Categories,
- [&](const llvm::cl::OptionCategory *Cat) {
-   return Cat == &cl::GeneralCategory;
- }))
+[&](const llvm::cl::OptionCategory *Cat) {
+  return Cat == &cl::getGeneralCategory();
+}))
   << "Failed to remove General Category.";
   ASSERT_NE(TestOption.Categories.end(),
 find_if(TestOption.Categories,
Index: llvm/unittests/Support/ARMAttributeParser.cpp
==

[PATCH] D105946: [PowerPC] Store, load, move from and to registers related builtins

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

This is getting close to approval. The newly added `__stfiw` needs to be fixed 
and some nits need to be addressed.




Comment at: clang/lib/Sema/SemaChecking.cpp:3369
+  case PPC::BI__builtin_ppc_stfiw:
+return SemaFeatureCheck(*this, TheCall, "isa-v30-instructions",
+diag::err_ppc_builtin_only_on_arch, "9");

This is not correct. The instruction (non-VSX version) has existed since 
Power3. The VSX version was added in Power8. No changes to the instruction came 
in Power9 so I have no idea where the decision to add this check came from.

In fact, this would also blow up in the back end if you compiled with something 
like `-mcpu=pwr9 -mno-altivec` or `-mcpu=pwr9 -mno-vsx`.



Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:1568
 [IntrWriteMem]>;
+  def int_ppc_sthcx : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty], 
[IntrWriteMem]>;
+  def int_ppc_dcbtstt : GCCBuiltin<"__builtin_ppc_dcbtstt">,

Nit: line too long.



Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:1577
+  Intrinsic<[llvm_i32_ty], [], [IntrNoMem]>;
+def int_ppc_stfiw : GCCBuiltin<"__builtin_ppc_stfiw">,
+Intrinsic<[], [llvm_ptr_ty, llvm_double_ty], 
[IntrWriteMem]>;

Nit: indentation is inconsistent here.



Comment at: llvm/lib/Target/PowerPC/PPCInstrVSX.td:4072
+
+def : Pat<(int_ppc_stfiw ForceXForm:$dst, f64:$XT),
+  (STXSIWX f64:$XT, ForceXForm:$dst)>;

This needs the non-VSX pattern as well.



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-stfiw.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \

One of the run lines should be with `-mattr=-vsx`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105946/new/

https://reviews.llvm.org/D105946

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106120: [PowerPC] Implement vector bool/pixel initialization under -faltivec-src-compat=xl

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

Why are `vector-scalar-altivec-init.c` and `vector-scalar-altivec-init2.c` 
added? There is no initialization of `vector bool` or `vector pixel` in them so 
I don't really see the need to add them. If it is just to test that the 
existing behaviour doesn't change for those, you can simply add two run lines 
for `xl` and `mixed` to existing test cases.

Also, please unify `vector-bool-pixel-altivec-init.c` and 
`vector-bool-pixel-altivec-init2.c` into a single test case. It is not 
immediately obvious to the reader that the difference is parenthesized vs. 
unparenthesized initialization.




Comment at: clang/include/clang/Sema/Sema.h:6097
+  // option, these types also splat the scalar value.
+  bool ShouldSplatAltivecScalarInCast(Sema &Self, const VectorType *VecTy);
+

Why take a `Sema &` parameter? It is called `Self` so presumably it is expected 
to point to `*this`. Is there a use case where it points to a different 
instance of `Sema`?



Comment at: clang/lib/Sema/SemaCast.cpp:2627
 
+// Checks if we have a valid AltiVec vector type, and splats the value into
+// the vector accordingly. If a 'vector bool' or 'vector pixel' type is used

No need to repeat the comment on the implementation.



Comment at: clang/test/CodeGen/vector-bool-pixel-altivec-init.c:57
+  // MIXED: insertelement <8 x i16>
+  // XL: %splat.splatinsert1 = insertelement <8 x i16>
+  // XL-NEXT: %splat.splat2 = shufflevector <8 x i16> %splat.splatinsert1

It is generally not safe to hard-code names of virtual registers 
(`llvm::Value*`'s) in test cases. The naming is different in Release vs. Debug 
builds and it could also change for any other reason as no guarantee is ever 
made about the names.

You should test for what's important:
- The `insertelement` of the right type (save the name with `[[INS:%.*]]`)
- The use of that value for a `shufflevector` where you check the shuffle mask 
(presumably `zeroinitializer`)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106120/new/

https://reviews.llvm.org/D106120

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106112: [clang-format] Break an unwrapped line at a K&R C parameter decl

2021-07-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Thanks for this, LGTM, maybe give the others some time


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106112/new/

https://reviews.llvm.org/D106112

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106065: [Clang] Add an empty builtins.h file.

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106065/new/

https://reviews.llvm.org/D106065

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105984: [PowerPC] Restore FastMathFlags of Builder for Vector FDiv Builtins

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for fixing this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105984/new/

https://reviews.llvm.org/D105984

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105660: [PowerPC][AIX] Add warning when alignment is incompatible with XL

2021-07-16 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3255-3256
+def warn_not_xl_compatible
+: Warning<"requested alignment of arguments 16 bytes or greater is not"
+  " compatible with previous versions of the AIX XL compiler">,
+  InGroup>;

aaron.ballman wrote:
> ZarkoCA wrote:
> > aaron.ballman wrote:
> > > ZarkoCA wrote:
> > > > aaron.ballman wrote:
> > > > > ZarkoCA wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Should we be talking about the AIX XL compiler in a Clang 
> > > > > > > diagnostic?
> > > > > > I see your point. Sorry if this isn't what is supposed to be done 
> > > > > > or if it doesn't a good precedent.
> > > > > > 
> > > > > > The reasons for adding this warning is that our back end 
> > > > > > implementation isn't totally compatible with XL now and, while 
> > > > > > buggy, users on AIX may expect clang and xlclang to be compatible 
> > > > > > since AIX is the reference compiler.  The xlclang name implies it's 
> > > > > > clang based and it's possible for users to expect some sort of 
> > > > > > binary compatibility.
> > > > > > 
> > > > > > I see your point. Sorry if this isn't what is supposed to be done 
> > > > > > or if it doesn't a good precedent.
> > > > > 
> > > > > No worries, it's a good discussion to have! We have some MSVC and GCC 
> > > > > compatibility warnings, so there's precedent for naming other 
> > > > > compilers. Now that you've moved the diagnostic into an AIX 
> > > > > compatibility diagnostic group, I am more comfortable with it. Thanks!
> > > > Thanks, glad it's better now. 
> > > I missed this last time, sorry, but is "arguments" actually necessary for 
> > > the diagnostic or can that be dropped?
> > It actually isn't correct, the warning should apply only to members of 
> > structs.  Thanks for bringing it to my attention again, I also missed this 
> > the last time. 
> Huttah for code review working as intended! :-)
Indeed, thank you for the timely reviews. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105660/new/

https://reviews.llvm.org/D105660

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 66225db - [PowerPC][AIX] Add warning when alignment is incompatible with XL

2021-07-16 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2021-07-16T07:52:47-04:00
New Revision: 66225db98d832bec75ffb96298107c015b0035f0

URL: 
https://github.com/llvm/llvm-project/commit/66225db98d832bec75ffb96298107c015b0035f0
DIFF: 
https://github.com/llvm/llvm-project/commit/66225db98d832bec75ffb96298107c015b0035f0.diff

LOG: [PowerPC][AIX] Add warning when alignment is incompatible with XL

https://reviews.llvm.org/D105659 implements ByVal handling in llc but
some cases are not compatible with existing XL compiler on AIX.  Adding
a clang warning for such cases.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D105660

Added: 
clang/test/Sema/aix-attr-align.c

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 18097cfcfffe..eb1b5641bfdf 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1083,6 +1083,9 @@ def GNU : DiagGroup<"gnu", [GNUAlignofExpression, 
GNUAnonymousStruct,
 // A warning group for warnings about code that clang accepts but gcc doesn't.
 def GccCompat : DiagGroup<"gcc-compat">;
 
+// A warning group for warnings about code that may be incompatible on AIX.
+def AIXCompat : DiagGroup<"aix-compat">;
+
 // Warnings for Microsoft extensions.
 def MicrosoftCharize : DiagGroup<"microsoft-charize">;
 def MicrosoftDrectveSection : DiagGroup<"microsoft-drectve-section">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 779093977da8..823a36a597c5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3254,6 +3254,10 @@ def warn_assume_aligned_too_great
 : Warning<"requested alignment must be %0 bytes or smaller; maximum "
   "alignment assumed">,
   InGroup>;
+def warn_not_xl_compatible
+: Warning<"requesting an alignment of 16 bytes or greater for struct"
+  " members is not binary compatible with AIX XL 16.1 and older">,
+  InGroup;
 def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
   "%q0 redeclared without %1 attribute: previous %1 ignored">,
   InGroup;

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 3586ad323b8e..9aac9d215644 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3953,6 +3953,12 @@ void Sema::AddAlignedAttr(Decl *D, const 
AttributeCommonInfo &CI, Expr *E,
 return;
 
   uint64_t AlignVal = Alignment.getZExtValue();
+  // 16 byte ByVal alignment not due to a vector member is not honoured by XL
+  // on AIX. Emit a warning here that users are generating binary incompatible
+  // code to be safe.
+  if (AlignVal >= 16 && isa(D) &&
+  Context.getTargetInfo().getTriple().isOSAIX())
+Diag(AttrLoc, diag::warn_not_xl_compatible) << E->getSourceRange();
 
   // C++11 [dcl.align]p2:
   //   -- if the constant expression evaluates to zero, the alignment

diff  --git a/clang/test/Sema/aix-attr-align.c 
b/clang/test/Sema/aix-attr-align.c
new file mode 100644
index ..ac70aab66900
--- /dev/null
+++ b/clang/test/Sema/aix-attr-align.c
@@ -0,0 +1,22 @@
+// off-no-diagnostics
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify=off -Wno-aix-compat 
-fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify=off -Wno-aix-compat 
-fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only 
%s
+
+struct S {
+  int a[8] __attribute__((aligned(8))); // no-warning
+};
+
+struct T {
+  int a[4] __attribute__((aligned(16))); // expected-warning {{requesting an 
alignment of 16 bytes or greater for struct members is not binary compatible 
with AIX XL 16.1 and older}}
+};
+
+struct U {
+  int a[2] __attribute__((aligned(32))); // expected-warning {{requesting an 
alignment of 16 bytes or greater for struct members is not binary compatible 
with AIX XL 16.1 and older}}
+};
+
+int a[8] __attribute__((aligned(8)));  // no-warning
+int b[4] __attribute__((aligned(16))); // no-warning
+int c[2] __attribute__((aligned(32))); // no-warning



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105660: [PowerPC][AIX] Add warning when alignment is incompatible with XL

2021-07-16 Thread Zarko Todorovski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66225db98d83: [PowerPC][AIX] Add warning when alignment is 
incompatible with XL (authored by ZarkoCA).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105660/new/

https://reviews.llvm.org/D105660

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/aix-attr-align.c


Index: clang/test/Sema/aix-attr-align.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-align.c
@@ -0,0 +1,22 @@
+// off-no-diagnostics
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify=off -Wno-aix-compat 
-fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify=off -Wno-aix-compat 
-fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only 
%s
+
+struct S {
+  int a[8] __attribute__((aligned(8))); // no-warning
+};
+
+struct T {
+  int a[4] __attribute__((aligned(16))); // expected-warning {{requesting an 
alignment of 16 bytes or greater for struct members is not binary compatible 
with AIX XL 16.1 and older}}
+};
+
+struct U {
+  int a[2] __attribute__((aligned(32))); // expected-warning {{requesting an 
alignment of 16 bytes or greater for struct members is not binary compatible 
with AIX XL 16.1 and older}}
+};
+
+int a[8] __attribute__((aligned(8)));  // no-warning
+int b[4] __attribute__((aligned(16))); // no-warning
+int c[2] __attribute__((aligned(32))); // no-warning
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3953,6 +3953,12 @@
 return;
 
   uint64_t AlignVal = Alignment.getZExtValue();
+  // 16 byte ByVal alignment not due to a vector member is not honoured by XL
+  // on AIX. Emit a warning here that users are generating binary incompatible
+  // code to be safe.
+  if (AlignVal >= 16 && isa(D) &&
+  Context.getTargetInfo().getTriple().isOSAIX())
+Diag(AttrLoc, diag::warn_not_xl_compatible) << E->getSourceRange();
 
   // C++11 [dcl.align]p2:
   //   -- if the constant expression evaluates to zero, the alignment
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3254,6 +3254,10 @@
 : Warning<"requested alignment must be %0 bytes or smaller; maximum "
   "alignment assumed">,
   InGroup>;
+def warn_not_xl_compatible
+: Warning<"requesting an alignment of 16 bytes or greater for struct"
+  " members is not binary compatible with AIX XL 16.1 and older">,
+  InGroup;
 def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
   "%q0 redeclared without %1 attribute: previous %1 ignored">,
   InGroup;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1083,6 +1083,9 @@
 // A warning group for warnings about code that clang accepts but gcc doesn't.
 def GccCompat : DiagGroup<"gcc-compat">;
 
+// A warning group for warnings about code that may be incompatible on AIX.
+def AIXCompat : DiagGroup<"aix-compat">;
+
 // Warnings for Microsoft extensions.
 def MicrosoftCharize : DiagGroup<"microsoft-charize">;
 def MicrosoftDrectveSection : DiagGroup<"microsoft-drectve-section">;


Index: clang/test/Sema/aix-attr-align.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-align.c
@@ -0,0 +1,22 @@
+// off-no-diagnostics
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify=off -Wno-aix-compat -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify=off -Wno-aix-compat -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only %s
+
+struct S {
+  int a[8] __attribute__((aligned(8))); // no-warning
+};
+
+struct T {
+  int a[4] __attribute__((aligned(16))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with AIX XL 16.1 and older}}
+};
+
+struct U {
+  int a[2] __attribute__((aligned(32))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not bin

[PATCH] D106093: SubstTemplateTypeParmType can contain an 'auto' type in their replacement type

2021-07-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a style nit, thanks for the fix!




Comment at: clang/lib/AST/Type.cpp:1804
 // Only these types can contain the desired 'auto' type.
+Type *VisitSubstTemplateTypeParmType(SubstTemplateTypeParmType const *T) {
+  return Visit(T->getReplacementType());




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106093/new/

https://reviews.llvm.org/D106093

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106130: [PowerPC] Implemented mtmsr, mfspr, mtspr Builtins

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

Why does this review have no reviewers listed?




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15586
+  case PPC::BI__builtin_ppc_mfspr: {
+llvm::Type *RetType = CGM.getDataLayout().getTypeSizeInBits(VoidPtrTy) == 
32
+  ? Int32Ty

Is this the formatting that `clang-format` produces? Seems surprising it would 
format it that way.



Comment at: clang/lib/Sema/SemaChecking.cpp:3374
+  case PPC::BI__builtin_ppc_mfspr:
+return SemaBuiltinConstantArgRange(TheCall, 0, 1, 898);
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \

I don't think we should enforce the range. The architecture may add more SPR's 
in the future and then this check will need to be updated. Just ensure that the 
register number (as well as the value for `mtspr`) are constants.



Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:1581
   Intrinsic<[llvm_i32_ty], [], [IntrNoMem]>;
+  def int_ppc_mfspr : Intrinsic<[llvm_anyint_ty], [llvm_i32_ty], 
[ImmArg>]>;
+  def int_ppc_mtmsr

Nit: line too long



Comment at: llvm/lib/Target/PowerPC/PPCInstr64Bit.td:415
 
-
 
//===--===//

Unrelated whitespace change.



Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.td:5442
 def : Pat<(int_ppc_mftbu), (MFTB 269)>;
+def : Pat<(i32 (int_ppc_mfspr i32:$SPR)),
+  (MFSPR $SPR)>;

Shouldn't this be `imm` instead of `i32`?
Have you tried compiling the test cases with `-filetype=obj` and/or with 
`-ppc-asm-full-reg-names`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106130/new/

https://reviews.llvm.org/D106130

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106093: SubstTemplateTypeParmType can contain an 'auto' type in their replacement type

2021-07-16 Thread serge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ada884cbc2f: SubstTemplateTypeParmType can contain an 
'auto' type in their replacement type (authored by serge-sans-paille).

Changed prior to commit:
  https://reviews.llvm.org/D106093?vs=359101&id=359293#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106093/new/

https://reviews.llvm.org/D106093

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/crash-auto-36064.cpp


Index: clang/test/SemaCXX/crash-auto-36064.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/crash-auto-36064.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+template  // expected-error{{new expression for 
type 'auto' requires a constructor argument}}
+struct b;
+struct d {
+  static auto c = ;  // expected-error{{expected expression}}
+  decltype(b); // expected-error{{expected '(' for 
function-style cast or type construction}}
+ // expected-note@-1{{while substituting prior 
template arguments into non-type template parameter [with A = auto]}}
+};
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -1801,6 +1801,9 @@
 }
 
 // Only these types can contain the desired 'auto' type.
+Type *VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
+  return Visit(T->getReplacementType());
+}
 
 Type *VisitElaboratedType(const ElaboratedType *T) {
   return Visit(T->getNamedType());


Index: clang/test/SemaCXX/crash-auto-36064.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/crash-auto-36064.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+template  // expected-error{{new expression for type 'auto' requires a constructor argument}}
+struct b;
+struct d {
+  static auto c = ;  // expected-error{{expected expression}}
+  decltype(b); // expected-error{{expected '(' for function-style cast or type construction}}
+ // expected-note@-1{{while substituting prior template arguments into non-type template parameter [with A = auto]}}
+};
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -1801,6 +1801,9 @@
 }
 
 // Only these types can contain the desired 'auto' type.
+Type *VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
+  return Visit(T->getReplacementType());
+}
 
 Type *VisitElaboratedType(const ElaboratedType *T) {
   return Visit(T->getNamedType());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8ada884 - SubstTemplateTypeParmType can contain an 'auto' type in their replacement type

2021-07-16 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-07-16T14:35:55+02:00
New Revision: 8ada884cbc2f02863cd71bddd97c7ff206ad3256

URL: 
https://github.com/llvm/llvm-project/commit/8ada884cbc2f02863cd71bddd97c7ff206ad3256
DIFF: 
https://github.com/llvm/llvm-project/commit/8ada884cbc2f02863cd71bddd97c7ff206ad3256.diff

LOG: SubstTemplateTypeParmType can contain an 'auto' type in their replacement 
type

This fixes bug 36064

Differential Revision: https://reviews.llvm.org/D106093

Added: 
clang/test/SemaCXX/crash-auto-36064.cpp

Modified: 
clang/lib/AST/Type.cpp

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index d3d0003e5adb..4a2fc5219ef0 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -1801,6 +1801,9 @@ namespace {
 }
 
 // Only these types can contain the desired 'auto' type.
+Type *VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
+  return Visit(T->getReplacementType());
+}
 
 Type *VisitElaboratedType(const ElaboratedType *T) {
   return Visit(T->getNamedType());

diff  --git a/clang/test/SemaCXX/crash-auto-36064.cpp 
b/clang/test/SemaCXX/crash-auto-36064.cpp
new file mode 100644
index ..5678cd8b730b
--- /dev/null
+++ b/clang/test/SemaCXX/crash-auto-36064.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+template  // expected-error{{new expression for 
type 'auto' requires a constructor argument}}
+struct b;
+struct d {
+  static auto c = ;  // expected-error{{expected expression}}
+  decltype(b); // expected-error{{expected '(' for 
function-style cast or type construction}}
+ // expected-note@-1{{while substituting prior 
template arguments into non-type template parameter [with A = auto]}}
+};



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106146: [clang][deps] Separate filesystem caches for minimized and original files

2021-07-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 added a project: clang.
Herald added a subscriber: mgorny.
jansvoboda11 requested review of this revision.

This patch separates the local and global caches of 
`DependencyScanningFilesystem` into two buckets: minimized files and original 
files. This is necessary to deal with precompiled modules/headers.

Consider a single worker with its instance of filesystem:

1. Build system uses the worker to scan dependencies of module A => filesystem 
cache gets populated with minimized input files.
2. Build system uses the results to explicitly build module A => explicitly 
built module captures the state of the real filesystem (containing 
non-minimized input files).
3. Build system uses the prebuilt module A as an explicit precompiled 
dependency for another compile job B.
4. Build system uses the same worker to scan dependencies for job B => worker 
uses implicit modular build to discover dependencies, which validates the 
filesystem state embedded in the prebuilt module (non-minimized files) to the 
current view of the filesystem (minimized files), resulting in validation 
failures.

This problem can be avoided in step 4 by collecting input files from the 
precompiled module and marking them as "ignored" in the minimizing filesystem. 
This way, the validation should succeed, since we should be always dealing with 
the original (non-minized) input files. However, the filesystem already 
minimized the input files in step 1 and put it in the cache, which gets used in 
step 4 as well even though it's marked ignored (do not minimize). This patch 
essentially fixes this oversight by making the `"file is minimized"` part of 
the cache key (from high level).

Depends on D106064 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106146

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
@@ -203,5 +204,35 @@
   EXPECT_EQ(convert_to_slash(Deps[5]), "/root/symlink.h");
 }
 
+namespace dependencies {
+TEST(DependencyScanningFilesystem, IgnoredFilesHaveSeparateCache) {
+  auto VFS = llvm::makeIntrusiveRefCnt();
+  VFS->addFile("/mod.h", 0, llvm::MemoryBuffer::getMemBuffer("// hi there!\n"));
+
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto Mappings = std::make_unique();
+  DependencyScanningWorkerFilesystem DepFS(SharedCache, VFS, Mappings.get());
+
+  auto StatusMinimized0 = DepFS.status("/mod.h");
+  DepFS.ignoreFile("/mod.h");
+  auto StatusFull1 = DepFS.status("/mod.h");
+  DepFS.clearIgnoredFiles();
+
+  auto StatusMinimized2 = DepFS.status("/mod.h");
+  DepFS.ignoreFile("/mod.h");
+  auto StatusFull3 = DepFS.status("/mod.h");
+
+  EXPECT_TRUE(StatusMinimized0);
+  EXPECT_EQ(StatusMinimized0->getSize(), 0u);
+  EXPECT_TRUE(StatusFull1);
+  EXPECT_EQ(StatusFull1->getSize(), 13u);
+
+  EXPECT_TRUE(StatusMinimized2);
+  EXPECT_EQ(StatusMinimized2->getSize(), 0u);
+  EXPECT_TRUE(StatusFull3);
+  EXPECT_EQ(StatusFull3->getSize(), 13u);
+}
+
+} // end namespace dependencies
 } // end namespace tooling
 } // end namespace clang
Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -68,6 +68,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangDependencyScanning
   clangFormat
   clangFrontend
   clangLex
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -99,8 +99,7 @@
   return Result;
 }
 
-DependencyScanningFilesystemSharedCache::
-DependencyScanningFilesystemSharedCache() {
+DependencyScanningFilesystemSharedCache::SingleCache::SingleCache() {
   // This heuristic was chosen using a empirical testing on a
   // reasonably high core machine (iMacPro 18 cores / 36 threads). The cache
   // sharding gives a performance edge by reducing the lock contention.
@@ -111,18 +110,20 @@
   CacheShards = std::m

[PATCH] D106084: [DebugInfo] Switch to using constructor homing (-debug-info-kind=constructor) by default when debug info is enabled

2021-07-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a reviewer: jmorse.
probinson added a subscriber: jmorse.
probinson added a comment.

+ @jmorse who is better placed than I am to say whether this is what Sony would 
prefer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106084/new/

https://reviews.llvm.org/D106084

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104536: [clang][deps] Avoid minimizing PCH input files

2021-07-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 359299.
jansvoboda11 added a comment.

Rebase on top of D106146 .


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104536/new/

https://reviews.llvm.org/D104536

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/modules-pch.c

Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -6,7 +6,7 @@
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb.json
 // RUN: echo -%t > %t/result_pch.json
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
-// RUN:   -generate-modules-path-args -module-files-dir %t/build -mode preprocess >> %t/result_pch.json
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_pch.json
 // RUN: cat %t/result_pch.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-PCH
 //
 // Check we didn't build the PCH during dependency scanning.
@@ -127,9 +127,8 @@
 //
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb.json
 // RUN: echo -%t > %t/result_tu.json
-// FIXME: Make this work with '-mode preprocess-minimized-sources'.
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
-// RUN:   -generate-modules-path-args -module-files-dir %t/build -mode preprocess >> %t/result_tu.json
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_tu.json
 // RUN: cat %t/result_tu.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-TU
 //
 // CHECK-TU:  -[[PREFIX:.*]]
@@ -193,7 +192,7 @@
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb.json
 // RUN: echo -%t > %t/result_tu_with_common.json
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
-// RUN:   -generate-modules-path-args -module-files-dir %t/build -mode preprocess >> %t/result_tu_with_common.json
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_tu_with_common.json
 // RUN: cat %t/result_tu_with_common.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-TU-WITH-COMMON
 //
 // CHECK-TU-WITH-COMMON:  -[[PREFIX:.*]]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -46,25 +46,73 @@
   DependencyConsumer &C;
 };
 
-/// A listener that collects the names and paths to imported modules.
-class ImportCollectingListener : public ASTReaderListener {
-  using PrebuiltModuleFilesT =
-  decltype(HeaderSearchOptions::PrebuiltModuleFiles);
-
+/// A listener that collects the imported modules and optionally the input
+/// files.
+class PrebuiltModuleListener : public ASTReaderListener {
 public:
-  ImportCollectingListener(PrebuiltModuleFilesT &PrebuiltModuleFiles)
-  : PrebuiltModuleFiles(PrebuiltModuleFiles) {}
+  PrebuiltModuleListener(llvm::StringMap &PrebuiltModuleFiles,
+ llvm::StringSet<> &InputFiles, bool VisitInputFiles)
+  : PrebuiltModuleFiles(PrebuiltModuleFiles), InputFiles(InputFiles),
+VisitInputFiles(VisitInputFiles) {}
 
   bool needsImportVisitation() const override { return true; }
+  bool needsInputFileVisitation() override { return VisitInputFiles; }
+  bool needsSystemInputFileVisitation() override { return VisitInputFiles; }
 
   void visitImport(StringRef ModuleName, StringRef Filename) override {
-PrebuiltModuleFiles[std::string(ModuleName)] = std::string(Filename);
+PrebuiltModuleFiles.insert({ModuleName, Filename.str()});
+  }
+
+  bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden,
+  bool isExplicitModule) override {
+InputFiles.insert(Filename);
+return true;
   }
 
 private:
-  PrebuiltModuleFilesT &PrebuiltModuleFiles;
+  llvm::StringMap &PrebuiltModuleFiles;
+  llvm::StringSet<> &InputFiles;
+  bool VisitInputFiles;
 };
 
+using PrebuiltModuleFilesT = decltype(HeaderSearchOptions::PrebuiltModuleFiles);
+
+/// Visit the given prebuilt module and collect all of the modules it
+/// transitively imports and contributing input files.
+static void visitPrebuiltModule(StringRef PrebuiltModuleFilename,
+CompilerInstance &CI,
+PrebuiltModuleFilesT &ModuleFiles,
+llvm::StringSet<> &InputFiles,
+bool VisitInputFiles) {
+  // Maps the names of modules that weren't yet visited to their PCM path.
+  llvm::StringMap ModuleFilesWorklist;
+  // Contains PCM paths of all visited modules.
+  llvm::StringSet<> VisitedModuleFiles;
+
+  Prebuil

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 359305.
ASDenysPetrov added a comment.

Adapted solution to ConstraintAssignor API. Added tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/symbol-integral-cast.cpp

Index: clang/test/Analysis/symbol-integral-cast.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-integral-cast.cpp
@@ -0,0 +1,374 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-config eagerly-assume=false -analyzer-config support-symbolic-integer-casts=true -verify %s
+
+template 
+void clang_analyzer_eval(T);
+void clang_analyzer_warnIfReached();
+
+typedef short int16_t;
+typedef int int32_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+
+void test1(int x) {
+  // Even if two lower bytes of `x` equal to zero, it doesn't mean that
+  // the entire `x` is zero. We are not able to know the exact value of x.
+  // It can be one of  65536 possible values like [0, 65536, 131072, ...]
+  // and so on. To avoid huge range sets we still assume `x` in the range
+  // [INT_MIN, INT_MAX].
+  if (!(short)x) {
+if (!x)
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+else
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  }
+}
+
+void test2(int x) {
+  // If two lower bytes of `x` equal to zero, and we know x to be 65537,
+  // which is not truncated to short as zero. Thus the branch is infisible.
+  short s = x;
+  if (!s) {
+if (x == 65537)
+  clang_analyzer_warnIfReached(); // no-warning
+else
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  }
+}
+
+void test3(int x, short s) {
+  s = x;
+  if ((short)x > -10 && s < 10) {
+if (x > 0 && x < 10) {
+  // If the range of the whole variable was constrained then reason again
+  // about truncated bytes to make the ranges more precise.
+  clang_analyzer_eval((short)x <= 0); // expected-warning {{FALSE}}
+}
+  }
+}
+
+void test4(unsigned x) {
+  if ((char)x > 8) {
+// Constraint the range of the lowest byte of `x` to [9, CHAR_MAX].
+// The original range of `x` still remains [0, UINT_MAX].
+clang_analyzer_eval((char)x < 42); // expected-warning {{UNKNOWN}}
+if (x < 42) {
+  // Constraint the original range to [0, 42] and update (re-constraint)
+  // the range of the lowest byte of 'x' to [9, 42].
+  clang_analyzer_eval((char)x < 42); // expected-warning {{TRUE}}
+}
+  }
+}
+
+void test5(unsigned x) {
+  if ((char)x > -10 && (char)x < 10) {
+if ((short)x == 8) {
+  // If the range of higher bytes(short) was constrained then reason again
+  // about smaller truncated ranges(char) to make it more precise.
+  clang_analyzer_eval((char)x == 8);  // expected-warning {{TRUE}}
+  clang_analyzer_eval((short)x == 8); // expected-warning {{TRUE}}
+  // We still assume full version of `x` in the range [INT_MIN, INT_MAX].
+  clang_analyzer_eval(x == 8); // expected-warning {{UNKNOWN}}
+}
+  }
+}
+
+void test6(int x) {
+  // Even if two lower bytes of `x` less than zero, it doesn't mean that `x`
+  // can't be greater than zero. Thence we don't change the native range of
+  // `x` and this branch is feasible.
+  if (x > 0)
+if ((short)x < 0)
+  clang_analyzer_eval(x > 0); // expected-warning {{TRUE}}
+}
+
+void test7(int x) {
+  // The range of two lower bytes of `x` [1, SHORT_MAX] is enough to cover
+  // all possible values of char [CHAR_MIN, CHAR_MAX]. So the lowest byte
+  // can be lower than zero.
+  if ((short)x > 0) {
+if ((char)x < 0)
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+else
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  }
+}
+
+void test8(int x) {
+  // Promotion from `signed int` to `signed long long` also reasoning about the
+  // original range, because we know the fact that even after promotion it
+  // remains in the range [INT_MIN, INT_MAX].
+  if ((long long)x < 0)
+clang_analyzer_eval(x < 0); // expected-warning {{TRUE}}
+}
+
+void test9(signed int x) {
+  // Any cast `signed` to `unsigned` produces an unsigned range, which is
+  // [0, UNSIGNED_MAX] and can not be lower than zero.
+  if ((unsigned long long)x < 0)
+clang_analyzer_warnIfReached(); // no-warning
+  else
+clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+
+  if ((unsigned int)x < 0)
+clang_analyzer_warnIfReached(); // no-warning
+  else
+clang_analy

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1908-1912
+// Handle SymbolCast before actual assignment.
+std::tie(Sym, NewConstraint) =
+modifySymbolAndConstraints(Sym, NewConstraint);
+if (!State)
+  return nullptr;

vsavchenko wrote:
> ASDenysPetrov wrote:
> > vsavchenko wrote:
> > > That's not using `ConstraintAssignor`, you simply put your implementation 
> > > in here.  That won't do!
> > OK, please tell me how to use it correctly in my case.
> Can you read the comments first and then ask me if you have any specific 
> questions?
I think I did it. Could you please review the changes?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105930: [PowerPC] Implement XL compact math builtins

2021-07-16 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.td:3087
 // RM should be set.
+let hasSideEffects = 1 in {
 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),

nemanjai wrote:
> nemanjai wrote:
> > I think we should conservatively set RM as an implicit def here. @ZhangKang 
> > you modified this code most recently, please provide your opinion here.
> This was not addressed. Will this be added in a follow-up patch?
Yes, sorry I will address this in a subsequent patch since adding RM will cause 
unrelated LIT failures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105930/new/

https://reviews.llvm.org/D105930

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106150: [PowerPC] swdiv_nochk Builtins for XL Compat

2021-07-16 Thread Quinn Pham via Phabricator via cfe-commits
quinnp created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
quinnp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch is in a series of patches to provide builtins for
compatibility with the XL compiler. This patch adds software divide
builtins with no checking. These builtins are each emitted as a fast
fdiv.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106150

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c

Index: clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
@@ -0,0 +1,113 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+
+extern double a;
+extern double b;
+extern double c;
+extern float d;
+extern float e;
+extern float f;
+
+// CHECK-LABEL: @test_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_swdiv_nochk() {
+  return __swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_swdivs_nochk() {
+  return __swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_swdiv_nochk() {
+  return __swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load float, float* @f, align 4
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret float [[ADD]]
+//
+float test_flags_swdivs_nochk() {
+  return __swdivs_nochk(d, e) + f;
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_builtin_ppc_swdivs_nochk() {
+  return __builtin_ppc_swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e

[PATCH] D105869: [Driver] fix PowerPC SPE musl dynamic linker name

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a subscriber: jhibbits.
nemanjai added a comment.

I personally don't see anything wrong with this, but then again I am not really 
familiar with SPE. I'll defer to @jhibbits for the approval.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105869/new/

https://reviews.llvm.org/D105869

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106150: [PowerPC] swdiv_nochk Builtins for XL Compat

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM other than a couple of nits.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15627
+Builder.getFastMathFlags().setFast();
+Value *fdiv = Builder.CreateFDiv(Ops[0], Ops[1], "swdiv_nochk");
+Builder.getFastMathFlags() &= (FMF);

Nit: naming convention for variables is that they are capitalized CamelCase.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c:3
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s

One Linux run line and one AIX run line should suffice.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106150/new/

https://reviews.llvm.org/D106150

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105869: [Driver] fix PowerPC SPE musl dynamic linker name

2021-07-16 Thread Justin Hibbits via Phabricator via cfe-commits
jhibbits accepted this revision.
jhibbits added a comment.
This revision is now accepted and ready to land.

Looks fine to me.  @nemanjai this one is more Musl, less SPE :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105869/new/

https://reviews.llvm.org/D105869

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106150: [PowerPC] swdiv_nochk Builtins for XL Compat

2021-07-16 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 359310.
quinnp added a comment.

Adressing review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106150/new/

https://reviews.llvm.org/D106150

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c

Index: clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
@@ -0,0 +1,109 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+
+extern double a;
+extern double b;
+extern double c;
+extern float d;
+extern float e;
+extern float f;
+
+// CHECK-LABEL: @test_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_swdiv_nochk() {
+  return __swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_swdivs_nochk() {
+  return __swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_swdiv_nochk() {
+  return __swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load float, float* @f, align 4
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret float [[ADD]]
+//
+float test_flags_swdivs_nochk() {
+  return __swdivs_nochk(d, e) + f;
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_builtin_ppc_swdivs_nochk() {
+  return __builtin_ppc_swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load float, float* @f, align 4
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret float [[ADD]]
+//
+float test_flags_builtin_ppc_swdivs_nochk() {
+  return __builtin_ppc_swdivs_nochk(d, e) + f;
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
---

[PATCH] D106136: [Analyzer][solver] Fix equivalence class invariant violation in removeDeadBindings

2021-07-16 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks for taking your time to take a look. And I accept your statements. 
Nevertheless, let me explain my motivation.

I thought that a class is trivial if it has only one member. And it seemed 
perfectly logical to not store equivalence classes with one member. I.e `a` 
equals to `a` does not hold any meaningful information it just takes precious 
memory. When we add a new constraint we take careful steps to avoid adding a 
new class with one member. However, when remove dead kicks in, suddenly we end 
up having classes stored with one member, which is a somewhat inconsistent 
design IMHO. Perhaps some better documentation could have helped.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106136/new/

https://reviews.llvm.org/D106136

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104925: [Analyzer] Improve report of file read at end-of-file condition.

2021-07-16 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

The bug reports speak for themselves, they are awesome. Nice work!




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:28-30
+//===--===//
+// Definition of state data structures.
+//===--===//

Thank you! Big fan of these.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:34-35
 
+const char *Desc_StreamEof = "Stream already in EOF";
+const char *Desc_ResourceLeak = "Resource leak";
+

You don't seem to reuse these in this or the followup patch? Its not a big 
deal, I don't mind you creating them, just feels a bit odd to me.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:409
+SymbolRef StreamSym) const {
+return C.getNoteTag([StreamSym](PathSensitiveBugReport &BR) {
+  if (!BR.isInteresting(StreamSym) ||

Can you not capture `this` as well? We could eliminate 
`StreamChecker::Instance` that way I suppose.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:715-716
   StateFailed = StateFailed->set(StreamSym, NewState);
-  C.addTransition(StateFailed);
+  if (IsFread && SS->ErrorState != ErrorFEof)
+C.addTransition(StateFailed, constructSetEofNoteTag(C, StreamSym));
+  else

Oh, this took me quite a bit. Can we change `SS` to something that reflects 
that its the current error state, not the new one? Like `CurrSS`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104925/new/

https://reviews.llvm.org/D104925

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106152: [analyzer] Remove test file as duplicated.

2021-07-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added a reviewer: NoQ.
ASDenysPetrov added a project: clang.
Herald added subscribers: manas, steakhal, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Remove test file as duplicated. The file was mistakenly added due to concerns 
of a hidden bug (see https://reviews.llvm.org/D104381). After it turned out, 
that the bug was already fixed with another revision 
(https://reviews.llvm.org/D85817) and corresponding test was added as well, we 
can remove this file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106152

Files:
  clang/test/Analysis/diagnostics/PR46264.cpp


Index: clang/test/Analysis/diagnostics/PR46264.cpp
===
--- clang/test/Analysis/diagnostics/PR46264.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
-
-// PR46264
-// This case shall not crash with an assertion failure about void* 
dereferening.
-// The crash has been last seen on commit
-// `3ed8ebc2f6b8172bed48cc5986d3b7af4cfca1bc` from 24.05.2020.
-namespace ns1 {
-namespace a {
-class b {
-public:
-  typedef int b::*c;
-  operator c() { return d ? &b::d : 0; }
-  // expected-note@-1{{'?' condition is true}}
-  // expected-note@-2{{Assuming field 'd' is not equal to 0}}
-  // expected-note@-3{{Returning value, which participates in a condition 
later}}
-  int d;
-};
-} // namespace a
-using a::b;
-class e {
-  void f();
-  void g();
-  b h;
-};
-void e::f() {
-  e *i;
-  // expected-note@-1{{'i' declared without an initial value}}
-  if (h)
-// expected-note@-1{{Taking true branch}}
-// expected-note@-2{{'b::operator int ns1::a::b::*'}}
-// expected-note@-3{{Returning from 'b::operator int ns1::a::b::*'}}
-i->g();
-  // expected-note@-1{{Called C++ object pointer is uninitialized}}
-  // expected-warning@-2{{Called C++ object pointer is uninitialized}}
-}
-} // namespace ns1


Index: clang/test/Analysis/diagnostics/PR46264.cpp
===
--- clang/test/Analysis/diagnostics/PR46264.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
-
-// PR46264
-// This case shall not crash with an assertion failure about void* dereferening.
-// The crash has been last seen on commit
-// `3ed8ebc2f6b8172bed48cc5986d3b7af4cfca1bc` from 24.05.2020.
-namespace ns1 {
-namespace a {
-class b {
-public:
-  typedef int b::*c;
-  operator c() { return d ? &b::d : 0; }
-  // expected-note@-1{{'?' condition is true}}
-  // expected-note@-2{{Assuming field 'd' is not equal to 0}}
-  // expected-note@-3{{Returning value, which participates in a condition later}}
-  int d;
-};
-} // namespace a
-using a::b;
-class e {
-  void f();
-  void g();
-  b h;
-};
-void e::f() {
-  e *i;
-  // expected-note@-1{{'i' declared without an initial value}}
-  if (h)
-// expected-note@-1{{Taking true branch}}
-// expected-note@-2{{'b::operator int ns1::a::b::*'}}
-// expected-note@-3{{Returning from 'b::operator int ns1::a::b::*'}}
-i->g();
-  // expected-note@-1{{Called C++ object pointer is uninitialized}}
-  // expected-warning@-2{{Called C++ object pointer is uninitialized}}
-}
-} // namespace ns1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105003: [Analyzer] Improve report of "indeterminate file position" condition (alpha.unix.Stream).

2021-07-16 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I suppose the counter is outdated, similarly to D104925#2850420 
?




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:101-109
   /// Indicate if the file has an "indeterminate file position indicator".
   /// This can be set at a failing read or write or seek operation.
   /// If it is set no more read or write is allowed.
   /// This value is not dependent on the stream error flags:
   /// The error flag may be cleared with `clearerr` but the file position
   /// remains still indeterminate.
   /// This value applies to all error states in ErrorState except FEOF.

Shouldn't this be all you need to retrieve the fact that the streams position 
is indeterminate?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105003/new/

https://reviews.llvm.org/D105003

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105898: [OpenMP] Rework OpenMP remarks

2021-07-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 359319.
jhuber6 added a comment.

Small changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105898/new/

https://reviews.llvm.org/D105898

Files:
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  llvm/lib/Transforms/IPO/AttributorAttributes.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/custom_state_machines_remarks.ll
  llvm/test/Transforms/OpenMP/deduplication_remarks.ll
  llvm/test/Transforms/OpenMP/globalization_remarks.ll
  llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
  llvm/test/Transforms/OpenMP/remove_globalization.ll
  llvm/test/Transforms/OpenMP/spmdization_remarks.ll

Index: llvm/test/Transforms/OpenMP/spmdization_remarks.ll
===
--- llvm/test/Transforms/OpenMP/spmdization_remarks.ll
+++ llvm/test/Transforms/OpenMP/spmdization_remarks.ll
@@ -1,12 +1,13 @@
 ; RUN: opt -passes=openmp-opt -pass-remarks=openmp-opt -pass-remarks-missed=openmp-opt -pass-remarks-analysis=openmp-opt -disable-output < %s 2>&1 | FileCheck %s
 target triple = "nvptx64"
 
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: Kernel will be executed in generic-mode due to this potential side-effect, consider to add `__attribute__((assume("ompx_spmd_amenable")))` to the called function 'unknown'.
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: Kernel will be executed in generic-mode due to this potential side-effect, consider to add `__attribute__((assume("ompx_spmd_amenable")))` to the called function 'unknown'.
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:11:1: Generic-mode kernel is executed with a customized state machine that requires a fallback [1 known parallel regions, 2 unkown parallel regions] (bad).
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: State machine fallback caused by this call. If it is a false positive, use `__attribute__((assume("omp_no_openmp")))` (or "omp_no_parallelism").
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: State machine fallback caused by this call. If it is a false positive, use `__attribute__((assume("omp_no_openmp")))` (or "omp_no_parallelism").
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:20:1: Generic-mode kernel is changed to SPMD-mode.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:11:1: Generic-mode kernel is executed with a customized state machine that requires a fallback.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: Call may contain unknown parallel regions. Use `__attribute__((assume("omp_no_parallelism")))` to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: Call may contain unknown parallel regions. Use `__attribute__((assume("omp_no_parallelism")))` to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:20:1: Transformed generic-mode kernel to SPMD-mode.
+
 
 ;; void unknown(void);
 ;; void known(void) {
Index: llvm/test/Transforms/OpenMP/remove_globalization.ll
===
--- llvm/test/Transforms/OpenMP/remove_globalization.ll
+++ llvm/test/Transforms/OpenMP/remove_globalization.ll
@@ -4,7 +4,7 @@
 target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
 target triple = "nvptx64"
 
-; CHECK-REMARKS: remark: remove_globalization.c:4:2: Could not move globalized variable to the stack as variable is potentially captured in call; mark parameter as `__attribute__((noescape))` to override.
+; CHECK-REMARKS: remark: remove_globalization.c:4:2: Could not move globalized variable to the stack. Variable is potentially captured in call. Mark parameter as `__attribute__((noescape))` to override.
 ; CHECK-REMARKS: remark: remove_globalization.c:2:2: Moving globalized variable to the stack.
 ; CHECK-REMARKS: remark: remove_globalization.c:6:2: Moving globalized variable to the stack.
 ; CHECK-REMARKS: remark: remove_globalization.c:4:2: Found thread data sharing on the GPU. Expect degraded performance due to data globalization.
Index: llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
+++ llvm/test/Transforms/OpenMP/p

[PATCH] D105946: [PowerPC] Store, load, move from and to registers related builtins

2021-07-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 359322.
Conanap marked 5 inline comments as done.
Conanap added a comment.

Added non-vsx pattern for stfiw, extra testline for that pattern,
some nits


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105946/new/

https://reviews.llvm.org/D105946

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  clang/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.c
  clang/test/CodeGen/builtins-ppc-xlcompat-prefetch.c
  clang/test/CodeGen/builtins-ppc-xlcompat-stfiw.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-stfiw.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX64
+
+declare void @llvm.ppc.dcbtstt(i8*)
+declare void @llvm.ppc.dcbtt(i8*)
+
+@vpa = external local_unnamed_addr global i8*, align 8
+
+define dso_local void @test_dcbtstt() {
+; CHECK-LABEL: test_dcbtstt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addis 3, 2, .LC0@toc@ha
+; CHECK-NEXT:ld 3, .LC0@toc@l(3)
+; CHECK-NEXT:ld 3, 0(3)
+; CHECK-NEXT:dcbtstt 0, 3
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_dcbtstt:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
+; CHECK-AIX-NEXT:lwz 3, 0(3)
+; CHECK-AIX-NEXT:dcbtstt 0, 3
+; CHECK-AIX-NEXT:blr
+;
+; CHECK-AIX64-LABEL: test_dcbtstt:
+; CHECK-AIX64:   # %bb.0: # %entry
+; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
+; CHECK-AIX64-NEXT:ld 3, 0(3)
+; CHECK-AIX64-NEXT:dcbtstt 0, 3
+; CHECK-AIX64-NEXT:blr
+entry:
+  %0 = load i8*, i8** @vpa, align 8
+  tail call void @llvm.ppc.dcbtstt(i8* %0)
+  ret void
+}
+
+
+define dso_local void @test_dcbtt() {
+; CHECK-LABEL: test_dcbtt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addis 3, 2, .LC0@toc@ha
+; CHECK-NEXT:ld 3, .LC0@toc@l(3)
+; CHECK-NEXT:ld 3, 0(3)
+; CHECK-NEXT:dcbtt 0, 3
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_dcbtt:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
+; CHECK-AIX-NEXT:lwz 3, 0(3)
+; CHECK-AIX-NEXT:dcbtt 0, 3
+; CHECK-AIX-NEXT:blr
+;
+; CHECK-AIX64-LABEL: test_dcbtt:
+; CHECK-AIX64:   # %bb.0: # %entry
+; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
+; CHECK-AIX64-NEXT:ld 3, 0(3)
+; CHECK-AIX64-NEXT:dcbtt 0, 3
+; CHECK-AIX64-NEXT:blr
+entry:
+  %0 = load i8*, i8** @vpa, align 8
+  tail call void @llvm.ppc.dcbtt(i8* %0)
+  ret void
+}
Index: llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-32BIT
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+
+declare i32 @llvm.ppc.mftbu()
+declare i32 @llvm.ppc.mfmsr()
+
+define dso_local zeroext i32 @test_mftbu() {
+; CHECK-LABEL: test_mftbu:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mftbu 3
+; CHECK-NEXT:clrldi 3, 3, 32
+; CHECK-NEXT:blr
+;
+; CHECK-32BIT-LABEL: test_mftbu:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mftbu 3
+; CHECK-32BIT-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.mftbu()
+  ret i32 %0
+}
+
+define dso_local i64 @test_mfmsr() {
+; CHECK-LABEL: test_mfmsr:
+; CHECK:   # %bb.0: # %ent

[PATCH] D106150: [PowerPC] swdiv_nochk Builtins for XL Compat

2021-07-16 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 359325.
quinnp added a comment.

Fixing a syntax error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106150/new/

https://reviews.llvm.org/D106150

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c

Index: clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
@@ -0,0 +1,109 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+
+extern double a;
+extern double b;
+extern double c;
+extern float d;
+extern float e;
+extern float f;
+
+// CHECK-LABEL: @test_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_swdiv_nochk() {
+  return __swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_swdivs_nochk() {
+  return __swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_swdiv_nochk() {
+  return __swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load float, float* @f, align 4
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret float [[ADD]]
+//
+float test_flags_swdivs_nochk() {
+  return __swdivs_nochk(d, e) + f;
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_builtin_ppc_swdivs_nochk() {
+  return __builtin_ppc_swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdiv_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdivs_nochk(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load float, float* @f, align 4
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret float [[ADD]]
+//
+float test_flags_builtin_ppc_swdivs_nochk() {
+  return __builtin_ppc_swdivs_nochk(d, e) + f;
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- cla

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer updated this revision to Diff 359326.
fmayer added a comment.

add llvm test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-stack-safety-analysis-asm.c
  clang/test/CodeGen/hwasan-stack-safety-analysis.c
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll

Index: llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
@@ -0,0 +1,43 @@
+; RUN: opt -hwasan -hwasan-use-stack-safety=1 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=SAFETY
+; RUN: opt -hwasan -hwasan-use-stack-safety=0 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=NOSAFETY
+
+; ModuleID = '/usr/local/google/home/fmayer/llvm-project/clang/test/CodeGen/hwasan-stack-safety-analysis.c'
+source_filename = "/usr/local/google/home/fmayer/llvm-project/clang/test/CodeGen/hwasan-stack-safety-analysis.c"
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+; Function Attrs: mustprogress nofree nounwind uwtable willreturn
+define i32 @test_load(i32* %a) sanitize_hwaddress {
+entry:
+  ; NOSAFETY: call {{.*}}__hwasan_generate_tag
+  ; SAFETY-NOT: call {{.*}}__hwasan_generate_tag
+  %buf.sroa.0 = alloca i8, align 4
+  call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  store volatile i8 0, i8* %buf.sroa.0, align 4, !tbaa !8
+  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  ret i32 0
+}
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
+
+attributes #0 = { mustprogress nofree nounwind uwtable willreturn "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
+attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
+
+!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 1, !"branch-target-enforcement", i32 0}
+!2 = !{i32 1, !"sign-return-address", i32 0}
+!3 = !{i32 1, !"sign-return-address-all", i32 0}
+!4 = !{i32 1, !"sign-return-address-with-bkey", i32 0}
+!5 = !{i32 7, !"uwtable", i32 1}
+!6 = !{i32 7, !"frame-pointer", i32 1}
+!7 = !{!"clang version 13.0.0 (/usr/local/google/home/fmayer/llvm-project/clang 267dacd628370863dd960ba41b664b6f86c56961)"}
+!8 = !{!9, !9, i64 0}
+!9 = !{!"omnipotent char", !10, i64 0}
+!10 = !{!"Simple C/C++ TBAA"}
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -109,6 +110,11 @@
cl::desc("instrument stack (allocas)"),
cl::Hidden, cl::init(true));
 
+static cl::opt
+ClUseStackSafety("hwasan-use-stack-safety", cl::Hidden, cl::init(true),
+ cl::Hidden, cl::desc("Use Stack Safety analysis results"),
+ cl::Optional);
+
 static cl::opt ClUARRetagToZero(
 "hwasan-uar-retag-to-zero",
 cl::desc("Clear alloca tags before returning from the function to allow "
@@ -210,13 +216,22 @@
 #pragma GCC poison ClInstrumentWithCalls
 }
 
+bool shouldUseStackSafetyAnalysis(const Triple &TargetTriple,
+  bool DisableOptimization) {
+  auto StackSafety = ClUseStackSafety.getNumOccurrences()
+ ? ClUseStackSafety
+ : !DisableOptimization;
+  return shouldInstrumentStack(TargetTriple) && StackSafety;
+// No one should use the option directly.
+#pragma GCC poison ClUseStackSafety
+}
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
 class HWAddressSanitizer {
 public:
-  explicit HWAddressSanitizer(Module &M, bool CompileKernel = false,
-  bool Recover = false)
-  : M(M) {
+  explicit HWAddressSanitizer(Module

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer marked 3 inline comments as done.
fmayer added inline comments.



Comment at: llvm/test/CodeGen/hwasan-stack-safety-analysis-asm.c:1
+// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -mllvm 
-hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls -O2 %s -o 
- | FileCheck %s --check-prefix=SAFETY
+// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -mllvm 
-hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls -O2 %s 
-o - | FileCheck %s --check-prefix=NOSAFETY

eugenis wrote:
> You can't use %clang in LLVM tests. There may be no clang. Use opt to invoke 
> the hwasan pass in isolation, see the tests under 
> test/Instrumentation/HWAddressSanitizer/.
> 
> The reason I did not say anything about the tests was because only in clang 
> we can test this thing end-to-end.
> Perhaps an LLVM test for instrumentation + a clang test for the passmanager 
> (use -fdebug-pass-manager and -mllvm -debug-pass=Structure for new/old).
> 
added an extra llvm test to check from IR, and left the existing clang end to 
end tests..



Comment at: llvm/test/CodeGen/hwasan-stack-safety-analysis-asm.c:8
+
+int main(int argc, char **argv) {
+  char buf[10];

vitalybuka wrote:
> these tests do not work because %clang is not defined here, in LLVM
> you can keep them but they need to stay in clang/
> 
> my request was to add new tests in 
> llvm-project/llvm/test/Instrumentation/HWAddressSanitizer/
> and they need to be *.ll tests
> you probably can generate them from C and cleanup manually
> or close existing *.ll tests and CHECK for expected difference if analysis is 
> enabled
> 
> Also try to generated CHECK statements with llvm/utils/update_test_checks.py, 
> often result is quite useful.
added llvm test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105957: [PowerPC] Implement intrinsics for mtfsf[i]

2021-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:1589
[IntrNoMem, IntrHasSideEffects]>;
   def int_ppc_mtfsfi
   : GCCBuiltin<"__builtin_ppc_mtfsfi">,

qiucf wrote:
> If `mtfsf` was changed, `mtfsfi` `mtfsb0` `mtfsb1` should also be changed?
There is no need for custom code generation for those. The reason we had to 
change `mtfsf` is because we need to take an integer and convert it to a double 
(and not a bitcast, but a `uinttofp` which I found a bit surprising).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105957/new/

https://reviews.llvm.org/D105957

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106150: [PowerPC] swdiv_nochk Builtins for XL Compat

2021-07-16 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 359327.
quinnp added a comment.

Removing entry checks from front end test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106150/new/

https://reviews.llvm.org/D106150

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c

Index: clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-swdiv_nochk.c
@@ -0,0 +1,100 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+
+extern double a;
+extern double b;
+extern double c;
+extern float d;
+extern float e;
+extern float f;
+
+// CHECK-LABEL: @test_swdiv_nochk(
+// CHECK:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_swdiv_nochk() {
+  return __swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_swdivs_nochk(
+// CHECK:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_swdivs_nochk() {
+  return __swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_swdiv_nochk(
+// CHECK:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_swdiv_nochk() {
+  return __swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_swdivs_nochk(
+// CHECK:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load float, float* @f, align 4
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret float [[ADD]]
+//
+float test_flags_swdivs_nochk() {
+  return __swdivs_nochk(d, e) + f;
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdiv_nochk(
+// CHECK:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[SWDIV_NOCHK]]
+//
+double test_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b);
+}
+
+// CHECK-LABEL: @test_builtin_ppc_swdivs_nochk(
+// CHECK:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret float [[SWDIV_NOCHK]]
+//
+float test_builtin_ppc_swdivs_nochk() {
+  return __builtin_ppc_swdivs_nochk(d, e);
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdiv_nochk(
+// CHECK:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load double, double* @c, align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double test_flags_builtin_ppc_swdiv_nochk() {
+  return __builtin_ppc_swdiv_nochk(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_builtin_ppc_swdivs_nochk(
+// CHECK:[[TMP0:%.*]] = load float, float* @d, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load float, float* @e, align 4
+// CHECK-NEXT:[[SWDIV_NOCHK:%.*]] = fdiv fast float [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP2:%.*]] = load float, float* @f, align 4
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[SWDIV_NOCHK]], [[TMP2]]
+// CHECK-NEXT:ret float [[ADD]]
+//
+float test_flags_builtin_ppc_swdivs_nochk() {
+  return __builtin_ppc_swdivs_nochk(d, e) + f;
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15620,6 +15620,15 @@
 Function *F = CGM.getIntrinsic(Intrinsic::ppc_popcntb, {ArgType, ArgType});
 return Builder.CreateCall(F, Ops, "popcntb");
   }
+
+  case PPC::BI__builtin_ppc_swdiv_nochk:
+  case PPC::BI__bui

[PATCH] D106112: [clang-format] Break an unwrapped line at a K&R C parameter decl

2021-07-16 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Looks okay, but I was wondering if we don't want to guard all K&R-related 
changes behind e.g. ```Standard: Cpp78``, so as not to possibly introduce 
strange bugs in newer modes.
It may be an overkill if there are 2 patches like this, but if there are more, 
that might become sensible to do so.
WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106112/new/

https://reviews.llvm.org/D106112

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105003: [Analyzer] Improve report of "indeterminate file position" condition (alpha.unix.Stream).

2021-07-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

This will be rebased on D104925  when that is 
finished.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:101-109
   /// Indicate if the file has an "indeterminate file position indicator".
   /// This can be set at a failing read or write or seek operation.
   /// If it is set no more read or write is allowed.
   /// This value is not dependent on the stream error flags:
   /// The error flag may be cleared with `clearerr` but the file position
   /// remains still indeterminate.
   /// This value applies to all error states in ErrorState except FEOF.

Szelethus wrote:
> Shouldn't this be all you need to retrieve the fact that the streams position 
> is indeterminate?
The "problem" can be that the error state can contain a combination of errors, 
this means FEOF and FERROR together. In this case the "indeterminate" is just 
not applicable to the FEOF state.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105003/new/

https://reviews.llvm.org/D105003

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104420: thread_local support for AIX

2021-07-16 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 359336.
jamieschmeiser added a comment.

Respond to review comments:  Change parameter name and tighten up conditions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104420/new/

https://reviews.llvm.org/D104420

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-reference.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-visibility.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp

Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -1,19 +1,20 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX --check-prefix=CHECK-OPT %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX,CHECK-OPT %s
 // RUN: %clang_cc1 -std=c++11 -femulated-tls -emit-llvm %s -o - \
-// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple powerpc64-unknown-aix-xcoff | FileCheck --check-prefixes=CHECK,AIX,LINUX_AIX %s
 
-// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
-// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX --check-prefix=CHECK-OPT %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX,CHECK-OPT %s
 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -femulated-tls -emit-llvm %s -o - \
-// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
 
 int f();
 int g();
 
-// LINUX-DAG: @a ={{.*}} thread_local global i32 0
+// LINUX_AIX-DAG: @a ={{.*}} thread_local global i32 0
 // DARWIN-DAG: @a = internal thread_local global i32 0
 thread_local int a = f();
 extern thread_local int b;
@@ -23,7 +24,7 @@
 static thread_local int d = g();
 
 struct U { static thread_local int m; };
-// LINUX-DAG: @_ZN1U1mE ={{.*}} thread_local global i32 0
+// LINUX_AIX-DAG: @_ZN1U1mE ={{.*}} thread_local global i32 0
 // DARWIN-DAG: @_ZN1U1mE = internal thread_local global i32 0
 thread_local int U::m = f();
 
@@ -89,9 +90,9 @@
 
 // CHECK-DAG: @llvm.global_ctors = appending global {{.*}} @[[GLOBAL_INIT:[^ ]*]]
 
-// LINUX-DAG: @_ZTH1a ={{.*}} alias void (), void ()* @__tls_init
+// LINUX_AIX-DAG: @_ZTH1a ={{.*}} alias void (), void ()* @__tls_init
 // DARWIN-DAG: @_ZTH1a = internal alias void (), void ()* @__tls_init
-// LINUX-DAG: @_ZTHN1U1mE ={{.*}} alias void (), void ()* @__tls_init
+// LINUX_AIX-DAG: @_ZTHN1U1mE ={{.*}} alias void (), void ()* @__tls_init
 // DARWIN-DAG: @_ZTHN1U1mE = internal alias void (), void ()* @__tls_init
 // CHECK-DAG: @_ZTHN1VIiE1mE = linkonce_odr alias void (), void ()* @[[V_M_INIT:[^, ]*]]
 // CHECK-DAG: @_ZTHN1XIiE1mE = linkonce_odr alias void (), void ()* @[[X_M_INIT:[^, ]*]]
@@ -106,16 +107,16 @@
 // Individual variable initialization functions:
 
 // CHECK: define {{.*}} @[[A_INIT:.*]]()
-// CHECK: call i32 @_Z1fv()
+// CHECK: call{{.*}} i32 @_Z1fv()
 // CHECK-NEXT: store i32 {{.*}}, i32* @a, align 4
 
 // CHECK-LABEL: define{{.*}} i32 @_Z1fv()
 int f() {
   // CHECK: %[[GUARD:.*]] = load i8, i8* @_ZGVZ1fvE1n, align 1
   // CHECK: %[[NEED_INIT:.*]] = icmp eq i8 %[[GUARD]], 0
-  // CHECK: br i1 %[[NEED_INIT]]
+  // CHECK: br i1 %[[NEED_INIT]]{{.*}}
 
-  // CHECK: %[[CALL:.*]] = call i32 @_Z1gv()
+  // CHECK: %[[CALL:.*]] = call{{.*}} i32 @_Z1gv()
   // CHECK: store i32 %[[CALL]], i32* @_ZZ1fvE1n, align 4
   // CHECK: store i8 1, 

[PATCH] D105984: [PowerPC] Restore FastMathFlags of Builder for Vector FDiv Builtins

2021-07-16 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 359338.
quinnp added a comment.

Removing entry checks from front end test and renaming a variable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105984/new/

https://reviews.llvm.org/D105984

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fastmath.c

Index: clang/test/CodeGen/builtins-ppc-fastmath.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-fastmath.c
@@ -0,0 +1,70 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+
+extern vector float a;
+extern vector float b;
+extern vector float c;
+extern vector double d;
+extern vector double e;
+extern vector double f;
+
+// CHECK-LABEL: @test_flags_recipdivf(
+// CHECK:[[TMP0:%.*]] = load <4 x float>, <4 x float>* @a, align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <4 x float>, <4 x float>* @b, align 16
+// CHECK-NEXT:[[TMP2:%.*]] = load <4 x float>, <4 x float>* @a, align 16
+// CHECK-NEXT:[[TMP3:%.*]] = load <4 x float>, <4 x float>* @b, align 16
+// CHECK-NEXT:[[RECIPDIV:%.*]] = fdiv fast <4 x float> [[TMP2]], [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = load <4 x float>, <4 x float>* @c, align 16
+// CHECK-NEXT:[[ADD:%.*]] = fadd <4 x float> [[RECIPDIV]], [[TMP4]]
+// CHECK-NEXT:ret <4 x float> [[ADD]]
+//
+vector float test_flags_recipdivf() {
+  return __builtin_ppc_recipdivf(a, b) + c;
+}
+
+// CHECK-LABEL: @test_flags_recipdivd(
+// CHECK:[[TMP0:%.*]] = load <2 x double>, <2 x double>* @d, align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <2 x double>, <2 x double>* @e, align 16
+// CHECK-NEXT:[[TMP2:%.*]] = load <2 x double>, <2 x double>* @d, align 16
+// CHECK-NEXT:[[TMP3:%.*]] = load <2 x double>, <2 x double>* @e, align 16
+// CHECK-NEXT:[[RECIPDIV:%.*]] = fdiv fast <2 x double> [[TMP2]], [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = load <2 x double>, <2 x double>* @f, align 16
+// CHECK-NEXT:[[ADD:%.*]] = fadd <2 x double> [[RECIPDIV]], [[TMP4]]
+// CHECK-NEXT:ret <2 x double> [[ADD]]
+//
+vector double test_flags_recipdivd() {
+  return __builtin_ppc_recipdivd(d, e) + f;
+}
+
+// CHECK-LABEL: @test_flags_rsqrtf(
+// CHECK:[[TMP0:%.*]] = load <4 x float>, <4 x float>* @a, align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <4 x float>, <4 x float>* @a, align 16
+// CHECK-NEXT:[[TMP2:%.*]] = call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> [[TMP1]])
+// CHECK-NEXT:[[RSQRT:%.*]] = fdiv fast <4 x float> , [[TMP2]]
+// CHECK-NEXT:[[TMP3:%.*]] = load <4 x float>, <4 x float>* @b, align 16
+// CHECK-NEXT:[[ADD:%.*]] = fadd <4 x float> [[RSQRT]], [[TMP3]]
+// CHECK-NEXT:ret <4 x float> [[ADD]]
+//
+vector float test_flags_rsqrtf() {
+  return __builtin_ppc_rsqrtf(a) + b;
+}
+
+// CHECK-LABEL: @test_flags_rsqrtd(
+// CHECK:[[TMP0:%.*]] = load <2 x double>, <2 x double>* @d, align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <2 x double>, <2 x double>* @d, align 16
+// CHECK-NEXT:[[TMP2:%.*]] = call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> [[TMP1]])
+// CHECK-NEXT:[[RSQRT:%.*]] = fdiv fast <2 x double> , [[TMP2]]
+// CHECK-NEXT:[[TMP3:%.*]] = load <2 x double>, <2 x double>* @e, align 16
+// CHECK-NEXT:[[ADD:%.*]] = fadd <2 x double> [[RSQRT]], [[TMP3]]
+// CHECK-NEXT:ret <2 x double> [[ADD]]
+//
+vector double test_flags_rsqrtd() {
+  return __builtin_ppc_rsqrtd(d) + e;
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15128,6 +15128,7 @@
   case PPC::BI__builtin_ppc_recipdivd:
   case PPC::BI__builtin_ppc_rsqrtf:
   case PPC::BI__builtin_ppc_rsqrtd: {
+FastMathFlags FMF = Builder.getFastMathFlags();
 Builder.getFastMathFlags().setFast();
 llvm::Type *ResultType = ConvertType(E->getType());
 Value *X = EmitScalarExpr(E->getArg(0));
@@ -15135,11 +15136,15 @@
 if (BuiltinID == PPC::BI__builtin_ppc_recipdivf ||
 BuiltinID == PPC::BI__builtin_ppc_recipdivd) {
   Value *Y = EmitScalarExpr(E->getArg(1));
-  return Builder.CreateFDiv(X, Y, "recipdiv");
+  Value *FDiv = Builder.CreateFDiv(X, Y, "recipdiv");
+  Builder.getFastMathFlags() &= (FMF);
+  return FDiv;
 }
 auto *One = ConstantFP::get(ResultType, 1.0);
 llvm::Function *F = CGM.getIntrinsic(Intrinsic::sqrt, ResultType);
-return Builder.CreateFDiv(One, Builder.CreateCall(F, X), "rsqrt");

[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-07-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3816
+
+def Error : Attr {
+  let Spellings = [GCC<"error">];

I think this should be an inheritable attribute (same below) so that 
redeclarations get the marking as well.

However, this does make for a bit of a novel situation with regards to other 
attributes. The typical behavior for function attributes is:
```
void func(void);

void use1(void) {
  func(); // Func is not marked yet, no attribute behavior
}

void func(void) __attribute__((whatever)));

void use2(void) {
  func(); // Func is marked, attribute does something
}

void func(void) {} // Func is still marked because the attribute is inheritted

void use3(void) {
  func(); // Func is marked, attribute does something
```
but because all of the interesting work is happening in the backend, I believe 
the unmarked use will still act as though the attribute was marked.



Comment at: clang/include/clang/Basic/Attr.td:3819
+  let Args = [StringArgument<"UserDiagnostic">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [ErrorAttrDocs];

ObjC methods as well?



Comment at: clang/include/clang/Basic/Attr.td:3823
+
+def Warning : Attr {
+  let Spellings = [GCC<"warning">];

Given that the only functional difference between these attributes is the 
diagnostic level, I sort of wonder whether we should have one semantic 
attribute with two spellings (one for warning, one for error) and an accessor 
field to distinguish which is which.

Another interesting question is: are these attributes mutually exclusive? Can 
they be duplicated (perhaps across declarations)? What happens if the messages 
differ? (We may need some attribute merging logic to catch these situations.)



Comment at: clang/include/clang/Basic/AttrDocs.td:6026
+depend on optimizations, while providing diagnostics pointing to precise
+locations of the call site in the source.
+  }];

I think the documentation for these should probably be combined into one 
documentation blob; the only difference in behavior is whether the diagnostic 
is a warning or an attribute.

I think the documentation needs to go into more details about how this 
attribute works in practice. For example, what should I expect from code like:
```
struct Base {
  __attribute__((warning("derp"))) virtual void foo();
};

struct Derived : Base {
  void foo() override; // Does calling this also warn?
};

__attribute__((error("DERP!"))) void func() { // external function symbol!
  func(); // Does this diagnose?
}
```
I suppose another interesting question given the design is to use the optimizer 
is: what about LTO? Say I have:
```
// TU1.c
__attribute__((error("Derp Derp Derp"))) void func(void);

// TU.c
extern void func(void);
void blerp(void) { func(); }
```
What should happen and does LTO change the answer?



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:75
 
+def err_fe_backend_user_diagnostic :
+  Error<"call to %0 declared with attribute error: %1">, BackendInfo;

Should probably give these names that relate to the attribute. How about 
`err_fe_backend_error_attr` (and `warn_fe_backend_warn_attr`) or something 
along those lines?



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:78
+def warn_fe_backend_user_diagnostic :
+  Warning<"call to %0 declared with attribute warning: %1">, BackendInfo, 
InGroup;
+

80-col limit



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:1205
 def BackendOptimizationFailure : DiagGroup<"pass-failed">;
+def BackendUserDiagnostic : DiagGroup<"user-diagnostic">;
 

GCC doesn't seem to support this spelling -- do they have a different one we 
should reuse?



Comment at: clang/lib/CodeGen/CGCall.cpp:5308-5310
+  if (TargetDecl)
+if (TargetDecl->hasAttr() ||
+TargetDecl->hasAttr()) {





Comment at: clang/lib/CodeGen/CodeGenAction.cpp:776
+
+  CalleeName = FD->getName();
+}

This isn't really safe -- not all functions have names that can be retrieved 
this way. We should be sure to add some test coverage for functions without 
"names" (like `operator int()`).

I think it's better to call `getNameForDiagnostic()` here (unless the 
diagnostic printer does that already for a `DeclarationName`, in which case 
`getDeclName()` would be better.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:783
+  else
+Diags.Report(DiagID) << CalleeName << D.getMsgStr();
+}

I think the usability in this situation is a concern -- only having a function 
name but no source location information is pretty tricky. Do you have a sense 
for how often we would hit this case?



Comment at: clang/

[PATCH] D106120: [PowerPC] Implement vector bool/pixel initialization under -faltivec-src-compat=xl

2021-07-16 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 359358.
amyk added a comment.

Update patch and touched base with Nemanja.

- Removed the scalar vector test files that we already test for.
- Update CHECKs in LIT tests accordingly.
- Remove unnecessary `Sema` parameter in added function.
- Keep two test files for initialization of `vector bool` and `vector pixel` 
with and without parentheses. The test without parentheses are separated in its 
own file rather than unified in a single file so we can successfully compile 
the parenthesized version of the test when we have `faltivec-src-compat=mixed`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106120/new/

https://reviews.llvm.org/D106120

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/vector-bool-pixel-altivec-init-no-parentheses.c
  clang/test/CodeGen/vector-bool-pixel-altivec-init.c

Index: clang/test/CodeGen/vector-bool-pixel-altivec-init.c
===
--- /dev/null
+++ clang/test/CodeGen/vector-bool-pixel-altivec-init.c
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=mixed -triple powerpc-unknown-unknown -S \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=MIXED
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=mixed -triple powerpc64le-unknown-unknown -S \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=MIXED
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=xl -triple powerpc-unknown-unknown -S \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=XL
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=xl -triple powerpc64le-unknown-unknown -S \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=XL
+// RUN: %clang -mcpu=pwr8 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \
+// RUN:   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MIXED
+// RUN: %clang -mcpu=pwr9 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \
+// RUN:   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MIXED
+// RUN: %clang -mcpu=pwr8 -faltivec-src-compat=xl --target=powerpc-unknown-unknown \
+// RUN:   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL
+// RUN: %clang -mcpu=pwr9 -faltivec-src-compat=xl --target=powerpc-unknown-unknown \
+// RUN:   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL
+
+// Vector bool type
+vector bool char vbi8_1;
+vector bool char vbi8_2;
+
+vector bool short vbi16_1;
+vector bool short vbi16_2;
+
+vector bool int vbi32_1;
+vector bool int vbi32_2;
+
+vector bool long long vbi64_1;
+vector bool long long vbi64_2;
+
+// Vector pixel type
+vector pixel p1;
+
+
+void test_vector_bool_pixel_init() {
+  // vector bool char initialization
+  vbi8_1 = (vector bool char)('a');
+  // MIXED: 
+  // XL: 
+  char c = 'c';
+  vbi8_2 = (vector bool char)(c);
+  // MIXED: [[INS:%.*]] = insertelement <16 x i8>
+  // MIXED: store <16 x i8> [[INS:%.*]]
+  // XL: [[INS_ELT:%.*]] = insertelement <16 x i8>
+  // XL: [[SHUFF:%.*]] = shufflevector <16 x i8> [[INS_ELT]], <16 x i8> poison, <16 x i32> zeroinitializer
+  // XL: store <16 x i8> [[SHUFF]]
+
+  // vector bool short initialization
+  vbi16_1 = (vector bool short)(5);
+  // MIXED: 
+  // XL: 
+  short si16 = 55;
+  vbi16_2 = (vector bool short)(si16);
+  // MIXED: [[INS:%.*]] = insertelement <8 x i16>
+  // MIXED: store <8 x i16> [[INS:%.*]]
+  // XL: [[INS_ELT:%.*]] = insertelement <8 x i16>
+  // XL: [[SHUFF:%.*]] = shufflevector <8 x i16> [[INS_ELT]], <8 x i16> poison, <8 x i32> zeroinitializer
+  // XL: store <8 x i16> [[SHUFF]]
+
+  // vector bool int initialization
+  vbi32_1 = (vector bool int)(9);
+  // MIXED: 
+  // XL: 
+  int si32 = 99;
+  vbi32_2 = (vector bool int)(si32);
+  // MIXED: [[INS:%.*]] = insertelement <4 x i32>
+  // MIXED: store <4 x i32> [[INS:%.*]]
+  // XL: [[INS_ELT:%.*]] = insertelement <4 x i32>
+  // XL: [[SHUFF:%.*]] = shufflevector <4 x i32> [[INS_ELT]], <4 x i32> poison, <4 x i32> zeroinitializer
+  // XL: store <4 x i32> [[SHUFF]]
+
+  // vector bool long long initialization
+  vbi64_1 = (vector bool long long)(13);
+  // MIXED: 
+  // XL: 
+  long long si64 = 1313;
+  vbi64_2 = (vector bool long long)(si64);
+  // MIXED: [[INS:%.*]] = insertelement <2 x i64>
+  // MIXED: store <2 x i64> [[INS:%.*]]
+  // XL: [[INS_ELT:%.*]] = insertelement <2 x i64>
+  // XL: [[SHUFF:%.*]] = shufflevector <2 x i64> [[INS_ELT]], <2 x i64> poison, <2 x i32> zeroinitializer
+  // XL: store <2 x i64> [[SHUFF]]
+
+  // vector pixel initialization
+  p1 = (vector pixel)(1);
+  // MIXED: 
+  // XL: 
+}
Index: clang/test/CodeGen/vector-bool-pixel-altivec-init-no-paren

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:407
   bool Recover;
+  bool DisableOptimization;
 };

No need to pass this down, just look at OptimizeNone function attribute.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCL/null_literal.cl:26
 
 #ifdef CL20
 // Accept explicitly pointer to generic address space in OpenCL v2.0.

while we are at it, do you mind changing this check into 

`__OPENCL_CPP_VERSION__ == 200`

and then we can remove `-DCL20` from the run line



Comment at: clang/test/SemaOpenCL/null_literal.cl:13
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__global void *'}}
+#endif

Topotuna wrote:
> Anastasia wrote:
> > hmm, you should not get those errors though https://godbolt.org/z/qvr7x11TM
> The `expected-error` here refers to line 15 which displays an error: 
> https://godbolt.org/z/zYzGedzv4
Makes sense. Sorry I didn't notice.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105987/new/

https://reviews.llvm.org/D105987

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106137: [flang][driver] Add support for Frontend Plugins

2021-07-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@stuartellis , thank you for working on this! I've left a few comments - mostly 
nits.




Comment at: flang/examples/HelloWorld/CMakeLists.txt:1-5
+add_llvm_library(
+flangHelloWorldPlugin
+MODULE
+HelloWorldPlugin.cpp
+)

I think that this should be fine as is, but will not work on Windows. Check 
this example: [[ 
https://github.com/llvm/llvm-project/blob/main/clang/examples/PrintFunctionNames/CMakeLists.txt
 | PrintFunctionNames ]]. I think that it's fine not to support Windows for 
now, but we should document this. Also, your tests need to marked as Linux-only 
(e.g. with `// REQUIRES: shell` or something similar).



Comment at: flang/examples/HelloWorld/HelloWorldPlugin.cpp:1
+#include "flang/Frontend/FrontendActions.h"
+#include "flang/Frontend/FrontendPluginRegistry.h"

Missing LLVM file header: 
https://llvm.org/docs/CodingStandards.html#file-headers



Comment at: flang/include/flang/Frontend/FrontendPluginRegistry.h:27
+#endif // LLVM_FLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H
\ No newline at end of file


FIXME



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:202
 
+  if (llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_load)) {
+opts.plugins.push_back(a->getValue());

[nit] Perhaps worth adding a comment to highlight _which_ option is being 
parsed?



Comment at: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:87
+  if (plugin.getName() == ci.frontendOpts().ActionName) {
+std::unique_ptr P(plugin.instantiate());
+return std::move(P);

Lower case `P`



Comment at: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:92
+unsigned diagID = ci.diagnostics().getCustomDiagID(
+clang::DiagnosticsEngine::Error, "unable to find plugin '%0'");
+ci.diagnostics().Report(diagID) << ci.frontendOpts().ActionName;

Could you add a test for this diagnostic?



Comment at: flang/test/Driver/plugin-example.f90:7
+! RUN: %flang_fc1 -load %llvmshlibdir/flangHelloWorldPlugin%pluginext -plugin 
-hello-world %s 2>&1 | FileCheck %s
+! CHECK: Hello World from your new plugin

[tiny nit] Could you make it Flang specific? E.g. `Hello World from your new 
Flang plugin`



Comment at: flang/test/lit.cfg.py:55
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')

Could `llvm_plugin_ext` be ever empty? Perhaps I'm missing something, but it 
feels that `if config.has_plugins` should be sufficient here.



Comment at: flang/tools/flang-driver/CMakeLists.txt:30
 
+export_executable_symbols_for_plugins(flang-new)
+

We should make it possible to turn this off, perhaps:
```lang=clamg
# Some clever comment
if(FLANG_PLUGIN_SUPPORT)
  export_executable_symbols_for_plugins(flang-new)
endif()
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106137/new/

https://reviews.llvm.org/D106137

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer marked 2 inline comments as done.
fmayer added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:407
   bool Recover;
+  bool DisableOptimization;
 };

eugenis wrote:
> No need to pass this down, just look at OptimizeNone function attribute.
Interesting, the Aarch64StackTagging code does pass this down, do you know why?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:407
   bool Recover;
+  bool DisableOptimization;
 };

fmayer wrote:
> eugenis wrote:
> > No need to pass this down, just look at OptimizeNone function attribute.
> Interesting, the Aarch64StackTagging code does pass this down, do you know 
> why?
Also we really should be using this at least in the getAnalysisUsage, which 
Vitaly's change made unconditional. Correct?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106112: [clang-format] Break an unwrapped line at a K&R C parameter decl

2021-07-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D106112#2883301 , @curdeius wrote:

> Looks okay, but I was wondering if we don't want to guard all K&R-related 
> changes behind e.g. ```Standard: Cpp78``, so as not to possibly introduce 
> strange bugs in newer modes.
> It may be an overkill if there are 2 patches like this, but if there are 
> more, that might become sensible to do so.
> WDYT?

I wouldn't be opposed to that idea


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106112/new/

https://reviews.llvm.org/D106112

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer updated this revision to Diff 359373.
fmayer added a comment.

don't use stack analysis for opt null


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-stack-safety-analysis-asm.c
  clang/test/CodeGen/hwasan-stack-safety-analysis.c
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll

Index: llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
@@ -0,0 +1,43 @@
+; RUN: opt -hwasan -hwasan-use-stack-safety=1 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=SAFETY
+; RUN: opt -hwasan -hwasan-use-stack-safety=0 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=NOSAFETY
+
+; ModuleID = '/usr/local/google/home/fmayer/llvm-project/clang/test/CodeGen/hwasan-stack-safety-analysis.c'
+source_filename = "/usr/local/google/home/fmayer/llvm-project/clang/test/CodeGen/hwasan-stack-safety-analysis.c"
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+; Function Attrs: mustprogress nofree nounwind uwtable willreturn
+define i32 @test_load(i32* %a) sanitize_hwaddress {
+entry:
+  ; NOSAFETY: call {{.*}}__hwasan_generate_tag
+  ; SAFETY-NOT: call {{.*}}__hwasan_generate_tag
+  %buf.sroa.0 = alloca i8, align 4
+  call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  store volatile i8 0, i8* %buf.sroa.0, align 4, !tbaa !8
+  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  ret i32 0
+}
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
+
+attributes #0 = { mustprogress nofree nounwind uwtable willreturn "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
+attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
+
+!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 1, !"branch-target-enforcement", i32 0}
+!2 = !{i32 1, !"sign-return-address", i32 0}
+!3 = !{i32 1, !"sign-return-address-all", i32 0}
+!4 = !{i32 1, !"sign-return-address-with-bkey", i32 0}
+!5 = !{i32 7, !"uwtable", i32 1}
+!6 = !{i32 7, !"frame-pointer", i32 1}
+!7 = !{!"clang version 13.0.0 (/usr/local/google/home/fmayer/llvm-project/clang 267dacd628370863dd960ba41b664b6f86c56961)"}
+!8 = !{!9, !9, i64 0}
+!9 = !{!"omnipotent char", !10, i64 0}
+!10 = !{!"Simple C/C++ TBAA"}
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -109,6 +110,11 @@
cl::desc("instrument stack (allocas)"),
cl::Hidden, cl::init(true));
 
+static cl::opt
+ClUseStackSafety("hwasan-use-stack-safety", cl::Hidden, cl::init(true),
+ cl::Hidden, cl::desc("Use Stack Safety analysis results"),
+ cl::Optional);
+
 static cl::opt ClUARRetagToZero(
 "hwasan-uar-retag-to-zero",
 cl::desc("Clear alloca tags before returning from the function to allow "
@@ -210,13 +216,22 @@
 #pragma GCC poison ClInstrumentWithCalls
 }
 
+bool shouldUseStackSafetyAnalysis(const Triple &TargetTriple,
+  bool DisableOptimization) {
+  auto StackSafety = ClUseStackSafety.getNumOccurrences()
+ ? ClUseStackSafety
+ : !DisableOptimization;
+  return shouldInstrumentStack(TargetTriple) && StackSafety;
+// No one should use the option directly.
+#pragma GCC poison ClUseStackSafety
+}
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
 class HWAddressSanitizer {
 public:
-  explicit HWAddressSanitizer(Module &M, bool CompileKernel = false,
-  bool Recover = false)
-  : M(M) {
+  explicit H

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/CodeGen/BackendUtil.cpp:1174
+CompileKernel, Recover,
+/*IsOptNull=*/CodeGenOpts.OptimizationLevel == 0));
   }

DisableOptimization=



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:407
   bool Recover;
+  bool DisableOptimization;
 };

fmayer wrote:
> fmayer wrote:
> > eugenis wrote:
> > > No need to pass this down, just look at OptimizeNone function attribute.
> > Interesting, the Aarch64StackTagging code does pass this down, do you know 
> > why?
> Also we really should be using this at least in the getAnalysisUsage, which 
> Vitaly's change made unconditional. Correct?
Ah right. Legacy pass needs to declare its analysis dependencies in advance.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Florian Mayer via Phabricator via cfe-commits
fmayer updated this revision to Diff 359376.
fmayer marked 3 inline comments as done.
fmayer added a comment.

fix comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-stack-safety-analysis-asm.c
  clang/test/CodeGen/hwasan-stack-safety-analysis.c
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll

Index: llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
@@ -0,0 +1,43 @@
+; RUN: opt -hwasan -hwasan-use-stack-safety=1 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=SAFETY
+; RUN: opt -hwasan -hwasan-use-stack-safety=0 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=NOSAFETY
+
+; ModuleID = '/usr/local/google/home/fmayer/llvm-project/clang/test/CodeGen/hwasan-stack-safety-analysis.c'
+source_filename = "/usr/local/google/home/fmayer/llvm-project/clang/test/CodeGen/hwasan-stack-safety-analysis.c"
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+; Function Attrs: mustprogress nofree nounwind uwtable willreturn
+define i32 @test_load(i32* %a) sanitize_hwaddress {
+entry:
+  ; NOSAFETY: call {{.*}}__hwasan_generate_tag
+  ; SAFETY-NOT: call {{.*}}__hwasan_generate_tag
+  %buf.sroa.0 = alloca i8, align 4
+  call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  store volatile i8 0, i8* %buf.sroa.0, align 4, !tbaa !8
+  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  ret i32 0
+}
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
+
+attributes #0 = { mustprogress nofree nounwind uwtable willreturn "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
+attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
+
+!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 1, !"branch-target-enforcement", i32 0}
+!2 = !{i32 1, !"sign-return-address", i32 0}
+!3 = !{i32 1, !"sign-return-address-all", i32 0}
+!4 = !{i32 1, !"sign-return-address-with-bkey", i32 0}
+!5 = !{i32 7, !"uwtable", i32 1}
+!6 = !{i32 7, !"frame-pointer", i32 1}
+!7 = !{!"clang version 13.0.0 (/usr/local/google/home/fmayer/llvm-project/clang 267dacd628370863dd960ba41b664b6f86c56961)"}
+!8 = !{!9, !9, i64 0}
+!9 = !{!"omnipotent char", !10, i64 0}
+!10 = !{!"Simple C/C++ TBAA"}
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -109,6 +110,11 @@
cl::desc("instrument stack (allocas)"),
cl::Hidden, cl::init(true));
 
+static cl::opt
+ClUseStackSafety("hwasan-use-stack-safety", cl::Hidden, cl::init(true),
+ cl::Hidden, cl::desc("Use Stack Safety analysis results"),
+ cl::Optional);
+
 static cl::opt ClUARRetagToZero(
 "hwasan-uar-retag-to-zero",
 cl::desc("Clear alloca tags before returning from the function to allow "
@@ -210,13 +216,22 @@
 #pragma GCC poison ClInstrumentWithCalls
 }
 
+bool shouldUseStackSafetyAnalysis(const Triple &TargetTriple,
+  bool DisableOptimization) {
+  auto StackSafety = ClUseStackSafety.getNumOccurrences()
+ ? ClUseStackSafety
+ : !DisableOptimization;
+  return shouldInstrumentStack(TargetTriple) && StackSafety;
+// No one should use the option directly.
+#pragma GCC poison ClUseStackSafety
+}
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
 class HWAddressSanitizer {
 public:
-  explicit HWAddressSanitizer(Module &M, bool CompileKernel = false,
-  bool Recover = false)
-  : M(M)

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-16 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Btw Vitaly, will this work with LTO out of the box? I think we used to add 
pre-LTO StackSafety pass explicitly for memtag only, but it looks like that 
code is gone.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105703/new/

https://reviews.llvm.org/D105703

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106136: [Analyzer][solver] Fix equivalence class invariant violation in removeDeadBindings

2021-07-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D106136#2883100 , @martong wrote:

> Thanks for taking your time to take a look. And I accept your statements. 
> Nevertheless, let me explain my motivation.
>
> I thought that a class is trivial if it has only one member. And it seemed 
> perfectly logical to not store equivalence classes with one member. I.e `a` 
> equals to `a` does not hold any meaningful information it just takes precious 
> memory. When we add a new constraint we take careful steps to avoid adding a 
> new class with one member. However, when remove dead kicks in, suddenly we 
> end up having classes stored with one member, which is a somewhat 
> inconsistent design IMHO. Perhaps some better documentation could have helped.

Representative symbol gives its equivalence class an ID.  We use this ID for 
everything, for comparing and for mapping.  Since we live in a persistent 
world, we can't just change this ID at some point, it will basically mean that 
we want to replace a class with another class.  So, all maps where this class 
participated (constraints, class, members, disequality) should remove the old 
class and add the new class.  This is a huge burden.  You need to carefully do 
all this, and bloat existing data structures.

Trivial class is an optimization for the vast majority of symbols that never 
get into any classes.  We still need to associate constraints with those.  This 
is where implicit Symbol to Class conversion comes in handy.

Now let's imagine that something else is merged into it.  We are obliged to 
officially map the symbol to its class, and the class to its members.  When 
this happens, it goes into the data structure FOREVER.  And when in the future, 
with only one member, instead of keeping something that we already have from 
other versions of the data structure, you decide to remove the item from the 
class map, you actually use more memory when it was there!  This is how 
persistent data structures work, different versions of the same data structure 
share data.  And I'm not even talking here about the fact that you now need to 
replace the class with one ID with the class with another ID in every 
relationship.

You can probably measure memory footprint in your example and see it for 
yourself.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106136/new/

https://reviews.llvm.org/D106136

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105946: [PowerPC] Store, load, move from and to registers related builtins

2021-07-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 359380.
Conanap added a comment.

Updated a test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105946/new/

https://reviews.llvm.org/D105946

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  clang/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.c
  clang/test/CodeGen/builtins-ppc-xlcompat-prefetch.c
  clang/test/CodeGen/builtins-ppc-xlcompat-stfiw.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-stfiw.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-prefetch.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX64
+
+declare void @llvm.ppc.dcbtstt(i8*)
+declare void @llvm.ppc.dcbtt(i8*)
+
+@vpa = external local_unnamed_addr global i8*, align 8
+
+define dso_local void @test_dcbtstt() {
+; CHECK-LABEL: test_dcbtstt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addis 3, 2, .LC0@toc@ha
+; CHECK-NEXT:ld 3, .LC0@toc@l(3)
+; CHECK-NEXT:ld 3, 0(3)
+; CHECK-NEXT:dcbtstt 0, 3
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_dcbtstt:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
+; CHECK-AIX-NEXT:lwz 3, 0(3)
+; CHECK-AIX-NEXT:dcbtstt 0, 3
+; CHECK-AIX-NEXT:blr
+;
+; CHECK-AIX64-LABEL: test_dcbtstt:
+; CHECK-AIX64:   # %bb.0: # %entry
+; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
+; CHECK-AIX64-NEXT:ld 3, 0(3)
+; CHECK-AIX64-NEXT:dcbtstt 0, 3
+; CHECK-AIX64-NEXT:blr
+entry:
+  %0 = load i8*, i8** @vpa, align 8
+  tail call void @llvm.ppc.dcbtstt(i8* %0)
+  ret void
+}
+
+
+define dso_local void @test_dcbtt() {
+; CHECK-LABEL: test_dcbtt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addis 3, 2, .LC0@toc@ha
+; CHECK-NEXT:ld 3, .LC0@toc@l(3)
+; CHECK-NEXT:ld 3, 0(3)
+; CHECK-NEXT:dcbtt 0, 3
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-LABEL: test_dcbtt:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
+; CHECK-AIX-NEXT:lwz 3, 0(3)
+; CHECK-AIX-NEXT:dcbtt 0, 3
+; CHECK-AIX-NEXT:blr
+;
+; CHECK-AIX64-LABEL: test_dcbtt:
+; CHECK-AIX64:   # %bb.0: # %entry
+; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
+; CHECK-AIX64-NEXT:ld 3, 0(3)
+; CHECK-AIX64-NEXT:dcbtt 0, 3
+; CHECK-AIX64-NEXT:blr
+entry:
+  %0 = load i8*, i8** @vpa, align 8
+  tail call void @llvm.ppc.dcbtt(i8* %0)
+  ret void
+}
Index: llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-32BIT
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+
+declare i32 @llvm.ppc.mftbu()
+declare i32 @llvm.ppc.mfmsr()
+
+define dso_local zeroext i32 @test_mftbu() {
+; CHECK-LABEL: test_mftbu:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mftbu 3
+; CHECK-NEXT:clrldi 3, 3, 32
+; CHECK-NEXT:blr
+;
+; CHECK-32BIT-LABEL: test_mftbu:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mftbu 3
+; CHECK-32BIT-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.mftbu()
+  ret i32 %0
+}
+
+define dso_local i64 @test_mfmsr() {
+; CHECK-LABEL: test_mfmsr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfmsr 3
+; CHECK-NEXT:clrldi 3, 3, 32
+; CHECK-NEXT:blr
+;
+; CHECK-3

[clang] 0bf4b81 - [Clang] Add an empty builtins.h file.

2021-07-16 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2021-07-16T12:50:04-05:00
New Revision: 0bf4b81d57b0b4d1ecc2752be3e4ad1504ee1eb3

URL: 
https://github.com/llvm/llvm-project/commit/0bf4b81d57b0b4d1ecc2752be3e4ad1504ee1eb3
DIFF: 
https://github.com/llvm/llvm-project/commit/0bf4b81d57b0b4d1ecc2752be3e4ad1504ee1eb3.diff

LOG: [Clang] Add an empty builtins.h file.

On Power PC some legacy compilers included a number of builtins in a
builtins.h header file. While this header file is not required to hold
builtins for clang some legacy code does try to include this file and so
this patch provides an empty version of that file.

Differential Revision: https://reviews.llvm.org/D106065

Added: 
clang/lib/Headers/builtins.h
clang/test/Headers/builtins-header.c

Modified: 
clang/lib/Headers/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index 382d40b2c0a99..8131f6005dc21 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -38,6 +38,7 @@ set(files
   avxvnniintrin.h
   bmi2intrin.h
   bmiintrin.h
+  builtins.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_math.h
   __clang_cuda_cmath.h

diff  --git a/clang/lib/Headers/builtins.h b/clang/lib/Headers/builtins.h
new file mode 100644
index 0..65095861ca9b1
--- /dev/null
+++ b/clang/lib/Headers/builtins.h
@@ -0,0 +1,16 @@
+/*=== builtins.h - Standard header for extra builtins 
-===*\
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+\*===--===*/
+
+/// Some legacy compilers have builtin definitions in a file named builtins.h.
+/// This header file has been added to allow compatibility with code that was
+/// written for those compilers. Code may have an include line for this file
+/// and to avoid an error an empty file with this name is provided.
+#ifndef __BUILTINS_H
+#define __BUILTINS_H
+
+#endif /* __BUILTINS_H */

diff  --git a/clang/test/Headers/builtins-header.c 
b/clang/test/Headers/builtins-header.c
new file mode 100644
index 0..db5e0c56765d0
--- /dev/null
+++ b/clang/test/Headers/builtins-header.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -ffreestanding -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -ffreestanding 
-emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+// Verify that we can include 
+
+// CHECK: target triple = "powerpc64



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106065: [Clang] Add an empty builtins.h file.

2021-07-16 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bf4b81d57b0: [Clang] Add an empty builtins.h file. 
(authored by stefanp).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106065/new/

https://reviews.llvm.org/D106065

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/builtins.h
  clang/test/Headers/builtins-header.c


Index: clang/test/Headers/builtins-header.c
===
--- /dev/null
+++ clang/test/Headers/builtins-header.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -ffreestanding -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -ffreestanding 
-emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+// Verify that we can include 
+
+// CHECK: target triple = "powerpc64
Index: clang/lib/Headers/builtins.h
===
--- /dev/null
+++ clang/lib/Headers/builtins.h
@@ -0,0 +1,16 @@
+/*=== builtins.h - Standard header for extra builtins 
-===*\
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+\*===--===*/
+
+/// Some legacy compilers have builtin definitions in a file named builtins.h.
+/// This header file has been added to allow compatibility with code that was
+/// written for those compilers. Code may have an include line for this file
+/// and to avoid an error an empty file with this name is provided.
+#ifndef __BUILTINS_H
+#define __BUILTINS_H
+
+#endif /* __BUILTINS_H */
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -38,6 +38,7 @@
   avxvnniintrin.h
   bmi2intrin.h
   bmiintrin.h
+  builtins.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_math.h
   __clang_cuda_cmath.h


Index: clang/test/Headers/builtins-header.c
===
--- /dev/null
+++ clang/test/Headers/builtins-header.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -ffreestanding -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -ffreestanding -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+// Verify that we can include 
+
+// CHECK: target triple = "powerpc64
Index: clang/lib/Headers/builtins.h
===
--- /dev/null
+++ clang/lib/Headers/builtins.h
@@ -0,0 +1,16 @@
+/*=== builtins.h - Standard header for extra builtins -===*\
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+\*===--===*/
+
+/// Some legacy compilers have builtin definitions in a file named builtins.h.
+/// This header file has been added to allow compatibility with code that was
+/// written for those compilers. Code may have an include line for this file
+/// and to avoid an error an empty file with this name is provided.
+#ifndef __BUILTINS_H
+#define __BUILTINS_H
+
+#endif /* __BUILTINS_H */
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -38,6 +38,7 @@
   avxvnniintrin.h
   bmi2intrin.h
   bmiintrin.h
+  builtins.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_math.h
   __clang_cuda_cmath.h
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104058: ThinLTO: Fix inline assembly references to static functions with CFI

2021-07-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D104058#2878083 , @samitolvanen 
wrote:

> In D104058#2877631 , 
> @nickdesaulniers wrote:
>
>> Change LGTM, but I don't understand why the following tests are modified:
>>
>> - llvm/test/ThinLTO/X86/devirt2.ll
>
> This is needed to fix two `missing symbol resolution` errors that are caused 
> by the aliases we added.

I'm curious if this will lead to breakages with LTO in general? I suppose not, 
since it's `llvm-lto2` that needs the explicit list of symbols that can be 
linked against.

>> - llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
>> - llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
>
> And for these, we need to specify a target triple to use module inline 
> assembly. According to pcc, there shouldn't be a real-world situation where 
> the triple is missing, but these two tests don't currently specify one.

Neither of these tests use module inline assembly though, AFAICT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104058/new/

https://reviews.llvm.org/D104058

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104058: ThinLTO: Fix inline assembly references to static functions with CFI

2021-07-16 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen added a comment.

In D104058#2883804 , @nickdesaulniers 
wrote:

> In D104058#2878083 , @samitolvanen 
> wrote:
>
>> In D104058#2877631 , 
>> @nickdesaulniers wrote:
>>
>>> Change LGTM, but I don't understand why the following tests are modified:
>>>
>>> - llvm/test/ThinLTO/X86/devirt2.ll
>>
>> This is needed to fix two `missing symbol resolution` errors that are caused 
>> by the aliases we added.
>
> I'm curious if this will lead to breakages with LTO in general? I suppose 
> not, since it's `llvm-lto2` that needs the explicit list of symbols that can 
> be linked against.

No, this won't break LTO.

>>> - llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
>>> - llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
>>
>> And for these, we need to specify a target triple to use module inline 
>> assembly. According to pcc, there shouldn't be a real-world situation where 
>> the triple is missing, but these two tests don't currently specify one.
>
> Neither of these tests use module inline assembly though, AFAICT?

The tests don't, but we add module inline assembly to create the aliases, which 
means that bitcode with type metadata will need a target triple for ThinLTO.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104058/new/

https://reviews.llvm.org/D104058

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101759: [PowerPC] Scalar IBM MASS library conversion pass

2021-07-16 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei updated this revision to Diff 359385.
masoud.ataei added a comment.

Removed clang changes from this PR.
Removed extra option for MASS pass.
Now MASS pass is active with -O3 and approx-func option.

Adding another PR for clang changes on approx-func option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101759/new/

https://reviews.llvm.org/D101759

Files:
  llvm/include/llvm/Analysis/ScalarFuncs.def
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/CMakeLists.txt
  llvm/lib/Target/PowerPC/PPC.h
  llvm/lib/Target/PowerPC/PPCGenScalarMASSEntries.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/lower-intrinsics-afn-mass.ll
  llvm/test/CodeGen/PowerPC/lower-intrinsics-fast-mass.ll
  llvm/test/CodeGen/PowerPC/lower-intrinsics-mass-aix.ll
  llvm/test/CodeGen/PowerPC/lower-intrinsics-nofast-mass.ll
  llvm/test/CodeGen/PowerPC/lower-scalar-mass-afn.ll
  llvm/test/CodeGen/PowerPC/lower-scalar-mass-fast.ll
  llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-afn.ll
  llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll
  llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll

Index: llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll
@@ -0,0 +1,456 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -O3 -enable-approx-func-fp-math -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK-LNX %s
+; RUN: llc -verify-machineinstrs -O3 -enable-approx-func-fp-math -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK-AIX %s
+
+declare float @powf (float, float);
+declare double @pow (double, double);
+declare float @__powf_finite (float, float);
+declare double @__pow_finite (double, double);
+
+; fast-math powf with 0.25
+define float @powf_f32_fast025(float %a) #1 {
+;
+; CHECK-LNX-LABEL: powf_f32_fast025:
+; CHECK-LNX:   # %bb.0: # %entry
+; CHECK-LNX-NEXT:mflr 0
+; CHECK-LNX-NEXT:std 0, 16(1)
+; CHECK-LNX-NEXT:stdu 1, -32(1)
+; CHECK-LNX-NEXT:.cfi_def_cfa_offset 32
+; CHECK-LNX-NEXT:.cfi_offset lr, 16
+; CHECK-LNX-NEXT:addis 3, 2, .LCPI0_0@toc@ha
+; CHECK-LNX-NEXT:lfs 2, .LCPI0_0@toc@l(3)
+; CHECK-LNX-NEXT:bl __xl_powf_finite
+; CHECK-LNX-NEXT:nop
+; CHECK-LNX-NEXT:addi 1, 1, 32
+; CHECK-LNX-NEXT:ld 0, 16(1)
+; CHECK-LNX-NEXT:mtlr 0
+; CHECK-LNX-NEXT:blr
+;
+; CHECK-AIX-LABEL: powf_f32_fast025:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:mflr 0
+; CHECK-AIX-NEXT:stw 0, 8(1)
+; CHECK-AIX-NEXT:stwu 1, -64(1)
+; CHECK-AIX-NEXT:lwz 3, L..C0(2) # %const.0
+; CHECK-AIX-NEXT:lfs 2, 0(3)
+; CHECK-AIX-NEXT:bl .__xl_powf_finite[PR]
+; CHECK-AIX-NEXT:nop
+; CHECK-AIX-NEXT:addi 1, 1, 64
+; CHECK-AIX-NEXT:lwz 0, 8(1)
+; CHECK-AIX-NEXT:mtlr 0
+; CHECK-AIX-NEXT:blr
+entry:
+  %call = tail call nnan ninf afn nsz float @powf(float %a, float 2.50e-01)
+  ret float %call
+}
+
+; fast-math pow with 0.25
+define double @pow_f64_fast025(double %a) #1 {
+;
+; CHECK-LNX-LABEL: pow_f64_fast025:
+; CHECK-LNX:   # %bb.0: # %entry
+; CHECK-LNX-NEXT:mflr 0
+; CHECK-LNX-NEXT:std 0, 16(1)
+; CHECK-LNX-NEXT:stdu 1, -32(1)
+; CHECK-LNX-NEXT:.cfi_def_cfa_offset 32
+; CHECK-LNX-NEXT:.cfi_offset lr, 16
+; CHECK-LNX-NEXT:addis 3, 2, .LCPI1_0@toc@ha
+; CHECK-LNX-NEXT:lfs 2, .LCPI1_0@toc@l(3)
+; CHECK-LNX-NEXT:bl __xl_pow_finite
+; CHECK-LNX-NEXT:nop
+; CHECK-LNX-NEXT:addi 1, 1, 32
+; CHECK-LNX-NEXT:ld 0, 16(1)
+; CHECK-LNX-NEXT:mtlr 0
+; CHECK-LNX-NEXT:blr
+;
+; CHECK-AIX-LABEL: pow_f64_fast025:
+; CHECK-AIX:   # %bb.0: # %entry
+; CHECK-AIX-NEXT:mflr 0
+; CHECK-AIX-NEXT:stw 0, 8(1)
+; CHECK-AIX-NEXT:stwu 1, -64(1)
+; CHECK-AIX-NEXT:lwz 3, L..C1(2) # %const.0
+; CHECK-AIX-NEXT:lfs 2, 0(3)
+; CHECK-AIX-NEXT:bl .__xl_pow_finite[PR]
+; CHECK-AIX-NEXT:nop
+; CHECK-AIX-NEXT:addi 1, 1, 64
+; CHECK-AIX-NEXT:lwz 0, 8(1)
+; CHECK-AIX-NEXT:mtlr 0
+; CHECK-AIX-NEXT:blr
+entry:
+  %call = tail call nnan ninf afn nsz double @pow(double %a, double 2.50e-01)
+  ret double %call
+}
+
+; fast-math powf with 0.75
+define float @powf_f32_fast075(float %a) #1 {
+;
+; CHECK-LNX-LABEL: powf_f32_fast075:
+; CHECK-LNX:   # %bb.0: # %entry
+; CHECK-LNX-NEXT:mflr 0
+; CHECK-LNX-NEXT:std 0, 16(1)
+; CHECK-LNX-NEXT:stdu 1, -32(1)
+; CHECK-LNX-NEXT:.cfi_def_cfa_offset 32
+; CHECK-LNX-NEXT:.cfi_offset lr, 16
+; CHECK-LNX-NEXT:addis 3, 2, .LCPI2_0@toc@ha
+; CHECK-LNX-NEXT:lfs 2, .LCPI2_0@toc@l(3)

[clang] eef6601 - [OpenMP] Rework OpenMP remarks

2021-07-16 Thread via cfe-commits

Author: Joseph Huber
Date: 2021-07-16T14:07:00-04:00
New Revision: eef6601b0fb6d5fee32627e07be4acbf769e5c0f

URL: 
https://github.com/llvm/llvm-project/commit/eef6601b0fb6d5fee32627e07be4acbf769e5c0f
DIFF: 
https://github.com/llvm/llvm-project/commit/eef6601b0fb6d5fee32627e07be4acbf769e5c0f.diff

LOG: [OpenMP] Rework OpenMP remarks

This patch rewrites and reworks a few of the existing remarks to make the mmore
concise and consistent prior to writing the documentation for them.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D105898

Added: 


Modified: 
clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/custom_state_machines_remarks.ll
llvm/test/Transforms/OpenMP/deduplication_remarks.ll
llvm/test/Transforms/OpenMP/globalization_remarks.ll
llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
llvm/test/Transforms/OpenMP/remove_globalization.ll
llvm/test/Transforms/OpenMP/spmdization_remarks.ll

Removed: 




diff  --git 
a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c 
b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
index 20142d944f362..9a7693e744de0 100644
--- a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
@@ -8,37 +8,28 @@ void baz(void) __attribute__((assume("omp_no_openmp")));
 
 void bar1(void) {
 #pragma omp parallel // #0
- // all-remark@#0 {{Found a parallel region that is called 
in a target region but not part of a combined target construct nor nested 
inside a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}}
- // safe-remark@#0 {{Parallel region is used in unknown 
ways; will not attempt to rewrite the state machine.}}
- // force-remark@#0 {{Specialize parallel region that is 
only reached from a single target region to avoid spurious call edges and 
excessive register usage in other target regions. (parallel region ID: 
__omp_outlined__2_wrapper, kernel ID: }}
+ // safe-remark@#0 {{Parallel region is used in unknown 
ways. Will not attempt to rewrite the state machine.}}
   {
   }
 }
 void bar2(void) {
 #pragma omp parallel // #1
- // all-remark@#1 {{Found a parallel region that is called 
in a target region but not part of a combined target construct nor nested 
inside a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}}
- // safe-remark@#1 {{Parallel region is used in unknown 
ways; will not attempt to rewrite the state machine.}}
- // force-remark@#1 {{Specialize parallel region that is 
only reached from a single target region to avoid spurious call edges and 
excessive register usage in other target regions. (parallel region ID: 
__omp_outlined__6_wrapper, kernel ID: }}
+ // safe-remark@#1 {{Parallel region is used in unknown 
ways. Will not attempt to rewrite the state machine.}}
   {
   }
 }
 
 void foo1(void) {
 #pragma omp target teams // #2
- // all-remark@#2 {{Generic-mode kernel is executed 
with a customized state machine [3 known parallel regions] (good).}}
- // all-remark@#2 {{Target region containing the 
parallel region that is specialized. (parallel region ID: 
__omp_outlined__1_wrapper, kernel ID: __omp_offloading}}
- // all-remark@#2 {{Target region containing the 
parallel region that is specialized. (parallel region ID: 
__omp_outlined__2_wrapper, kernel ID: __omp_offloading}}
+ // all-remark@#2 {{Rewriting generic-mode kernel with 
a customized state machine.}}
+
   {
-baz();   // all-remark {{Kernel will be executed in generic-mode 
due to this potential side-effect, consider to add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function 
'_Z3bazv'.}}
+baz();   // all-remark {{Value has potential side effects 
preventing SPMD-mode execution. Add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function to 
override.}}
 #pragma omp parallel // #3
- // all-remark@#3 {{Found a parallel region that is called 
in a target region but not part of a combined target construct nor nested 
inside a target construct without intermediate code. This can lead to excessive 
register us

[PATCH] D105898: [OpenMP] Rework OpenMP remarks

2021-07-16 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeef6601b0fb6: [OpenMP] Rework OpenMP remarks (authored by 
jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D105898?vs=359319&id=359390#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105898/new/

https://reviews.llvm.org/D105898

Files:
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  llvm/lib/Transforms/IPO/AttributorAttributes.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/custom_state_machines_remarks.ll
  llvm/test/Transforms/OpenMP/deduplication_remarks.ll
  llvm/test/Transforms/OpenMP/globalization_remarks.ll
  llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
  llvm/test/Transforms/OpenMP/remove_globalization.ll
  llvm/test/Transforms/OpenMP/spmdization_remarks.ll

Index: llvm/test/Transforms/OpenMP/spmdization_remarks.ll
===
--- llvm/test/Transforms/OpenMP/spmdization_remarks.ll
+++ llvm/test/Transforms/OpenMP/spmdization_remarks.ll
@@ -1,12 +1,13 @@
 ; RUN: opt -passes=openmp-opt -pass-remarks=openmp-opt -pass-remarks-missed=openmp-opt -pass-remarks-analysis=openmp-opt -disable-output < %s 2>&1 | FileCheck %s
 target triple = "nvptx64"
 
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: Kernel will be executed in generic-mode due to this potential side-effect, consider to add `__attribute__((assume("ompx_spmd_amenable")))` to the called function 'unknown'.
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: Kernel will be executed in generic-mode due to this potential side-effect, consider to add `__attribute__((assume("ompx_spmd_amenable")))` to the called function 'unknown'.
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:11:1: Generic-mode kernel is executed with a customized state machine that requires a fallback [1 known parallel regions, 2 unkown parallel regions] (bad).
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: State machine fallback caused by this call. If it is a false positive, use `__attribute__((assume("omp_no_openmp")))` (or "omp_no_parallelism").
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: State machine fallback caused by this call. If it is a false positive, use `__attribute__((assume("omp_no_openmp")))` (or "omp_no_parallelism").
-; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:20:1: Generic-mode kernel is changed to SPMD-mode.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:11:1: Generic-mode kernel is executed with a customized state machine that requires a fallback.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:13:5: Call may contain unknown parallel regions. Use `__attribute__((assume("omp_no_parallelism")))` to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:15:5: Call may contain unknown parallel regions. Use `__attribute__((assume("omp_no_parallelism")))` to override.
+; CHECK: remark: llvm/test/Transforms/OpenMP/spmdization_remarks.c:20:1: Transformed generic-mode kernel to SPMD-mode.
+
 
 ;; void unknown(void);
 ;; void known(void) {
Index: llvm/test/Transforms/OpenMP/remove_globalization.ll
===
--- llvm/test/Transforms/OpenMP/remove_globalization.ll
+++ llvm/test/Transforms/OpenMP/remove_globalization.ll
@@ -4,7 +4,7 @@
 target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
 target triple = "nvptx64"
 
-; CHECK-REMARKS: remark: remove_globalization.c:4:2: Could not move globalized variable to the stack as variable is potentially captured in call; mark parameter as `__attribute__((noescape))` to override.
+; CHECK-REMARKS: remark: remove_globalization.c:4:2: Could not move globalized variable to the stack. Variable is potentially captured in call. Mark parameter as `__attribute__((noescape))` to override.
 ; CHECK-REMARKS: remark: remove_globalization.c:2:2: Moving globalized variable to the stack.
 ; CHECK-REMARKS: remark: remove_globalization.c:6:2: Moving globalized variable to the stack.
 ; CHECK-REMARKS: remark: remove_globalization.c:4:2: Found thread data sharing on the GPU. Expect degraded performance due to data globalization.
Index: llvm

[clang] 2c31d5e - [OpenMP] Add IDs to OpenMP remarks

2021-07-16 Thread via cfe-commits

Author: Joseph Huber
Date: 2021-07-16T14:07:03-04:00
New Revision: 2c31d5ebfbbb36de37d41b6945d0c45efa512790

URL: 
https://github.com/llvm/llvm-project/commit/2c31d5ebfbbb36de37d41b6945d0c45efa512790
DIFF: 
https://github.com/llvm/llvm-project/commit/2c31d5ebfbbb36de37d41b6945d0c45efa512790.diff

LOG: [OpenMP] Add IDs to OpenMP remarks

This patch adds unique idenfitiers to the existing OpenMP remarks. This makes
it easier to identify the corresponding documentation for each remark that will
be hosted in the OpenMP webpage.

Depends on D105898

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D105939

Added: 


Modified: 
clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Removed: 




diff  --git 
a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c 
b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
index 9a7693e744de0..3c74febc61874 100644
--- a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
@@ -8,23 +8,23 @@ void baz(void) __attribute__((assume("omp_no_openmp")));
 
 void bar1(void) {
 #pragma omp parallel // #0
- // safe-remark@#0 {{Parallel region is used in unknown 
ways. Will not attempt to rewrite the state machine.}}
+ // safe-remark@#0 {{Parallel region is used in unknown 
ways. Will not attempt to rewrite the state machine. [OMP101]}}
   {
   }
 }
 void bar2(void) {
 #pragma omp parallel // #1
- // safe-remark@#1 {{Parallel region is used in unknown 
ways. Will not attempt to rewrite the state machine.}}
+ // safe-remark@#1 {{Parallel region is used in unknown 
ways. Will not attempt to rewrite the state machine. [OMP101]}}
   {
   }
 }
 
 void foo1(void) {
 #pragma omp target teams // #2
- // all-remark@#2 {{Rewriting generic-mode kernel with 
a customized state machine.}}
+ // all-remark@#2 {{Rewriting generic-mode kernel with 
a customized state machine. [OMP131]}}
 
   {
-baz();   // all-remark {{Value has potential side effects 
preventing SPMD-mode execution. Add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function to 
override.}}
+baz();   // all-remark {{Value has potential side effects 
preventing SPMD-mode execution. Add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function to 
override. [OMP121]}}
 #pragma omp parallel // #3
 {
 }
@@ -37,9 +37,9 @@ void foo1(void) {
 
 void foo2(void) {
 #pragma omp target teams // #5
- // all-remark@#5 {{Rewriting generic-mode kernel with 
a customized state machine.}}
+ // all-remark@#5 {{Rewriting generic-mode kernel with 
a customized state machine. [OMP131]}}
   {
-baz();   // all-remark {{Value has potential side effects 
preventing SPMD-mode execution. Add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function to 
override.}}
+baz();   // all-remark {{Value has potential side effects 
preventing SPMD-mode execution. Add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function to 
override. [OMP121]}}
 #pragma omp parallel // #6
 {
 }
@@ -55,9 +55,9 @@ void foo2(void) {
 
 void foo3(void) {
 #pragma omp target teams // #8
- // all-remark@#8 {{Rewriting generic-mode kernel with 
a customized state machine.}}
+ // all-remark@#8 {{Rewriting generic-mode kernel with 
a customized state machine. [OMP131]}}
   {
-baz();   // all-remark {{Value has potential side effects 
preventing SPMD-mode execution. Add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function to 
override.}}
+baz();   // all-remark {{Value has potential side effects 
preventing SPMD-mode execution. Add 
`__attribute__((assume("ompx_spmd_amenable")))` to the called function to 
override. [OMP121]}}
 #pragma omp parallel // #9
 {
 }
@@ -83,4 +83,4 @@ void spmd(void) {
   }
 }
 
-// all-remark@* 9 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
+// all-remark@* 9 {{OpenMP runtime call __kmpc_global_thread_num deduplicated. 
[OMP170]}}

diff  --git a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c 
b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
index 69891d1a36384..38c8a80502599 100644
--- a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
+++ b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
@@ -8,16 +8,16 @@ void baz(void) __attribute__((a

[PATCH] D105939: [OpenMP] Add IDs to OpenMP remarks

2021-07-16 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c31d5ebfbbb: [OpenMP] Add IDs to OpenMP remarks (authored 
by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D105939?vs=358461&id=359391#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105939/new/

https://reviews.llvm.org/D105939

Files:
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/Transforms/IPO/AttributorAttributes.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -949,8 +949,7 @@
 return OR << ".";
   };
 
-  emitRemark(MergableCIs.front(),
- "OpenMPParallelRegionMerging", Remark);
+  emitRemark(MergableCIs.front(), "OMP150", Remark);
 
   Function *OriginalFn = BB->getParent();
   LLVM_DEBUG(dbgs() << TAG << "Merge " << MergableCIs.size()
@@ -1204,8 +1203,7 @@
   auto Remark = [&](OptimizationRemark OR) {
 return OR << "Removing parallel region with no side-effects.";
   };
-  emitRemark(CI, "OpenMPParallelRegionDeletion",
- Remark);
+  emitRemark(CI, "OMP160", Remark);
 
   CGUpdater.removeCallSite(*CI);
   CI->eraseFromParent();
@@ -1311,7 +1309,7 @@
  << "Found thread data sharing on the GPU. "
  << "Expect degraded performance due to data globalization.";
 };
-emitRemark(CI, "OpenMPGlobalization", Remark);
+emitRemark(CI, "OMP112", Remark);
   }
 
   return false;
@@ -1593,9 +1591,9 @@
   << ore::NV("OpenMPOptRuntime", RFI.Name) << " deduplicated.";
   };
   if (CI->getDebugLoc())
-emitRemark(CI, "OpenMPRuntimeDeduplicated", Remark);
+emitRemark(CI, "OMP170", Remark);
   else
-emitRemark(&F, "OpenMPRuntimeDeduplicated", Remark);
+emitRemark(&F, "OMP170", Remark);
 
   CGUpdater.removeCallSite(*CI);
   CI->replaceAllUsesWith(ReplVal);
@@ -1702,7 +1700,14 @@
 Function *F = I->getParent()->getParent();
 auto &ORE = OREGetter(F);
 
-ORE.emit([&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, I)); });
+if (RemarkName.startswith("OMP"))
+  ORE.emit([&]() {
+return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, I))
+   << " [" << RemarkName << "]";
+  });
+else
+  ORE.emit(
+  [&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, I)); });
   }
 
   /// Emit a remark on a function.
@@ -1711,7 +1716,14 @@
   RemarkCallBack &&RemarkCB) const {
 auto &ORE = OREGetter(F);
 
-ORE.emit([&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, F)); });
+if (RemarkName.startswith("OMP"))
+  ORE.emit([&]() {
+return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, F))
+   << " [" << RemarkName << "]";
+  });
+else
+  ORE.emit(
+  [&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, F)); });
   }
 
   /// The underlying module.
@@ -1880,8 +1892,7 @@
<< (UnknownUse ? "unknown" : "unexpected")
<< " ways. Will not attempt to rewrite the state machine.";
   };
-  emitRemark(F, "OpenMPParallelRegionInNonSPMD",
- Remark);
+  emitRemark(F, "OMP101", Remark);
   continue;
 }
 
@@ -1893,8 +1904,7 @@
 return ORA << "Parallel region is not called from a unique kernel. "
   "Will not attempt to rewrite the state machine.";
   };
-  emitRemark(
-  F, "OpenMPParallelRegionInMultipleKernesl", Remark);
+  emitRemark(F, "OMP102", Remark);
   continue;
 }
 
@@ -2581,8 +2591,7 @@
   << ((AllocSize->getZExtValue() != 1) ? " bytes " : " byte ")
   << "of shared memory.";
   };
-  A.emitRemark(CB, "OpenMPReplaceGlobalization",
-   Remark);
+  A.emitRemark(CB, "OMP111", Remark);
 
   SharedMem->setAlignment(MaybeAlign(32));
 
@@ -2823,8 +2832,8 @@
   }
   return ORA << ".";
 };
-A.emitRemark(
-NonCompatibleI, "OpenMPKernelNonSPMDMode", Remark);
+A.emitRemark(NonCompatibleI, "OMP121",
+ Remark);
 
 LLVM_DEBUG(dbgs() << TAG << "SPMD-incompatible side-effect: "
   << *NonCompatibleI << "\n");
@@ -2864,8 +2873,7 @@
 auto Remark = [&](OptimizationRemark OR) {
   return OR << "Transformed generic-mode kernel to SPMD-

[PATCH] D101759: [PowerPC] Scalar IBM MASS library conversion pass

2021-07-16 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei marked 9 inline comments as done.
masoud.ataei added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1370
+  // to be consistent to PPCGenScalarMASSEntries pass
+  if (TM.Options.PPCGenScalarMASSEntries && TM.Options.ApproxFuncFPMath) {
+if (TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath &&

bmahjour wrote:
> if someone compiles with -Ofast without any extra options, would 
> `TM.Options.ApproxFuncFPMath` be true here?
In clang changes, I had `Options.ApproxFuncFPMath = LangOpts.ApproxFunc;` in 
`clang/lib/CodeGen/BackendUtil.cpp`. That was responsible to update this TM 
option based on the clang approximate func option. And clang approximate func 
option will be set with -Ofast. 

Then, the answer for your question is yes. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101759/new/

https://reviews.llvm.org/D101759

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104058: ThinLTO: Fix inline assembly references to static functions with CFI

2021-07-16 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104058/new/

https://reviews.llvm.org/D104058

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D105959#2882136 , @mehdi_amini 
wrote:

> In D105959#2882099 , @bondhugula 
> wrote:
>
>> This is a really welcome change! Multiple registration issues were really an 
>> inconvenience - I had no clue this was the pattern to use to fix it. Thanks!
>
> To be fair: we can do it transparently only for libSupport, as it contains 
> the entry point for command line parsing it can explicitly trigger the 
> registration of the options for itself. Other libraries in LLVM don't have 
> this luxury...

We could probably combine this with the technique used to avoid static 
constructors in compiler-rt/lib/profile to pick up other libraries in the same 
final linked image. The idea would be to ask the linker to build an array of 
initializer functions that LLVMSupport could iterate through to initialize 
options it doesn't know about.

For example, on Darwin, this code adds an initializer to a global array in 
section `__DATA,__llvmopts`:

  using OptionConstructorT = void (*)(); // Declared in LLVMSupport headers to 
get safety.
  
  void initOptions();
  
  // Add an options constructor the array of cl::opt initializers.
  __attribute__((section("__DATA,__llvmopts"),visibility("hidden")))
  OptionConstructorT OptionsConstructor = initOptions;

Also on Darwin, this could go in LLVMSupport to access it:

  using OptionConstructorT = void (*)(); // Declared in LLVMSupport headers to 
get safety.
  
  // Declare symbols to access the global array.
  extern OptionConstructorT *ExternalOptionsInitBegin
__asm("section$start$__DATA$__llvmopts");
  extern OptionConstructorT *ExternalOptionsInitEnd
__asm("section$end$__DATA$__llvmopts");
  
  void initCommonOptions();
  void initOptions() {
initCommonOptions();
// Iterate through external initializers for options.
for (auto I = ExternalOptionsInitBegin, E = ExternalOptionsInitEnd; I != E; 
++I)
  (*I)();
  }

The relevant code for other platforms is in 
`compiler-rt/lib/profile/InstrProfilingPlatform*.c`.

If we did this, we'd maybe want to control it with a CMake configuration? When 
off (always for platforms where we don't have/know the magic incantations), the 
various `initOptions()` would be added to static initializers as before. When 
on, we could add `-Werror=global-constructors` to other libraries (once they're 
clean).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c8937b6 - [PowerPC] Implement XL compact math builtins

2021-07-16 Thread Lei Huang via cfe-commits

Author: Lei Huang
Date: 2021-07-16T13:21:13-05:00
New Revision: c8937b6cb9751807de1e69f0f0f70a9a58f8f5dc

URL: 
https://github.com/llvm/llvm-project/commit/c8937b6cb9751807de1e69f0f0f70a9a58f8f5dc
DIFF: 
https://github.com/llvm/llvm-project/commit/c8937b6cb9751807de1e69f0f0f70a9a58f8f5dc.diff

LOG: [PowerPC] Implement XL compact math builtins

Implement a subset of builtins required for compatiblilty with AIX XL compiler.

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D105930

Added: 
clang/test/CodeGen/builtins-ppc-xlcompat-math.c
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9-64bit.ll
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-xlcompat-error.c
clang/test/CodeGen/builtins-ppc-xlcompat-pwr9-64bit.c
clang/test/CodeGen/builtins-ppc-xlcompat-pwr9.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/lib/Target/PowerPC/PPCInstrVSX.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index f7f34122f17db..1c83c59e16233 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -29,7 +29,7 @@
 #define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE)
 
-// builtins for compatibility with the XL compiler
+// XL Compatibility built-ins
 BUILTIN(__builtin_ppc_popcntb, "ULiULi", "")
 BUILTIN(__builtin_ppc_poppar4, "iUi", "")
 BUILTIN(__builtin_ppc_poppar8, "iULLi", "")
@@ -97,6 +97,21 @@ BUILTIN(__builtin_ppc_load8r, "ULLiULLi*", "")
 BUILTIN(__builtin_ppc_store2r, "vUiUs*", "")
 BUILTIN(__builtin_ppc_store4r, "vUiUi*", "")
 BUILTIN(__builtin_ppc_store8r, "vULLiULLi*", "")
+BUILTIN(__builtin_ppc_extract_exp, "Uid", "")
+BUILTIN(__builtin_ppc_extract_sig, "ULLid", "")
+BUILTIN(__builtin_ppc_mtfsb0, "vUIi", "")
+BUILTIN(__builtin_ppc_mtfsb1, "vUIi", "")
+BUILTIN(__builtin_ppc_mtfsf, "vUIiUi", "")
+BUILTIN(__builtin_ppc_mtfsfi, "vUIiUIi", "")
+BUILTIN(__builtin_ppc_insert_exp, "ddULLi", "")
+BUILTIN(__builtin_ppc_fmsub, "", "")
+BUILTIN(__builtin_ppc_fmsubs, "", "")
+BUILTIN(__builtin_ppc_fnmadd, "", "")
+BUILTIN(__builtin_ppc_fnmadds, "", "")
+BUILTIN(__builtin_ppc_fnmsub, "", "")
+BUILTIN(__builtin_ppc_fnmsubs, "", "")
+BUILTIN(__builtin_ppc_fre, "dd", "")
+BUILTIN(__builtin_ppc_fres, "ff", "")
 
 BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n")
 

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 84cd3d4db0280..10af8494c44ec 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -151,6 +151,21 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
   Builder.defineMacro("__store2r", "__builtin_ppc_store2r");
   Builder.defineMacro("__store4r", "__builtin_ppc_store4r");
   Builder.defineMacro("__store8r", "__builtin_ppc_store8r");
+  Builder.defineMacro("__extract_exp", "__builtin_ppc_extract_exp");
+  Builder.defineMacro("__extract_sig", "__builtin_ppc_extract_sig");
+  Builder.defineMacro("__mtfsb0", "__builtin_ppc_mtfsb0");
+  Builder.defineMacro("__mtfsb1", "__builtin_ppc_mtfsb1");
+  Builder.defineMacro("__mtfsf", "__builtin_ppc_mtfsf");
+  Builder.defineMacro("__mtfsfi", "__builtin_ppc_mtfsfi");
+  Builder.defineMacro("__insert_exp", "__builtin_ppc_insert_exp");
+  Builder.defineMacro("__fmsub", "__builtin_ppc_fmsub");
+  Builder.defineMacro("__fmsubs", "__builtin_ppc_fmsubs");
+  Builder.defineMacro("__fnmadd", "__builtin_ppc_fnmadd");
+  Builder.defineMacro("__fnmadds", "__builtin_ppc_fnmadds");
+  Builder.defineMacro("__fnmsub", "__builtin_ppc_fnmsub");
+  Builder.defineMacro("__fnmsubs", "__builtin_ppc_fnmsubs");
+  Builder.defineMacro("__fre", "__builtin_ppc_fre");
+  Builder.defineMacro("__fres", "__builtin_ppc_fres");
 }
 
 /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 849444fc4c25c..cf9a954fd2a23 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3278,6 +3278,8 @@ static bool isPPC_64Builtin(unsigned BuiltinID) {
   case PPC::BI__builtin_ppc_maddld:
   case PPC::BI__builtin_ppc_load8r:
   case PPC::BI__builtin_ppc_store8r:
+  case PPC::BI__builtin_ppc_insert_exp:
+  case PPC::BI__builtin_ppc_extract_sig:
 return true;
   }
   return false;
@@ -3414,6 +3416,19 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo 
&TI, unsigned BuiltinID,
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||
SemaValueIsRunOfOnes(TheCall, 3);
+  ca

[PATCH] D105930: [PowerPC] Implement XL compact math builtins

2021-07-16 Thread Lei Huang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8937b6cb975: [PowerPC] Implement XL compact math builtins 
(authored by lei).

Changed prior to commit:
  https://reviews.llvm.org/D105930?vs=359070&id=359397#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105930/new/

https://reviews.llvm.org/D105930

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-math.c
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr9-64bit.c
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr9.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9-64bit.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9.ll
@@ -0,0 +1,27 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-32BIT
+
+define dso_local zeroext i32 @extract_exp(double %d) {
+; CHECK-LABEL: extract_exp:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xsxexpdp 3, 1
+; CHECK-NEXT:clrldi 3, 3, 32
+; CHECK-NEXT:blr
+;
+; CHECK-32BIT-LABEL: extract_exp:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:xsxexpdp 3, 1
+; CHECK-32BIT-NEXT:# kill: def $r3 killed $r3 killed $x3
+; CHECK-32BIT-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.extract.exp(double %d)
+  ret i32 %0
+}
+declare i32 @llvm.ppc.extract.exp(double)
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9-64bit.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr9-64bit.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s
+
+define dso_local i64 @extract_sig(double %d) {
+; CHECK-LABEL: extract_sig:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xsxsigdp 3, 1
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call i64 @llvm.ppc.extract.sig(double %d)
+  ret i64 %0
+}
+declare i64 @llvm.ppc.extract.sig(double)
+
+define dso_local double @insert_exp(double %d, i64 %ull) {
+; CHECK-LABEL: insert_exp:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mffprd 3, 1
+; CHECK-NEXT:xsiexpdp 1, 3, 4
+; CHECK-NEXT:# kill: def $f1 killed $f1 killed $vsl1
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call double @llvm.ppc.insert.exp(double %d, i64 %ull)
+  ret double %0
+}
+declare double @llvm.ppc.insert.exp(double, i64)
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll
@@ -0,0 +1,231 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s |\
+; RUN:   FileCheck %s --check-prefix=CHECK-PWR8
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mattr=-vsx < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix -mcpu=pwr7 \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix -mcpu=pwr8 < %s |\
+; RUN:   FileCheck %s --check-prefix=CHECK-PWR8
+
+define dso_local void @mtfsb0() {
+; CHECK-PWR8-LABEL: mtfsb0:
+; CHECK-PWR8:   # %bb.0: # %entry
+; CHECK-PWR8-NEXT:mtfsb0 10
+; CHECK-PWR8-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: mtfsb0:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:mtfsb

[PATCH] D105834: [PowerPC] Semachecking for XL compat builtin icbt

2021-07-16 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 359398.
quinnp added a comment.

Adding a `REQUIRES: powerpc-registered-target` to a testcase and removing 
checks for `entry:` in front end test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105834/new/

https://reviews.llvm.org/D105834

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
  clang/test/CodeGen/builtins-ppc-xlcompat-sync.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-32.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
@@ -94,7 +94,6 @@
 }
 declare void @llvm.ppc.iospace.sync()
 
-; FIXME: __icbt is only valid for pwr8 and up.
 define dso_local void @test_builtin_ppc_icbt() {
 ; CHECK-LABEL: test_builtin_ppc_icbt:
 ; CHECK:   # %bb.0: # %entry
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-32.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-32.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-32.ll
@@ -60,18 +60,3 @@
   ret void
 }
 declare void @llvm.ppc.iospace.sync()
-
-; FIXME: __icbt is only valid for pwr8 and up.
-define dso_local void @test_builtin_ppc_icbt() {
-; CHECK-LABEL: test_builtin_ppc_icbt:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:lwz 3, -8(1)
-; CHECK-NEXT:icbt 0, 0, 3
-; CHECK-NEXT:blr
-entry:
-  %a = alloca i8*, align 8
-  %0 = load i8*, i8** %a, align 8
-  call void @llvm.ppc.icbt(i8* %0)
-  ret void
-}
-declare void @llvm.ppc.icbt(i8*)
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1534,7 +1534,6 @@
 [IntrArgMemOnly, NoCapture>]>;
   def int_ppc_dcbz  : GCCBuiltin<"__builtin_ppc_dcbz">,
   Intrinsic<[], [llvm_ptr_ty], []>;
-// FIXME: __icbt is only valid for pwr8 and up.
   def int_ppc_icbt : GCCBuiltin<"__builtin_ppc_icbt">,
  Intrinsic<[], [llvm_ptr_ty], []>;
   
Index: clang/test/CodeGen/builtins-ppc-xlcompat-sync.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-sync.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-sync.c
@@ -1,4 +1,3 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
 // RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
@@ -14,15 +13,13 @@
 extern void *c;
 
 // CHECK-LABEL: @test_popcntb(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = load i64, i64* @a, align 8
+// CHECK:[[TMP0:%.*]] = load i64, i64* @a, align 8
 // CHECK-NEXT:[[TMP1:%.*]] = load i64, i64* @a, align 8
 // CHECK-NEXT:[[POPCNTB:%.*]] = call i64 @llvm.ppc.popcntb.i64.i64(i64 [[TMP0]])
 // CHECK-NEXT:ret i64 [[POPCNTB]]
 //
 // CHECK-32-LABEL: @test_popcntb(
-// CHECK-32-NEXT:  entry:
-// CHECK-32-NEXT:[[TMP0:%.*]] = load i32, i32* @a, align 4
+// CHECK-32:[[TMP0:%.*]] = load i32, i32* @a, align 4
 // CHECK-32-NEXT:[[TMP1:%.*]] = load i32, i32* @a, align 4
 // CHECK-32-NEXT:[[POPCNTB:%.*]] = call i32 @llvm.ppc.popcntb.i32.i32(i32 [[TMP0]])
 // CHECK-32-NEXT:ret i32 [[POPCNTB]]
@@ -32,13 +29,11 @@
 }
 
 // CHECK-LABEL: @test_eieio(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:call void @llvm.ppc.eieio()
+// CHECK:call void @llvm.ppc.eieio()
 // CHECK-NEXT:ret void
 //
 // CHECK-32-LABEL: @test_eieio(
-// CHECK-32-NEXT:  entry:
-// CHECK-32-NEXT:call void @llvm.ppc.eieio()
+// CHECK-32:call void @llvm.ppc.eieio()
 // CHECK-32-NEXT:ret void
 //
 void test_eieio() {
@@ -46,13 +41,11 @@
 }
 
 // CHECK-LABEL: @test_iospace_eieio(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:call void @llvm.ppc.iospace.eieio()
+// CHECK:call void @llvm.ppc.iospace.eieio()
 // CHECK-NEXT:ret void
 //
 // CHECK-32-LABEL: @test_iospace_eieio(
-// CHECK-32-NEXT:  entry:
-// CHECK-32-NEXT:call void @llvm.ppc.iospace.eieio()
+// CHECK-32:call void @llvm.ppc.iospace.eieio()
 // CHECK-32-NEXT:ret void
 //
 void test_iospace_eieio() {
@@ -60,13 +53,11 @@
 }
 
 // CHECK-LABEL: @test_isync(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:call void @llvm.ppc.isync()
+// CHECK:call void @llvm.ppc.isync()
 // CHECK-NEXT:ret void
 //
 // CHECK-32-LABEL: @test_isync(
-// CHECK-32-NEXT:  entry:
-// CHECK-32-NEXT:call void @llvm.ppc.isync()
+// CHECK-32:call void @llvm.ppc.isync()
 // CHECK-32-NEXT:ret void
 //
 void test_isync() {
@@ -74,13 +65,11 @@
 }
 

[PATCH] D106130: [PowerPC] Implemented mtmsr, mfspr, mtspr Builtins

2021-07-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 359400.
Conanap marked 4 inline comments as done.
Conanap added a comment.

Changed `i32` to `timm` for patterns, some nits


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106130/new/

https://reviews.llvm.org/D106130

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-64bit-only.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
  llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
===
--- llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-move-tofrom-regs.ll
@@ -1,15 +1,20 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; NOTE: Had to manually modify the last test case (mtmsr) to allow the
+; NOTE: common check of mtmsr instead of 4 different check prefixes
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 < %s | FileCheck %s
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr7 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
-; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-AIX
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
 ; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-32BIT
 
 declare i32 @llvm.ppc.mftbu()
 declare i32 @llvm.ppc.mfmsr()
+declare void @llvm.ppc.mtmsr(i32)
+
+@ula = external local_unnamed_addr global i64, align 8
 
 define dso_local zeroext i32 @test_mftbu() {
 ; CHECK-LABEL: test_mftbu:
@@ -18,10 +23,10 @@
 ; CHECK-NEXT:clrldi 3, 3, 32
 ; CHECK-NEXT:blr
 ;
-; CHECK-AIX-LABEL: test_mftbu:
-; CHECK-AIX:   # %bb.0: # %entry
-; CHECK-AIX-NEXT:mftbu 3
-; CHECK-AIX-NEXT:blr
+; CHECK-32BIT-LABEL: test_mftbu:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mftbu 3
+; CHECK-32BIT-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.mftbu()
   ret i32 %0
@@ -34,13 +39,31 @@
 ; CHECK-NEXT:clrldi 3, 3, 32
 ; CHECK-NEXT:blr
 ;
-; CHECK-AIX-LABEL: test_mfmsr:
-; CHECK-AIX:   # %bb.0: # %entry
-; CHECK-AIX-NEXT:mfmsr 4
-; CHECK-AIX-NEXT:li 3, 0
-; CHECK-AIX-NEXT:blr
+; CHECK-32BIT-LABEL: test_mfmsr:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:mfmsr 4
+; CHECK-32BIT-NEXT:li 3, 0
+; CHECK-32BIT-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.mfmsr()
   %conv = zext i32 %0 to i64
   ret i64 %conv
 }
+
+define dso_local void @test_mtmsr() {
+; CHECK-LABEL: test_mtmsr:
+; CHECK:mtmsr 3
+; CHECK-NEXT:blr
+;
+; CHECK-32BIT-LABEL: test_mtmsr:
+; CHECK-32BIT:   # %bb.0: # %entry
+; CHECK-32BIT-NEXT:lwz 3, L..C0(2) # @ula
+; CHECK-32BIT-NEXT:lwz 3, 4(3)
+; CHECK-32BIT-NEXT:mtmsr 3, 0
+; CHECK-32BIT-NEXT:blr
+entry:
+  %0 = load i64, i64* @ula, align 8
+  %conv = trunc i64 %0 to i32
+  call void @llvm.ppc.mtmsr(i32 %conv)
+  ret void
+}
Index: llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-mfspr-mtspr-aix32.ll
@@ -0,0 +1,123 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+
+declare i32 @llvm.ppc.mfspr.i32(i32 immarg)
+declare void @llvm.ppc.mtspr.i32(i32 immarg, i32)
+
+@ula = external dso_local global i32, align 4
+
+define dso_local i32 @test_mfxer() {
+; CHECK-LABEL: test_mfxer:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfxer 3
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 1)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mflr() {
+; CHECK-LABEL: test_mflr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 8
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 8)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfctr() {
+; CHECK-LABEL: test_mfctr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 9
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 9)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfppr() {
+; CHECK-LABEL: test_mfppr:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mfspr 3, 896
+; CHECK-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mfspr.i32(i32 896)
+  ret i32 %0
+}
+
+define dso_local i32 @test_mfppr32

[PATCH] D106130: [PowerPC] Implemented mtmsr, mfspr, mtspr Builtins

2021-07-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15586
+  case PPC::BI__builtin_ppc_mfspr: {
+llvm::Type *RetType = CGM.getDataLayout().getTypeSizeInBits(VoidPtrTy) == 
32
+  ? Int32Ty

nemanjai wrote:
> Is this the formatting that `clang-format` produces? Seems surprising it 
> would format it that way.
I ran `git clang-format HEAD^` and it didn't change it, so seems like it was 
happy with this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106130/new/

https://reviews.llvm.org/D106130

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105909: [clang][CallGraphSection] Add type id metadata to indirect call and targets

2021-07-16 Thread Necip Fazil Yildiran via Phabricator via cfe-commits
necipfazil updated this revision to Diff 359401.
necipfazil added a comment.
Herald added subscribers: dexonsmith, hiraditya.
Herald added a project: LLVM.

Use operand bundles for callsite type ids

- Use (unlossy) operand bundles for propagating indirect callsite type ids
- No longer use type metadata for indirect callsites
- Adapt the tests to the changes

Currently, all callsites are annotated with a `type` operand bundle regardless
of whether indirect or not. While this does not affect the correctness for
call graph section as the extra information is not used, unnecessary operand
bundles on direct callsites increases IR program size. This will be fixed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105909/new/

https://reviews.llvm.org/D105909

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/call-graph-section-1.cpp
  clang/test/CodeGen/call-graph-section-2.cpp
  clang/test/CodeGen/call-graph-section-3.cpp
  clang/test/CodeGen/call-graph-section.c
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -2877,7 +2877,7 @@
  {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
   LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
   LLVMContext::OB_cfguardtarget,
-  LLVMContext::OB_clang_arc_attachedcall}) &&
+  LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_type}) &&
  "Cannot lower invokes with arbitrary operand bundles yet!");
 
   const Value *Callee(I.getCalledOperand());
@@ -2960,8 +2960,9 @@
 
   // Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't
   // have to do anything here to lower funclet bundles.
-  assert(!I.hasOperandBundlesOtherThan(
- {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) &&
+  assert(!I.hasOperandBundlesOtherThan({LLVMContext::OB_deopt,
+LLVMContext::OB_funclet,
+LLVMContext::OB_type}) &&
  "Cannot lower callbrs with arbitrary operand bundles yet!");
 
   assert(I.isInlineAsm() && "Only know how to handle inlineasm callbr");
@@ -8086,7 +8087,7 @@
   assert(!I.hasOperandBundlesOtherThan(
  {LLVMContext::OB_deopt, LLVMContext::OB_funclet,
   LLVMContext::OB_cfguardtarget, LLVMContext::OB_preallocated,
-  LLVMContext::OB_clang_arc_attachedcall}) &&
+  LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_type}) &&
  "Cannot lower calls with arbitrary operand bundles!");
 
   SDValue Callee = getValue(I.getCalledOperand());
Index: llvm/include/llvm/IR/LLVMContext.h
===
--- llvm/include/llvm/IR/LLVMContext.h
+++ llvm/include/llvm/IR/LLVMContext.h
@@ -94,6 +94,7 @@
 OB_preallocated = 4,   // "preallocated"
 OB_gc_live = 5,// "gc-live"
 OB_clang_arc_attachedcall = 6, // "clang.arc.attachedcall"
+OB_type = 7,   // "type"
   };
 
   /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
Index: clang/test/CodeGen/call-graph-section.c
===
--- /dev/null
+++ clang/test/CodeGen/call-graph-section.c
@@ -0,0 +1,85 @@
+// Tests that we assign appropriate identifiers to indirect calls and targets.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fcall-graph-section -S \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,ITANIUM %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fcall-graph-section -S \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,MS %s
+
+// CHECK-DAG: define {{(dso_local)?}} void @foo({{.*}} !type [[F_TVOID:![0-9]+]]
+void foo() {
+}
+
+// CHECK-DAG: define {{(dso_local)?}} void @bar({{.*}} !type [[F_TVOID]]
+void bar() {
+  void (*fp)() = foo;
+  // ITANIUM: call {{.*}} [ "type"(metadata !"_ZTSFvE.generalized") ]
+  // MS:  call {{.*}} [ "type"(metadata !"?6AX@Z.generalized") ]
+  fp();
+}
+
+// CHECK-DAG: define {{(dso_local)?}} i32 @baz({{.*}} !type [[F_TPRIMITIVE:![0-9]+]]
+int baz(char a, float b, double c) {
+  return 1;
+}
+
+// CHECK-DAG: define {{(dso_local)?}} i32* @qux({{.*}} !type [[F_TPTR:![0-9]+]]
+int *qux(char *a, float *b, double *c) {
+  return 0;
+}
+
+// CHECK-DAG: define {{(dso_local)?}} void @corge({{.*}} !type [[F_TVOID]]
+void corge() {
+  int (*fp_baz)(char, float, double) = baz;
+  // ITANIUM: call i32 {{.*}} [ "type"(metadata !"_ZTSFicfdE.generalized") ]
+  // MS:  call i32 {{.*}} [ "type"(metadata !"?6AHDMN@Z.generalized") ]
+  fp_baz('a', .0f, .0);
+
+  int *(*fp

[PATCH] D106172: [clang][CallGraphSection] Add type id metadata to indirect call and targets

2021-07-16 Thread Necip Fazil Yildiran via Phabricator via cfe-commits
necipfazil created this revision.
Herald added subscribers: dexonsmith, hiraditya.
necipfazil requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Create and add generalized type identifier metadata to indirect calls,
and to functions that may be target to indirect calls.

To avoid metadata loss, indirect callsite type identifier metadata are
carried with operand bundles.

Type identifiers will be used by the back-end to construct the call
graph section to precisely represent the possible targets for indirect calls.
The type information is deliberately pulled from the front-end to have extra
precision since some type information is lost at IR, and to ensure
consistent type identifiers between object files compiled at different
times (as C/C++ standards require language-level types to match).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106172

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/call-graph-section-1.cpp
  clang/test/CodeGen/call-graph-section-2.cpp
  clang/test/CodeGen/call-graph-section-3.cpp
  clang/test/CodeGen/call-graph-section.c
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -2877,7 +2877,7 @@
  {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
   LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
   LLVMContext::OB_cfguardtarget,
-  LLVMContext::OB_clang_arc_attachedcall}) &&
+  LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_type}) &&
  "Cannot lower invokes with arbitrary operand bundles yet!");
 
   const Value *Callee(I.getCalledOperand());
@@ -2960,8 +2960,9 @@
 
   // Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't
   // have to do anything here to lower funclet bundles.
-  assert(!I.hasOperandBundlesOtherThan(
- {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) &&
+  assert(!I.hasOperandBundlesOtherThan({LLVMContext::OB_deopt,
+LLVMContext::OB_funclet,
+LLVMContext::OB_type}) &&
  "Cannot lower callbrs with arbitrary operand bundles yet!");
 
   assert(I.isInlineAsm() && "Only know how to handle inlineasm callbr");
@@ -8086,7 +8087,7 @@
   assert(!I.hasOperandBundlesOtherThan(
  {LLVMContext::OB_deopt, LLVMContext::OB_funclet,
   LLVMContext::OB_cfguardtarget, LLVMContext::OB_preallocated,
-  LLVMContext::OB_clang_arc_attachedcall}) &&
+  LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_type}) &&
  "Cannot lower calls with arbitrary operand bundles!");
 
   SDValue Callee = getValue(I.getCalledOperand());
Index: llvm/include/llvm/IR/LLVMContext.h
===
--- llvm/include/llvm/IR/LLVMContext.h
+++ llvm/include/llvm/IR/LLVMContext.h
@@ -94,6 +94,7 @@
 OB_preallocated = 4,   // "preallocated"
 OB_gc_live = 5,// "gc-live"
 OB_clang_arc_attachedcall = 6, // "clang.arc.attachedcall"
+OB_type = 7,   // "type"
   };
 
   /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
Index: clang/test/CodeGen/call-graph-section.c
===
--- /dev/null
+++ clang/test/CodeGen/call-graph-section.c
@@ -0,0 +1,85 @@
+// Tests that we assign appropriate identifiers to indirect calls and targets.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fcall-graph-section -S \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,ITANIUM %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fcall-graph-section -S \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,MS %s
+
+// CHECK-DAG: define {{(dso_local)?}} void @foo({{.*}} !type [[F_TVOID:![0-9]+]]
+void foo() {
+}
+
+// CHECK-DAG: define {{(dso_local)?}} void @bar({{.*}} !type [[F_TVOID]]
+void bar() {
+  void (*fp)() = foo;
+  // ITANIUM: call {{.*}} [ "type"(metadata !"_ZTSFvE.generalized") ]
+  // MS:  call {{.*}} [ "type"(metadata !"?6AX@Z.generalized") ]
+  fp();
+}
+
+// CHECK-DAG: define {{(dso_local)?}} i32 @baz({{.*}} !type [[F_TPRIMITIVE:![0-9]+]]
+int baz(char a, float b, double c) {
+  return 1;
+}
+
+// CHECK-DAG: define {{(dso_local)?}} i32* @qux({{.*}} !type [[F_TPTR:![0-9]+]]
+int *qux(char *a, float *b, double *c) {
+  return 0;
+}
+
+// CHECK-DAG: define {{(dso_local)?}} void @corge({{.*}} !type [[F_TVOID]]
+void corge() {
+  int (*fp_baz)(char, float, double) = baz;
+  // ITANIUM: call i32 {{.*}} [ "type"(metadata !"_ZT

[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

2021-07-16 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

That's interesting!

I'm not sure how to get there though: a complete solution should be able to 
"degrade" to global constructor when the platform-specific logic isn't 
available (unless we're confident that no such environment can exist?).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >