[clang] 6dd738e - [StackSafety,NFC] Switch tests to aarch64

2020-06-05 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-06-05T00:24:02-07:00
New Revision: 6dd738e2f0609f7d3313b574a1d471263d2d3ba1

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

LOG: [StackSafety,NFC] Switch tests to aarch64

Added: 


Modified: 
clang/test/Driver/memtag_lto.c
llvm/test/Analysis/StackSafetyAnalysis/Inputs/ipa-alias.ll
llvm/test/Analysis/StackSafetyAnalysis/Inputs/ipa.ll
llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
llvm/test/Analysis/StackSafetyAnalysis/ipa.ll

Removed: 




diff  --git a/clang/test/Driver/memtag_lto.c b/clang/test/Driver/memtag_lto.c
index d9cf327c1bca..81a6f7b842e1 100644
--- a/clang/test/Driver/memtag_lto.c
+++ b/clang/test/Driver/memtag_lto.c
@@ -5,13 +5,13 @@
 // RUN: rm -f %t*
 
 // -O1, no tagging
-// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck 
%s
-// RUN: %clang-fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck 
%s
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang-fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck %s
 
 // Full LTO
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=full -o %t.lto1.bc
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=full -o %t.lto2.bc
-// RUN: llvm-lto2 run -o %t.lto %t.lto1.bc %t.lto2.bc -save-temps 
-stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -o %t.lto %t.lto1.bc %t.lto2.bc -save-temps 
-stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.lto1.bc,fn,plx \
 // RUN:  -r %t.lto1.bc,use,lx \
 // RUN:  -r %t.lto1.bc,use_local,plx \
@@ -22,7 +22,7 @@
 // Full LTO, new PM
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=full -o %t.ltonewpm1.bc
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=full -o %t.ltonewpm2.bc
-// RUN: llvm-lto2 run -use-new-pm -o %t.ltonewpm %t.ltonewpm1.bc 
%t.ltonewpm2.bc -save-temps -stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -use-new-pm -o %t.ltonewpm %t.ltonewpm1.bc 
%t.ltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.ltonewpm1.bc,fn,plx \
 // RUN:  -r %t.ltonewpm1.bc,use,lx \
 // RUN:  -r %t.ltonewpm1.bc,use_local,plx \
@@ -33,7 +33,7 @@
 // Thin LTO
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=thin -o %t.thinlto1.bc
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=thin -o %t.thinlto2.bc
-// RUN: llvm-lto2 run -o %t.thinlto %t.thinlto1.bc %t.thinlto2.bc -save-temps 
-stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -o %t.thinlto %t.thinlto1.bc %t.thinlto2.bc -save-temps 
-stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.thinlto1.bc,fn,plx \
 // RUN:  -r %t.thinlto1.bc,use,lx \
 // RUN:  -r %t.thinlto1.bc,use_local,plx \
@@ -44,7 +44,7 @@
 // Thin LTO, new PM
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=thin -o %t.thinltonewpm1.bc
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=thin -o %t.thinltonewpm2.bc
-// RUN: llvm-lto2 run -use-new-pm -o %t.thinltonewpm %t.thinltonewpm1.bc 
%t.thinltonewpm2.bc -save-temps -stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -use-new-pm -o %t.thinltonewpm %t.thinltonewpm1.bc 
%t.thinltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.thinltonewpm1.bc,fn,plx \
 // RUN:  -r %t.thinltonewpm1.bc,use,lx \
 // RUN:  -r %t.thinltonewpm1.bc,use_local,plx \
@@ -56,17 +56,17 @@
 // RUN: rm -f %t*
 
 // -O0: both are unsafe.
-// RUN: %clang -fno-experimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s
-// RUN: %clang-fexperimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang-fexperimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-pri

[PATCH] D74025: [clangd] Add the missing elaborated types in FindTarget.

2020-06-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D74025#2073946 , @jaafar wrote:

> I'm very happy this fix exists. I see it's in master, but not in 10.0.0 or 
> 10.0.1-rc1 either. Is there any chance it can be released?


unfortunately, it is not picked up in 10.0.0 release, but it is possible to get 
it in 10.0.1-rc1. We also have a few other crash fixes.
btw, we have weekly snapshot for clangd, 
https://github.com/clangd/clangd/releases, it contains latest fixes and 
features.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74025



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


[PATCH] D80699: [Analyzer][StreamChecker] Add check for pointer escape.

2020-06-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 268696.
balazske added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80699

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -192,4 +192,51 @@
 rewind(f1); // expected-warning {{Stream might be invalid}}
 fclose(f1);
   }
-}
\ No newline at end of file
+}
+
+extern FILE *GlobalF;
+extern void takeFile(FILE *);
+
+void check_escape1() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  GlobalF = F;
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape2() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  takeFile(F);
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape3() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  takeFile(F);
+  F = freopen(0, "w", F);
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape4() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+
+  // no escape at (non-StreamChecker-handled) system call
+  // FIXME: all such calls should be handled by the checker
+  fprintf(F, "0");
+
+  fwrite("1", 1, 1, F); // expected-warning {{might be 'indeterminate'}}
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -194,7 +194,9 @@
 }
 
 class StreamChecker
-: public Checker {
+: public Checker {
   BuiltinBug BT_FileNull{this, "NULL stream pointer",
  "Stream pointer might be NULL."};
   BuiltinBug BT_UseAfterClose{
@@ -223,6 +225,10 @@
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+  ProgramStateRef checkPointerEscape(ProgramStateRef State,
+ const InvalidatedSymbols &Escaped,
+ const CallEvent *Call,
+ PointerEscapeKind Kind) const;
 
   /// If true, evaluate special testing stream functions.
   bool TestMode = false;
@@ -448,10 +454,14 @@
 
   SymbolRef StreamSym = StreamVal->getAsSymbol();
   // Do not care about concrete values for stream ("(FILE *)0x12345"?).
-  // FIXME: Are stdin, stdout, stderr such values?
+  // FIXME: Can be stdin, stdout, stderr such values?
   if (!StreamSym)
 return;
 
+  // Do not handle untracked stream. It is probably escaped.
+  if (!State->get(StreamSym))
+return;
+
   // Generate state for non-failed case.
   // Return value is the passed stream pointer.
   // According to the documentations, the stream is closed first
@@ -918,6 +928,28 @@
   }
 }
 
+ProgramStateRef StreamChecker::checkPointerEscape(
+ProgramStateRef State, const InvalidatedSymbols &Escaped,
+const CallEvent *Call, PointerEscapeKind Kind) const {
+  // Check for file-handling system call that is not handled by the checker.
+  // FIXME: The checker should be updated to handle all system calls that take
+  // 'FILE*' argument. These are now ignored.
+  if (Kind == PSK_DirectEscapeOnCall && Call->isInSystemHeader())
+return State;
+
+  for (SymbolRef Sym : Escaped) {
+// The symbol escaped.
+// From now the stream can be manipulated in unknown way to the checker,
+// it is not possible to handle it any more.
+// Optimistically, assume that the corresponding file handle will be closed
+// somewhere else.
+// Remove symbol from state so the following stream calls on this symbol are
+// not handled by the checker.
+State = State->remove(Sym);
+  }
+  return State;
+}
+
 void ento::registerStreamChecker(CheckerManager &Mgr) {
   Mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80699: [Analyzer][StreamChecker] Add check for pointer escape.

2020-06-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 268701.
balazske added a comment.

Removed bad empty line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80699

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -192,4 +192,51 @@
 rewind(f1); // expected-warning {{Stream might be invalid}}
 fclose(f1);
   }
-}
\ No newline at end of file
+}
+
+extern FILE *GlobalF;
+extern void takeFile(FILE *);
+
+void check_escape1() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  GlobalF = F;
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape2() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  takeFile(F);
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape3() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  takeFile(F);
+  F = freopen(0, "w", F);
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape4() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+
+  // no escape at (non-StreamChecker-handled) system call
+  // FIXME: all such calls should be handled by the checker
+  fprintf(F, "0");
+
+  fwrite("1", 1, 1, F); // expected-warning {{might be 'indeterminate'}}
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -193,8 +193,8 @@
   return State;
 }
 
-class StreamChecker
-: public Checker {
+class StreamChecker : public Checker {
   BuiltinBug BT_FileNull{this, "NULL stream pointer",
  "Stream pointer might be NULL."};
   BuiltinBug BT_UseAfterClose{
@@ -223,6 +223,10 @@
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+  ProgramStateRef checkPointerEscape(ProgramStateRef State,
+ const InvalidatedSymbols &Escaped,
+ const CallEvent *Call,
+ PointerEscapeKind Kind) const;
 
   /// If true, evaluate special testing stream functions.
   bool TestMode = false;
@@ -448,10 +452,14 @@
 
   SymbolRef StreamSym = StreamVal->getAsSymbol();
   // Do not care about concrete values for stream ("(FILE *)0x12345"?).
-  // FIXME: Are stdin, stdout, stderr such values?
+  // FIXME: Can be stdin, stdout, stderr such values?
   if (!StreamSym)
 return;
 
+  // Do not handle untracked stream. It is probably escaped.
+  if (!State->get(StreamSym))
+return;
+
   // Generate state for non-failed case.
   // Return value is the passed stream pointer.
   // According to the documentations, the stream is closed first
@@ -918,6 +926,28 @@
   }
 }
 
+ProgramStateRef StreamChecker::checkPointerEscape(
+ProgramStateRef State, const InvalidatedSymbols &Escaped,
+const CallEvent *Call, PointerEscapeKind Kind) const {
+  // Check for file-handling system call that is not handled by the checker.
+  // FIXME: The checker should be updated to handle all system calls that take
+  // 'FILE*' argument. These are now ignored.
+  if (Kind == PSK_DirectEscapeOnCall && Call->isInSystemHeader())
+return State;
+
+  for (SymbolRef Sym : Escaped) {
+// The symbol escaped.
+// From now the stream can be manipulated in unknown way to the checker,
+// it is not possible to handle it any more.
+// Optimistically, assume that the corresponding file handle will be closed
+// somewhere else.
+// Remove symbol from state so the following stream calls on this symbol are
+// not handled by the checker.
+State = State->remove(Sym);
+  }
+  return State;
+}
+
 void ento::registerStreamChecker(CheckerManager &Mgr) {
   Mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] a7534dc - [clangd] Populate the parse options to CodeCompletion/SignatureHelp.

2020-06-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-06-05T10:32:07+02:00
New Revision: a7534dc8198f2ff966f55fd9a68d2c444886f2b2

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

LOG: [clangd] Populate the parse options to CodeCompletion/SignatureHelp.

Summary: A followup of D79938.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 044b37944b6c..0721c8ddaf73 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -238,11 +238,16 @@ void ClangdServer::codeComplete(PathRef File, Position 
Pos,
 }
   }
 }
+ParseInputs ParseInput{IP->Command, FS, IP->Contents.str()};
+ParseInput.Index = Index;
+ParseInput.Opts.BuildRecoveryAST = BuildRecoveryAST;
+ParseInput.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
+
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CodeCompleteResult Result = clangd::codeComplete(
-File, IP->Command, IP->Preamble, IP->Contents, Pos, FS,
-CodeCompleteOpts, SpecFuzzyFind ? SpecFuzzyFind.getPointer() : 
nullptr);
+File, Pos, IP->Preamble, ParseInput, CodeCompleteOpts,
+SpecFuzzyFind ? SpecFuzzyFind.getPointer() : nullptr);
 {
   clang::clangd::trace::Span Tracer("Completion results callback");
   CB(std::move(Result));
@@ -281,8 +286,11 @@ void ClangdServer::signatureHelp(PathRef File, Position 
Pos,
   return CB(llvm::createStringError(llvm::inconvertibleErrorCode(),
 "Failed to parse includes"));
 
-CB(clangd::signatureHelp(File, IP->Command, *PreambleData, IP->Contents,
- Pos, FS, Index));
+ParseInputs ParseInput{IP->Command, FS, IP->Contents.str()};
+ParseInput.Index = Index;
+ParseInput.Opts.BuildRecoveryAST = BuildRecoveryAST;
+ParseInput.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
+CB(clangd::signatureHelp(File, Pos, *PreambleData, ParseInput));
   };
 
   // Unlike code completion, we wait for a preamble here.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index bc06199eb38f..4c05daac61bf 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1029,12 +1029,10 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
 
 struct SemaCompleteInput {
   PathRef FileName;
-  const tooling::CompileCommand &Command;
+  size_t Offset;
   const PreambleData &Preamble;
   const llvm::Optional Patch;
-  llvm::StringRef Contents;
-  size_t Offset;
-  llvm::IntrusiveRefCntPtr VFS;
+  const ParseInputs &ParseInput;
 };
 
 void loadMainFilePreambleMacros(const Preprocessor &PP,
@@ -1062,17 +1060,12 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   const SemaCompleteInput &Input,
   IncludeStructure *Includes = nullptr) {
   trace::Span Tracer("Sema completion");
-  llvm::IntrusiveRefCntPtr VFS = Input.VFS;
+  llvm::IntrusiveRefCntPtr VFS = Input.ParseInput.FS;
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
-  ParseInputs ParseInput;
-  ParseInput.CompileCommand = Input.Command;
-  ParseInput.FS = VFS;
-  ParseInput.Contents = std::string(Input.Contents);
-  // FIXME: setup the recoveryAST and recoveryASTType in ParseInput properly.
 
   IgnoreDiagnostics IgnoreDiags;
-  auto CI = buildCompilerInvocation(ParseInput, IgnoreDiags);
+  auto CI = buildCompilerInvocation(Input.ParseInput, IgnoreDiags);
   if (!CI) {
 elog("Couldn't create CompilerInvocation");
 return false;
@@ -1090,10 +1083,11 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   FrontendOpts.CodeCompletionAt.FileName = std::string(Input.FileName);
   std::tie(FrontendOpts.CodeCompletionAt.Line,
FrontendOpts.CodeCompletionAt.Column) =
-  offsetToClangLineColumn(Input.Contents, Input.Offset);
+  offsetToClangLineColumn(Input.ParseInput.Contents, Input.Offset);
 
   std::unique_ptr ContentsBuffer =
-  llvm::MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName);
+  llvm::MemoryBuffer::getMemBufferCopy(Input.ParseInput.Contents

[PATCH] D81242: [StackSafety] Run ThinLTO

2020-06-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: eugenis, pcc.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya, inglorion.
Herald added projects: clang, LLVM.

ThinLTO linking runs dataflow processing
on collected function parameters.
Then StackSafetyGlobalInfoWrapperPass
user in ThinLTO backend is going to run as
usual with lockups to external symbol in
processed summary if it's availible.

Depends on D80985 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81242

Files:
  clang/test/Driver/memtag_lto.c
  llvm/include/llvm/Analysis/StackSafetyAnalysis.h
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
  llvm/test/Analysis/StackSafetyAnalysis/ipa.ll

Index: llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
===
--- llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
+++ llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
@@ -10,6 +10,111 @@
 ; RUN: opt -S -analyze -stack-safety %t.combined.bc | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
 ; RUN: opt -S -passes="print-stack-safety" -disable-output %t.combined.bc 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
 
+; Do an end-to-test using the new LTO API
+; TODO: Hideous llvm-lto2 invocation, add a --default-symbol-resolution to llvm-lto2?
+; RUN: opt -module-summary %s -o %t.summ0.bc
+; RUN: opt -module-summary %S/Inputs/ipa.ll -o %t.summ1.bc
+
+; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t.lto -stack-safety-print -stack-safety-run -save-temps -thinlto-threads 1 -O0 \
+; RUN:  -r %t.summ0.bc,Write1, \
+; RUN:  -r %t.summ0.bc,Write4, \
+; RUN:  -r %t.summ0.bc,Write4_2, \
+; RUN:  -r %t.summ0.bc,Write8, \
+; RUN:  -r %t.summ0.bc,WriteAndReturn8, \
+; RUN:  -r %t.summ0.bc,TestUpdateArg,px \
+; RUN:  -r %t.summ0.bc,ExternalCall, \
+; RUN:  -r %t.summ0.bc,PreemptableWrite1, \
+; RUN:  -r %t.summ0.bc,InterposableWrite1, \
+; RUN:  -r %t.summ0.bc,ReturnDependent, \
+; RUN:  -r %t.summ0.bc,Rec2, \
+; RUN:  -r %t.summ0.bc,RecursiveNoOffset, \
+; RUN:  -r %t.summ0.bc,RecursiveWithOffset, \
+; RUN:  -r %t.summ0.bc,f1,px \
+; RUN:  -r %t.summ0.bc,f2,px \
+; RUN:  -r %t.summ0.bc,f3,px \
+; RUN:  -r %t.summ0.bc,f4,px \
+; RUN:  -r %t.summ0.bc,f5,px \
+; RUN:  -r %t.summ0.bc,f6,px \
+; RUN:  -r %t.summ0.bc,PreemptableCall,px \
+; RUN:  -r %t.summ0.bc,InterposableCall,px \
+; RUN:  -r %t.summ0.bc,PrivateCall,px \
+; RUN:  -r %t.summ0.bc,f7,px \
+; RUN:  -r %t.summ0.bc,f8left,px \
+; RUN:  -r %t.summ0.bc,f8right,px \
+; RUN:  -r %t.summ0.bc,f8oobleft,px \
+; RUN:  -r %t.summ0.bc,f8oobright,px \
+; RUN:  -r %t.summ0.bc,TwoArguments,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOne,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOther,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBBoth,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveNoOffset,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,Write1,px \
+; RUN:  -r %t.summ1.bc,Write4,px \
+; RUN:  -r %t.summ1.bc,Write4_2,px \
+; RUN:  -r %t.summ1.bc,Write8,px \
+; RUN:  -r %t.summ1.bc,WriteAndReturn8,px \
+; RUN:  -r %t.summ1.bc,ExternalCall,px \
+; RUN:  -r %t.summ1.bc,PreemptableWrite1,px \
+; RUN:  -r %t.summ1.bc,InterposableWrite1,px \
+; RUN:  -r %t.summ1.bc,ReturnDependent,px \
+; RUN:  -r %t.summ1.bc,Rec0,px \
+; RUN:  -r %t.summ1.bc,Rec1,px \
+; RUN:  -r %t.summ1.bc,Rec2,px \
+; RUN:  -r %t.summ1.bc,RecursiveNoOffset,px \
+; RUN:  -r %t.summ1.bc,RecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,ReturnAlloca,px 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,LTO
+
+; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t-newpm.lto -use-new-pm -stack-safety-print -stack-safety-run -save-temps -thinlto-threads 1 -O0 \
+; RUN:  -r %t.summ0.bc,Write1, \
+; RUN:  -r %t.summ0.bc,Write4, \
+; RUN:  -r %t.summ0.bc,Write4_2, \
+; RUN:  -r %t.summ0.bc,Write8, \
+; RUN:  -r %t.summ0.bc,WriteAndReturn8, \
+; RUN:  -r %t.summ0.bc,TestUpdateArg,px \
+; RUN:  -r %t.summ0.bc,ExternalCall, \
+; RUN:  -r %t.summ0.bc,PreemptableWrite1, \
+; RUN:  -r %t.summ0.bc,InterposableWrite1, \
+; RUN:  -r %t.summ0.bc,ReturnDependent, \
+; RUN:  -r %t.summ0.bc,Rec2, \
+; RUN:  -r %t.summ0.bc,RecursiveNoOffset, \
+; RUN:  -r %t.summ0.bc,RecursiveWithOffset, \
+; RUN:  -r %t.summ0.bc,f1,px \
+; RUN:  -r %t.summ0.bc,f2,px \
+; RUN:  -r %t.summ0.bc,f3,px \
+; RUN:  -r %t.summ0.bc,f4,px \
+; RUN:  -r %t.summ0.bc,f5,px \
+; RUN:  -r %t.summ0.bc,f6,px \
+; RUN:  -r %t.summ0.bc,PreemptableCall,px \
+; RUN:  -r %t.summ0.bc,InterposableCall,px \
+; RUN:  -r %t.summ0.bc,PrivateCall,px \
+; RUN:  -r %t.summ0.bc,f7,px \
+; RUN:  -r %t.summ0.bc,f8left,px \
+; RUN:  -r %t.summ0.bc,f8right,px \
+; RUN:  -r %t.summ0.bc,f8oobleft,px \
+; RUN:  -r %t.summ0.bc,f8oobright,px \
+; RUN:  -r %t.summ0.bc,TwoArguments,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOne,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOther,px \
+; RUN: 

[clang] 767516c - Fix gcc5 build of ASTMatchersTest.h

2020-06-05 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-06-05T10:38:03+02:00
New Revision: 767516c5463a58f64cc3e0e1125b761aedceecf5

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

LOG: Fix gcc5 build of ASTMatchersTest.h

After a180d54 the build was failing with:

In file included from 
/work/llvm.monorepo/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:9:0:
/work/llvm.monorepo/clang/unittests/ASTMatchers/ASTMatchersTest.h:
In function ‘llvm::ArrayRef 
clang::ast_matchers::langCxx11OrLater()’:
/work/llvm.monorepo/clang/unittests/ASTMatchers/ASTMatchersTest.h:64:10:
error: could not convert ‘(const clang::TestLanguage*)(& Result)’ from
‘const clang::TestLanguage*’ to ‘llvm::ArrayRef’
   return Result;
  ^

Added: 


Modified: 
clang/unittests/ASTMatchers/ASTMatchersTest.h

Removed: 




diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h 
b/clang/unittests/ASTMatchers/ASTMatchersTest.h
index 11aedf65ec29..fec033c4d72e 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -61,22 +61,22 @@ class VerifyMatch : public MatchFinder::MatchCallback {
 inline ArrayRef langCxx11OrLater() {
   static const TestLanguage Result[] = {Lang_CXX11, Lang_CXX14, Lang_CXX17,
 Lang_CXX20};
-  return Result;
+  return ArrayRef(Result);
 }
 
 inline ArrayRef langCxx14OrLater() {
   static const TestLanguage Result[] = {Lang_CXX14, Lang_CXX17, Lang_CXX20};
-  return Result;
+  return ArrayRef(Result);
 }
 
 inline ArrayRef langCxx17OrLater() {
   static const TestLanguage Result[] = {Lang_CXX17, Lang_CXX20};
-  return Result;
+  return ArrayRef(Result);
 }
 
 inline ArrayRef langCxx20OrLater() {
   static const TestLanguage Result[] = {Lang_CXX20};
-  return Result;
+  return ArrayRef(Result);
 }
 
 template 



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


[PATCH] D81244: [StackSafety] Control paramer access summary from frontend

2020-06-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: eugenis, pcc.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya.
Herald added projects: clang, LLVM.

MAYBE? let me know if you think we need it. I'll improve the patch.

This way we don't need to rely on MTE attributes and let
clang to controll when to include this info into summary.

Depends on D81242 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81244

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
  llvm/include/llvm/Analysis/StackSafetyAnalysis.h
  llvm/include/llvm/Bitcode/BitcodeWriterPass.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
  llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
  llvm/test/Bitcode/thinlto-function-summary-paramaccess.ll
  llvm/tools/llvm-extract/llvm-extract.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/NewPMDriver.h
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -192,6 +192,10 @@
 static cl::opt EmitModuleHash("module-hash", cl::desc("Emit module hash"),
 cl::init(false));
 
+cl::opt ModuleSummaryStackSafety("module-summary-stack-safety",
+   cl::init(false), cl::Hidden,
+   cl::desc("Emit Stack Safety summary."));
+
 static cl::opt
 DisableSimplifyLibCalls("disable-simplify-libcalls",
 cl::desc("Disable simplify-libcalls"));
@@ -754,7 +758,8 @@
RemarksFile.get(), PassPipeline, OK, VK,
PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
-   EmitModuleHash, EnableDebugify, Coroutines)
+   EmitModuleHash, EnableDebugify, Coroutines,
+   ModuleSummaryStackSafety)
? 0
: 1;
   }
@@ -964,10 +969,12 @@
   Passes.add(createPrintModulePass(*OS, "", PreserveAssemblyUseListOrder));
 } else if (OutputThinLTOBC)
   Passes.add(createWriteThinLTOBitcodePass(
-  *OS, ThinLinkOut ? &ThinLinkOut->os() : nullptr));
+  *OS, ThinLinkOut ? &ThinLinkOut->os() : nullptr,
+  ModuleSummaryStackSafety));
 else
   Passes.add(createBitcodeWriterPass(*OS, PreserveBitcodeUseListOrder,
- EmitSummaryIndex, EmitModuleHash));
+ EmitSummaryIndex, EmitModuleHash,
+ ModuleSummaryStackSafety));
   }
 
   // Before executing passes, print the final values of the LLVM options.
Index: llvm/tools/opt/NewPMDriver.h
===
--- llvm/tools/opt/NewPMDriver.h
+++ llvm/tools/opt/NewPMDriver.h
@@ -63,7 +63,8 @@
  bool ShouldPreserveAssemblyUseListOrder,
  bool ShouldPreserveBitcodeUseListOrder,
  bool EmitSummaryIndex, bool EmitModuleHash,
- bool EnableDebugify, bool Coroutines);
+ bool EnableDebugify, bool Coroutines,
+ bool ModuleSummaryStackSafety);
 } // namespace llvm
 
 #endif
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -219,7 +219,8 @@
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,
-   bool EnableDebugify, bool Coroutines) {
+   bool EnableDebugify, bool Coroutines,
+   bool ModuleSummaryStackSafety) {
   bool VerifyEachPass = VK == VK_VerifyEachPass;
 
   Optional P;
@@ -357,7 +358,8 @@
 break;
   case OK_OutputThinLTOBitcode:
 MPM.addPass(ThinLTOBitcodeWriterPass(
-Out->os(), ThinLTOLinkOut ? &ThinLTOLinkOut->os() : nullptr));
+Out->os(), ThinLTOLinkOut ? &ThinLTOLinkOut->os() : nullptr,
+ModuleSummaryStackSafety));
 break;
   }
 
Index: llvm/tools/llvm-extract/llvm-extract.cpp
===
--- llvm/tools/llvm-extract/llvm-extract.cpp
+++ llvm/tools/llvm-extract/llvm-extract.c

[PATCH] D81066: [clangd] Populate the parse options to CodeCompletion/SignatureHelp.

2020-06-05 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7534dc8198f: [clangd] Populate the parse options to 
CodeCompletion/SignatureHelp. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D81066?vs=268164&id=268707#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81066

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -117,8 +117,11 @@
   }
   auto Preamble = buildPreamble(testPath(TU.Filename), *CI, Inputs,
 /*InMemory=*/true, /*Callback=*/nullptr);
-  return codeComplete(testPath(TU.Filename), Inputs.CompileCommand,
-  Preamble.get(), TU.Code, Point, Inputs.FS, Opts);
+  ParseInputs ParseInput{Inputs.CompileCommand, Inputs.FS, TU.Code};
+  ParseInput.Opts.BuildRecoveryAST = true;
+  ParseInput.Opts.PreserveRecoveryASTType = true;
+  return codeComplete(testPath(TU.Filename), Point, Preamble.get(), ParseInput,
+  Opts);
 }
 
 // Runs code completion.
@@ -148,8 +151,10 @@
 
   MockFSProvider FS;
   Annotations Test(Text);
-  return codeComplete(FilePath, tooling::CompileCommand(), /*Preamble=*/nullptr,
-  Test.code(), Test.point(), FS.getFileSystem(), Opts);
+  ParseInputs ParseInput{tooling::CompileCommand(), FS.getFileSystem(),
+ Test.code().str()};
+  return codeComplete(FilePath, Test.point(), /*Preamble=*/nullptr, ParseInput,
+  Opts);
 }
 
 Symbol withReferences(int N, Symbol S) {
@@ -753,8 +758,7 @@
   EXPECT_THAT(Results, ElementsAre(Named("ifndef")));
 }
 
-// FIXME: enable it.
-TEST(CompletionTest, DISABLED_CompletionRecoveryASTType) {
+TEST(CompletionTest, CompletionRecoveryASTType) {
   auto Results = completions(R"cpp(
 struct S { int member; };
 S overloaded(int);
@@ -1067,8 +1071,11 @@
 ADD_FAILURE() << "Couldn't build Preamble";
 return {};
   }
-  return signatureHelp(testPath(TU.Filename), Inputs.CompileCommand, *Preamble,
-   Text, Point, Inputs.FS, Index.get());
+  ParseInputs ParseInput{Inputs.CompileCommand, Inputs.FS, Text.str()};
+  ParseInput.Index = Index.get();
+  ParseInput.Opts.BuildRecoveryAST = true;
+  ParseInput.Opts.PreserveRecoveryASTType = true;
+  return signatureHelp(testPath(TU.Filename), Point, *Preamble, ParseInput);
 }
 
 SignatureHelp signatures(llvm::StringRef Text,
@@ -1219,9 +1226,10 @@
 void bar() { foo(^2); })cpp");
   TU.Code = Test.code().str();
   Inputs = TU.inputs();
-  auto Results =
-  signatureHelp(testPath(TU.Filename), Inputs.CompileCommand,
-*EmptyPreamble, TU.Code, Test.point(), Inputs.FS, nullptr);
+
+  ParseInputs ParseInput{Inputs.CompileCommand, Inputs.FS, TU.Code};
+  auto Results = signatureHelp(testPath(TU.Filename), Test.point(),
+   *EmptyPreamble, ParseInput);
   EXPECT_THAT(Results.signatures, ElementsAre(Sig("foo([[int x]]) -> int")));
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(0, Results.activeParameter);
Index: clang-tools-extra/clangd/Compiler.h
===
--- clang-tools-extra/clangd/Compiler.h
+++ clang-tools-extra/clangd/Compiler.h
@@ -54,7 +54,7 @@
   bool ForceRebuild = false;
   // Used to recover from diagnostics (e.g. find missing includes for symbol).
   const SymbolIndex *Index = nullptr;
-  ParseOptions Opts;
+  ParseOptions Opts = ParseOptions();
 };
 
 /// Builds compiler invocation that could be used to build AST or preamble.
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 
+#include "Compiler.h"
 #include "Headers.h"
 #include "Protocol.h"
 #include "Quality.h"
@@ -270,21 +271,16 @@
 /// the speculative result is used by code completion (e.g. speculation failed),
 /// the speculative result is not consumed, and `SpecFuzzyFind` is only
 /// destroyed when the async request finishes.
-CodeCompleteResult codeComplete(PathRef FileName,
-const tooling::CompileCommand &Command,
+CodeCompleteResult codeComplete(PathRef FileName, Position Pos,
 const PreambleData *Preamble,
-String

[clang] ecd682b - [ARM] Add __bf16 as new Bfloat16 C Type

2020-06-05 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2020-06-05T10:32:43+01:00
New Revision: ecd682bbf5e69e8690b7e3634258f05ae0a70448

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

LOG: [ARM] Add __bf16 as new Bfloat16 C Type

Summary:
This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:

https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

In detail this patch:
- introduces an opaque, storage-only C-type __bf16, which introduces a new 
bfloat IR type.

This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.

The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Alexandros Lamprineas
- Luke Geeson
- Simon Tatham
- Ties Stuij

Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, 
jfb, LukeGeeson, fpetrogalli

Reviewed By: SjoerdMeijer

Subscribers: labrinea, majnemer, asmith, dexonsmith, kristof.beyls, arphaman, 
danielkiss, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/arm-bf16-params-returns.c
clang/test/CodeGen/arm-bf16-softfloat.c
clang/test/CodeGen/arm-mangle-bf16.cpp
clang/test/Sema/arm-bf16-forbidden-ops.c
clang/test/Sema/arm-bf16-forbidden-ops.cpp
clang/test/Sema/arm-bfloat.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang-c/Index.h
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/BuiltinTypes.def
clang/include/clang/AST/Type.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenTypeCache.h
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Format/FormatToken.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReader.cpp
clang/tools/libclang/CXType.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index d3d73bf238f9..ba0a7d9cf95c 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -516,8 +516,8 @@ float matrices and add the result to a third 4x4 matrix.
 Half-Precision Floating Point
 =
 
-Clang supports two half-precision (16-bit) floating point types: ``__fp16`` and
-``_Float16``.  These types are supported in all language modes.
+Clang supports three half-precision (16-bit) floating point types: ``__fp16``,
+``_Float16`` and ``__bf16``.  These types are supported in all language modes.
 
 ``__fp16`` is supported on every target, as it is purely a storage format; see 
below.
 ``_Float16`` is currently only supported on the following targets, with further
@@ -529,6 +529,12 @@ targets pending ABI standardization:
 
 ``_Float16`` will be supported on more targets as they define ABIs for it.
 
+``__bf16`` is purely a storage format; it is cur

[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-06-05 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecd682bbf5e6: [ARM] Add __bf16 as new Bfloat16 C Type 
(authored by stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypeCache.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-bf16-softfloat.c
  clang/test/CodeGen/arm-mangle-bf16.cpp
  clang/test/Sema/arm-bf16-forbidden-ops.c
  clang/test/Sema/arm-bf16-forbidden-ops.cpp
  clang/test/Sema/arm-bfloat.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -608,6 +608,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(BFloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
Index: clang/test/Sema/arm-bfloat.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bfloat.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+
+void test(bool b) {
+  __bf16 bf16;
+
+  bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+
+  __fp16 fp16;
+
+  bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 / fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 / bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 = fp16; // expected-error {{assigning to '__bf16' from incompatible type '__fp16'}}
+  fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible type '__bf16'}}
+  bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types ('__fp16' and '__bf16')}}
+}
Index: clang/test/Sema/arm-bf16-forbidden-ops.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bf16-forbidden-ops.cpp
@@ -0,0 +

[clang] a30b5c5 - Fix MSVC "not all control paths return a value" warning. NFC.

2020-06-05 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-06-05T10:45:59+01:00
New Revision: a30b5c5a51f95dc81fdfbeea42cc01b451cd5a08

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

LOG: Fix MSVC "not all control paths return a value" warning. NFC.

Add llvm_unreachable after switch statement for TestLanguage enum

Added: 


Modified: 
clang/lib/Testing/CommandLineArgs.cpp

Removed: 




diff  --git a/clang/lib/Testing/CommandLineArgs.cpp 
b/clang/lib/Testing/CommandLineArgs.cpp
index 7375dbc6ee70..cd4d8c188da9 100644
--- a/clang/lib/Testing/CommandLineArgs.cpp
+++ b/clang/lib/Testing/CommandLineArgs.cpp
@@ -64,6 +64,7 @@ StringRef getFilenameForTesting(TestLanguage Lang) {
   case Lang_OBJCXX:
 return "input.mm";
   }
+  llvm_unreachable("Unhandled TestLanguage enum");
 }
 
 } // end namespace clang



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


[clang] c31d213 - [clang][test] Put output into temp directory

2020-06-05 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-05T13:02:32+02:00
New Revision: c31d2134639bb87d6705fe8fb1a46de61bc4cebf

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

LOG: [clang][test] Put output into temp directory

To unbreak builds that happen on a read-only directory

Added: 


Modified: 
clang/test/CodeGen/arm-bf16-softfloat.c

Removed: 




diff  --git a/clang/test/CodeGen/arm-bf16-softfloat.c 
b/clang/test/CodeGen/arm-bf16-softfloat.c
index 99c122c0f078..5ea7319ec50b 100644
--- a/clang/test/CodeGen/arm-bf16-softfloat.c
+++ b/clang/test/CodeGen/arm-bf16-softfloat.c
@@ -1,4 +1,4 @@
-// RUN: not %clang -target arm-arm-eabi -march=armv8-a+bf16 -mfloat-abi=soft 
-c %s 2>&1 | FileCheck %s
+// RUN: not %clang -o %t.out -target arm-arm-eabi -march=armv8-a+bf16 
-mfloat-abi=soft -c %s 2>&1 | FileCheck %s
 
 // CHECK: error: __bf16 is not supported on this target
 extern __bf16 var;



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


[PATCH] D80301: [yaml][clang-tidy] Fix new line YAML serialization

2020-06-05 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added inline comments.



Comment at: llvm/lib/Support/YAMLTraits.cpp:894
+   std::string &Val) {
+  Val.clear();
+  size_t CurrentPos = 0;

njames93 wrote:
> If you want to do the same here...
> ```
>   SmallVector Lines;
>   Scalar.split(Lines, "\n\n");
>   Val = llvm::join(Lines, "\n");
>   return StringRef();```
Personally I don't like approach with string split because it is potentially 
less efficient due to memory allocations in case of multiple newlines that can 
be avoided. BUT I would like to move the needle and fix this real bug in clang 
ASAP. So I'm ready to rewrite it to something that (1) works and (2) moves 
review forward. So thank you for review and please take another look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301



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


[PATCH] D80301: [yaml][clang-tidy] Fix new line YAML serialization

2020-06-05 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 268736.
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added a comment.

Rewrite input string split too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/Support/YAMLIOTest.cpp

Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -274,8 +274,8 @@
 
 TEST(YAMLIO, MultilineStrings) {
   WithStringField Original;
-  Original.str1 = "a multiline string\nfoobarbaz";
-  Original.str2 = "another one\rfoobarbaz";
+  Original.str1 = "a\n\nmultiline\nstring\nfoobarbaz";
+  Original.str2 = "another one\rfoobarbaz\n";
   Original.str3 = "a one-line string";
 
   std::string Serialized;
@@ -285,10 +285,10 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
+  "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
   "foobarbaz'\n"
   "str2:'another one\r"
-  "foobarbaz'\n"
+  "foobarbaz\n\n'\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
@@ -305,6 +305,25 @@
   EXPECT_EQ(Original.str1, Deserialized.str1);
   EXPECT_EQ(Original.str2, Deserialized.str2);
   EXPECT_EQ(Original.str3, Deserialized.str3);
+
+  // Check deserialization of single '\n' that should be ignored.
+  Serialized = "---\n"
+   "str1:'\na\n\n\n\nmultiline\n\nstring\n\n"
+   "foobarbaz\n'\n"
+   "str2:'another\n one\r"
+   "foobarbaz\n\n'\n"
+   "str3:a one-line string\n"
+   "...\n";
+  {
+Input YIn(Serialized);
+YIn >> Deserialized;
+ASSERT_FALSE(YIn.error())
+<< "Parsing error occurred during deserialization. Serialized string:\n"
+<< Serialized;
+  }
+  EXPECT_EQ(Original.str1, Deserialized.str1);
+  EXPECT_EQ(Original.str2, Deserialized.str2);
+  EXPECT_EQ(Original.str3, Deserialized.str3);
 }
 
 TEST(YAMLIO, NoQuotesForTab) {
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -876,13 +876,35 @@
 }
 
 void ScalarTraits::output(const std::string &Val, void *,
- raw_ostream &Out) {
-  Out << Val;
+   raw_ostream &Out) {
+  SmallVector Lines;
+  StringRef(Val).split(Lines, '\n');
+  bool First = true;
+  for (StringRef Line : Lines) {
+if (First)
+  First = false;
+else
+  Out << "\n\n";
+Out << Line;
+  }
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
- std::string &Val) {
-  Val = Scalar.str();
+   std::string &Val) {
+  Val.clear();
+  SmallVector Lines;
+  Scalar.split(Lines, '\n');
+  size_t C = Lines.size();
+  for (size_t I = 0; I < C; ++I) {
+Val += Lines[I];
+// Next empty line means that it was '\n\n' that should convert to '\n'
+// single '\n' should be skiped. +2 here for the right hadling single '\n'
+// at the end of line.
+if (I + 2 < C && Lines[I + 1].empty()) {
+  Val += '\n';
+  ++I;
+}
+  }
   return StringRef();
 }
 
Index: clang/include/clang/Tooling/ReplacementsYaml.h
===
--- clang/include/clang/Tooling/ReplacementsYaml.h
+++ clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,13 +35,7 @@
 
 NormalizedReplacement(const IO &, const clang::tooling::Replacement &R)
 : FilePath(R.getFilePath()), Offset(R.getOffset()),
-  Length(R.getLength()), ReplacementText(R.getReplacementText()) {
-  size_t lineBreakPos = ReplacementText.find('\n');
-  while (lineBreakPos != std::string::npos) {
-ReplacementText.replace(lineBreakPos, 1, "\n\n");
-lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);
-  }
-}
+  Length(R.getLength()), ReplacementText(R.getReplacementText()) {}
 
 clang::tooling::Replacement denormalize(const IO &) {
   return clang::tooling::Replacement(FilePath, Offset, Length,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80301: [yaml][clang-tidy] Fix new line YAML serialization

2020-06-05 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 268737.
DmitryPolukhin marked 2 inline comments as done.
DmitryPolukhin added a comment.

Fix spelling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/Support/YAMLIOTest.cpp

Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -274,8 +274,8 @@
 
 TEST(YAMLIO, MultilineStrings) {
   WithStringField Original;
-  Original.str1 = "a multiline string\nfoobarbaz";
-  Original.str2 = "another one\rfoobarbaz";
+  Original.str1 = "a\n\nmultiline\nstring\nfoobarbaz";
+  Original.str2 = "another one\rfoobarbaz\n";
   Original.str3 = "a one-line string";
 
   std::string Serialized;
@@ -285,10 +285,10 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
+  "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
   "foobarbaz'\n"
   "str2:'another one\r"
-  "foobarbaz'\n"
+  "foobarbaz\n\n'\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
@@ -305,6 +305,25 @@
   EXPECT_EQ(Original.str1, Deserialized.str1);
   EXPECT_EQ(Original.str2, Deserialized.str2);
   EXPECT_EQ(Original.str3, Deserialized.str3);
+
+  // Check deserialization of single '\n' that should be ignored.
+  Serialized = "---\n"
+   "str1:'\na\n\n\n\nmultiline\n\nstring\n\n"
+   "foobarbaz\n'\n"
+   "str2:'another\n one\r"
+   "foobarbaz\n\n'\n"
+   "str3:a one-line string\n"
+   "...\n";
+  {
+Input YIn(Serialized);
+YIn >> Deserialized;
+ASSERT_FALSE(YIn.error())
+<< "Parsing error occurred during deserialization. Serialized string:\n"
+<< Serialized;
+  }
+  EXPECT_EQ(Original.str1, Deserialized.str1);
+  EXPECT_EQ(Original.str2, Deserialized.str2);
+  EXPECT_EQ(Original.str3, Deserialized.str3);
 }
 
 TEST(YAMLIO, NoQuotesForTab) {
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -876,13 +876,35 @@
 }
 
 void ScalarTraits::output(const std::string &Val, void *,
- raw_ostream &Out) {
-  Out << Val;
+   raw_ostream &Out) {
+  SmallVector Lines;
+  StringRef(Val).split(Lines, '\n');
+  bool First = true;
+  for (StringRef Line : Lines) {
+if (First)
+  First = false;
+else
+  Out << "\n\n";
+Out << Line;
+  }
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
- std::string &Val) {
-  Val = Scalar.str();
+   std::string &Val) {
+  Val.clear();
+  SmallVector Lines;
+  Scalar.split(Lines, '\n');
+  size_t C = Lines.size();
+  for (size_t I = 0; I < C; ++I) {
+Val += Lines[I];
+// Next empty line means that it was '\n\n' that should convert to '\n'.
+// Single '\n' should be skipped. +2 here for the right handling
+// single '\n' at the end of line.
+if (I + 2 < C && Lines[I + 1].empty()) {
+  Val += '\n';
+  ++I;
+}
+  }
   return StringRef();
 }
 
Index: clang/include/clang/Tooling/ReplacementsYaml.h
===
--- clang/include/clang/Tooling/ReplacementsYaml.h
+++ clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,13 +35,7 @@
 
 NormalizedReplacement(const IO &, const clang::tooling::Replacement &R)
 : FilePath(R.getFilePath()), Offset(R.getOffset()),
-  Length(R.getLength()), ReplacementText(R.getReplacementText()) {
-  size_t lineBreakPos = ReplacementText.find('\n');
-  while (lineBreakPos != std::string::npos) {
-ReplacementText.replace(lineBreakPos, 1, "\n\n");
-lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);
-  }
-}
+  Length(R.getLength()), ReplacementText(R.getReplacementText()) {}
 
 clang::tooling::Replacement denormalize(const IO &) {
   return clang::tooling::Replacement(FilePath, Offset, Length,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79587: [CodeGen][SVE] Legalisation of extends with scalable types

2020-06-05 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89fc0166f532: [CodeGen][SVE] Legalisation of extends with 
scalable types (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79587

Files:
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/test/CodeGen/AArch64/sve-sext-zext.ll

Index: llvm/test/CodeGen/AArch64/sve-sext-zext.ll
===
--- llvm/test/CodeGen/AArch64/sve-sext-zext.ll
+++ llvm/test/CodeGen/AArch64/sve-sext-zext.ll
@@ -186,3 +186,143 @@
   %r = zext  %a to 
   ret  %r
 }
+
+; Extending to illegal types
+
+define  @sext_b_to_h( %a) {
+; CHECK-LABEL: sext_b_to_h:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z2.h, z0.b
+; CHECK-NEXT:sunpkhi z1.h, z0.b
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_h_to_s( %a) {
+; CHECK-LABEL: sext_h_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z2.s, z0.h
+; CHECK-NEXT:sunpkhi z1.s, z0.h
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_s_to_d( %a) {
+; CHECK-LABEL: sext_s_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z2.d, z0.s
+; CHECK-NEXT:sunpkhi z1.d, z0.s
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_b_to_s( %a) {
+; CHECK-LABEL: sext_b_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z1.h, z0.b
+; CHECK-NEXT:sunpkhi z3.h, z0.b
+; CHECK-NEXT:sunpklo z0.s, z1.h
+; CHECK-NEXT:sunpkhi z1.s, z1.h
+; CHECK-NEXT:sunpklo z2.s, z3.h
+; CHECK-NEXT:sunpkhi z3.s, z3.h
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_b_to_d( %a) {
+; CHECK-LABEL: sext_b_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z1.h, z0.b
+; CHECK-NEXT:sunpkhi z0.h, z0.b
+; CHECK-NEXT:sunpklo z2.s, z1.h
+; CHECK-NEXT:sunpkhi z3.s, z1.h
+; CHECK-NEXT:sunpklo z5.s, z0.h
+; CHECK-NEXT:sunpkhi z7.s, z0.h
+; CHECK-NEXT:sunpklo z0.d, z2.s
+; CHECK-NEXT:sunpkhi z1.d, z2.s
+; CHECK-NEXT:sunpklo z2.d, z3.s
+; CHECK-NEXT:sunpkhi z3.d, z3.s
+; CHECK-NEXT:sunpklo z4.d, z5.s
+; CHECK-NEXT:sunpkhi z5.d, z5.s
+; CHECK-NEXT:sunpklo z6.d, z7.s
+; CHECK-NEXT:sunpkhi z7.d, z7.s
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @zext_b_to_h( %a) {
+; CHECK-LABEL: zext_b_to_h:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z2.h, z0.b
+; CHECK-NEXT:uunpkhi z1.h, z0.b
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_h_to_s( %a) {
+; CHECK-LABEL: zext_h_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z2.s, z0.h
+; CHECK-NEXT:uunpkhi z1.s, z0.h
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_s_to_d( %a) {
+; CHECK-LABEL: zext_s_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z2.d, z0.s
+; CHECK-NEXT:uunpkhi z1.d, z0.s
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_b_to_s( %a) {
+; CHECK-LABEL: zext_b_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z1.h, z0.b
+; CHECK-NEXT:uunpkhi z3.h, z0.b
+; CHECK-NEXT:uunpklo z0.s, z1.h
+; CHECK-NEXT:uunpkhi z1.s, z1.h
+; CHECK-NEXT:uunpklo z2.s, z3.h
+; CHECK-NEXT:uunpkhi z3.s, z3.h
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_b_to_d( %a) {
+; CHECK-LABEL: zext_b_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z1.h, z0.b
+; CHECK-NEXT:uunpkhi z0.h, z0.b
+; CHECK-NEXT:uunpklo z2.s, z1.h
+; CHECK-NEXT:uunpkhi z3.s, z1.h
+; CHECK-NEXT:uunpklo z5.s, z0.h
+; CHECK-NEXT:uunpkhi z7.s, z0.h
+; CHECK-NEXT:uunpklo z0.d, z2.s
+; CHECK-NEXT:uunpkhi z1.d, z2.s
+; CHECK-NEXT:uunpklo z2.d, z3.s
+; CHECK-NEXT:uunpkhi z3.d, z3.s
+; CHECK-NEXT:uunpklo z4.d, z5.s
+; CHECK-NEXT:uunpkhi z5.d, z5.s
+; CHECK-NEXT:uunpklo z6.d, z7.s
+; CHECK-NEXT:uunpkhi z7.d, z7.s
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.h
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -889,6 +889,9 @@
 
   void ReplaceNodeResults(SDNode *N, SmallVectorImpl &Results,
   SelectionDAG &DAG) const override;
+  void ReplaceExtractSubVectorResults(SDNode *N,
+  SmallVectorImpl &Results,
+ 

[PATCH] D81252: [SVE ACLE] Remove redundant bool_t typedef.

2020-06-05 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm created this revision.
Herald added subscribers: cfe-commits, tschuett.
Herald added a project: clang.
paulwalker-arm added a reviewer: sdesmalen.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81252

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1058,7 +1058,6 @@
   OS << "typedef __fp16 float16_t;\n";
   OS << "typedef float float32_t;\n";
   OS << "typedef double float64_t;\n";
-  OS << "typedef bool bool_t;\n\n";
 
   OS << "typedef __SVInt8_t svint8_t;\n";
   OS << "typedef __SVInt16_t svint16_t;\n";


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1058,7 +1058,6 @@
   OS << "typedef __fp16 float16_t;\n";
   OS << "typedef float float32_t;\n";
   OS << "typedef double float64_t;\n";
-  OS << "typedef bool bool_t;\n\n";
 
   OS << "typedef __SVInt8_t svint8_t;\n";
   OS << "typedef __SVInt16_t svint16_t;\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-05 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 268746.
dang marked 3 inline comments as done.
dang added a comment.

Address some code review feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -9,6 +9,7 @@
 #include "OptEmitter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
@@ -33,18 +34,18 @@
   return OS;
 }
 
-static void emitMarshallingInfo(raw_ostream &OS, const Record &R) {
-  OS << R.getValueAsString("KeyPath");
+static void emitMarshallingInfoFlag(raw_ostream &OS, const Record *R) {
+  OS << R->getValueAsBit("IsPositive");
+  OS << ",";
+  OS << R->getValueAsString("DefaultValue");
+}
+
+static void emitMarshallingInfoString(raw_ostream &OS, const Record *R) {
+  OS << R->getValueAsString("DefaultValue");
   OS << ", ";
-  if (!isa(R.getValueInit("IsPositive")))
-OS << R.getValueAsBit("IsPositive");
-  else
-OS << "INVALID";
+  OS << R->getValueAsString("Normalizer");
   OS << ", ";
-  if (!isa(R.getValueInit("DefaultValue")))
-OS << R.getValueAsString("DefaultValue");
-  else
-OS << "INVALID";
+  OS << R->getValueAsString("Denormalizer");
 }
 
 /// OptParserEmitter - This tablegen backend takes an input .td file
@@ -246,15 +247,30 @@
   OS << "#endif // OPTION\n";
 
   OS << "#ifdef OPTION_WITH_MARSHALLING\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record &R = *Opts[i];
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record &R = *Opts[I];
 
 if (!isa(R.getValueInit("MarshallingInfo"))) {
-  OS << "OPTION_WITH_MARSHALLING(";
+  Record *MarshallingInfoRecord =
+  cast(R.getValueInit("MarshallingInfo"))->getDef();
+  StringRef KindStr = MarshallingInfoRecord->getValueAsString("Kind");
+  auto KindInfoPair =
+  StringSwitch>>(
+  KindStr)
+  .Case("flag", std::make_pair("OPTION_WITH_MARSHALLING_FLAG",
+   &emitMarshallingInfoFlag))
+  .Case("string", std::make_pair("OPTION_WITH_MARSHALLING_STRING",
+ &emitMarshallingInfoString))
+  .Default(std::make_pair("", nullptr));
+  OS << KindInfoPair.first << "(";
   WriteOptRecordFields(OS, R);
   OS << ", ";
-  emitMarshallingInfo(
-  OS, *cast(R.getValueInit("MarshallingInfo"))->getDef());
+  OS << MarshallingInfoRecord->getValueAsBit("ShouldAlwaysEmit");
+  OS << ", ";
+  OS << MarshallingInfoRecord->getValueAsString("KeyPath");
+  OS << ", ";
+  KindInfoPair.second(OS, MarshallingInfoRecord);
   OS << ")\n";
 }
   }
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -81,13 +81,15 @@
 }
 
 // Add support for generating marshalling code
-
-class OptionMarshallingInfo {
+class OptionMarshallingInfo {
+  string Kind = kind;
+  bit ShouldAlwaysEmit = 0;
   code KeyPath = keypath;
   // Used by the Flag option kind.
   bit IsPositive = ?;
   code DefaultValue = ?;
-  list EnumValues = ?;
+  code Normalizer = ?;
+  code Denormalizer = ?;
 }
 
 // Define the option class.
@@ -143,20 +145,24 @@
 
 class MarshallingInfo { OptionMarshallingInfo MarshallingInfo = info; }
 class MarshallingFlag
-  : OptionMarshallingInfo {
+  : OptionMarshallingInfo<"flag", keypath> {
   bit IsPositive = ispositive;
   code DefaultValue = defaultvalue;
 }
-class MarshallingString
-  : OptionMarshallingInfo {
-  code DefaultValue = defaultvalue;
+class MarshallingFlagAlwaysEmit
+  : MarshallingFlag {
+  let ShouldAlwaysEmit = 1;
 }
-class MarshallingEnum enumvalues>
-  : OptionMarshallingInfo {
+class MarshallingString
+  : OptionMarshallingInfo<"string", keypath> {
   code DefaultValue = defaultvalue;
-  listEnumValues = enumvalues;
+  code Normalizer = normalizer;
+  code Denormalizer = denormalizer;
+}
+class MarshallingStringAlwaysEmit
+  : MarshallingString {
+  let ShouldAlwaysEmit = 1;
 }
-
 // Predefined options.
 
 // FIXME: Have generator validate that these appear in correct position (and
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- c

[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-05 Thread Daniel Grumberg via Phabricator via cfe-commits
dang marked 4 inline comments as done.
dang added inline comments.



Comment at: clang/include/clang/Frontend/CompilerInvocation.h:248
+  /// \returns - True if parsing was successful, false otherwise
+  bool parseSimpleArgs(const llvm::opt::ArgList &Args,
+   DiagnosticsEngine &Diags);

Bigcheese wrote:
> Is there a reason for this to be a member of `CompilerInvocation`? The rest 
> of the argument parsing functions are static file local functions.
All the keypaths have to be "relative" to `CompilerInvocation` so that 
different options can be processed uniformly i.e. we don't want to add extra 
specialization to the table-gen file that indicates if an option is for the 
analyzer or for codegen e.t.c. Some of the members of `CompilerInvocation` that 
store options are private, which means that if parseSimpleArgs which precludes 
it from being an free function with internal linkage. Unless you think all the 
`CompilerInvocation` members should be public, but that is a different can of 
worms.



Comment at: clang/unittests/Frontend/CompilerInvocationTest.cpp:41
+TEST_F(CC1CommandLineGenerationTest, CanGenerateCC1CommandLineFlag) {
+  const char *Args[] = {"clang", "-xc++", "-fmodules-strict-context-hash", 
"-"};
+

Bigcheese wrote:
> This reminded me that some of the -cc1 arguments are positional such as 
> `-xc++`. I think we'll need custom handling for `INPUT` arguments, although 
> we don't need them (or want them) for the modules use case. Do you have any 
> thoughts on how to handle them? I don't think answering that should block the 
> initial patch though.
`-x` flags are no `INPUT` arguments as in it can appear anywhere but will apply 
to the inputs. The only part of `CompilerInvocation` that uses positional 
arguments is the input file(s) which is quite small (21 LOC) so I am happy to 
leave it as is, having a few line to add it at the end of the command line is 
not a big problem IMO. 
The thing I am more worried about is that the processing for some options 
depends on other options having already been processed, I was planning to 
reorder them accordingly in the td file although I am not a fan of doing this, 
I think it would be better to addd the information using table-gen's DAG 
support although that would complicated the table-gen backend.



Comment at: llvm/include/llvm/Option/OptParser.td:167-171
+class MarshallingEnum enumvalues>
+  : OptionMarshallingInfo<"enum", keypath> {
+  code DefaultValue = defaultvalue;
+  listEnumValues = enumvalues;
+}

Bigcheese wrote:
> I noticed that this isn't being used for the enum case you added 
> (`-mrelocation-model`). Do you intend to use it? You should either use it in 
> this patch or remove it until it actually is used.
Yeah, I forgot to remove it, since the normalizer scheme subsumes the 
functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796



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


[clang] 1e44731 - [ARM] Add poly64_t on AArch32.

2020-06-05 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2020-06-05T13:04:21+01:00
New Revision: 1e447318339a6e740819ec1568002f4751527efe

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

LOG: [ARM] Add poly64_t on AArch32.

Summary:
The poly64 types are guarded with ifdefs for AArch64 only. This is wrong. This
was also incorrectly documented in the ACLE spec, but this has been rectified in
the latest release. See paragraph 13.1.2 "Vector data types":

https://developer.arm.com/docs/101028/latest

This patch was written by Alexandros Lamprineas.

Reviewers: ostannard, sdesmalen, fpetrogalli, labrinea, t.p.northover, 
LukeGeeson

Reviewed By: ostannard

Subscribers: pbarrio, LukeGeeson, kristof.beyls, danielkiss, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/arm-poly64.c

Modified: 
clang/include/clang/Basic/TargetBuiltins.h
clang/lib/AST/ItaniumMangle.cpp
clang/lib/Sema/SemaType.cpp
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index b20a544b7889..5fa5f9f0bcef 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -157,7 +157,7 @@ namespace clang {
 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
 bool isPoly() const {
   EltType ET = getEltType();
-  return ET == Poly8 || ET == Poly16;
+  return ET == Poly8 || ET == Poly16 || ET == Poly64;
 }
 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
 bool isQuad() const { return (Flags & QuadFlag) != 0; }

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index aae33c5962e0..46815e5a107e 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3167,6 +3167,7 @@ void CXXNameMangler::mangleNeonVectorType(const 
VectorType *T) {
 case BuiltinType::UShort:
   EltName = "poly16_t";
   break;
+case BuiltinType::LongLong:
 case BuiltinType::ULongLong:
   EltName = "poly64_t";
   break;

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 93bb2e15c4da..46fa8bc0608b 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7650,15 +7650,16 @@ static bool isPermittedNeonBaseType(QualType &Ty,
 Triple.getArch() == llvm::Triple::aarch64_be;
   if (VecKind == VectorType::NeonPolyVector) {
 if (IsPolyUnsigned) {
-  // AArch64 polynomial vectors are unsigned and support poly64.
+  // AArch64 polynomial vectors are unsigned.
   return BTy->getKind() == BuiltinType::UChar ||
  BTy->getKind() == BuiltinType::UShort ||
  BTy->getKind() == BuiltinType::ULong ||
  BTy->getKind() == BuiltinType::ULongLong;
 } else {
-  // AArch32 polynomial vector are signed.
+  // AArch32 polynomial vectors are signed.
   return BTy->getKind() == BuiltinType::SChar ||
- BTy->getKind() == BuiltinType::Short;
+ BTy->getKind() == BuiltinType::Short ||
+ BTy->getKind() == BuiltinType::LongLong;
 }
   }
 

diff  --git a/clang/test/CodeGen/arm-poly64.c b/clang/test/CodeGen/arm-poly64.c
new file mode 100644
index ..52c757f0acbb
--- /dev/null
+++ b/clang/test/CodeGen/arm-poly64.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi -target-feature +neon \
+// RUN:  -emit-llvm -o - %s | FileCheck %s
+
+// Test that we can use the poly64 type on AArch32
+
+#include 
+
+// CHECK-LABEL: @test_poly64
+// CHECK: ret i64 %0
+poly64_t test_poly64(poly64_t a) {
+  return a;
+}

diff  --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 625954fe8a04..e93c4c653edf 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -2233,6 +2233,7 @@ void NeonEmitter::run(raw_ostream &OS) {
   OS << "#else\n";
   OS << "typedef int8_t poly8_t;\n";
   OS << "typedef int16_t poly16_t;\n";
+  OS << "typedef int64_t poly64_t;\n";
   OS << "#endif\n";
 
   // Emit Neon vector typedefs.
@@ -2245,7 +2246,7 @@ void NeonEmitter::run(raw_ostream &OS) {
   for (auto &TS : TDTypeVec) {
 bool IsA64 = false;
 Type T(TS, ".");
-if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+if (T.isDouble())
   IsA64 = true;
 
 if (InIfdef && !IsA64) {
@@ -2278,7 +2279,7 @@ void NeonEmitter::run(raw_ostream &OS) {
 for (auto &TS : TDTypeVec) {
   bool IsA64 = false;
   Type T(TS, ".");
-  if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+  if (T.isDouble())
 IsA64 = true;
 
   if (InIfdef && !IsA64) {


 

[PATCH] D81254: [analyzer] Produce symbolic values for C-array elements

2020-06-05 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: dcoughlin, NoQ, alexfh.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

Problem:
The issue is that UnknownVal is produced for an array element when it is used 
in expressions with unknown bounds and unknown index. Thus it doesn't bind in 
the list of Expressions and never be used twice then.

Solution:
Produce symbolic values for array elements instead of UnknownVal. This also 
enables to bind these values and use them later in the next expressions.

This fixes https://bugs.llvm.org/show_bug.cgi?id=9289


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81254

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/PR9289.cpp


Index: clang/test/Analysis/PR9289.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR9289.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int fun(const int *a, int index) {
+  int var;
+  int ret = 0;
+  if (a[index] < 2)
+var = 1;
+  if (a[index] < 2)
+ret = var; // no warning about garbage value
+  return ret;
+}
+
+int fun2(const int **a, int index, int index2) {
+  int var;
+  int ret = 0;
+  if (a[index][index2] < 2)
+var = 1;
+  if (a[index][index2] < 2)
+ret = var; // no warning about garbage value
+  return ret;
+}
+
+int fun3(const int *a, int index, int index2) {
+  int var;
+  int ret = 0;
+  if (a[index] < 2)
+var = 1;
+  index = index2;
+  if (a[index] < 2)
+ret = var; // expected-warning{{Assigned value is garbage or undefined 
[core.uninitialized.Assign]}}
+  return ret;
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1704,9 +1704,9 @@
   // FIXME: This is a hack, and doesn't do anything really intelligent yet.
   const RegionRawOffset &O = R->getAsArrayOffset();
 
-  // If we cannot reason about the offset, return an unknown value.
+  // If we cannot reason about the offset, return a symbolic value.
   if (!O.getRegion())
-return UnknownVal();
+return svalBuilder.getRegionValueSymbolVal(R);
 
   if (const TypedValueRegion *baseR =
 dyn_cast_or_null(O.getRegion())) {


Index: clang/test/Analysis/PR9289.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR9289.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int fun(const int *a, int index) {
+  int var;
+  int ret = 0;
+  if (a[index] < 2)
+var = 1;
+  if (a[index] < 2)
+ret = var; // no warning about garbage value
+  return ret;
+}
+
+int fun2(const int **a, int index, int index2) {
+  int var;
+  int ret = 0;
+  if (a[index][index2] < 2)
+var = 1;
+  if (a[index][index2] < 2)
+ret = var; // no warning about garbage value
+  return ret;
+}
+
+int fun3(const int *a, int index, int index2) {
+  int var;
+  int ret = 0;
+  if (a[index] < 2)
+var = 1;
+  index = index2;
+  if (a[index] < 2)
+ret = var; // expected-warning{{Assigned value is garbage or undefined [core.uninitialized.Assign]}}
+  return ret;
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1704,9 +1704,9 @@
   // FIXME: This is a hack, and doesn't do anything really intelligent yet.
   const RegionRawOffset &O = R->getAsArrayOffset();
 
-  // If we cannot reason about the offset, return an unknown value.
+  // If we cannot reason about the offset, return a symbolic value.
   if (!O.getRegion())
-return UnknownVal();
+return svalBuilder.getRegionValueSymbolVal(R);
 
   if (const TypedValueRegion *baseR =
 dyn_cast_or_null(O.getRegion())) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81252: [SVE ACLE] Remove redundant bool_t typedef.

2020-06-05 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen 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/D81252/new/

https://reviews.llvm.org/D81252



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


[PATCH] D81255: [clang-format] treat 'lock' as a keyword for C# code

2020-06-05 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a reviewer: krasimir.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
krasimir accepted this revision.
This revision is now accepted and ready to land.

This will put a space in `lock (process)` when spaces are required after 
keywords.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81255

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -741,6 +741,9 @@
 })",
Style);
 
+  // space after lock in `lock (processes)`.
+  verifyFormat("lock (process)", Style);
+
   Style.SpacesInSquareBrackets = true;
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3080,7 +3080,8 @@
 
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
-  if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
+  if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when,
+   Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements 
||
spaceRequiredBeforeParens(Right);
   } else if (Style.Language == FormatStyle::LK_JavaScript) {


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -741,6 +741,9 @@
 })",
Style);
 
+  // space after lock in `lock (processes)`.
+  verifyFormat("lock (process)", Style);
+
   Style.SpacesInSquareBrackets = true;
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3080,7 +3080,8 @@
 
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
-  if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
+  if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when,
+   Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements ||
spaceRequiredBeforeParens(Right);
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79711: [ARM] Add poly64_t on AArch32.

2020-06-05 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e447318339a: [ARM] Add poly64_t on AArch32. (authored by 
stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79711

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/arm-poly64.c
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2233,6 +2233,7 @@
   OS << "#else\n";
   OS << "typedef int8_t poly8_t;\n";
   OS << "typedef int16_t poly16_t;\n";
+  OS << "typedef int64_t poly64_t;\n";
   OS << "#endif\n";
 
   // Emit Neon vector typedefs.
@@ -2245,7 +2246,7 @@
   for (auto &TS : TDTypeVec) {
 bool IsA64 = false;
 Type T(TS, ".");
-if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+if (T.isDouble())
   IsA64 = true;
 
 if (InIfdef && !IsA64) {
@@ -2278,7 +2279,7 @@
 for (auto &TS : TDTypeVec) {
   bool IsA64 = false;
   Type T(TS, ".");
-  if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+  if (T.isDouble())
 IsA64 = true;
 
   if (InIfdef && !IsA64) {
Index: clang/test/CodeGen/arm-poly64.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-poly64.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi -target-feature +neon \
+// RUN:  -emit-llvm -o - %s | FileCheck %s
+
+// Test that we can use the poly64 type on AArch32
+
+#include 
+
+// CHECK-LABEL: @test_poly64
+// CHECK: ret i64 %0
+poly64_t test_poly64(poly64_t a) {
+  return a;
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7650,15 +7650,16 @@
 Triple.getArch() == llvm::Triple::aarch64_be;
   if (VecKind == VectorType::NeonPolyVector) {
 if (IsPolyUnsigned) {
-  // AArch64 polynomial vectors are unsigned and support poly64.
+  // AArch64 polynomial vectors are unsigned.
   return BTy->getKind() == BuiltinType::UChar ||
  BTy->getKind() == BuiltinType::UShort ||
  BTy->getKind() == BuiltinType::ULong ||
  BTy->getKind() == BuiltinType::ULongLong;
 } else {
-  // AArch32 polynomial vector are signed.
+  // AArch32 polynomial vectors are signed.
   return BTy->getKind() == BuiltinType::SChar ||
- BTy->getKind() == BuiltinType::Short;
+ BTy->getKind() == BuiltinType::Short ||
+ BTy->getKind() == BuiltinType::LongLong;
 }
   }
 
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3167,6 +3167,7 @@
 case BuiltinType::UShort:
   EltName = "poly16_t";
   break;
+case BuiltinType::LongLong:
 case BuiltinType::ULongLong:
   EltName = "poly64_t";
   break;
Index: clang/include/clang/Basic/TargetBuiltins.h
===
--- clang/include/clang/Basic/TargetBuiltins.h
+++ clang/include/clang/Basic/TargetBuiltins.h
@@ -157,7 +157,7 @@
 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
 bool isPoly() const {
   EltType ET = getEltType();
-  return ET == Poly8 || ET == Poly16;
+  return ET == Poly8 || ET == Poly16 || ET == Poly64;
 }
 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
 bool isQuad() const { return (Flags & QuadFlag) != 0; }


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2233,6 +2233,7 @@
   OS << "#else\n";
   OS << "typedef int8_t poly8_t;\n";
   OS << "typedef int16_t poly16_t;\n";
+  OS << "typedef int64_t poly64_t;\n";
   OS << "#endif\n";
 
   // Emit Neon vector typedefs.
@@ -2245,7 +2246,7 @@
   for (auto &TS : TDTypeVec) {
 bool IsA64 = false;
 Type T(TS, ".");
-if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+if (T.isDouble())
   IsA64 = true;
 
 if (InIfdef && !IsA64) {
@@ -2278,7 +2279,7 @@
 for (auto &TS : TDTypeVec) {
   bool IsA64 = false;
   Type T(TS, ".");
-  if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+  if (T.isDouble())
 IsA64 = true;
 
   if (InIfdef && !IsA64) {
Index: clang/test/CodeGen/arm-poly64.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-poly64.c
@@ -0,0 +1,12 @@
+// RUN: %

[clang] a6fcf5c - [clang][BFloat] add NEON emitter for bfloat

2020-06-05 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2020-06-05T14:11:51+01:00
New Revision: a6fcf5ca033a83b815f760664e0cff91c2c13dcd

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

LOG: [clang][BFloat] add NEON emitter for bfloat

Summary:
This patch adds the bfloat16_t struct typedefs (e.g. bfloat16x8x2_t) to
arm_neon.h

This patch is part of a series implementing the Bfloat16 extension of the
Armv8.6-a architecture, as detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:

https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

The following people contributed to this patch:
- Luke Cheeseman
- Simon Tatham
- Ties Stuij

Reviewers: t.p.northover, fpetrogalli, sdesmalen, az, LukeGeeson

Reviewed By: fpetrogalli

Subscribers: SjoerdMeijer, LukeGeeson, pbarrio, mgorny, kristof.beyls, 
ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 
clang/include/clang/Basic/arm_bf16.td

Modified: 
clang/include/clang/Basic/arm_neon_incl.td
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Headers/CMakeLists.txt
clang/test/CodeGen/arm-bf16-params-returns.c
clang/test/Preprocessor/aarch64-target-features.c
clang/test/Preprocessor/arm-target-features.c
clang/utils/TableGen/NeonEmitter.cpp
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h

Removed: 




diff  --git a/clang/include/clang/Basic/arm_bf16.td 
b/clang/include/clang/Basic/arm_bf16.td
new file mode 100644
index ..d837a7666d40
--- /dev/null
+++ b/clang/include/clang/Basic/arm_bf16.td
@@ -0,0 +1,14 @@
+//===--- arm_fp16.td - ARM BF16 compiler interface 
===//
+//
+// 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
+//
+//===--===//
+//
+//  This file defines the TableGen definitions from which the ARM BF16 header
+//  file will be generated.
+//
+//===--===//
+
+include "arm_neon_incl.td"

diff  --git a/clang/include/clang/Basic/arm_neon_incl.td 
b/clang/include/clang/Basic/arm_neon_incl.td
index 7593fdcfb486..a1031fe4ad4f 100644
--- a/clang/include/clang/Basic/arm_neon_incl.td
+++ b/clang/include/clang/Basic/arm_neon_incl.td
@@ -215,6 +215,7 @@ def OP_UNAVAILABLE : Operation {
 // f: float
 // h: half-float
 // d: double
+// b: bfloat16
 //
 // Typespec modifiers
 // --
@@ -236,6 +237,7 @@ def OP_UNAVAILABLE : Operation {
 // S: change to signed integer category.
 // U: change to unsigned integer category.
 // F: change to floating category.
+// B: change to BFloat16
 // P: change to polynomial category.
 // p: change polynomial to equivalent integer category. Otherwise nop.
 //

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 080571c6ea4f..b474d1203dee 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -286,6 +286,12 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasMatMul)
 Builder.defineMacro("__ARM_FEATURE_MATMUL_INT8", "1");
 
+  if (HasBFloat16) {
+Builder.defineMacro("__ARM_FEATURE_BF16", "1");
+Builder.defineMacro("__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", "1");
+Builder.defineMacro("__ARM_BF16_FORMAT_ALTERNATIVE", "1");
+  }
+
   if ((FPU & NeonMode) && HasFP16FML)
 Builder.defineMacro("__ARM_FEATURE_FP16FML", "1");
 

diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 5e605abfc137..21cfe0107bbb 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -838,6 +838,12 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasMatMul)
 Builder.defineMacro("__ARM_FEATURE_MATMUL_INT8", "1");
 
+  if (HasBFloat16) {
+Builder.defineMacro("__ARM_FEATURE_BF16", "1");
+Builder.defineMacro("__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", "1");
+Builder.defineMacro("__ARM_BF16_FORMAT_ALTERNATIVE", "1");
+  }
+
   switch (ArchKind) {
   default:
 break;

diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index c5215eede3f9..1a1f7b30f106 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -190,6 +190,8 @@ clang_generate_hea

[PATCH] D80961: WIP: Ignore template instantiations if not in AsIs mode

2020-06-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D80961#2073049 , @klimek wrote:

> Without jumping into the discussion whether it should be the default, I think 
> we should be able to control template instantiation visitation separately 
> from other implicit nodes.
>  Having to put AsIs on a matcher every time you need to match template 
> instantiations is a rather big change (suddenly you have to change all the 
> matchers you've written so far).


I think that's the intended meaning of `AsIs` though. Template instantiations 
are not source code the user wrote, they're source code the compiler stamped 
out from code the user wrote. I hope `IgnoreUnlessSpelledInSource` isn't a 
misnomer.

> I love the idea of being able to control visitation of template instantiation.
>  I am somewhat torn on whether it should be the default, and would like to 
> see more data.
>  I feel more strongly about needing AsIs when I want to match template 
> instantiations.

FWIW, my experience in clang-tidy has been that template instantiations are 
ignored far more often than they're desired. In fact, instantiations tend to be 
a source of bugs for us because they're easy to forget about when writing 
matchers without keeping templates in mind. The times when template 
instantiations become important to *not* ignore within the checks is when the 
check is specific to template behavior, but that's a minority of the public 
checks thus far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961



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


[PATCH] D81173: [clangd] Change ParseInputs to store FSProvider rather than VFS

2020-06-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Hmm, having looked at this it is a bit of a mess, but I think partly because 
we're not converting *enough* code to use this abstraction (e.g. the preamble 
caching stuff, or prepareCompilerInstance).
We should work how how to get the bugfix part of this landed, but I think 
ultimately we should rename FSprovider and avoid most direct use of VFS in 
clangd, it bakes in this assumption about threadign that's very hard to deal 
with locally.




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:184
   Opts.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
+  auto VFS = FSProvider.getFileSystem();
   // FIXME: call tidy options builder on the worker thread, it can do IO.

As a question of style, I think we should inline these wherever we're handing 
off a VFS to another library and we don't want to reuse it for some reason.

We can shorten the names if needed to make this nice.




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1069
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  auto FSProvider = getFSProvider(VFS);
   ParseInputs ParseInput;

can we leave a fixme to propagate this change further instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81173



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


[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-05 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, but please wait a bit in case @njames93 has any final thoughts.


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

https://reviews.llvm.org/D80896



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


[PATCH] D79708: [clang][BFloat] add NEON emitter for bfloat

2020-06-05 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa6fcf5ca033a: [clang][BFloat] add NEON emitter for bfloat 
(authored by stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79708

Files:
  clang/include/clang/Basic/arm_bf16.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  clang/utils/TableGen/NeonEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -85,6 +85,7 @@
 
 void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitBF16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitNeonSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitNeonTest(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitNeon2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangOpenCLBuiltins,
   GenArmNeon,
   GenArmFP16,
+  GenArmBF16,
   GenArmNeonSema,
   GenArmNeonTest,
   GenArmMveHeader,
@@ -186,6 +187,7 @@
"Generate OpenCL builtin declaration handlers"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
+clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
 clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
"Generate ARM NEON sema support for clang"),
 clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
@@ -360,6 +362,9 @@
   case GenArmFP16:
 EmitFP16(Records, OS);
 break;
+  case GenArmBF16:
+EmitBF16(Records, OS);
+break;
   case GenArmNeonSema:
 EmitNeonSema(Records, OS);
 break;
Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -99,7 +99,8 @@
   Poly128,
   Float16,
   Float32,
-  Float64
+  Float64,
+  BFloat16
 };
 
 } // end namespace NeonTypeFlags
@@ -147,6 +148,7 @@
 SInt,
 UInt,
 Poly,
+BFloat16,
   };
   TypeKind Kind;
   bool Immediate, Constant, Pointer;
@@ -199,6 +201,7 @@
   bool isInt() const { return isInteger() && ElementBitwidth == 32; }
   bool isLong() const { return isInteger() && ElementBitwidth == 64; }
   bool isVoid() const { return Kind == Void; }
+  bool isBFloat16() const { return Kind == BFloat16; }
   unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
   unsigned getSizeInBits() const { return Bitwidth; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -583,8 +586,11 @@
   // runFP16 - Emit arm_fp16.h.inc
   void runFP16(raw_ostream &o);
 
-  // runHeader - Emit all the __builtin prototypes used in arm_neon.h
-	// and arm_fp16.h
+  // runBF16 - Emit arm_bf16.h.inc
+  void runBF16(raw_ostream &o);
+
+  // runHeader - Emit all the __builtin prototypes used in arm_neon.h,
+  // arm_fp16.h and arm_bf16.h
   void runHeader(raw_ostream &o);
 
   // runTests - Emit tests for all the Neon intrinsics.
@@ -609,6 +615,8 @@
 S += "poly";
   else if (isFloating())
 S += "float";
+  else if (isBFloat16())
+S += "bfloat";
   else
 S += "int";
 
@@ -648,7 +656,10 @@
 case 128: S += "LLLi"; break;
 default: llvm_unreachable("Unhandled case!");
 }
-  else
+  else if (isBFloat16()) {
+assert(ElementBitwidth == 16 && "BFloat16 can only be 16 bits");
+S += "y";
+  } else
 switch (ElementBitwidth) {
 case 16: S += "h"; break;
 case 32: S += "f"; break;
@@ -702,6 +713,11 @@
 Base = (unsigned)NeonTypeFlags::Float16 + (Addend - 1);
   }
 
+  if (isBFloat16()) {
+assert(Addend == 1 && "BFloat16 is only 16 bit");
+Base = (unsigned)NeonTypeFlags::BFloat16;
+  }
+
   if (Bitwidth == 128)
 Base |= (unsigned)NeonTypeFlags::QuadFlag;
   if (isInteger() && !isSigned())
@@ -725,6 +741,9 @@
   } else if (Name.startswith("poly")) {
 T.Kind = Poly;
 Name = Name.drop_front(4);
+  } else if (Name.startswith("bfloat")) {
+T.Kind = BFloat16;
+Name = Name.drop_front(6);
   } else {
 assert(Name.startswith("int"));
 Name = Name.drop_front(3);
@@ -823,6 +842,10 @@
   if (isPoly())

[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2020-06-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

I'm looking at this again and I am not sure how it is meant to work. For 
example in `Parser::parseClassSpecifier` in `ParseDeclCXX.cpp`.
Here `attrs` is a local variable of type `ParsedAttributesWithRange`, already 
before my patch. `attrs` is then passed to

1. `MaybeParseGNUAttributes`
2. `MaybeParseMicrosoftDeclSpecs`
3. `ParseMicrosoftInheritanceClassAttributes`
4. `MaybeParseCXX11Attributes`

and later `parseClassSpecifier` calls `ProhibitAttributes(attrs)` a few times. 
`ProhibitAttributes` in turn will not do anything if the given attrs have an 
invalid (i.e. unset) range.
So, how could they ever have a valid range set? All the four functions above 
only take a  `ParsedAttributes`, no range.

This is one of the cases that now (that `MaybeParseGNUAttributes` sets the 
range of the given `attrs` if it really parses attributes) generates errors in 
various test cases.
For example in `clang/test/AST/ast-print-record-decl.c`: File 
/home/tbaeder/llvm-project/clang/test/AST/ast-print-record-decl.c Line 209: an 
attribute list cannot appear here

Am I missing something?


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

https://reviews.llvm.org/D75844



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


[clang] 8b137a4 - [clang][BFloat] Add create/set/get/dup intrinsics

2020-06-05 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2020-06-05T14:35:10+01:00
New Revision: 8b137a430636c6626fcc6ef93b05eb69d6183e57

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

LOG: [clang][BFloat] Add create/set/get/dup intrinsics

Summary:
This patch is part of a series that adds support for the Bfloat16 extension of
the Armv8.6-a architecture, as detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type and its properties are specified in the Arm Architecture
Reference Manual:

https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Luke Geeson
- Ties Stuij
- Mikhail Maltsev

Reviewers: t.p.northover, sdesmalen, fpetrogalli, LukeGeeson, stuij, labrinea

Reviewed By: labrinea

Subscribers: miyuki, dmgreen, labrinea, kristof.beyls, ilya-biryukov, MaskRay, 
jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
clang/test/CodeGen/arm-bf16-getset-intrinsics.c

Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 82e44aaec69b..98fda8b13142 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -190,20 +190,28 @@ def OP_SCALAR_QRDMLAH_LN : Op<(call "vqadd", $p0, (call 
"vqrdmulh", $p1,
 def OP_SCALAR_QRDMLSH_LN : Op<(call "vqsub", $p0, (call "vqrdmulh", $p1,
   (call "vget_lane", $p2, $p3)))>;
 
-def OP_SCALAR_HALF_GET_LN : Op<(bitcast "float16_t",
-   (call "vget_lane",
- (bitcast "int16x4_t", $p0), $p1))>;
-def OP_SCALAR_HALF_GET_LNQ : Op<(bitcast "float16_t",
-(call "vget_lane",
-  (bitcast "int16x8_t", $p0), $p1))>;
-def OP_SCALAR_HALF_SET_LN : Op<(bitcast "float16x4_t",
-   (call "vset_lane",
- (bitcast "int16_t", $p0),
- (bitcast "int16x4_t", $p1), $p2))>;
-def OP_SCALAR_HALF_SET_LNQ : Op<(bitcast "float16x8_t",
-(call "vset_lane",
-  (bitcast "int16_t", $p0),
-  (bitcast "int16x8_t", $p1), $p2))>;
+multiclass ScalarGetSetLaneOpsF16 {
+  def _GET_LN  : Op<(bitcast scalarTy,
+(call "vget_lane",
+(bitcast "int16x4_t", $p0), $p1))>;
+  def _GET_LNQ : Op<(bitcast scalarTy,
+(call "vget_lane",
+(bitcast "int16x8_t", $p0), $p1))>;
+  def _SET_LN  : Op<(bitcast vectorTy4,
+(call "vset_lane",
+(bitcast "int16_t", $p0),
+(bitcast "int16x4_t", $p1), $p2))>;
+  def _SET_LNQ : Op<(bitcast vectorTy8,
+(call "vset_lane",
+(bitcast "int16_t", $p0),
+(bitcast "int16x8_t", $p1), $p2))>;
+}
+
+defm OP_SCALAR_HALF: ScalarGetSetLaneOpsF16<"float16_t",
+"float16x4_t", "float16x8_t">;
+defm OP_SCALAR_BF16: ScalarGetSetLaneOpsF16<"bfloat16_t",
+"bfloat16x4_t", "bfloat16x8_t">;
 
 def OP_DOT_LN
 : Op<(call "vdot", $p0, $p1,
@@ -247,6 +255,12 @@ def SPLATQ : WInst<"splat_laneq", ".(!Q)I",

"UcUsUicsilPcPsfQUcQUsQUiQcQsQiQPcQPsQflUlQlQUlhdQhQdPlQPl"> {
   let isLaneQ = 1;
 }
+let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
+  def SPLAT_BF  : WInst<"splat_lane", ".(!q)I", "bQb">;
+  def SPLATQ_BF : WInst<"splat_laneq", ".(!Q)I", "bQb"> {
+let isLaneQ = 1;
+  }
+}
 
 
//===--===//
 // Intrinsics
@@ -1841,3 +1855,39 @@ let ArchGuard = "defined(__ARM_FEATURE_COMPLEX) && 
defined(__aarch64__)" in {
   def VCADDQ_ROT90_FP64  : SInst<"vcaddq_rot90", "QQQ", "d">;
   def VCADDQ_ROT270_FP64 : SInst<"vcaddq_rot270", "QQQ", "d">;
 }
+
+// V8.2-A BFloat intrinsics
+let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
+  def VCREATE_BF : NoTestOpInst<"vcreate", ".(IU>)", "b", OP_CAST> {
+let BigEndianSafe = 1;
+  }
+
+  def VDUP_N_BF: WOpInst<"vdup_n", ".1", "bQb", OP_DUP>;
+
+  def VDUP_LANE_BF : WOpInst

[PATCH] D79710: [clang][BFloat] Add create/set/get/dup intrinsics

2020-06-05 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b137a430636: [clang][BFloat] Add create/set/get/dup 
intrinsics (authored by stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79710

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
  clang/test/CodeGen/arm-bf16-getset-intrinsics.c

Index: clang/test/CodeGen/arm-bf16-getset-intrinsics.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-bf16-getset-intrinsics.c
@@ -0,0 +1,151 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-feature +neon -target-feature +bf16 -mfloat-abi hard \
+// RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg -instcombine | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vcreate_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast i64 [[A:%.*]] to <4 x bfloat>
+// CHECK-NEXT:ret <4 x bfloat> [[TMP0]]
+//
+bfloat16x4_t test_vcreate_bf16(uint64_t a) {
+  return vcreate_bf16(a);
+}
+
+// CHECK-LABEL: @test_vdup_n_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <4 x bfloat> undef, bfloat [[V:%.*]], i32 0
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = shufflevector <4 x bfloat> [[VECINIT_I]], <4 x bfloat> undef, <4 x i32> zeroinitializer
+// CHECK-NEXT:ret <4 x bfloat> [[VECINIT3_I]]
+//
+bfloat16x4_t test_vdup_n_bf16(bfloat16_t v) {
+  return vdup_n_bf16(v);
+}
+
+// CHECK-LABEL: @test_vdupq_n_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <8 x bfloat> undef, bfloat [[V:%.*]], i32 0
+// CHECK-NEXT:[[VECINIT7_I:%.*]] = shufflevector <8 x bfloat> [[VECINIT_I]], <8 x bfloat> undef, <8 x i32> zeroinitializer
+// CHECK-NEXT:ret <8 x bfloat> [[VECINIT7_I]]
+//
+bfloat16x8_t test_vdupq_n_bf16(bfloat16_t v) {
+  return vdupq_n_bf16(v);
+}
+
+// CHECK-LABEL: @test_vdup_lane_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LANE:%.*]] = shufflevector <4 x bfloat> [[V:%.*]], <4 x bfloat> undef, <4 x i32> 
+// CHECK-NEXT:ret <4 x bfloat> [[LANE]]
+//
+bfloat16x4_t test_vdup_lane_bf16(bfloat16x4_t v) {
+  return vdup_lane_bf16(v, 1);
+}
+
+// CHECK-LABEL: @test_vdupq_lane_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LANE:%.*]] = shufflevector <4 x bfloat> [[V:%.*]], <4 x bfloat> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x bfloat> [[LANE]]
+//
+bfloat16x8_t test_vdupq_lane_bf16(bfloat16x4_t v) {
+  return vdupq_lane_bf16(v, 1);
+}
+
+// CHECK-LABEL: @test_vdup_laneq_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LANE:%.*]] = shufflevector <8 x bfloat> [[V:%.*]], <8 x bfloat> undef, <4 x i32> 
+// CHECK-NEXT:ret <4 x bfloat> [[LANE]]
+//
+bfloat16x4_t test_vdup_laneq_bf16(bfloat16x8_t v) {
+  return vdup_laneq_bf16(v, 7);
+}
+
+// CHECK-LABEL: @test_vdupq_laneq_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LANE:%.*]] = shufflevector <8 x bfloat> [[V:%.*]], <8 x bfloat> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x bfloat> [[LANE]]
+//
+bfloat16x8_t test_vdupq_laneq_bf16(bfloat16x8_t v) {
+  return vdupq_laneq_bf16(v, 7);
+}
+
+// CHECK-LABEL: @test_vcombine_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[SHUFFLE_I:%.*]] = shufflevector <4 x bfloat> [[LOW:%.*]], <4 x bfloat> [[HIGH:%.*]], <8 x i32> 
+// CHECK-NEXT:ret <8 x bfloat> [[SHUFFLE_I]]
+//
+bfloat16x8_t test_vcombine_bf16(bfloat16x4_t low, bfloat16x4_t high) {
+  return vcombine_bf16(low, high);
+}
+
+// CHECK-LABEL: @test_vget_high_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[SHUFFLE_I:%.*]] = shufflevector <8 x bfloat> [[A:%.*]], <8 x bfloat> undef, <4 x i32> 
+// CHECK-NEXT:ret <4 x bfloat> [[SHUFFLE_I]]
+//
+bfloat16x4_t test_vget_high_bf16(bfloat16x8_t a) {
+  return vget_high_bf16(a);
+}
+
+// CHECK-LABEL: @test_vget_low_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[SHUFFLE_I:%.*]] = shufflevector <8 x bfloat> [[A:%.*]], <8 x bfloat> undef, <4 x i32> 
+// CHECK-NEXT:ret <4 x bfloat> [[SHUFFLE_I]]
+//
+bfloat16x4_t test_vget_low_bf16(bfloat16x8_t a) {
+  return vget_low_bf16(a);
+}
+
+// CHECK-LABEL: @test_vget_lane_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <4 x bfloat> [[V:%.*]], i32 1
+// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+//
+bfloat16_t test_vget_lane_bf16(bfloat16x4_t v) {
+  return vget_lane_bf16(v, 1);
+}
+
+// CHECK-LABEL: @test_vgetq_lane_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
+// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+//
+bfloat16_t test_vgetq_lane_bf16(bfloat16x8_t v) {
+  return vgetq_lane_bf16(v, 7);
+}
+
+// CHECK-LABEL: @test_vset_lane_bf16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x bfloat> [[V:%.

[clang] 23291b9 - Return "[InstCombine] Simplify compare of Phi with constant inputs against a constant"

2020-06-05 Thread Max Kazantsev via cfe-commits

Author: Max Kazantsev
Date: 2020-06-05T20:48:29+07:00
New Revision: 23291b9863c8af7ad348c4a7d85d8d784df88eb1

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

LOG: Return "[InstCombine] Simplify compare of Phi with constant inputs against 
a constant"

This reverts commit c4b5a66e44f031eb89c9d6ea32b144f1169bdbae.

Returning along with Clang test fix

Added: 


Modified: 
clang/test/CodeGenObjC/exceptions.m
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
llvm/test/Transforms/InstCombine/zext-or-icmp.ll

Removed: 




diff  --git a/clang/test/CodeGenObjC/exceptions.m 
b/clang/test/CodeGenObjC/exceptions.m
index 741f8a819158..3bb4f86cf025 100644
--- a/clang/test/CodeGenObjC/exceptions.m
+++ b/clang/test/CodeGenObjC/exceptions.m
@@ -97,7 +97,7 @@ void f3() {
 // CHECK:call void @objc_exception_try_exit(
 f3_helper(0, &x);
   } @finally {
-// CHECK:[[DEST1:%.*]] = phi i32 [ 0, {{%.*}} ], [ 3, {{%.*}} ]
+// CHECK:[[DEST1:%.*]] = phi i1 [ true, {{%.*}} ], [ false, {{%.*}} ]
 // CHECK:call void @objc_exception_try_enter
 // CHECK:call i32 @_setjmp
 @try {
@@ -105,7 +105,7 @@ void f3() {
   // CHECK:  call void @objc_exception_try_exit(
   f3_helper(1, &x);
 } @finally {
-  // CHECK:  [[DEST2:%.*]] = phi i32 [ 0, {{%.*}} ], [ 5, {{%.*}} ]
+  // CHECK:  [[DEST2:%.*]] = phi i1 [ true, {{%.*}} ], [ false, {{%.*}} ]
   // CHECK:  call void @f3_helper(i32 2, i32* nonnull [[X]])
   f3_helper(2, &x);
 

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 48375a1a323f..a7b9ecb9bf3b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1452,6 +1452,27 @@ Instruction *InstCombiner::foldICmpWithConstant(ICmpInst 
&Cmp) {
 if (Instruction *Res = processUGT_ADDCST_ADD(Cmp, A, B, CI2, CI, *this))
   return Res;
 
+  // icmp(phi(C1, C2, ...), C) -> phi(icmp(C1, C), icmp(C2, C), ...).
+  Constant *C = dyn_cast(Op1);
+  if (!C)
+return nullptr;
+
+  if (auto *Phi = dyn_cast(Op0))
+if (all_of(Phi->operands(), [](Value *V) { return isa(V); })) {
+  Type *Ty = Cmp.getType();
+  Builder.SetInsertPoint(Phi);
+  PHINode *NewPhi =
+  Builder.CreatePHI(Ty, Phi->getNumOperands());
+  for (BasicBlock *Predecessor : predecessors(Phi->getParent())) {
+auto *Input =
+cast(Phi->getIncomingValueForBlock(Predecessor));
+auto *BoolInput = ConstantExpr::getCompare(Pred, Input, C);
+NewPhi->addIncoming(BoolInput, Predecessor);
+  }
+  NewPhi->takeName(&Cmp);
+  return replaceInstUsesWith(Cmp, NewPhi);
+}
+
   return nullptr;
 }
 

diff  --git a/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll 
b/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
index 9753149f8012..7d4b9294143f 100644
--- a/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
@@ -2,8 +2,6 @@
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
 
-; TODO: Replace with boolean Phi.
-
 define i1 @test_eq(i1 %cond) {
 ; CHECK-LABEL: @test_eq(
 ; CHECK-NEXT:  entry:
@@ -13,10 +11,9 @@ define i1 @test_eq(i1 %cond) {
 ; CHECK:   if.false:
 ; CHECK-NEXT:br label [[MERGE]]
 ; CHECK:   merge:
-; CHECK-NEXT:[[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, 
[[IF_FALSE]] ]
+; CHECK-NEXT:[[COMPARE:%.*]] = phi i1 [ true, [[IF_FALSE]] ], [ false, 
[[IF_TRUE]] ]
 ; CHECK-NEXT:br label [[EXIT:%.*]]
 ; CHECK:   exit:
-; CHECK-NEXT:[[COMPARE:%.*]] = icmp eq i32 [[PHI]], 456
 ; CHECK-NEXT:ret i1 [[COMPARE]]
 ;
 entry:
@@ -46,10 +43,9 @@ define i1 @test_slt(i1 %cond) {
 ; CHECK:   if.false:
 ; CHECK-NEXT:br label [[MERGE]]
 ; CHECK:   merge:
-; CHECK-NEXT:[[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, 
[[IF_FALSE]] ]
+; CHECK-NEXT:[[COMPARE:%.*]] = phi i1 [ false, [[IF_FALSE]] ], [ true, 
[[IF_TRUE]] ]
 ; CHECK-NEXT:br label [[EXIT:%.*]]
 ; CHECK:   exit:
-; CHECK-NEXT:[[COMPARE:%.*]] = icmp ult i32 [[PHI]], 456
 ; CHECK-NEXT:ret i1 [[COMPARE]]
 ;
 entry:
@@ -110,10 +106,9 @@ define i1 @test_ne(i1 %cond) {
 ; CHECK:   if.false:
 ; CHECK-NEXT:br label [[MERGE]]
 ; CHECK:   merge:
-; CHECK-NEXT:[[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, 
[[IF_FALSE]] ]
+; CHECK-NEXT:[[COMPARE:%.*]] = phi i1 [ false, [[IF_FALSE]] ], [ true, 
[[IF_TRUE]] ]
 ; CHECK-NEXT:br label [[EXIT:%.*]]
 ; CHECK:   exit:
-

[PATCH] D80699: [Analyzer][StreamChecker] Add check for pointer escape.

2020-06-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a reviewer: NoQ.
Szelethus added a subscriber: NoQ.
Szelethus added a comment.

@NoQ @baloghadamsoftware Escapes are more within your realm of expertise. 
Anything to add?

From my end, this looks okay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80699



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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2020-06-05 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, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59520



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


[PATCH] D81169: [clangd] Improve hover on arguments to function call

2020-06-05 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 268780.
adamcz marked 11 inline comments as done.
adamcz added a comment.

addressed review comments, some UI questions remain open for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81169

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -696,6 +696,51 @@
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Extra info for function call.
+   R"cpp(
+  void fun(int arg_a, int &arg_b) {};
+  void code() {
+int a = 1, b = 2;
+fun(a, [[^b]]);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "b";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int b = 2";
+ HI.LocalScope = "code::";
+ HI.Value = "2";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_b";
+ HI.CalleeArgInfo->Type = "int &";
+   }},
+  {// Extra info for method call.
+   R"cpp(
+  class C {
+   public:
+void fun(int arg_a = 3, int arg_b = 4) {}
+  };
+  void code() {
+int a = 1, b = 2;
+C c;
+c.fun([[^a]], b);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "a";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int a = 1";
+ HI.LocalScope = "code::";
+ HI.Value = "1";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_a";
+ HI.CalleeArgInfo->Type = "int";
+ HI.CalleeArgInfo->Default = "3";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -729,6 +774,7 @@
 EXPECT_EQ(H->Size, Expected.Size);
 EXPECT_EQ(H->Offset, Expected.Offset);
 EXPECT_EQ(H->AccessSpecifier, Expected.AccessSpecifier);
+EXPECT_EQ(H->CalleeArgInfo, Expected.CalleeArgInfo);
   }
 }
 
@@ -2022,6 +2068,29 @@
 
 // In namespace ns1
 private: union foo {})",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Variable;
+HI.Name = "foo";
+HI.Definition = "int foo = 3";
+HI.LocalScope = "test::Bar::";
+HI.Value = "3";
+HI.Type = "int";
+HI.CalleeArgInfo.emplace();
+HI.CalleeArgInfo->Name = "arg_a";
+HI.CalleeArgInfo->Type = "int";
+HI.CalleeArgInfo->Default = "7";
+  },
+  R"(variable foo
+
+Type: int
+Value = 3
+
+Passed as int arg_a = 7
+
+// In test::Bar
+int foo = 3)",
   }};
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -77,6 +77,9 @@
   llvm::Optional Size;
   /// Contains the offset of fields within the enclosing class.
   llvm::Optional Offset;
+  // Set when symbol is inside function call. Contains information extracted
+  // from the callee definition about the argument this is passed as.
+  llvm::Optional CalleeArgInfo;
 
   /// Produce a user-readable information.
   markup::Document present() const;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -289,30 +289,35 @@
 : PVD->getDefaultArg();
 }
 
+HoverInfo::Param toHoverInfoParam(const ParmVarDecl *PVD,
+  const PrintingPolicy &Policy) {
+  HoverInfo::Param Out;
+  if (!PVD->getType().isNull()) {
+Out.Type = printType(PVD->getType(), Policy);
+  } else {
+std::string Param;
+llvm::raw_string_ostream OS(Param);
+PVD->dump(OS);
+OS.flush();
+elog("Got param with null type: {0}", Param);
+  }
+  if (!PVD->getName().empty())
+Out.Name = PVD->getNameAsString();
+  if (const Expr *DefArg = getDefaultArg(PVD)) {
+Out.Default.emplace();
+llvm::raw_string_ostream OS(*Out.Default);
+DefArg->printPretty(OS, nullptr, Policy);
+  }
+  return Out;
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D,
const FunctionDecl *FD,
const PrintingPolicy &Policy) {
   HI.Parameters.emplace();
  

[PATCH] D81169: [clangd] Improve hover on arguments to function call

2020-06-05 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:525
 
+  if (const auto *Var = dyn_cast(D)) {
+// Check if we are inside CallExpr

kadircet wrote:
> umm, is this a fixme or a leftover? I suppose it is from a previous version 
> of the patch.
Yep, previous version, sorry about that.



Comment at: clang-tools-extra/clangd/Hover.cpp:713
+  }
+  if (I >= CE->getNumArgs())
+return;

kadircet wrote:
> i don't think this is necessary, we are baling out if `FD->getNumParams() <= 
> I` anyways.
It's possible for FD->getNumParams() to be higher than CE->getNumArgs(), for 
example due to default arguments. If we couldn't find selected node inside 
CallExpr, we shouldn't be trying to match it to some "random" argument in 
FunctionDecl.

It's a bit irrelevant now, after addressing other review comments ;-)



Comment at: clang-tools-extra/clangd/Hover.cpp:716
+  // Extract matching argument from function declaration.
+  if (const FunctionDecl *FD = CE->getDirectCallee()) {
+if (FD->isOverloadedOperator() || FD->isVariadic() ||

kadircet wrote:
> nit: put this before arg index finding logic and do an early exit:
> 
> ```
> if(!CE) return;
> auto *FD = CE->getDirectCallee();
> if(!FD || FD->isOverloaded || variadic..) return;
> ```
> 
> after doing this you can also change the arg index finding logic to:
> ```
> auto *SelectedArg = N->outerImplicit().ASTNode.get();
> if(!SelectedParam) return; // you can also move this above other exit 
> conditions.
> for (unsigned I = 0; I < min(CE->getNumArgs, FD->getNumParams())...) { // I 
> suppose these two can be different in presence of default params ?
>   if (CE->getArg(I) == SelectedArg) {
>   // do magic;
>   break;
>   }
> }
> ``
Yea, that's nicer, thanks.

(I opted for "continue" rather than "break" to reduce indentation).



Comment at: clang-tools-extra/clangd/Hover.cpp:717
+  if (const FunctionDecl *FD = CE->getDirectCallee()) {
+if (FD->isOverloadedOperator() || FD->isVariadic() ||
+FD->getNumParams() <= I)

kadircet wrote:
> i can see the reason for variadics, but why bail out on overloaded operators? 
> also can we have some tests for these two?
I could totally see us supporting variadic, I'm just not sure how useful that 
will be, so I didn't do it right away.

As for the operators, I don't think we should trigger on those. There are two 
cases:
- things that do not look like a function call: operator+, operator<<, etc. 
When you hover over a variable it's not immediately obvious what the "passed 
to" would be referring to. Something like:
foo(a+b);
if I see "a passed as const int&" I might think this is about passing it to 
foo() (at least of first glance).
At the same time, the value of this is very low for operators. You know what 
their signature is already.

-operator() - this is much more like a function call. Maybe it would make sense 
to support it. It gets tricky with matching CallExpr args to FD params though. 
I'll leave a todo for now and worry about this in a separate change, if don't 
mind.jj



Comment at: clang-tools-extra/clangd/Hover.cpp:897
+llvm::raw_string_ostream OS(Buffer);
+OS << "Passed as " << *CalleeArgInfo;
+Output.addParagraph().appendText(OS.str());

kadircet wrote:
> i bet there will always be some people getting confused no matter what we say 
> in here (especially since we are not just printing the type, and I totally 
> find printing param name useful especially in case of literals). But to align 
> with other types of information we provide maybe say:
> 
> `Substitutes: ` ?
I am very much open to suggestions for phrasing, I'm not too happy about 
"Passed as". 

However, I am not a fan of Substitutes. If I saw that, I would have no idea 
what it's referring to. Since there is no visible connection between this hover 
card and the function call, without knowing what I'm looking at I would not 
make this connection. 

Might be just me. I am really as far from being a UI expert as possible. I'll 
ask around to see if people would get the Substitute: and get back to you on 
this one.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:728
+C c;
+c.fun([[^a]], b);
+  }

kadircet wrote:
> can you also add a test for a literal ?
Currently there is no hover at all for literals. The reason was that it 
wouldn't be useful. This information, however, might be, especially in cases 
like:
printThis(that, true, false, true);
knowing what these refer to could be useful.

Do you think this is good enough reason to enable hover on literals, with just 
this information? I'm thinking yes, but I'm not sure.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:2093
+
+Passed as int arg_a = 7)",
   }};

[PATCH] D80805: [KernelAddressSanitizer] Make globals constructors compatible with kernel

2020-06-05 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 268796.
melver added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update IR test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80805

Files:
  clang/test/CodeGen/asan-globals.cpp
  llvm/include/llvm/Transforms/Utils/ModuleUtils.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Utils/ModuleUtils.cpp

Index: llvm/lib/Transforms/Utils/ModuleUtils.cpp
===
--- llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -119,6 +119,15 @@
   AttributeList());
 }
 
+Function *llvm::createSanitizerCtor(Module &M, StringRef CtorName) {
+  Function *Ctor = Function::Create(
+  FunctionType::get(Type::getVoidTy(M.getContext()), false),
+  GlobalValue::InternalLinkage, CtorName, &M);
+  BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor);
+  ReturnInst::Create(M.getContext(), CtorBB);
+  return Ctor;
+}
+
 std::pair llvm::createSanitizerCtorAndInitFunctions(
 Module &M, StringRef CtorName, StringRef InitName,
 ArrayRef InitArgTypes, ArrayRef InitArgs,
@@ -128,11 +137,8 @@
  "Sanitizer's init function expects different number of arguments");
   FunctionCallee InitFunction =
   declareSanitizerInitFunction(M, InitName, InitArgTypes);
-  Function *Ctor = Function::Create(
-  FunctionType::get(Type::getVoidTy(M.getContext()), false),
-  GlobalValue::InternalLinkage, CtorName, &M);
-  BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor);
-  IRBuilder<> IRB(ReturnInst::Create(M.getContext(), CtorBB));
+  Function *Ctor = createSanitizerCtor(M, CtorName);
+  IRBuilder<> IRB(Ctor->getEntryBlock().getTerminator());
   IRB.CreateCall(InitFunction, InitArgs);
   if (!VersionCheckName.empty()) {
 FunctionCallee VersionCheckFunction = M.getOrInsertFunction(
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -589,11 +589,10 @@
   AddressSanitizer(Module &M, const GlobalsMetadata *GlobalsMD,
bool CompileKernel = false, bool Recover = false,
bool UseAfterScope = false)
-  : UseAfterScope(UseAfterScope || ClUseAfterScope), GlobalsMD(*GlobalsMD) {
-this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
-this->CompileKernel =
-ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan : CompileKernel;
-
+  : CompileKernel(ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan
+: CompileKernel),
+Recover(ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover),
+UseAfterScope(UseAfterScope || ClUseAfterScope), GlobalsMD(*GlobalsMD) {
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -742,7 +741,11 @@
   ModuleAddressSanitizer(Module &M, const GlobalsMetadata *GlobalsMD,
  bool CompileKernel = false, bool Recover = false,
  bool UseGlobalsGC = true, bool UseOdrIndicator = false)
-  : GlobalsMD(*GlobalsMD), UseGlobalsGC(UseGlobalsGC && ClUseGlobalsGC),
+  : GlobalsMD(*GlobalsMD),
+CompileKernel(ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan
+: CompileKernel),
+Recover(ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover),
+UseGlobalsGC(UseGlobalsGC && ClUseGlobalsGC && !this->CompileKernel),
 // Enable aliases as they should have no downside with ODR indicators.
 UsePrivateAlias(UseOdrIndicator || ClUsePrivateAlias),
 UseOdrIndicator(UseOdrIndicator || ClUseOdrIndicator),
@@ -753,11 +756,7 @@
 // argument is designed as workaround. Therefore, disable both
 // ClWithComdat and ClUseGlobalsGC unless the frontend says it's ok to
 // do globals-gc.
-UseCtorComdat(UseGlobalsGC && ClWithComdat) {
-this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
-this->CompileKernel =
-ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan : CompileKernel;
-
+UseCtorComdat(UseGlobalsGC && ClWithComdat && !this->CompileKernel) {
 C = &(M.getContext());
 int LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -1838,6 +1837,12 @@
   }
 
   if (G->hasSection()) {
+// The kernel uses explicit sections for mostly special global variables
+// that we should not instrument. E.g. the kernel may rely on their layout
+// without redzones, or remove them at link time

[PATCH] D81252: [SVE ACLE] Remove redundant bool_t typedef.

2020-06-05 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm updated this revision to Diff 268795.
paulwalker-arm added a comment.

Stop SveEmitter adding a _t suffix to the scalar boolean type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81252

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -437,7 +437,8 @@
   S += "x" + utostr(getNumElements());
 if (NumVectors > 1)
   S += "x" + utostr(NumVectors);
-S += "_t";
+if (!isScalarPredicate())
+  S += "_t";
   }
 
   if (Constant)
@@ -1058,7 +1059,6 @@
   OS << "typedef __fp16 float16_t;\n";
   OS << "typedef float float32_t;\n";
   OS << "typedef double float64_t;\n";
-  OS << "typedef bool bool_t;\n\n";
 
   OS << "typedef __SVInt8_t svint8_t;\n";
   OS << "typedef __SVInt16_t svint16_t;\n";


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -437,7 +437,8 @@
   S += "x" + utostr(getNumElements());
 if (NumVectors > 1)
   S += "x" + utostr(NumVectors);
-S += "_t";
+if (!isScalarPredicate())
+  S += "_t";
   }
 
   if (Constant)
@@ -1058,7 +1059,6 @@
   OS << "typedef __fp16 float16_t;\n";
   OS << "typedef float float32_t;\n";
   OS << "typedef double float64_t;\n";
-  OS << "typedef bool bool_t;\n\n";
 
   OS << "typedef __SVInt8_t svint8_t;\n";
   OS << "typedef __SVInt16_t svint16_t;\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 28c2bdf - [AST] Record SourceLocation for TypoExpr.

2020-06-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-06-05T17:03:32+02:00
New Revision: 28c2bdf18f508460401ba1d6958de87b27d52618

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

LOG: [AST] Record SourceLocation for TypoExpr.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLookup.cpp
clang/test/AST/ast-dump-recovery.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 4de2259ebaf3..670c0fe80b4e 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6152,8 +6152,12 @@ class AtomicExpr : public Expr {
 /// TypoExpr - Internal placeholder for expressions where typo correction
 /// still needs to be performed and/or an error diagnostic emitted.
 class TypoExpr : public Expr {
+  // The location for the typo name.
+  SourceLocation TypoLoc;
+
 public:
-  TypoExpr(QualType T) : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary) {
+  TypoExpr(QualType T, SourceLocation TypoLoc)
+  : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary), TypoLoc(TypoLoc) {
 assert(T->isDependentType() && "TypoExpr given a non-dependent type");
 setDependence(ExprDependence::TypeValueInstantiation |
   ExprDependence::Error);
@@ -6166,8 +6170,8 @@ class TypoExpr : public Expr {
 return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
-  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
-  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
+  SourceLocation getBeginLoc() const LLVM_READONLY { return TypoLoc; }
+  SourceLocation getEndLoc() const LLVM_READONLY { return TypoLoc; }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == TypoExprClass;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2a71d01d6edb..5f0a03b1c93f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3695,7 +3695,7 @@ class Sema final {
   /// Creates a new TypoExpr AST node.
   TypoExpr *createDelayedTypo(std::unique_ptr TCC,
   TypoDiagnosticGenerator TDG,
-  TypoRecoveryCallback TRC);
+  TypoRecoveryCallback TRC, SourceLocation 
TypoLoc);
 
   // The set of known/encountered (unique, canonicalized) NamespaceDecls.
   //

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 9c4e5b4a7848..c22af86d57aa 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -8307,8 +8307,6 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE, 
SourceLocation CC,
   if (FullExpr.isInvalid()) {
 // Typo-correction fails, we rebuild the broken AST with the typos degraded
 // to RecoveryExpr.
-// FIXME: we lose source locations for RecoveryExpr, as TypoExpr doesn't
-// track source locations.
 struct TyposReplace : TreeTransform {
   TyposReplace(Sema &SemaRef) : TreeTransform(SemaRef) {}
   ExprResult TransformTypoExpr(TypoExpr *E) {

diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index dbbd190caea9..0afb75752c12 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -5167,9 +5167,9 @@ TypoExpr *Sema::CorrectTypoDelayed(
   IdentifierInfo *Typo = TypoName.getName().getAsIdentifierInfo();
   if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3)
 return nullptr;
-
   ExprEvalContexts.back().NumTypos++;
-  return createDelayedTypo(std::move(Consumer), std::move(TDG), 
std::move(TRC));
+  return createDelayedTypo(std::move(Consumer), std::move(TDG), std::move(TRC),
+   TypoName.getLoc());
 }
 
 void TypoCorrection::addCorrectionDecl(NamedDecl *CDecl) {
@@ -5481,9 +5481,10 @@ void Sema::diagnoseTypo(const TypoCorrection &Correction,
 
 TypoExpr *Sema::createDelayedTypo(std::unique_ptr TCC,
   TypoDiagnosticGenerator TDG,
-  TypoRecoveryCallback TRC) {
+  TypoRecoveryCallback TRC,
+  SourceLocation TypoLoc) {
   assert(TCC && "createDelayedTypo requires a valid TypoCorrectionConsumer");
-  auto TE = new (Context) TypoExpr(Context.DependentTy);
+  auto TE = new (Context) TypoExpr(Context.DependentTy, TypoLoc);
   auto &State = DelayedTypos[TE];
   State.Consumer = std::move(TCC);
   State.DiagHandler = std::move(TDG);

diff  --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index 6

[clang] 99d6e05 - [lit] Improve naming of test result categories

2020-06-05 Thread Julian Lettner via cfe-commits

Author: Julian Lettner
Date: 2020-06-05T08:14:42-07:00
New Revision: 99d6e05e7144a2638c4e85ea75099e9dc6432cde

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

LOG: [lit] Improve naming of test result categories

Improve consistency when printing test results:
Previously we were using different labels for group names (the header
for the list of, e.g., failing tests) and summary count lines.  For
example, "Failing Tests"/"Unexpected Failures".  This commit changes lit
to label things consistently.

Improve wording of labels:
When talking about individual test results, the first word in
"Unexpected Failures", "Expected Passes", and "Individual Timeouts" is
superfluous.  Some labels contain the word "Tests" and some don't.
Let's simplify the names.

Before:
```
Failing Tests (1):
  ...

Expected Passes: 3
Unexpected Failures: 1
```

After:
```
Failed Tests (1):
  ...

Passed: 3
Failed: 1
```

Reviewed By: ldionne

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

Added: 


Modified: 
clang/www/hacking.html
llvm/utils/lit/lit/main.py
llvm/utils/lit/tests/allow-retries.py
llvm/utils/lit/tests/custom-result-category.py
llvm/utils/lit/tests/googletest-discovery-failed.py
llvm/utils/lit/tests/googletest-format.py
llvm/utils/lit/tests/googletest-timeout.py
llvm/utils/lit/tests/googletest-upstream-format.py
llvm/utils/lit/tests/lit-opts.py
llvm/utils/lit/tests/max-failures.py
llvm/utils/lit/tests/max-time.py
llvm/utils/lit/tests/parallelism-groups.py
llvm/utils/lit/tests/selecting.py
llvm/utils/lit/tests/shtest-env.py
llvm/utils/lit/tests/shtest-format.py
llvm/utils/lit/tests/shtest-inject.py
llvm/utils/lit/tests/shtest-not.py
llvm/utils/lit/tests/shtest-shell.py
llvm/utils/lit/tests/shtest-timeout.py
mlir/test/Examples/standalone/test.toy

Removed: 




diff  --git a/clang/www/hacking.html b/clang/www/hacking.html
index 3623b904119a..ad1b4ea94bf5 100755
--- a/clang/www/hacking.html
+++ b/clang/www/hacking.html
@@ -264,12 +264,12 @@ Testing on the Command Line
 -- Testing: Testing: 2534 tests, 4 threads --
 Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
 Testing Time: 81.52s
-  Expected Passes: 2503
-  Expected Failures  : 28
-  Unsupported Tests  : 3
+  Passed   : 2503
+  Expectedly Failed:   28
+  Unsupported  :3
 
 
-  The statistic, "Unexpected Failures" (not shown if all tests pass), is 
the important one.
+  The statistic, "Failed" (not shown if all tests pass), is the important 
one.
 
   
   Creating Patch Files

diff  --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 6c423167ff4c..b8c951360322 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -265,34 +265,33 @@ def print_histogram(tests):
 
 def add_result_category(result_code, label):
 assert isinstance(result_code, lit.Test.ResultCode)
-category = (result_code, "%s Tests" % label, label)
+category = (result_code, label)
 result_codes.append(category)
 
 
-# Status code, summary label, group label
 result_codes = [
 # Passes
-(lit.Test.EXCLUDED,'Excluded Tests',  'Excluded'),
-(lit.Test.SKIPPED, 'Skipped Tests',   'Skipped'),
-(lit.Test.UNSUPPORTED, 'Unsupported Tests',   'Unsupported'),
-(lit.Test.PASS,'Expected Passes', ''),
-(lit.Test.FLAKYPASS,   'Passes With Retry',   ''),
-(lit.Test.XFAIL,   'Expected Failures',   'Expected Failing'),
+(lit.Test.EXCLUDED,'Excluded'),
+(lit.Test.SKIPPED, 'Skipped'),
+(lit.Test.UNSUPPORTED, 'Unsupported'),
+(lit.Test.PASS,'Passed'),
+(lit.Test.FLAKYPASS,   'Passed With Retry'),
+(lit.Test.XFAIL,   'Expectedly Failed'),
 # Failures
-(lit.Test.UNRESOLVED,  'Unresolved Tests','Unresolved'),
-(lit.Test.TIMEOUT, 'Individual Timeouts', 'Timed Out'),
-(lit.Test.FAIL,'Unexpected Failures', 'Failing'),
-(lit.Test.XPASS,   'Unexpected Passes',   'Unexpected Passing')
+(lit.Test.UNRESOLVED,  'Unresolved'),
+(lit.Test.TIMEOUT, 'Timed Out'),
+(lit.Test.FAIL,'Failed'),
+(lit.Test.XPASS,   'Unexpectedly Passed')
 ]
 
 
 def print_results(tests, elapsed, opts):
-tests_by_code = {code: [] for (code, _, _) in result_codes}
+tests_by_code = {code: [] for code, _ in result_codes}
 for test in tests:
 tests_by_code[test.result.code].append(test)
 
-for (code, _, group_label) in result_codes:
-print_group(code, group_label, tests_by_code[code], opts)
+for (code, label) in result_codes:
+print_group(code, label, tests_by_code[code], opts)
 
 print_summary(tests_by_code, opts.quiet, elapsed)
 
@@ -318,7 +317,7 @@ def 

[PATCH] D81176: [HIP] Add default header and include path

2020-06-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 6 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/ROCm.h:68
+
+  // CUDA architectures for which we have raised an error in
+  // CheckRocmVersionSupportsArch.

tra wrote:
> CUDA -> GPU?
> Looks like there are number of other mentions of CUDA that should be fixed.
will fix when commit



Comment at: clang/lib/Headers/__clang_hip_math.h:26
+__DEVICE__
+inline uint64_t __make_mantissa_base8(const char *tagp) {
+  uint64_t r = 0;

tra wrote:
> Arguments for compiler-internal declarations and local symbols should all be 
> prefixed with `__`.
> 
will fix when committing



Comment at: clang/lib/Headers/__clang_hip_math.h:931-935
+#pragma push_macro("__DEF_FLOAT_FUN")
+#pragma push_macro("__DEF_FLOAT_FUN2")
+#pragma push_macro("__DEF_FLOAT_FUN2I")
+#pragma push_macro("__HIP_OVERLOAD")
+#pragma push_macro("__HIP_OVERLOAD2")

tra wrote:
> The macros pushed here do not match the set of macros defined below.
> E.g. `__HIP_OVERLOAD` vs `__HIP_OVERLOAD1`, `__DEF_FLOAT_FUN` vs. 
> `__DEF_FUN1`, etc.
will fix when commit


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

https://reviews.llvm.org/D81176



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


[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-05 Thread Rodrigo Caetano Rocha via Phabricator via cfe-commits
rcorcs added a comment.

LLVM already has the class PassBuilder::OptimizationLevel that encapsulates the 
logic of both speed and size optimization levels. This class already checks 
which values for SpeedLevel and SizeLevel are valid.

However, other parts of the code define two separate variables to describe 
speed and size optimization levels with their semantic specified either in 
comments or code. Note that when SizeLevel!=0, OptLevel (or SpeedLevel) is 
usually expected to be 2, that is, their values are interdependent.

From my understanding, ideally, LLVM would use the same OptimizationLevel 
encapsulation everywhere. If the same encapsulation is used everywhere we can 
avoid conversions and guarantee
that they always have the same semantics.

For example, the class PassManagerBuilder defines these two separate variables 
with their semantics in comments:

  /// The Optimization Level - Specify the basic optimization level.
  ///0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3 
  unsigned OptLevel;
  
  /// SizeLevel - How much we're optimizing for size.
  ///0 = none, 1 = -Os, 2 = -Oz
  unsigned SizeLevel;

On the other hand, the class ThinLTOCodeGenerator defines the semantics of 
OptLevel in code:

  /// IR optimization level: from 0 to 3.
  void setOptLevel(unsigned NewOptLevel) {
OptLevel = (NewOptLevel > 3) ? 3 : NewOptLevel;
  }

This patch standardizes the use of OptimizationLevel across PassBuilder, 
PassManagerBuilder, LTO configuration, and LTO code generators. Even with this 
patch, further work is still needed to standardize the use of OptimizationLevel 
across LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

2020-06-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

So this is late in the game but... maybe we should just not report this case as 
a reference?

`#undef foo` is valid if `foo` was never defined, and doesn't refer to 
anything. If we similarly don't resolve the reference in this case as we only 
import macros that were used and undef doesn't count as a use... I think that's 
defensible as a weird edge case.

In practice, I doubt anyone cares - AIUI the cases we've seen this, it's 
defensive claiming of the macro namespace, and not a targeted undef of a 
particular known macro at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80525



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


[PATCH] D81263: [Sema][CodeComplete][ObjC] Don't include arrow/dot fixits

2020-06-05 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added reviewers: sammccall, yvvan.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.
dgoldman updated this revision to Diff 268803.
dgoldman added a comment.

- Fix test run line


Exempt ObjC from arrow/dot fixits since this has limited value for
Objective-C, where properties (referenced by dot syntax) are normally
backed by ivars (referenced by arrow syntax).

In addition, the current implementation doesn't properly mark
the fix it condition for Objective-C.

This was initially added in https://reviews.llvm.org/D41537
for C++ and then later C, don't believe the Objective-C changes
were intentional.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81263

Files:
  clang/test/CodeCompletion/objc-member-access.m


Index: clang/test/CodeCompletion/objc-member-access.m
===
--- clang/test/CodeCompletion/objc-member-access.m
+++ clang/test/CodeCompletion/objc-member-access.m
@@ -15,7 +15,7 @@
   return foo;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits 
-code-completion-at=%s:16:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits 
-code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1-NOT: [#int#]_bar
 // CHECK-CC1-NOT: [#int#]_foo
 // CHECK-CC1: [#int#]bar


Index: clang/test/CodeCompletion/objc-member-access.m
===
--- clang/test/CodeCompletion/objc-member-access.m
+++ clang/test/CodeCompletion/objc-member-access.m
@@ -15,7 +15,7 @@
   return foo;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:16:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1-NOT: [#int#]_bar
 // CHECK-CC1-NOT: [#int#]_foo
 // CHECK-CC1: [#int#]bar
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-05 Thread Rodrigo Caetano Rocha via Phabricator via cfe-commits
rcorcs added a comment.

If reviewers think that this patch is touching in too many files, I could try 
to focus it only on the LTO related files, converting OptimizationLevel back to 
two separate values when necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D81263: [Sema][CodeComplete][ObjC] Don't include arrow/dot fixits

2020-06-05 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 268803.
dgoldman added a comment.

- Fix test run line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81263

Files:
  clang/test/CodeCompletion/objc-member-access.m


Index: clang/test/CodeCompletion/objc-member-access.m
===
--- clang/test/CodeCompletion/objc-member-access.m
+++ clang/test/CodeCompletion/objc-member-access.m
@@ -15,7 +15,7 @@
   return foo;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits 
-code-completion-at=%s:16:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits 
-code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1-NOT: [#int#]_bar
 // CHECK-CC1-NOT: [#int#]_foo
 // CHECK-CC1: [#int#]bar


Index: clang/test/CodeCompletion/objc-member-access.m
===
--- clang/test/CodeCompletion/objc-member-access.m
+++ clang/test/CodeCompletion/objc-member-access.m
@@ -15,7 +15,7 @@
   return foo;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:16:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1-NOT: [#int#]_bar
 // CHECK-CC1-NOT: [#int#]_foo
 // CHECK-CC1: [#int#]bar
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-05 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

LGTM, nothing else to add.


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

https://reviews.llvm.org/D80896



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


[PATCH] D74299: [clang-tidy] extend tests of run-clang-tidy

2020-06-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Generally looks good to me, but I had a question about test coverage.




Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp:1
-// RUN: %run_clang_tidy --help
 // RUN: rm -rf %t

Is there a reason to remove this test coverage? I believe this is testing that 
we can access the help without crashing.


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

https://reviews.llvm.org/D74299



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


[PATCH] D80202: [ASTMatchers] Performance optimization for memoization

2020-06-05 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I decided to do some more stringent benchmarking, just focusing on the 
matching, not the boilerplate of running clang-tidy.

  
=BeforePatch===
  Matcher Timings:   116.0756 user  29.1397 system  145.2154 process  145.2168 
wall
  Matcher Timings:   117.7205 user  29.2475 system  146.9681 process  146.9158 
wall
  Matcher Timings:   116.8313 user  29.5170 system  146.3483 process  146.2655 
wall
  Matcher Timings:   117.9491 user  29.0969 system  147.0459 process  146.9678 
wall
  Matcher Timings:   117.6309 user  29.1864 system  146.8173 process  146.7687 
wall
  
  user:117.2+-0.753
  system:  29.24+-0.166
  process: 146.5+-0.760

  
==AfterPatch===
  Matcher Timings:   110.5497 user  28.3316 system  138.8813 process  138.7960 
wall
  Matcher Timings:   112.5151 user  28.8616 system  141.3767 process  141.3003 
wall
  Matcher Timings:   116.1578 user  28.9472 system  145.1049 process  145.0785 
wall
  Matcher Timings:   107.1089 user  27.2752 system  134.3841 process  134.3459 
wall
  Matcher Timings:   105.9242 user  27.0338 system  132.9580 process  132.9010 
wall
  
  user:110.4+-4.159
  system:  28.09+-0.890
  process: 138.6+-4.979

This is showing ~5% improvement when running every clang-tidy check on a 
translation unit (Specifically 
`clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80202



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


[PATCH] D81008: [AST] Record SourceLocation for TypoExpr.

2020-06-05 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28c2bdf18f50: [AST] Record SourceLocation for TypoExpr. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81008

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/AST/ast-dump-recovery.cpp

Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -13,9 +13,9 @@
 void test_invalid_call(int s) {
   // CHECK:  CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} 'some_func'
-  // CHECK-NEXT: |-RecoveryExpr {{.*}} <>
-  // CHECK-NEXT: `-BinaryOperator {{.*}} <, col:28>
-  // CHECK-NEXT:   |-RecoveryExpr {{.*}} <>
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} 
+  // CHECK-NEXT: `-BinaryOperator {{.*}}
+  // CHECK-NEXT:   |-RecoveryExpr {{.*}}
   // CHECK-NEXT:   `-IntegerLiteral {{.*}}  'int' 1
   some_func(undef1, undef2+1);
 
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -5167,9 +5167,9 @@
   IdentifierInfo *Typo = TypoName.getName().getAsIdentifierInfo();
   if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3)
 return nullptr;
-
   ExprEvalContexts.back().NumTypos++;
-  return createDelayedTypo(std::move(Consumer), std::move(TDG), std::move(TRC));
+  return createDelayedTypo(std::move(Consumer), std::move(TDG), std::move(TRC),
+   TypoName.getLoc());
 }
 
 void TypoCorrection::addCorrectionDecl(NamedDecl *CDecl) {
@@ -5481,9 +5481,10 @@
 
 TypoExpr *Sema::createDelayedTypo(std::unique_ptr TCC,
   TypoDiagnosticGenerator TDG,
-  TypoRecoveryCallback TRC) {
+  TypoRecoveryCallback TRC,
+  SourceLocation TypoLoc) {
   assert(TCC && "createDelayedTypo requires a valid TypoCorrectionConsumer");
-  auto TE = new (Context) TypoExpr(Context.DependentTy);
+  auto TE = new (Context) TypoExpr(Context.DependentTy, TypoLoc);
   auto &State = DelayedTypos[TE];
   State.Consumer = std::move(TCC);
   State.DiagHandler = std::move(TDG);
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -8307,8 +8307,6 @@
   if (FullExpr.isInvalid()) {
 // Typo-correction fails, we rebuild the broken AST with the typos degraded
 // to RecoveryExpr.
-// FIXME: we lose source locations for RecoveryExpr, as TypoExpr doesn't
-// track source locations.
 struct TyposReplace : TreeTransform {
   TyposReplace(Sema &SemaRef) : TreeTransform(SemaRef) {}
   ExprResult TransformTypoExpr(TypoExpr *E) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3695,7 +3695,7 @@
   /// Creates a new TypoExpr AST node.
   TypoExpr *createDelayedTypo(std::unique_ptr TCC,
   TypoDiagnosticGenerator TDG,
-  TypoRecoveryCallback TRC);
+  TypoRecoveryCallback TRC, SourceLocation TypoLoc);
 
   // The set of known/encountered (unique, canonicalized) NamespaceDecls.
   //
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -6152,8 +6152,12 @@
 /// TypoExpr - Internal placeholder for expressions where typo correction
 /// still needs to be performed and/or an error diagnostic emitted.
 class TypoExpr : public Expr {
+  // The location for the typo name.
+  SourceLocation TypoLoc;
+
 public:
-  TypoExpr(QualType T) : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary) {
+  TypoExpr(QualType T, SourceLocation TypoLoc)
+  : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary), TypoLoc(TypoLoc) {
 assert(T->isDependentType() && "TypoExpr given a non-dependent type");
 setDependence(ExprDependence::TypeValueInstantiation |
   ExprDependence::Error);
@@ -6166,8 +6170,8 @@
 return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
-  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
-  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
+  SourceLocation getBeginLoc() const LLVM_READONLY { return TypoLoc; }
+  SourceLocation getEndLoc() const LLVM_READONLY { return TypoLoc; }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass

[PATCH] D77708: [lit] Improve naming of test result categories

2020-06-05 Thread Julian Lettner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99d6e05e7144: [lit] Improve naming of test result categories 
(authored by yln).
Herald added subscribers: cfe-commits, msifontes, jurahul, Kayjukh, frgossen, 
grosul1, Joonsoo, stephenneuendorffer, liufengdb, lucyrfox, mgester, 
arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, 
mehdi_amini.
Herald added projects: clang, MLIR.

Changed prior to commit:
  https://reviews.llvm.org/D77708?vs=264307&id=268809#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77708

Files:
  clang/www/hacking.html
  llvm/utils/lit/lit/main.py
  llvm/utils/lit/tests/allow-retries.py
  llvm/utils/lit/tests/custom-result-category.py
  llvm/utils/lit/tests/googletest-discovery-failed.py
  llvm/utils/lit/tests/googletest-format.py
  llvm/utils/lit/tests/googletest-timeout.py
  llvm/utils/lit/tests/googletest-upstream-format.py
  llvm/utils/lit/tests/lit-opts.py
  llvm/utils/lit/tests/max-failures.py
  llvm/utils/lit/tests/max-time.py
  llvm/utils/lit/tests/parallelism-groups.py
  llvm/utils/lit/tests/selecting.py
  llvm/utils/lit/tests/shtest-env.py
  llvm/utils/lit/tests/shtest-format.py
  llvm/utils/lit/tests/shtest-inject.py
  llvm/utils/lit/tests/shtest-not.py
  llvm/utils/lit/tests/shtest-shell.py
  llvm/utils/lit/tests/shtest-timeout.py
  mlir/test/Examples/standalone/test.toy

Index: mlir/test/Examples/standalone/test.toy
===
--- mlir/test/Examples/standalone/test.toy
+++ mlir/test/Examples/standalone/test.toy
@@ -1,4 +1,4 @@
 # RUN: %cmake %mlir_src_root/examples/standalone -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc -DMLIR_DIR=%llvm_lib_dir/cmake/mlir ; %cmake --build . --target check-standalone | tee %t | FileCheck %s
 
-# CHECK: Expected Passes: 3
+# CHECK: Passed: 3
 # UNSUPPORTED: windows, android
Index: llvm/utils/lit/tests/shtest-timeout.py
===
--- llvm/utils/lit/tests/shtest-timeout.py
+++ llvm/utils/lit/tests/shtest-timeout.py
@@ -50,8 +50,8 @@
 
 # CHECK-OUT-COMMON: PASS: per_test_timeout :: short.py
 
-# CHECK-OUT-COMMON: Expected Passes{{ *}}: 1
-# CHECK-OUT-COMMON: Individual Timeouts{{ *}}: 1
+# CHECK-OUT-COMMON: Passed   : 1
+# CHECK-OUT-COMMON: Timed Out: 1
 
 # Test per test timeout via a config file and on the command line.
 # The value set on the command line should override the config file.
@@ -71,5 +71,5 @@
 
 # CHECK-CMDLINE-OVERRIDE-OUT: PASS: per_test_timeout :: short.py
 
-# CHECK-CMDLINE-OVERRIDE-OUT: Expected Passes{{ *}}: 1
-# CHECK-CMDLINE-OVERRIDE-OUT: Individual Timeouts{{ *}}: 1
+# CHECK-CMDLINE-OVERRIDE-OUT: Passed   : 1
+# CHECK-CMDLINE-OVERRIDE-OUT: Timed Out: 1
Index: llvm/utils/lit/tests/shtest-shell.py
===
--- llvm/utils/lit/tests/shtest-shell.py
+++ llvm/utils/lit/tests/shtest-shell.py
@@ -583,4 +583,4 @@
 # CHECK: ***
 
 # CHECK: PASS: shtest-shell :: valid-shell.txt
-# CHECK: Failing Tests (35)
+# CHECK: Failed Tests (35)
Index: llvm/utils/lit/tests/shtest-not.py
===
--- llvm/utils/lit/tests/shtest-not.py
+++ llvm/utils/lit/tests/shtest-not.py
@@ -110,6 +110,6 @@
 # CHECK: Error: 'not --crash' cannot call 'rm'
 # CHECK: error: command failed with exit status: {{.*}}
 
-# CHECK: Expected Passes : 1
-# CHECK: Unexpected Failures: 12
+# CHECK: Passed:  1
+# CHECK: Failed: 12
 # CHECK-NOT: {{.}}
Index: llvm/utils/lit/tests/shtest-inject.py
===
--- llvm/utils/lit/tests/shtest-inject.py
+++ llvm/utils/lit/tests/shtest-inject.py
@@ -11,7 +11,7 @@
 # CHECK-TEST1: THIS WAS
 # CHECK-TEST1: INJECTED
 #
-# CHECK-TEST1: Expected Passes: 1
+# CHECK-TEST1: Passed: 1
 
 # RUN: %{lit} -j 1 %{inputs}/shtest-inject/test-one.txt --show-all | FileCheck --check-prefix=CHECK-TEST2 %s
 #
@@ -26,7 +26,7 @@
 # CHECK-TEST2: INJECTED
 # CHECK-TEST2: IN THE FILE
 #
-# CHECK-TEST2: Expected Passes: 1
+# CHECK-TEST2: Passed: 1
 
 # RUN: %{lit} -j 1 %{inputs}/shtest-inject/test-many.txt --show-all | FileCheck --check-prefix=CHECK-TEST3 %s
 #
@@ -45,4 +45,4 @@
 # CHECK-TEST3: IF IT WORKS
 # CHECK-TEST3: AS EXPECTED
 #
-# CHECK-TEST3: Expected Passes: 1
+# CHECK-TEST3: Passed: 1
Index: llvm/utils/lit/tests/shtest-format.py
===
--- llvm/utils/lit/tests/shtest-format.py
+++ llvm/utils/lit/tests/shtest-format.py
@@ -69,21 +69,21 @@
 # CHECK-NEXT: true
 # CHECK-NEXT: --
 
-# CHECK: Failing Tests (3)
+# CHECK: Failed Tests (3)
 # CHECK: shtest-format :: external_shell/fail.txt
 # CHECK: shtest-format :: external_shell/fail_with_bad_encoding.txt
 # CHECK: shtest-format :: fail.txt
 
-# CHECK: Unexpected Passing Tests (1)
+# CHECK: U

[clang-tools-extra] c063b4a - Fix crash on misc-redundant-expression

2020-06-05 Thread Zinovy Nis via cfe-commits

Author: Zinovy Nis
Date: 2020-06-05T18:43:57+03:00
New Revision: c063b4a72bb39d9ae4bd13851873ddcbc16f6804

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

LOG: Fix crash on misc-redundant-expression

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index edb765b287f9..aef513a527b5 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,8 +72,8 @@ static bool areEquivalentExpr(const Expr *Left, const Expr 
*Right) {
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
-   dyn_cast(*RightIter)))
+if (!areEquivalentExpr(dyn_cast_or_null(*LeftIter),
+   dyn_cast_or_null(*RightIter)))
   return false;
 ++LeftIter;
 ++RightIter;
@@ -117,6 +117,9 @@ static bool areEquivalentExpr(const Expr *Left, const Expr 
*Right) {
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass:
+return cast(Left)->getOperator() ==
+   cast(Right)->getOperator();
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
index 4a4304be9bf4..c47ef7d36ff5 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@ struct Bar {
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
-}
+
+template 
+struct Bar2 {
+  static_assert((... && (sizeof(Values) > 0)) == (... && (sizeof(Values) > 
0)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: both sides of operator are 
equivalent [misc-redundant-expression]
+};
+} // namespace no_crash



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


[PATCH] D81163: [AST][RecoveryExpr] Preserve the AST for invalid conditions.

2020-06-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81163



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


[PATCH] D81263: [Sema][CodeComplete][ObjC] Don't include arrow/dot fixits

2020-06-05 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 268818.
dgoldman added a comment.

- Fix broken diff base (due to lint fixes maybe?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81263

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/objc-member-access.m


Index: clang/test/CodeCompletion/objc-member-access.m
===
--- /dev/null
+++ clang/test/CodeCompletion/objc-member-access.m
@@ -0,0 +1,22 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface TypeWithPropertiesBackedByIvars {
+  int _bar;
+  int _foo;
+}
+@property(nonatomic) int foo;
+@property(nonatomic) int bar;
+@end
+
+int getFoo(id object) {
+  TypeWithPropertiesBackedByIvars *model = (TypeWithPropertiesBackedByIvars 
*)object;
+  int foo = model.;
+  return foo;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits 
-code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1-NOT: [#int#]_bar
+// CHECK-CC1-NOT: [#int#]_foo
+// CHECK-CC1: [#int#]bar
+// CHECK-CC1: [#int#]foo
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5150,7 +5150,7 @@
 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
 &ResultBuilder::IsMember);
 
-  auto DoCompletion = [&](Expr *Base, bool IsArrow,
+  auto DoCompletion = [&](Expr *Base, bool IsArrow, bool IncludeObjC,
   Optional AccessOpFixIt) -> bool {
 if (!Base)
   return false;
@@ -5196,6 +5196,9 @@
   }
 } else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
   // Objective-C property reference.
+  if (!IncludeObjC) {
+return false;
+  }
   AddedPropertiesSet AddedProperties;
 
   if (const ObjCObjectPointerType *ObjCPtr =
@@ -5216,6 +5219,9 @@
 } else if ((IsArrow && BaseType->isObjCObjectPointerType()) ||
(!IsArrow && BaseType->isObjCObjectType())) {
   // Objective-C instance variable access.
+  if (!IncludeObjC) {
+return false;
+  }
   ObjCInterfaceDecl *Class = nullptr;
   if (const ObjCObjectPointerType *ObjCPtr =
   BaseType->getAs())
@@ -5239,12 +5245,18 @@
 
   Results.EnterNewScope();
 
-  bool CompletionSucceded = DoCompletion(Base, IsArrow, None);
+  bool CompletionSucceded =
+  DoCompletion(Base, IsArrow, /*IncludeObjC=*/true, None);
+
+  // Fixits are only included for C++. We avoid this for Objective-C properties
+  // and ivars since most properties are backed by an ivar; otherwise we would
+  // recommend an ivar fixit when code-completing a property. Another possible
+  // solution would be to de-duplicate the ivar/property mixing.
   if (CodeCompleter->includeFixIts()) {
 const CharSourceRange OpRange =
 CharSourceRange::getTokenRange(OpLoc, OpLoc);
 CompletionSucceded |= DoCompletion(
-OtherOpBase, !IsArrow,
+OtherOpBase, !IsArrow, /*IncludeObjC=*/false,
 FixItHint::CreateReplacement(OpRange, IsArrow ? "." : "->"));
   }
 


Index: clang/test/CodeCompletion/objc-member-access.m
===
--- /dev/null
+++ clang/test/CodeCompletion/objc-member-access.m
@@ -0,0 +1,22 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface TypeWithPropertiesBackedByIvars {
+  int _bar;
+  int _foo;
+}
+@property(nonatomic) int foo;
+@property(nonatomic) int bar;
+@end
+
+int getFoo(id object) {
+  TypeWithPropertiesBackedByIvars *model = (TypeWithPropertiesBackedByIvars *)object;
+  int foo = model.;
+  return foo;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1-NOT: [#int#]_bar
+// CHECK-CC1-NOT: [#int#]_foo
+// CHECK-CC1: [#int#]bar
+// CHECK-CC1: [#int#]foo
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5150,7 +5150,7 @@
 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
 &ResultBuilder::IsMember);
 
-  auto DoCompletion = [&](Expr *Base, bool IsArrow,
+  auto DoCompletion = [&](Expr *Base, bool IsArrow, bool IncludeObjC,
   Optional AccessOpFixIt) -> bool {
 if (!Base)
   return false;
@@ -5196,6 +5196,9 @@
   }
 } else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
   // Objective-C property reference.
+  if (!IncludeObjC) {
+return false;
+  }
   AddedPropertiesSet AddedProperties;
 
  

[PATCH] D80743: (PR46111) Properly handle elaborated types in an implicit deduction guide

2020-06-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added a comment.

In D80743#2074537 , @rsmith wrote:

> In D80743#2074121 , @erichkeane 
> wrote:
>
> > @rsmith I think this implements what you've suggested?
>
>
> Yes, thanks.
>
> > This seems to 'work' for a small subset of works, but it doesn't properly 
> > register the typedef to the LocalInstantiationScope, so the normal template 
> > instantiation (like here 
> > https://github.com/llvm/llvm-project/blob/master/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp#L156)
> >  ends up hitting the 'findInstantiationOf' assert here: 
> > https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaTemplateInstantiate.cpp#L3564
>
> Hm. Yes, that'd be a problem. To fix that, we'll need to transform the 
> typedef declarations as part of transforming the deduction guide. 
> Roughly-speaking, we've transformed
>
>   template struct A {
> using U = X1;
> A(X2);
>   };
>
>
> into something like
>
>   template A(X2) -> A {
> using U = X1;
>   };
>
>
> ... and the problem is that we need to substitute into the new `using U =` 
> typedef before we form a use of `U` when producing the substituted type of 
> the alias declaration.
>
> There are a couple of ways we could approach this:
>
> 1. when we start transforming a deduction guide, we can walk its 
> `TypedefDecl` children, and instantiate those into new typedef declarations 
> immediately, so that later references to them work
> 2. when we reach the reference to the typedef declaration (in 
> `FindInstantiatedDecl`, when we see a declaration whose decl context is a 
> deduction guide), instantiate the declaration then
>
>   These are distinguishable by an example such as:
>
>   ``` template struct Type { using type = typename T::type; }; 
> struct B { using type = int; }; template struct A { using 
> type = Type::type; A(T, typename T::type, type); // #1 A(...); // #2 }; A 
> a(1, 2, 3); ```
>
>   For which option 1 would result in a hard error when substituting T=int 
> into the injected typedef for #1, but option 2 would accept, because 
> substitution stops at the 'typename T::type' without ever reaching the 
> typedef.
>
>   For that reason I think option 2 is the way to go. We already have some 
> logic for this in `FindInstantiatedDecl`; search there for `NeedInstantiate` 
> and try extending it from local classes and enums to also cover typedefs 
> whose decl context is a deduction guide. (You'll need a matching change in 
> `findInstantiationOf` to return `nullptr` in that case. This code doesn't 
> seem very well factored...)


Patch incoming!  option 2 ended up being pretty easy to implement (perhaps 
embarassingly so on my part after your explaination, I can't help but think I 
should have put that together), and it results in it passing all the tests.  
Thanks so much for your patience.




Comment at: clang/lib/Sema/SemaTemplate.cpp:1969-1970
+SemaRef.getASTContext(),
+SemaRef.getASTContext().getTranslationUnitDecl(), SourceLocation(),
+SourceLocation(), TL.getTypedefNameDecl()->getIdentifier(), TSI);
+MaterializedTypedefs.push_back(Decl);

rsmith wrote:
> I think it would be a good idea to retain the source location from the 
> original typedef (and to produce a `TypeAliasDecl` if that's what we started 
> with); if any diagnostics end up referring to this typedef, we will want them 
> to point to the one in the class template (and describe it as a "typedef 
> declaration" or "alias declaration" as appropriate).
Ah, right!  I had a TODO in my notebook for the source locations, but didn't 
think about TypeAliasDecl, though I should have.

Looks like it shouldbe easy enough, thanks!


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

https://reviews.llvm.org/D80743



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


[PATCH] D80743: (PR46111) Properly handle elaborated types in an implicit deduction guide

2020-06-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 268822.
erichkeane retitled this revision from "(PR46111) Desugar Elaborated types in 
Deduction Guides." to "(PR46111) Properly handle elaborated types in an 
implicit  deduction guide".
erichkeane edited the summary of this revision.

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

https://reviews.llvm.org/D80743

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/deduction-guides.cpp

Index: clang/test/AST/deduction-guides.cpp
===
--- /dev/null
+++ clang/test/AST/deduction-guides.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump -std=c++17 | FileCheck %s
+
+namespace PR46111 {
+template 
+struct S;
+
+template 
+struct HasDeductionGuide {
+  typedef PR46111::S STy;
+  HasDeductionGuide(typename STy::Child);
+};
+
+// This causes deduction guides to be generated for all constructors.
+HasDeductionGuide()->HasDeductionGuide;
+
+template 
+struct HasDeductionGuideTypeAlias {
+  using STy = PR46111::S;
+  HasDeductionGuideTypeAlias(typename STy::Child);
+};
+
+// This causes deduction guides to be generated for all constructors.
+HasDeductionGuideTypeAlias()->HasDeductionGuideTypeAlias;
+
+// The parameter to this one shouldn't be an elaborated type.
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (typename STy::Child) -> HasDeductionGuide'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (HasDeductionGuide) -> HasDeductionGuide'
+// CHECK: CXXDeductionGuideDecl {{.*}}  'auto () -> HasDeductionGuide'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (typename STy::Child) -> HasDeductionGuideTypeAlias'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (HasDeductionGuideTypeAlias) -> HasDeductionGuideTypeAlias'
+// CHECK: CXXDeductionGuideDecl {{.*}}  'auto () -> HasDeductionGuideTypeAlias'
+} // namespace PR46111
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5701,6 +5701,9 @@
 bool NeedInstantiate = false;
 if (CXXRecordDecl *RD = dyn_cast(D))
   NeedInstantiate = RD->isLocalClass();
+else if (isa(D) &&
+ isa(D->getDeclContext()))
+  NeedInstantiate = true;
 else
   NeedInstantiate = isa(D);
 if (NeedInstantiate) {
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3558,6 +3558,12 @@
   if (isa(D))
 return nullptr;
 
+  // Materialized typedefs/type alias for implicit deduction guides may require
+  // instantiation.
+  if (isa(D) &&
+  isa(D->getDeclContext()))
+return nullptr;
+
   // If we didn't find the decl, then we either have a sema bug, or we have a
   // forward reference to a label declaration.  Return null to indicate that
   // we have an uninstantiated label.
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1947,16 +1947,45 @@
 /// constructor to a deduction guide.
 class ExtractTypeForDeductionGuide
   : public TreeTransform {
+  llvm::SmallVectorImpl &MaterializedTypedefs;
+
 public:
   typedef TreeTransform Base;
-  ExtractTypeForDeductionGuide(Sema &SemaRef) : Base(SemaRef) {}
+  ExtractTypeForDeductionGuide(
+  Sema &SemaRef,
+  llvm::SmallVectorImpl &MaterializedTypedefs)
+  : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs) {}
 
   TypeSourceInfo *transform(TypeSourceInfo *TSI) { return TransformType(TSI); }
 
   QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) {
-return TransformType(
-TLB,
-TL.getTypedefNameDecl()->getTypeSourceInfo()->getTypeLoc());
+ASTContext &Context = SemaRef.getASTContext();
+TypedefNameDecl *OrigDecl = TL.getTypedefNameDecl();
+TypeLocBuilder InnerTLB;
+QualType Transformed =
+TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
+TypeSourceInfo *TSI = Context.getTrivialTypeSourceInfo(Transformed);
+
+TypedefNameDecl *Decl = nullptr;
+
+if (isa(OrigDecl))
+  Decl = TypeAliasDecl::Create(
+  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+else {
+  assert(isa(OrigDecl) && "Not a Type alias or typedef");
+  Decl = TypedefDecl::Create(
+  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+}
+
+MaterializedTypedefs.push_back(Decl);
+
+QualType TDT

[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-05 Thread Zinovy Nis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc063b4a72bb3: Fix crash on misc-redundant-expression 
(authored by zinovy.nis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80896

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
-}
+
+template 
+struct Bar2 {
+  static_assert((... && (sizeof(Values) > 0)) == (... && (sizeof(Values) > 
0)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: both sides of operator are 
equivalent [misc-redundant-expression]
+};
+} // namespace no_crash
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,8 +72,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
-   dyn_cast(*RightIter)))
+if (!areEquivalentExpr(dyn_cast_or_null(*LeftIter),
+   dyn_cast_or_null(*RightIter)))
   return false;
 ++LeftIter;
 ++RightIter;
@@ -117,6 +117,9 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass:
+return cast(Left)->getOperator() ==
+   cast(Right)->getOperator();
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
-}
+
+template 
+struct Bar2 {
+  static_assert((... && (sizeof(Values) > 0)) == (... && (sizeof(Values) > 0)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: both sides of operator are equivalent [misc-redundant-expression]
+};
+} // namespace no_crash
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,8 +72,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
-   dyn_cast(*RightIter)))
+if (!areEquivalentExpr(dyn_cast_or_null(*LeftIter),
+   dyn_cast_or_null(*RightIter)))
   return false;
 ++LeftIter;
 ++RightIter;
@@ -117,6 +117,9 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass:
+return cast(Left)->getOperator() ==
+   cast(Right)->getOperator();
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-05 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 268840.
Xiangling_L added a comment.

Replace `int` with an more self-explanatory enum;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

Index: clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc64-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+struct A {
+  double d1;
+  virtual void boo() {}
+};
+
+struct B {
+  double d2;
+  A a;
+};
+
+struct C : public A {
+  double d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::A
+// CHECK-NEXT:0 |   (A vtable pointer)
+// CHECK32-NEXT:  4 |   double d1
+// CHECK32-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 |   double d1
+// CHECK64-NEXT:| [sizeof=16, dsize=16, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::B
+// CHECK-NEXT:0 |   double d2
+// CHECK-NEXT:8 |   struct test1::A a
+// CHECK-NEXT:8 | (A vtable pointer)
+// CHECK32-NEXT: 12 | double d1
+// CHECK32-NEXT:| [sizeof=24, dsize=20, align=4, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=8]
+// CHECK64-NEXT: 16 | double d1
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::C
+// CHECK-NEXT:0 |   struct test1::A (primary base)
+// CHECK-NEXT:0 | (A vtable pointer)
+// CHECK32-NEXT:  4 | double d1
+// CHECK32-NEXT: 12 |   double d3
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 | double d1
+// CHECK64-NEXT: 16 |   double d3
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+}; // namespace test1
+
+namespace test2 {
+struct A {
+  long long l1;
+};
+
+struct B : public virtual A {
+  double d2;
+};
+
+#pragma pack(2)
+struct C : public virtual A {
+  double __attribute__((aligned(4))) d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::A
+// CHECK-NEXT:0 |   long long l1
+// CHECK-NEXT:  | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK-NEXT:  |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::B
+// CHECK-NEXT:0 |   (B vtable pointer)
+// CHECK32-NEXT:  4 |   double d2
+// CHECK64-NEXT:  8 |   double d2
+// CHECK-NEXT:   16 |   struct test2::A (virtual base)
+// CHECK-NEXT:   16 | long long l1
+// CHECK-NEXT:  | [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::C
+// CHECK-NEXT:0 |   (C vtable pointer)
+// CHECK32-NEXT:  4 |   double d3
+// CHECK32-NEXT: 12 |   struct test2::A (virtual base)
+// CHECK32-NEXT: 12 | long long l1
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=2, preferredalign=2,
+// CHECK32-NEXT:|  nvsize=12, nvalign=2, preferrednvalign=2

[PATCH] D81272: [Clang-Tidy] New check `misc-redundant-condition`

2020-06-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: aaron.ballman, gribozavr2.
baloghadamsoftware added a project: clang-tools-extra.
Herald added subscribers: martong, steakhal, gamesh411, Szelethus, dkrupp, 
rnkovacs, xazax.hun, whisperity, mgorny.
Herald added a project: clang.
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

This check was made upon user request. I think it is a good base that can later 
be extended also for the negated cases (where the code inside the inner `if` 
never executes). That case is even more suspicious. I put it into `misc` 
because it is not such a bug that it should go into `bugprone` but rather a 
suspicious thing. The type of the bug is somewhat similar to the bugs detected 
by `misc-redundant-expression` so I think `misc` is the best place also for 
this one.




Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:135
`cppcoreguidelines-avoid-goto `_,
+   `cppcoreguidelines-avoid-non-const-global-variables 
`_,
`cppcoreguidelines-init-variables 
`_, "Yes"

What are these changes? I surely did not make them? Maybe the check adder 
Python script?


Checking the same condition again in a nested if usually make no sense, except 
if the value of the expression could have been changed between the two checks. 
Although compilers may optimize this out, such code is suspicious: the 
programmer may have meant to check something else. Therefore it is worth to 
find such places in the code and notify the user about the problem.

This patch implements a basic check for this problem. Currently it only detects 
redundant conditions where the condition is a variable of integral type. It 
also detects the possible bug if the variable is in an "or" or "and" logical 
expression in the inner if and/or the variable is in an "and" logical 
expression in the outer if statement. Negated cases are not handled yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81272

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp
  clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.h
  clang-tools-extra/clang-tidy/utils/Aliasing.cpp
  clang-tools-extra/clang-tidy/utils/Aliasing.h
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-redundant-condition.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp
@@ -0,0 +1,1058 @@
+// RUN: %check_clang_tidy %s misc-redundant-condition %t
+
+extern unsigned peopleInTheBuilding;
+extern unsigned fireFighters;
+
+bool isBurning();
+bool isReallyBurning();
+bool isCollapsing();
+void tryToExtinguish(bool&);
+void scream();
+
+bool someOtherCondition();
+
+//===--- Basic Positives --===//
+
+void positive_direct() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: {{^\ *$}}
+  scream();
+}
+// CHECK-FIXES: {{^\ *$}}
+  }
+}
+
+void positive_indirect() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [misc-redundant-condition]
+// CHECK-FIXES: {{^\ *$}}
+scream();
+}
+  }
+}
+
+void positive_direct_inner_and_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire && peopleInTheBuilding > 0) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: if (peopleInTheBuilding > 0) {
+  scream();
+}
+  }
+}
+
+void positive_indirect_inner_and_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire && peopleInTheBuilding > 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [misc-redundant-condition]
+// CHECK-FIXES: if (peopleInTheBuilding > 0) {
+scream();
+  }
+}
+  }
+}
+
+void positive_direct_inner_and_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (peopleInTheBuilding > 0 && onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: if (peopleInTheBuilding > 0) {
+  scream();
+}
+  }
+}
+
+v

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-05 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

This looks like a continuation of the work started in D61643 
 (which makes the loc of `#pragma` available 
to pragma handlers) and D61509  (which changes 
the start loc for OpenMP pragmas from `omp` to `#pragma`).




Comment at: clang/lib/Parse/ParsePragma.cpp:2941
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());

When I remove this change, the new test still passes.  Please make sure this 
case is covered.



Comment at: clang/lib/Parse/ParseStmt.cpp:2167
+  SourceLocation StartLoc =
+  PP.getSourceManager().getExpansionLoc(Tok.getLocation());
+

I think the call to getExpansionLoc shouldn't be here.  If the ast dumper or 
other clients want to convert to that form, they can do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944



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


[PATCH] D81272: [Clang-Tidy] New check `misc-redundant-condition`

2020-06-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

This check was made upon user request. I think it is a good base that can later 
be extended also for the negated cases (where the code inside the inner `if` 
never executes). That case is even more suspicious. I put it into `misc` 
because it is not such a bug that it should go into `bugprone` but rather a 
suspicious thing. The type of the bug is somewhat similar to the bugs detected 
by `misc-redundant-expression` so I think `misc` is the best place also for 
this one.




Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:135
`cppcoreguidelines-avoid-goto `_,
+   `cppcoreguidelines-avoid-non-const-global-variables 
`_,
`cppcoreguidelines-init-variables 
`_, "Yes"

What are these changes? I surely did not make them? Maybe the check adder 
Python script?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81272



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


[PATCH] D81273: [WIP] Enable new pass manager as default DO NOT SUBMIT

2020-06-05 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: llvm-commits, cfe-commits, mgorny.
Herald added projects: clang, LLVM.

Just for bot testing

Depends on D81175 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81273

Files:
  clang/CMakeLists.txt
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/clang/test/BUILD.gn


Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -57,7 +57,7 @@
 # builds exist, to make sure it's a toolchain var.
 "CMAKE_CXX_COMPILER=c++",
 "ENABLE_BACKTRACES=1",
-"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=0",
+"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=1",
 "LLVM_HOST_TRIPLE=$llvm_current_triple",
 "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
 "LLVM_USE_SANITIZER=",
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -34,7 +34,7 @@
 "BACKEND_PACKAGE_STRING=LLVM ${llvm_version}git",
 "ENABLE_LINKER_BUILD_ID=",
 "ENABLE_X86_RELAX_RELOCATIONS=",
-"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=",
+"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=1",
 "CLANG_ENABLE_OBJC_REWRITER=1",  # FIXME: flag?
 "CLANG_SYSTEMZ_DEFAULT_ARCH=z10",
   ]
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -256,7 +256,7 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
-set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER TRUE CACHE BOOL
   "Enable the experimental new pass manager by default.")
 
 set(CLANG_SPAWN_CC1 OFF CACHE BOOL


Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -57,7 +57,7 @@
 # builds exist, to make sure it's a toolchain var.
 "CMAKE_CXX_COMPILER=c++",
 "ENABLE_BACKTRACES=1",
-"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=0",
+"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=1",
 "LLVM_HOST_TRIPLE=$llvm_current_triple",
 "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
 "LLVM_USE_SANITIZER=",
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -34,7 +34,7 @@
 "BACKEND_PACKAGE_STRING=LLVM ${llvm_version}git",
 "ENABLE_LINKER_BUILD_ID=",
 "ENABLE_X86_RELAX_RELOCATIONS=",
-"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=",
+"ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=1",
 "CLANG_ENABLE_OBJC_REWRITER=1",  # FIXME: flag?
 "CLANG_SYSTEMZ_DEFAULT_ARCH=z10",
   ]
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -256,7 +256,7 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
-set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER TRUE CACHE BOOL
   "Enable the experimental new pass manager by default.")
 
 set(CLANG_SPAWN_CC1 OFF CACHE BOOL
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74025: [clangd] Add the missing elaborated types in FindTarget.

2020-06-05 Thread Jeff Trull via Phabricator via cfe-commits
jaafar added a comment.

Thank you. I'm trying to balance stability with getting the fixes I need and so 
have been avoiding the "bleeding edge". I find that unfortunately the newest 
code tends to be "unstable", as those releases are rightfully named, and I need 
clangd for my daily work.

There are three commits, including this one, without which clangd cannot run 
for more than 10 or 20 seconds. They have all been in the codebase for several 
months now.  I would be happy to provide a list. Thanks again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74025



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


[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-05 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

How are you landing these changes, because the commit message isn't lining up 
with the PR name?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80896



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


[PATCH] D81176: [HIP] Add default header and include path

2020-06-05 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 3 inline comments as done.
Closed by commit rG11d06b9511bd: [HIP] Add default header and include path 
(authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D81176?vs=268515&id=268861#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81176

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/ROCm.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_math_forward_declares.h
  clang/lib/Headers/__clang_hip_libdevice_declares.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_finite_only_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_unsafe_math_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/opencl.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_daz_opt_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_finite_only_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_finite_only_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_1010.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_1011.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_1012.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_803.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_900.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_unsafe_math_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_unsafe_math_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/opencl.bc
  clang/test/Driver/Inputs/rocm/include/hip/hip_runtime.h
  clang/test/Driver/hip-device-libs.hip
  clang/test/Driver/hip-include-path.hip
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-detect.hip
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.cl

Index: clang/test/Driver/rocm-not-found.cl
===
--- clang/test/Driver/rocm-not-found.cl
+++ clang/test/Driver/rocm-not-found.cl
@@ -5,7 +5,7 @@
 
 // RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
 // RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
-// ERR: cannot find ROCm installation. Provid

[clang] e987c37 - Fix lit tests hip-include-path.hip and hip-host-cpu-macros.cu

2020-06-05 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-05T13:21:35-04:00
New Revision: e987c372185d805e3a30097366af2c6f94bc0b29

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

LOG: Fix lit tests hip-include-path.hip and hip-host-cpu-macros.cu

Added: 


Modified: 
clang/test/Driver/hip-include-path.hip
clang/test/Preprocessor/hip-host-cpu-macros.cu

Removed: 




diff  --git a/clang/test/Driver/hip-include-path.hip 
b/clang/test/Driver/hip-include-path.hip
index 9fa3125a5070..f4a312656d1c 100644
--- a/clang/test/Driver/hip-include-path.hip
+++ b/clang/test/Driver/hip-include-path.hip
@@ -22,7 +22,7 @@
 // COMMON: {{.*}}include/c++
 // COMMON: clang/{{.*}}/include
 
-// COMMON-LABEL: clang{{.*}} -cc1 -triple x86_64-unknown-linux-gnu
+// COMMON-LABEL: clang{{.*}} -cc1 -triple x86_64
 // WRAP: clang/{{.*}}/include/cuda_wrappers
 // NOWRAP-NOT: clang/{{.*}}/include/cuda_wrappers
 // HIP: {{.*}}Inputs/rocm/include

diff  --git a/clang/test/Preprocessor/hip-host-cpu-macros.cu 
b/clang/test/Preprocessor/hip-host-cpu-macros.cu
index efec439c3656..559541eecb0a 100644
--- a/clang/test/Preprocessor/hip-host-cpu-macros.cu
+++ b/clang/test/Preprocessor/hip-host-cpu-macros.cu
@@ -8,6 +8,6 @@ DEVICE __SSE3__
 HOST __SSE3__
 #endif
 
-// RUN: %clang -x hip -E -target x86_64-linux-gnu -msse3 
--cuda-gpu-arch=gfx803 -nogpulib -o - %s 2>&1 | FileCheck %s
+// RUN: %clang -x hip -E -target x86_64-linux-gnu -msse3 
--cuda-gpu-arch=gfx803 -nogpulib -nogpuinc -o - %s 2>&1 | FileCheck %s
 
 // CHECK-NOT: SSE3



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


[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-05 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In D80896#2076735 , @njames93 wrote:

> How are you landing these changes, because the commit message isn't lining up 
> with the PR name?


It was my fault: I hadn't changed a title in my local branch and pushed it with 
git.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80896



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


[PATCH] D81280: (Incomplete)Add support for id-expression

2020-06-05 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- TODO: Differ between NameQualifiers
- TODO: Box all operators
- Done: Treat NestedNameSpecifiers
- Done: [Try] Unbox all operators


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81280

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -485,7 +485,7 @@
 | | |-SimpleDeclarator
 | | | `-x
 | | `-:
-| |-UnknownExpression
+| |-IdExpression
 | | `-a
 | |-)
 | `-EmptyStatement
@@ -662,7 +662,7 @@
 |-{
 |-ExpressionStatement
 | |-UnknownExpression
-| | |-UnknownExpression
+| | |-IdExpression
 | | | `-test
 | | |-(
 | | `-)
@@ -675,7 +675,7 @@
 | |-)
 | |-ExpressionStatement
 | | |-UnknownExpression
-| | | |-UnknownExpression
+| | | |-IdExpression
 | | | | `-test
 | | | |-(
 | | | `-)
@@ -683,7 +683,7 @@
 | |-else
 | `-ExpressionStatement
 |   |-UnknownExpression
-|   | |-UnknownExpression
+|   | |-IdExpression
 |   | | `-test
 |   | |-(
 |   | `-)
@@ -724,12 +724,10 @@
 |-ExpressionStatement
 | |-BinaryOperatorExpression
 | | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-a
+| | | `-a
 | | |-=
 | | `-IdExpression
-| |   `-UnqualifiedId
-| | `-b
+| |   `-b
 | `-;
 `-}
 )txt"));
@@ -800,38 +798,22 @@
   |   `-)
   `-CompoundStatement
 |-{
-|-DeclarationStatement
-| |-SimpleDeclaration
-| | |-a
-| | |-::
-| | |-b
-| | |-::
-| | |-S
-| | `-SimpleDeclarator
-| |   `-UnknownExpression
-| | `-s
-| `-;
 |-ExpressionStatement
 | |-UnknownExpression
 | | |-IdExpression
 | | | |-NestedNameSpecifier
 | | | | |-NameQualifier
-| | | | | |-GlobalNamespace
-| | | | | `::
+| | | | | `-::
 | | | | |-NameQualifier
-| | | | | |-NamespaceName
-| | | | | | `-a
+| | | | | |-a
 | | | | | `-::
 | | | | |-NameQualifier
-| | | | | |-NamespaceName
-| | | | | | `-b
+| | | | | |-b
 | | | | | `-::
 | | | | `-NameQualifier
-| | | |   |-TypeName
-| | | |   | `-S
+| | | |   |-S
 | | | |   `-::
-| | | `-UnqualifiedId
-| | |   `-f
+| | | `-f
 | | |-(
 | | `-)
 | `-;
@@ -1036,13 +1018,13 @@
 |-{
 |-ExpressionStatement
 | |-PostfixUnaryOperatorExpression
-| | |-UnknownExpression
+| | |-IdExpression
 | | | `-a
 | | `-++
 | `-;
 |-ExpressionStatement
 | |-PostfixUnaryOperatorExpression
-| | |-UnknownExpression
+| | |-IdExpression
 | | | `-a
 | | `---
 | `-;
@@ -1088,61 +1070,61 @@
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |---
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-++
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-~
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |--
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-+
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-&
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-*
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-ap
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-!
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-__real
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-__imag
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 `-}
@@ -1183,13 +1165,13 @@
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-compl
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-a
 | `-;
 |-ExpressionStatement
 | |-PrefixUnaryOperatorExpression
 | | |-not
-| | `-UnknownExpression
+| | `-IdExpression
 | |   `-b
   

[PATCH] D81282: [builtins] Move more float128-related helpers to GENERIC_TF_SOURCES list

2020-06-05 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: howard.hinnant, samsonov.
Herald added subscribers: Sanitizers, mgorny.
Herald added a project: Sanitizers.

There are two different _generic_ lists of source files in the 
compiler-rt/lib/builtins/CMakeLists.txt. Now there is no simple way to not use 
the tf-variants of helpers at all.

Since there exists a separate `GENERIC_TF_SOURCES` list, it seems quite natural 
to move all float128-related helpers there. If it is not possible for some 
reason, it would be useful to have an explanation of that reason somewhere near 
the `GENERIC_TF_SOURCES` definition.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81282

Files:
  compiler-rt/lib/builtins/CMakeLists.txt


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -46,7 +46,6 @@
   absvti2.c
   adddf3.c
   addsf3.c
-  addtf3.c
   addvdi3.c
   addvsi3.c
   addvti3.c
@@ -75,9 +74,7 @@
   divsc3.c
   divsf3.c
   divsi3.c
-  divtc3.c
   divti3.c
-  divtf3.c
   extendsfdf2.c
   extendhfsf2.c
   ffsdi2.c
@@ -123,7 +120,6 @@
   mulsc3.c
   mulsf3.c
   multi3.c
-  multf3.c
   mulvdi3.c
   mulvsi3.c
   mulvti3.c
@@ -149,7 +145,6 @@
   subvdi3.c
   subvsi3.c
   subvti3.c
-  subtf3.c
   trampoline_setup.c
   truncdfhf2.c
   truncdfsf2.c
@@ -168,7 +163,10 @@
 )
 
 set(GENERIC_TF_SOURCES
+  addtf3.c
   comparetf2.c
+  divtc3.c
+  divtf3.c
   extenddftf2.c
   extendsftf2.c
   fixtfdi.c
@@ -184,6 +182,8 @@
   floatunsitf.c
   floatuntitf.c
   multc3.c
+  multf3.c
+  subtf3.c
   trunctfdf2.c
   trunctfsf2.c
 )


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -46,7 +46,6 @@
   absvti2.c
   adddf3.c
   addsf3.c
-  addtf3.c
   addvdi3.c
   addvsi3.c
   addvti3.c
@@ -75,9 +74,7 @@
   divsc3.c
   divsf3.c
   divsi3.c
-  divtc3.c
   divti3.c
-  divtf3.c
   extendsfdf2.c
   extendhfsf2.c
   ffsdi2.c
@@ -123,7 +120,6 @@
   mulsc3.c
   mulsf3.c
   multi3.c
-  multf3.c
   mulvdi3.c
   mulvsi3.c
   mulvti3.c
@@ -149,7 +145,6 @@
   subvdi3.c
   subvsi3.c
   subvti3.c
-  subtf3.c
   trampoline_setup.c
   truncdfhf2.c
   truncdfsf2.c
@@ -168,7 +163,10 @@
 )
 
 set(GENERIC_TF_SOURCES
+  addtf3.c
   comparetf2.c
+  divtc3.c
+  divtf3.c
   extenddftf2.c
   extendsftf2.c
   fixtfdi.c
@@ -184,6 +182,8 @@
   floatunsitf.c
   floatuntitf.c
   multc3.c
+  multf3.c
+  subtf3.c
   trunctfdf2.c
   trunctfsf2.c
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80805: [KernelAddressSanitizer] Make globals constructors compatible with kernel

2020-06-05 Thread Alexander Potapenko via Phabricator via cfe-commits
glider accepted this revision.
glider 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/D80805/new/

https://reviews.llvm.org/D80805



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-05 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 268869.
dang marked an inline comment as done.
dang added a comment.

Updating the patch with the correct merge base


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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -9,6 +9,7 @@
 #include "OptEmitter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
@@ -33,6 +34,20 @@
   return OS;
 }
 
+static void emitMarshallingInfoFlag(raw_ostream &OS, const Record *R) {
+  OS << R->getValueAsBit("IsPositive");
+  OS << ",";
+  OS << R->getValueAsString("DefaultValue");
+}
+
+static void emitMarshallingInfoString(raw_ostream &OS, const Record *R) {
+  OS << R->getValueAsString("DefaultValue");
+  OS << ", ";
+  OS << R->getValueAsString("Normalizer");
+  OS << ", ";
+  OS << R->getValueAsString("Denormalizer");
+}
+
 /// OptParserEmitter - This tablegen backend takes an input .td file
 /// describing a list of options and emits a data structure for parsing and
 /// working with those options when given an input command line.
@@ -135,12 +150,8 @@
 
   OS << "//\n";
   OS << "// Options\n\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record &R = *Opts[i];
-
-// Start a single option entry.
-OS << "OPTION(";
 
+  auto WriteOptRecordFields = [&](raw_ostream &OS, const Record &R) {
 // The option prefix;
 std::vector prf = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(prf.begin(), prf.end())] << ", ";
@@ -223,11 +234,48 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+  };
+
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record &R = *Opts[i];
 
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
 
+  OS << "#ifdef OPTION_WITH_MARSHALLING\n";
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record &R = *Opts[I];
+
+if (!isa(R.getValueInit("MarshallingInfo"))) {
+  Record *MarshallingInfoRecord =
+  cast(R.getValueInit("MarshallingInfo"))->getDef();
+  StringRef KindStr = MarshallingInfoRecord->getValueAsString("Kind");
+  auto KindInfoPair =
+  StringSwitch>>(
+  KindStr)
+  .Case("flag", std::make_pair("OPTION_WITH_MARSHALLING_FLAG",
+   &emitMarshallingInfoFlag))
+  .Case("string", std::make_pair("OPTION_WITH_MARSHALLING_STRING",
+ &emitMarshallingInfoString))
+  .Default(std::make_pair("", nullptr));
+  OS << KindInfoPair.first << "(";
+  WriteOptRecordFields(OS, R);
+  OS << ", ";
+  OS << MarshallingInfoRecord->getValueAsBit("ShouldAlwaysEmit");
+  OS << ", ";
+  OS << MarshallingInfoRecord->getValueAsString("KeyPath");
+  OS << ", ";
+  KindInfoPair.second(OS, MarshallingInfoRecord);
+  OS << ")\n";
+}
+  }
+  OS << "#endif // OPTION_WITH_MARSHALLING\n";
+
   OS << "\n";
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -80,6 +80,18 @@
   list Flags = [];
 }
 
+// Add support for generating marshalling code
+class OptionMarshallingInfo {
+  string Kind = kind;
+  bit ShouldAlwaysEmit = 0;
+  code KeyPath = keypath;
+  // Used by the Flag option kind.
+  bit IsPositive = ?;
+  code DefaultValue = ?;
+  code Normalizer = ?;
+  code Denormalizer = ?;
+}
+
 // Define the option class.
 
 class Option prefixes, string name, OptionKind kind> {
@@ -97,6 +109,7 @@
   OptionGroup Group = ?;
   Option Alias = ?;
   list AliasArgs = [];
+  OptionMarshallingInfo MarshallingInfo = ?;
 }
 
 // Helpers for defining options.
@@ -130,6 +143,26 @@
 class Values { string Values = value; }
 class ValuesCode { code ValuesCode = valuecode; }
 
+class MarshallingInfo { OptionMarshallingInfo MarshallingInfo = info; }
+class MarshallingFlag
+  : OptionMarshallingInfo<"flag", keypath> {
+  bit IsPositive = ispositive;
+  code DefaultValue = defaultvalue;
+}
+class MarshallingFlagAlwaysEmit
+  : MarshallingFlag {
+  

[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-05 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 268872.
dang added a comment.

This is the good diff


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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -9,6 +9,7 @@
 #include "OptEmitter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
@@ -33,6 +34,20 @@
   return OS;
 }
 
+static void emitMarshallingInfoFlag(raw_ostream &OS, const Record *R) {
+  OS << R->getValueAsBit("IsPositive");
+  OS << ",";
+  OS << R->getValueAsString("DefaultValue");
+}
+
+static void emitMarshallingInfoString(raw_ostream &OS, const Record *R) {
+  OS << R->getValueAsString("DefaultValue");
+  OS << ", ";
+  OS << R->getValueAsString("Normalizer");
+  OS << ", ";
+  OS << R->getValueAsString("Denormalizer");
+}
+
 /// OptParserEmitter - This tablegen backend takes an input .td file
 /// describing a list of options and emits a data structure for parsing and
 /// working with those options when given an input command line.
@@ -135,12 +150,8 @@
 
   OS << "//\n";
   OS << "// Options\n\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record &R = *Opts[i];
-
-// Start a single option entry.
-OS << "OPTION(";
 
+  auto WriteOptRecordFields = [&](raw_ostream &OS, const Record &R) {
 // The option prefix;
 std::vector prf = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(prf.begin(), prf.end())] << ", ";
@@ -223,11 +234,48 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+  };
+
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record &R = *Opts[i];
 
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
 
+  OS << "#ifdef OPTION_WITH_MARSHALLING\n";
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record &R = *Opts[I];
+
+if (!isa(R.getValueInit("MarshallingInfo"))) {
+  Record *MarshallingInfoRecord =
+  cast(R.getValueInit("MarshallingInfo"))->getDef();
+  StringRef KindStr = MarshallingInfoRecord->getValueAsString("Kind");
+  auto KindInfoPair =
+  StringSwitch>>(
+  KindStr)
+  .Case("flag", std::make_pair("OPTION_WITH_MARSHALLING_FLAG",
+   &emitMarshallingInfoFlag))
+  .Case("string", std::make_pair("OPTION_WITH_MARSHALLING_STRING",
+ &emitMarshallingInfoString))
+  .Default(std::make_pair("", nullptr));
+  OS << KindInfoPair.first << "(";
+  WriteOptRecordFields(OS, R);
+  OS << ", ";
+  OS << MarshallingInfoRecord->getValueAsBit("ShouldAlwaysEmit");
+  OS << ", ";
+  OS << MarshallingInfoRecord->getValueAsString("KeyPath");
+  OS << ", ";
+  KindInfoPair.second(OS, MarshallingInfoRecord);
+  OS << ")\n";
+}
+  }
+  OS << "#endif // OPTION_WITH_MARSHALLING\n";
+
   OS << "\n";
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -80,6 +80,18 @@
   list Flags = [];
 }
 
+// Add support for generating marshalling code
+class OptionMarshallingInfo {
+  string Kind = kind;
+  bit ShouldAlwaysEmit = 0;
+  code KeyPath = keypath;
+  // Used by the Flag option kind.
+  bit IsPositive = ?;
+  code DefaultValue = ?;
+  code Normalizer = ?;
+  code Denormalizer = ?;
+}
+
 // Define the option class.
 
 class Option prefixes, string name, OptionKind kind> {
@@ -97,6 +109,7 @@
   OptionGroup Group = ?;
   Option Alias = ?;
   list AliasArgs = [];
+  OptionMarshallingInfo MarshallingInfo = ?;
 }
 
 // Helpers for defining options.
@@ -130,6 +143,26 @@
 class Values { string Values = value; }
 class ValuesCode { code ValuesCode = valuecode; }
 
+class MarshallingInfo { OptionMarshallingInfo MarshallingInfo = info; }
+class MarshallingFlag
+  : OptionMarshallingInfo<"flag", keypath> {
+  bit IsPositive = ispositive;
+  code DefaultValue = defaultvalue;
+}
+class MarshallingFlagAlwaysEmit
+  : MarshallingFlag {
+  let ShouldAlwaysEmit = 1;
+}
+class MarshallingString
+  : Optio

[clang] 5eedf07 - [apple clang] disable in-process CC1 to preserve crashlog compatibility

2020-06-05 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2020-06-05T10:55:42-07:00
New Revision: 5eedf07ab999d0a8ba43f41e0c1012d8f6e62c11

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

LOG: [apple clang] disable in-process CC1 to preserve crashlog compatibility

The in-process CC1 currently doesn't interoperate with the macOS crash 
analytics,
which we would like to keep enabled for Apple clang. This commit restores the
out-of-process CC1 to the Apple clang CMake configuration for now.

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

Added: 
clang/test/Driver/apple-clang-defaults.c

Modified: 
clang/cmake/caches/Apple-stage1.cmake
clang/cmake/caches/Apple-stage2.cmake
clang/test/lit.cfg.py
clang/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/cmake/caches/Apple-stage1.cmake 
b/clang/cmake/caches/Apple-stage1.cmake
index 4b11342086a5..8a4fe6dfdfdf 100644
--- a/clang/cmake/caches/Apple-stage1.cmake
+++ b/clang/cmake/caches/Apple-stage1.cmake
@@ -20,6 +20,7 @@ set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(CLANG_BOOTSTRAP_PASSTHROUGH
   CMAKE_OSX_ARCHITECTURES
   CACHE STRING "")

diff  --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index eb4827002011..b24ec558c071 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -16,6 +16,7 @@ set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")
 
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "Build Compiler-RT with 
just-built clang")

diff  --git a/clang/test/Driver/apple-clang-defaults.c 
b/clang/test/Driver/apple-clang-defaults.c
new file mode 100644
index ..5673e32855a5
--- /dev/null
+++ b/clang/test/Driver/apple-clang-defaults.c
@@ -0,0 +1,7 @@
+// RUN: %clang -c %s -### 2>&1 | FileCheck %s --check-prefix=APPLE-CLANG
+// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=EXPLICIT-IN-PROCESS
+
+// REQUIRES: clang-vendor=com.apple.clang
+
+// APPLE-CLANG-NOT: (in-process)
+// EXPLICIT-IN-PROCESS: (in-process)

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 0358a9d8a959..413f81175420 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -198,3 +198,7 @@ def calculate_arch_features(arch_string):
 
 if config.enable_shared:
 config.available_features.add("enable_shared")
+
+# Add a vendor-specific feature.
+if config.clang_vendor_uti:
+config.available_features.add('clang-vendor=' + config.clang_vendor_uti)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 4527ccadbb4a..d9b5b2f2592e 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -30,6 +30,7 @@ config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', 
"@USE_Z3_SOLVER@")
 config.has_plugins = @LLVM_ENABLE_PLUGINS@
+config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-05 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D80833#2073458 , @hans wrote:

> a. The compiler path is only absolute because it was absolute when put into 
> argv[0] right? I don't see anything in the code that makes it absolute? I 
> imagine most build systems will invoke the compiler using an absolute path so 
> you'll get the desired result.


Understood, I wasn't using `-no-canonical-prefixes` that's why I was seeing 
full paths for argv[0].




Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:1
+// RUN: %clang_cl /c /Z7 %s /Fo%t.obj
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s

hans wrote:
> The %s arg needs to come after "--", otherwise it can be interpreted as a 
> command line flag, e.g. on Mac files are often under /Users which will be 
> interpreted as a /U flag (see other tests using %clang_cl for examples).
Fixed, Reid already mentionned that a while ago, I'll remember next time!



Comment at: clang/tools/driver/cc1_main.cpp:184
 
-int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr) {
   ensureSufficientStack();

hans wrote:
> Maybe I'm missing something, but why is this changing? The current code with 
> Argv0 and the rest of the args as separate parameters seems like it would fit 
> in will with the rest of the patch?
Reverted.



Comment at: lld/COFF/PDB.cpp:1041
+  // Remap the contents of the LF_BUILDINFO record.
+  remapBuildInfo(tMerger.getIDTable());
+

hans wrote:
> Naive question because I'm not familiar with the PDB writing, but would it be 
> possible to remap the LF_BUILDINFO entries earlier, e.g. when they're read in 
> from the object files? It seems like a lot of code is now added to do the 
> remapping "after the fact".
The whole type merging machinery isn't designed for changing records 
on-the-fly. We only modify TypeIndex values inside the record, but for that we 
have hardcoded offsets (all the `discoverTypeIndices` functions in 
https://github.com/llvm/llvm-project/blob/cda7ff9ddcefe0051d173e7c126c679063d29fbb/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp).
 The rest of the record is emitted as-it-is in the output TPI or IPI streams.

It's certainly feaseable to modify records in `TypeStreamMerger` in the same 
way we examine the `LF_ENDPRECOMP` record. However that requires a lot more 
piping, and I figured it wasn't worth it (unless we have other record types to 
modify in the future).



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:840
+  erase_if(Vec, [&](StringRef Arg) {
+return Arg.data() == nullptr || Arg == MainFilename;
+  });

hans wrote:
> Does Arg.data() == nullptr really happen here?
Yes if passing `clang -cc1` directly. Both the `CC1Command` and `InitLLVM` are 
pushing a `nullptr` terminator as the last arg :-( This seems quite widespead 
behavior across the codebase.



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:846
+#else
+  std::string FlatCmdLine = llvm::join(Vec, " ");
+#endif

hans wrote:
> I suppose this won't work with filenames that contain spaces.
> 
> I was hoping we could do whatever "clang -v" does when it prints arguments. 
> It seems to do some basic quoting and escaping. Does it have some function we 
> could call from here?
The code for printing "clang -v" is/was entirely in Clang: 
https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/Job.cpp#L103

I've moved `Command::printArg` to `llvm::sys::printArg` and using that now.
This creates a slight difference from MSVC, in the sense that with Clang all 
arguments are quoted, no matter what. Whereas MSVC adds quotes when it's 
necessary (that's LLVM's `sys::flattenWindowsCommandLine` behavior). But I 
think that shouldn't matter much.

Please @stefan_reinalter @lantictac let me know if you think otherwise.

```
D:\llvm-project> buildninjaRel\bin\clang-cl /c b.cpp /Z7 
-fdebug-compilation-dir . -no-canonical-prefixes
D:\llvm-project> buildninjaRel\bin\llvm-pdbutil.exe dump -all b.obj | grep 
LF_BUILDINFO -A 5
0x1007 | LF_BUILDINFO [size = 28]
 0x1003: `.`
 0x1005: `buildninjaRel\bin\clang-cl.exe`
 0x1004: `b.cpp`
 : ``
 0x1006: `"-cc1" "-triple" "x86_64-pc-windows-msvc19.26.28806" 
"-emit-obj" "-mrelax-all" "-mincremental-linker-compatible" "-disable-free" 
"-main-file-name" "b.cpp" "-mrelocation-model" "pic" "-pic-level" "2" 
"-mthread-model" "posix" "-mframe-pointer=none" "-relaxed-aliasing" 
"-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" 
"-target-cpu" "x86-64" "-mllvm" "-x86-asm-syntax=intel" "-D_MT" 
"-flto-visibility-public-std" "--dependent-lib=libcmt" 
"--dependent-lib=oldnames" "-stack-protector" "2" "-fms-volatile" 
"-fdiagnostics-format" "msvc" "-gcodeview" "-debug-info-kind=limited" 
"-resource-dir" "buildninjaRel\\lib\\clang\\11.0.0" "-internal-isyst

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-05 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 268881.
aganea marked 11 inline comments as done.
aganea added a comment.

Addressed comments (see inline). Ensured the generated .OBJ contains relative 
paths when passing `-fdebug-compilation-dir . -no-canonical-prefixes`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Job.h
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Job.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  clang/tools/driver/cc1_main.cpp
  clang/tools/driver/driver.cpp
  lld/COFF/PDB.cpp
  lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
  lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
  lld/test/COFF/pdb-relative-source-lines.test
  llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/Support/Program.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
  llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
  llvm/lib/Support/Program.cpp

Index: llvm/lib/Support/Program.cpp
===
--- llvm/lib/Support/Program.cpp
+++ llvm/lib/Support/Program.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Program.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 using namespace llvm;
 using namespace sys;
@@ -73,6 +74,24 @@
   return commandLineFitsWithinSystemLimits(Program, StringRefArgs);
 }
 
+void sys::printArg(raw_ostream &OS, StringRef Arg, bool Quote) {
+  const bool Escape = Arg.find_first_of(" \"\\$") != StringRef::npos;
+
+  if (!Quote && !Escape) {
+OS << Arg;
+return;
+  }
+
+  // Quote and escape. This isn't really complete, but good enough.
+  OS << '"';
+  for (const auto c : Arg) {
+if (c == '"' || c == '\\' || c == '$')
+  OS << '\\';
+OS << c;
+  }
+  OS << '"';
+}
+
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/Program.inc"
Index: llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
===
--- llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
+++ llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
@@ -58,3 +58,8 @@
 uint32_t TypeTableCollection::size() { return Records.size(); }
 
 uint32_t TypeTableCollection::capacity() { return Records.size(); }
+
+bool TypeTableCollection::replaceType(TypeIndex &Index, CVType Data,
+  bool Stabilize) {
+  llvm_unreachable("Method cannot be called");
+}
Index: llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
===
--- llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
+++ llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
@@ -123,3 +123,30 @@
 TI = insertRecordBytes(C.RecordData);
   return TI;
 }
+
+bool MergingTypeTableBuilder::replaceType(TypeIndex &Index, CVType Data,
+  bool Stabilize) {
+  assert(Index.toArrayIndex() < SeenRecords.size() &&
+ "This function cannot be used to insert records!");
+
+  ArrayRef Record = Data.data();
+  assert(Record.size() < UINT32_MAX && "Record too big");
+  assert(Record.size() % 4 == 0 &&
+ "The type record size is not a multiple of 4 bytes which will cause "
+ "misalignment in the output TPI stream!");
+
+  LocallyHashedType WeakHash{hash_value(Record), Record};
+  auto Result = HashedRecords.try_emplace(WeakHash, Index.toArrayIndex());
+  if (!Result.second) {
+Index = Result.first->second;
+return false; // The record is already there, at a different location
+  }
+
+  if (Stabilize) {
+Record = stabilize(RecordStorage, Record);
+Result.first->first.RecordData = Record;
+  }
+
+  SeenRecords[Index.toArrayIndex()] = Record;
+  return true;
+}
Index: llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
===
--- llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
+++ llvm/lib/DebugInfo/CodeView/LazyR

[PATCH] D81285: [builtins] Change si_int to int in some helper declarations

2020-06-05 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added a reviewer: howard.hinnant.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

This patch changes types of some integer function arguments or return values 
from `si_int` to the default `int` type (`typedef`ed to `native_int` to make it 
obvious this is intentional) to make it more compatible with `libgcc`.

The compiler-rt/lib/builtins/README.txt has a link to the libgcc specification 
. This specification 
has an explicit note on `int`, `float` and other such types being just 
illustrations in some cases while the actual types are expressed with machine 
modes.

Such usage of always-32-bit-wide integer type may lead to issues on 16-bit 
platforms such as MSP430. Provided libgcc2.h 
 
can be used as a reference for all targets supported by the libgcc, this patch 
fixes some existing differences in helper declarations.

This patch is expected to not change behavior at all for targets with 32-bit 
`int` type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81285

Files:
  compiler-rt/lib/builtins/README.txt
  compiler-rt/lib/builtins/clzdi2.c
  compiler-rt/lib/builtins/clzsi2.c
  compiler-rt/lib/builtins/clzti2.c
  compiler-rt/lib/builtins/ctzdi2.c
  compiler-rt/lib/builtins/ctzsi2.c
  compiler-rt/lib/builtins/ctzti2.c
  compiler-rt/lib/builtins/ffsdi2.c
  compiler-rt/lib/builtins/ffssi2.c
  compiler-rt/lib/builtins/ffsti2.c
  compiler-rt/lib/builtins/int_lib.h
  compiler-rt/lib/builtins/int_types.h
  compiler-rt/lib/builtins/paritydi2.c
  compiler-rt/lib/builtins/paritysi2.c
  compiler-rt/lib/builtins/parityti2.c
  compiler-rt/lib/builtins/popcountdi2.c
  compiler-rt/lib/builtins/popcountsi2.c
  compiler-rt/lib/builtins/popcountti2.c
  compiler-rt/lib/builtins/powidf2.c
  compiler-rt/lib/builtins/powisf2.c
  compiler-rt/lib/builtins/powitf2.c
  compiler-rt/lib/builtins/powixf2.c
  compiler-rt/test/builtins/Unit/clzdi2_test.c
  compiler-rt/test/builtins/Unit/clzsi2_test.c
  compiler-rt/test/builtins/Unit/clzti2_test.c
  compiler-rt/test/builtins/Unit/ctzdi2_test.c
  compiler-rt/test/builtins/Unit/ctzsi2_test.c
  compiler-rt/test/builtins/Unit/ctzti2_test.c
  compiler-rt/test/builtins/Unit/ffsdi2_test.c
  compiler-rt/test/builtins/Unit/ffssi2_test.c
  compiler-rt/test/builtins/Unit/ffsti2_test.c
  compiler-rt/test/builtins/Unit/paritydi2_test.c
  compiler-rt/test/builtins/Unit/paritysi2_test.c
  compiler-rt/test/builtins/Unit/parityti2_test.c
  compiler-rt/test/builtins/Unit/popcountdi2_test.c
  compiler-rt/test/builtins/Unit/popcountsi2_test.c
  compiler-rt/test/builtins/Unit/popcountti2_test.c
  compiler-rt/test/builtins/Unit/powidf2_test.c
  compiler-rt/test/builtins/Unit/powisf2_test.c
  compiler-rt/test/builtins/Unit/powitf2_test.c
  compiler-rt/test/builtins/Unit/powixf2_test.c

Index: compiler-rt/test/builtins/Unit/powixf2_test.c
===
--- compiler-rt/test/builtins/Unit/powixf2_test.c
+++ compiler-rt/test/builtins/Unit/powixf2_test.c
@@ -22,9 +22,9 @@
 
 // Returns: a ^ b
 
-COMPILER_RT_ABI long double __powixf2(long double a, si_int b);
+COMPILER_RT_ABI long double __powixf2(long double a, native_int b);
 
-int test__powixf2(long double a, si_int b, long double expected)
+int test__powixf2(long double a, native_int b, long double expected)
 {
 long double x = __powixf2(a, b);
 int correct = (x == expected) && (signbit(x) == signbit(expected));
@@ -69,9 +69,9 @@
 return 1;
 if (test__powixf2(0, 4, 0))
 return 1;
-if (test__powixf2(0, 0x7FFE, 0))
+if (test__powixf2(0, INT_MAX - 1, 0))
 return 1;
-if (test__powixf2(0, 0x7FFF, 0))
+if (test__powixf2(0, INT_MAX, 0))
 return 1;
 
 if (test__powixf2(-0., 1, -0.))
@@ -82,9 +82,9 @@
 return 1;
 if (test__powixf2(-0., 4, 0))
 return 1;
-if (test__powixf2(-0., 0x7FFE, 0))
+if (test__powixf2(-0., INT_MAX - 1, 0))
 return 1;
-if (test__powixf2(-0., 0x7FFF, -0.))
+if (test__powixf2(-0., INT_MAX, -0.))
 return 1;
 
 if (test__powixf2(1, 1, 1))
@@ -95,9 +95,9 @@
 return 1;
 if (test__powixf2(1, 4, 1))
 return 1;
-if (test__powixf2(1, 0x7FFE, 1))
+if (test__powixf2(1, INT_MAX - 1, 1))
 return 1;
-if (test__powixf2(1, 0x7FFF, 1))
+if (test__powixf2(1, INT_MAX, 1))
 return 1;
 
 if (test__powixf2(INFINITY, 1, INFINITY))
@@ -108,9 +108,9 @@
 return 1;
 if (test__powixf2(INFINITY, 4, INFINITY))
 return 1;
-if (test__powixf2(INFINITY, 0x7FFE, INFINITY))
+if (test__powixf2(INFINITY, INT_MAX - 1, INFINITY))
 return 1;
-if (test__powixf2(INFINITY, 0x7FFF, INFINITY))
+if (test__powixf2(INFINITY, INT_MAX, INFINITY))
 return 1;
 
 i

[PATCH] D80849: [apple clang] disable in-process CC1 to preserve crashlog compatibility

2020-06-05 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5eedf07ab999: [apple clang] disable in-process CC1 to 
preserve crashlog compatibility (authored by arphaman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80849

Files:
  clang/cmake/caches/Apple-stage1.cmake
  clang/cmake/caches/Apple-stage2.cmake
  clang/test/Driver/apple-clang-defaults.c
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in


Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -30,6 +30,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', 
"@USE_Z3_SOLVER@")
 config.has_plugins = @LLVM_ENABLE_PLUGINS@
+config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -198,3 +198,7 @@
 
 if config.enable_shared:
 config.available_features.add("enable_shared")
+
+# Add a vendor-specific feature.
+if config.clang_vendor_uti:
+config.available_features.add('clang-vendor=' + config.clang_vendor_uti)
Index: clang/test/Driver/apple-clang-defaults.c
===
--- /dev/null
+++ clang/test/Driver/apple-clang-defaults.c
@@ -0,0 +1,7 @@
+// RUN: %clang -c %s -### 2>&1 | FileCheck %s --check-prefix=APPLE-CLANG
+// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=EXPLICIT-IN-PROCESS
+
+// REQUIRES: clang-vendor=com.apple.clang
+
+// APPLE-CLANG-NOT: (in-process)
+// EXPLICIT-IN-PROCESS: (in-process)
Index: clang/cmake/caches/Apple-stage2.cmake
===
--- clang/cmake/caches/Apple-stage2.cmake
+++ clang/cmake/caches/Apple-stage2.cmake
@@ -16,6 +16,7 @@
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")
 
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "Build Compiler-RT with 
just-built clang")
Index: clang/cmake/caches/Apple-stage1.cmake
===
--- clang/cmake/caches/Apple-stage1.cmake
+++ clang/cmake/caches/Apple-stage1.cmake
@@ -20,6 +20,7 @@
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(CLANG_BOOTSTRAP_PASSTHROUGH
   CMAKE_OSX_ARCHITECTURES
   CACHE STRING "")


Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -30,6 +30,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
 config.has_plugins = @LLVM_ENABLE_PLUGINS@
+config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -198,3 +198,7 @@
 
 if config.enable_shared:
 config.available_features.add("enable_shared")
+
+# Add a vendor-specific feature.
+if config.clang_vendor_uti:
+config.available_features.add('clang-vendor=' + config.clang_vendor_uti)
Index: clang/test/Driver/apple-clang-defaults.c
===
--- /dev/null
+++ clang/test/Driver/apple-clang-defaults.c
@@ -0,0 +1,7 @@
+// RUN: %clang -c %s -### 2>&1 | FileCheck %s --check-prefix=APPLE-CLANG
+// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s --check-prefix=EXPLICIT-IN-PROCESS
+
+// REQUIRES: clang-vendor=com.apple.clang
+
+// APPLE-CLANG-NOT: (in-process)
+// EXPLICIT-IN-PROCESS: (in-process)
Index: clang/cmake/caches/Apple-stage2.cmake
===
--- clang/cmake/caches/Apple-stage2.cmake
+++ clang/cmake/caches/Apple-stage2.cmake
@@ -16,6 +16,7 @@
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")
 
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "Build Compiler-RT 

[clang] 866ee23 - [KernelAddressSanitizer] Make globals constructors compatible with kernel

2020-06-05 Thread Marco Elver via cfe-commits

Author: Marco Elver
Date: 2020-06-05T20:20:46+02:00
New Revision: 866ee2353f7d0224644799d0d1faed53c7f3a06d

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

LOG: [KernelAddressSanitizer] Make globals constructors compatible with kernel

Summary:
This makes -fsanitize=kernel-address emit the correct globals
constructors for the kernel. We had to do the following:

- Disable generation of constructors that rely on linker features such
  as dead-global elimination.

- Only emit constructors for globals *not* in explicit sections. The
  kernel uses sections for special globals, which we should not touch.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203493

Tested:
1. With 'clang/test/CodeGen/asan-globals.cpp'.
2. With test_kasan.ko, we can see:

BUG: KASAN: global-out-of-bounds in kasan_global_oob+0xb3/0xba 
[test_kasan]

Reviewers: glider, andreyknvl

Reviewed By: glider

Subscribers: cfe-commits, nickdesaulniers, hiraditya, llvm-commits

Tags: #llvm, #clang

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

Added: 


Modified: 
clang/test/CodeGen/asan-globals.cpp
llvm/include/llvm/Transforms/Utils/ModuleUtils.h
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Utils/ModuleUtils.cpp

Removed: 




diff  --git a/clang/test/CodeGen/asan-globals.cpp 
b/clang/test/CodeGen/asan-globals.cpp
index 93abb0023cfa..2feb305ebecd 100644
--- a/clang/test/CodeGen/asan-globals.cpp
+++ b/clang/test/CodeGen/asan-globals.cpp
@@ -1,40 +1,59 @@
 // RUN: echo "int extra_global;" > %t.extra-source.cpp
 // RUN: echo "global:*blacklisted_global*" > %t.blacklist
-// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address 
-fsanitize-blacklist=%t.blacklist -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address 
-fsanitize-blacklist=%t.blacklist -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,ASAN
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=kernel-address 
-fsanitize-blacklist=%t.blacklist -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,KASAN
 // The blacklist file uses regexps, so Windows path backslashes.
 // RUN: echo "src:%s" | sed -e 's/\\//g' > %t.blacklist-src
 // RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address 
-fsanitize-blacklist=%t.blacklist-src -emit-llvm -o - %s | FileCheck %s 
--check-prefix=BLACKLIST-SRC
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=kernel-address 
-fsanitize-blacklist=%t.blacklist-src -emit-llvm -o - %s | FileCheck %s 
--check-prefix=BLACKLIST-SRC
 
 int global;
 int dyn_init_global = global;
 int __attribute__((no_sanitize("address"))) attributed_global;
 int blacklisted_global;
+int __attribute__((section(".foo.bar"))) sectioned_global;
 
 void func() {
   static int static_var = 0;
   const char *literal = "Hello, world!";
 }
 
-// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], 
![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], 
![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// CHECK-LABEL: define internal void @asan.module_ctor
+// ASAN-NEXT: call void @__asan_init
+// ASAN-NEXT: call void @__asan_version_mismatch_check
+// KASAN-NOT: call void @__asan_init
+// KASAN-NOT: call void @__asan_version_mismatch_check
+// ASAN-NEXT: call void @__asan_register_globals(i64 ptrtoint ({{.*}}, i64 6)
+// KASAN-NEXT: call void @__asan_register_globals(i64 ptrtoint ({{.*}}, i64 5)
+// CHECK-NEXT: ret void
+
+// CHECK-LABEL: define internal void @asan.module_dtor
+// CHECK-NEXT: call void @__asan_unregister_globals
+// CHECK-NEXT: ret void
+
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], 
![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], 
![[BLACKLISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], 
![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], 
!"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, 
i1 false}
-// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 8, i32 5}
+// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 10, i32 5}
 // CHECK: ![[DYN_INIT_GLOBAL]] = !{{{.*}} ![[DYN_INIT_LOC:[0-9]+]], 
!"dyn_init_global", i1 true, i1 false}
-// CHECK: ![[DYN_INIT_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 9, i32 5}
+// CHECK: ![[DYN_INIT_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 11, i32 5}
 // CHECK: ![[ATTR_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
 // CHECK: ![[BLACKLISTED_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
+// CHECK: ![[SECTIONED_GLOBAL]] = !{{{.*}} ![

[clang] 931fcd3 - [WebAssembly] Improve clang diagnostics for wasm attributes

2020-06-05 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2020-06-05T11:27:51-07:00
New Revision: 931fcd3ba011c27626a95e5e35b657763284882a

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

LOG: [WebAssembly] Improve clang diagnostics for wasm attributes

This patch addresses the review comments on r352930:

 - Removes redundant diagnostic checking code
 - Removes errnoneous use of diag::err_alias_is_definition, which
   turned out to be ineffective anyway since functions can be defined later
   in the translation unit and avoid detection.
 - Adds a test for various invalid cases for import_name and import_module.

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

Added: 
clang/test/AST/ast-dump-wasm-attr-export.c
clang/test/AST/ast-dump-wasm-attr-import.c
clang/test/Sema/attr-wasm.c

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

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0a284b9a8906..e4bdfe17471d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10770,6 +10770,12 @@ def err_matrix_separate_incomplete_index: Error<
 def err_matrix_subscript_comma: Error<
   "comma expressions are not allowed as indices in matrix subscript 
expressions">;
 
+def warn_mismatched_import : Warning<
+  "import %select{module|name}0 (%1) does not match the import 
%select{module|name}0 (%2) of the "
+  "previous declaration">;
+def warn_import_on_definition : Warning<
+  "import %select{module|name}0 cannot be applied to a function with a 
definition">;
+
 def err_preserve_field_info_not_field : Error<
   "__builtin_preserve_field_info argument %0 not a field access">;
 def err_preserve_field_info_not_const: Error<

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5f0a03b1c93f..cef25fc927aa 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2999,6 +2999,10 @@ class Sema final {
 const InternalLinkageAttr &AL);
   CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL);
   CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL);
+  WebAssemblyImportNameAttr *mergeImportNameAttr(
+  Decl *D, const WebAssemblyImportNameAttr &AL);
+  WebAssemblyImportModuleAttr *mergeImportModuleAttr(
+  Decl *D, const WebAssemblyImportModuleAttr &AL);
 
   void mergeDeclAttributes(NamedDecl *New, Decl *Old,
AvailabilityMergeKind AMK = AMK_Redeclaration);

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6e52c95ad488..025b09de0ad1 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2598,6 +2598,10 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
 NewAttr = S.mergeSpeculativeLoadHardeningAttr(D, *SLHA);
   else if (const auto *SLHA = dyn_cast(Attr))
 NewAttr = S.mergeNoSpeculativeLoadHardeningAttr(D, *SLHA);
+  else if (const auto *IMA = dyn_cast(Attr))
+NewAttr = S.mergeImportModuleAttr(D, *IMA);
+  else if (const auto *INA = dyn_cast(Attr))
+NewAttr = S.mergeImportNameAttr(D, *INA);
   else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr))
 NewAttr = cast(Attr->clone(S.Context));
 

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index df44b6fcf2af..763db5b41bb8 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5892,45 +5892,75 @@ static void handleWebAssemblyExportNameAttr(Sema &S, 
Decl *D, const ParsedAttr &
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
-static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
-  if (!isFunctionOrMethod(D)) {
-S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
-<< "'import_module'" << ExpectedFunction;
-return;
+WebAssemblyImportModuleAttr *
+Sema::mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL) {
+  auto *FD = cast(D);
+
+  if (const auto *ExistingAttr = FD->getAttr()) {
+if (ExistingAttr->getImportModule() == AL.getImportModule())
+  return nullptr;
+Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
+  << ExistingAttr->getImportModule() << AL.getImportModule();
+Diag(AL.getLoc(), diag::note_previous_attribute);
+return nullptr;
+  }
+  if (FD->hasBody()) {
+Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
+return nullptr;
   }
+  return ::new (Context) WebAssemblyImportModuleAttr(Context, AL,
+  

[clang] ee60847 - Attempt to fix hip-include-path.hip

2020-06-05 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-05T14:36:36-04:00
New Revision: ee608478623a716da38cd09383f640f3a96f8d61

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

LOG: Attempt to fix hip-include-path.hip

Added: 


Modified: 
clang/test/Driver/hip-include-path.hip

Removed: 




diff  --git a/clang/test/Driver/hip-include-path.hip 
b/clang/test/Driver/hip-include-path.hip
index f4a312656d1c..12d6aa2a5216 100644
--- a/clang/test/Driver/hip-include-path.hip
+++ b/clang/test/Driver/hip-include-path.hip
@@ -19,7 +19,7 @@
 // NOWRAP-NOT: clang/{{.*}}/include/cuda_wrappers
 // HIP: {{.*}}Inputs/rocm/include
 // NOHIP-NOT: {{.*}}Inputs/rocm/include
-// COMMON: {{.*}}include/c++
+// skip check of standard C++ include path
 // COMMON: clang/{{.*}}/include
 
 // COMMON-LABEL: clang{{.*}} -cc1 -triple x86_64
@@ -27,5 +27,5 @@
 // NOWRAP-NOT: clang/{{.*}}/include/cuda_wrappers
 // HIP: {{.*}}Inputs/rocm/include
 // NOHIP-NOT: {{.*}}Inputs/rocm/include
-// COMMON: {{.*}}include/c++
+// skip check of standard C++ include path
 // COMMON: clang/{{.*}}/include



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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2020-06-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks check-clang everywhere, e.g. here 
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/39534/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Awarning-flags.c

Please take a look and revert if it takes a while to fix.

Going forward, please run check-clang before landing clang changes, or look at 
the permerge bot output which predicted this failure 
(https://reviews.llvm.org/B59001)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59520



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


[PATCH] D80758: [PowerPC] Add -m[no-]power10-vector clang and llvm option

2020-06-05 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 268893.
saghir added a comment.

Updated the diff based on latest changes in master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80758

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-dependent-options.cpp
  clang/test/Driver/ppc-features.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h

Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -105,6 +105,7 @@
   bool HasP8Crypto;
   bool HasP9Vector;
   bool HasP9Altivec;
+  bool HasP10Vector;
   bool HasPrefixInstrs;
   bool HasPCRelativeMemops;
   bool HasFCPSGN;
@@ -262,6 +263,7 @@
   bool hasP8Crypto() const { return HasP8Crypto; }
   bool hasP9Vector() const { return HasP9Vector; }
   bool hasP9Altivec() const { return HasP9Altivec; }
+  bool hasP10Vector() const { return HasP10Vector; }
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -78,6 +78,7 @@
   HasP8Crypto = false;
   HasP9Vector = false;
   HasP9Altivec = false;
+  HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
   HasFCPSGN = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -216,6 +216,10 @@
 "Enable POWER9 vector instructions",
 [FeatureISA3_0, FeatureP8Vector,
  FeatureP9Altivec]>;
+def FeatureP10Vector  : SubtargetFeature<"power10-vector", "HasP10Vector",
+ "true",
+ "Enable POWER10 vector instructions",
+ [FeatureISA3_1, FeatureP9Vector]>;
 // A separate feature for this even though it is equivalent to P9Vector
 // because this is a feature of the implementation rather than the architecture
 // and may go away with future CPU's.
@@ -337,7 +341,7 @@
   // still exist with the exception of those we know are Power9 specific.
   list P10AdditionalFeatures =
 [DirectivePwr10, FeatureISA3_1, FeaturePrefixInstrs,
- FeaturePCRelativeMemops];
+ FeaturePCRelativeMemops, FeatureP10Vector];
   list P10SpecificFeatures = [];
   list P10InheritableFeatures =
 !listconcat(P9InheritableFeatures, P10AdditionalFeatures);
Index: clang/test/Driver/ppc-features.cpp
===
--- clang/test/Driver/ppc-features.cpp
+++ clang/test/Driver/ppc-features.cpp
@@ -150,6 +150,12 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power8-vector -mpower8-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P8VECTOR %s
 // CHECK-P8VECTOR: "-target-feature" "+power8-vector"
 
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power10-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOP10VECTOR %s
+// CHECK-NOP10VECTOR: "-target-feature" "-power10-vector"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power10-vector -mpower10-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P10VECTOR %s
+// CHECK-P10VECTOR: "-target-feature" "+power10-vector"
+
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-crbits -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s
 // CHECK-NOCRBITS: "-target-feature" "-crbits"
 
Index: clang/test/Driver/ppc-dependent-options.cpp
===
--- clang/test/Driver/ppc-dependent-options.cpp
+++ clang/test/Driver/ppc-dependent-options.cpp
@@ -58,6 +58,14 @@
 // RUN: -mcpu=power9 -std=c++11 -mno-vsx -mfloat128 -mpower9-vector %s 2>&1 | \
 // RUN: FileCheck %s -check-prefix=CHECK-NVSX-MULTI
 
+// RUN: not %clang -target powerpc64le-unknown-unknown -fsyntax-only \
+// RUN: -mcpu=power10 -std=c++11 %s 2>&1 | FileCheck %s \
+// RUN: -check-prefix=CHECK-DEFAULT-P10
+
+// RUN: not %clang -target powerpc64le-unknown-unknown -fsyntax-only \
+// RUN: -mcpu=power10 -std=c++11 -mno-vsx -mpower10-vector %s 2>&1 | \
+// RUN: FileCheck %s -check-prefix=CHECK-NVSX-P10V
+
 #ifdef __VSX__
 static_assert(false, "VSX enabled");
 #endif
@@ -70,6 +78,10 @@
 static_assert(false, "P9V enabled");
 #endif
 
+#ifdef __POWER10_VECTOR__
+static_assert(false, "P10V enabled")

[PATCH] D80805: [KernelAddressSanitizer] Make globals constructors compatible with kernel

2020-06-05 Thread Marco Elver via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG866ee2353f7d: [KernelAddressSanitizer] Make globals 
constructors compatible with kernel (authored by melver).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80805

Files:
  clang/test/CodeGen/asan-globals.cpp
  llvm/include/llvm/Transforms/Utils/ModuleUtils.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Utils/ModuleUtils.cpp

Index: llvm/lib/Transforms/Utils/ModuleUtils.cpp
===
--- llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -119,6 +119,15 @@
   AttributeList());
 }
 
+Function *llvm::createSanitizerCtor(Module &M, StringRef CtorName) {
+  Function *Ctor = Function::Create(
+  FunctionType::get(Type::getVoidTy(M.getContext()), false),
+  GlobalValue::InternalLinkage, CtorName, &M);
+  BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor);
+  ReturnInst::Create(M.getContext(), CtorBB);
+  return Ctor;
+}
+
 std::pair llvm::createSanitizerCtorAndInitFunctions(
 Module &M, StringRef CtorName, StringRef InitName,
 ArrayRef InitArgTypes, ArrayRef InitArgs,
@@ -128,11 +137,8 @@
  "Sanitizer's init function expects different number of arguments");
   FunctionCallee InitFunction =
   declareSanitizerInitFunction(M, InitName, InitArgTypes);
-  Function *Ctor = Function::Create(
-  FunctionType::get(Type::getVoidTy(M.getContext()), false),
-  GlobalValue::InternalLinkage, CtorName, &M);
-  BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor);
-  IRBuilder<> IRB(ReturnInst::Create(M.getContext(), CtorBB));
+  Function *Ctor = createSanitizerCtor(M, CtorName);
+  IRBuilder<> IRB(Ctor->getEntryBlock().getTerminator());
   IRB.CreateCall(InitFunction, InitArgs);
   if (!VersionCheckName.empty()) {
 FunctionCallee VersionCheckFunction = M.getOrInsertFunction(
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -589,11 +589,10 @@
   AddressSanitizer(Module &M, const GlobalsMetadata *GlobalsMD,
bool CompileKernel = false, bool Recover = false,
bool UseAfterScope = false)
-  : UseAfterScope(UseAfterScope || ClUseAfterScope), GlobalsMD(*GlobalsMD) {
-this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
-this->CompileKernel =
-ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan : CompileKernel;
-
+  : CompileKernel(ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan
+: CompileKernel),
+Recover(ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover),
+UseAfterScope(UseAfterScope || ClUseAfterScope), GlobalsMD(*GlobalsMD) {
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -742,7 +741,11 @@
   ModuleAddressSanitizer(Module &M, const GlobalsMetadata *GlobalsMD,
  bool CompileKernel = false, bool Recover = false,
  bool UseGlobalsGC = true, bool UseOdrIndicator = false)
-  : GlobalsMD(*GlobalsMD), UseGlobalsGC(UseGlobalsGC && ClUseGlobalsGC),
+  : GlobalsMD(*GlobalsMD),
+CompileKernel(ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan
+: CompileKernel),
+Recover(ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover),
+UseGlobalsGC(UseGlobalsGC && ClUseGlobalsGC && !this->CompileKernel),
 // Enable aliases as they should have no downside with ODR indicators.
 UsePrivateAlias(UseOdrIndicator || ClUsePrivateAlias),
 UseOdrIndicator(UseOdrIndicator || ClUseOdrIndicator),
@@ -753,11 +756,7 @@
 // argument is designed as workaround. Therefore, disable both
 // ClWithComdat and ClUseGlobalsGC unless the frontend says it's ok to
 // do globals-gc.
-UseCtorComdat(UseGlobalsGC && ClWithComdat) {
-this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
-this->CompileKernel =
-ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan : CompileKernel;
-
+UseCtorComdat(UseGlobalsGC && ClWithComdat && !this->CompileKernel) {
 C = &(M.getContext());
 int LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -1838,6 +1837,12 @@
   }
 
   if (G->hasSection()) {
+// The kernel uses explicit sections for mostly special global variables
+// that we should not instrument. E.g. the kernel may rely on their layout
+//

[PATCH] D59520: [WebAssembly] Address review comments on r352930

2020-06-05 Thread sunfishcode via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG931fcd3ba011: [WebAssembly] Improve clang diagnostics for 
wasm attributes (authored by sunfishcode).

Changed prior to commit:
  https://reviews.llvm.org/D59520?vs=268329&id=268900#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59520

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-dump-wasm-attr-export.c
  clang/test/AST/ast-dump-wasm-attr-import.c
  clang/test/Sema/attr-wasm.c

Index: clang/test/Sema/attr-wasm.c
===
--- /dev/null
+++ clang/test/Sema/attr-wasm.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+
+void name_a() __attribute__((import_name)); //expected-error {{'import_name' attribute takes one argument}}
+
+int name_b __attribute__((import_name("foo"))); //expected-error {{'import_name' attribute only applies to functions}}
+
+void name_c() __attribute__((import_name("foo", "bar"))); //expected-error {{'import_name' attribute takes one argument}}
+
+void name_d() __attribute__((import_name("foo", "bar", "qux"))); //expected-error {{'import_name' attribute takes one argument}}
+
+void name_z() __attribute__((import_name("foo"))); //expected-note {{previous attribute is here}}
+
+void name_z() __attribute__((import_name("bar"))); //expected-warning {{import name (bar) does not match the import name (foo) of the previous declaration}}
+
+void module_a() __attribute__((import_module)); //expected-error {{'import_module' attribute takes one argument}}
+
+int module_b __attribute__((import_module("foo"))); //expected-error {{'import_module' attribute only applies to functions}}
+
+void module_c() __attribute__((import_module("foo", "bar"))); //expected-error {{'import_module' attribute takes one argument}}
+
+void module_d() __attribute__((import_module("foo", "bar", "qux"))); //expected-error {{'import_module' attribute takes one argument}}
+
+void module_z() __attribute__((import_module("foo"))); //expected-note {{previous attribute is here}}
+
+void module_z() __attribute__((import_module("bar"))); //expected-warning {{import module (bar) does not match the import module (foo) of the previous declaration}}
+
+void both() __attribute__((import_name("foo"), import_module("bar")));
Index: clang/test/AST/ast-dump-wasm-attr-import.c
===
--- /dev/null
+++ clang/test/AST/ast-dump-wasm-attr-import.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -ast-dump %s | FileCheck --strict-whitespace %s
+
+// Test that functions can be redeclared and they retain their attributes.
+
+__attribute__((import_name("import_red"), import_module("mod"))) void red(void);
+__attribute__((import_name("import_orange"), import_module("mod"))) void orange(void);
+__attribute__((import_name("import_yellow"), import_module("mod"))) void yellow(void);
+
+void red(void);
+void orange(void);
+void yellow(void);
+
+void calls(void) {
+red();
+orange();
+yellow();
+}
+
+// CHECK: |-FunctionDecl {{.+}} used red 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_red"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod"
+// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_orange"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod"
+// CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_yellow"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod"
+// CHECK: |-FunctionDecl {{.+}} used red 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_red"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod"
+// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_orange"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod"
+// CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_yellow"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod"
Index: clang/test/AST/ast-dump-wasm-attr-export.c
===
--- /dev/null
+++ clang/test/AST/ast-dump-wasm-attr-export.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -ast-dump %s | FileCheck --strict-whitespace %s
+
+// Test that functions can be redeclared and they retain their attributes.
+
+__attribute__((export_name("export_red"))) void red(void) {}
+__attribute__((export_name("export_orange"))) void orange(void) {}
+__attribute__((export_name("export_yellow"))) void yellow(voi

[PATCH] D81045: [MLIR] Modify HasParent trait to allow one of several op's as a parent

2020-06-05 Thread Rahul Joshi via Phabricator via cfe-commits
jurahul updated this revision to Diff 268903.
jurahul added a comment.

Fix Clang build failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81045

Files:
  clang/include/clang/AST/DeclBase.h
  llvm/include/llvm/Support/Casting.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
  mlir/include/mlir/IR/OpBase.td
  mlir/include/mlir/IR/OpDefinition.h
  mlir/test/IR/traits.mlir
  mlir/test/lib/Dialect/Test/TestOps.td

Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -439,10 +439,18 @@
   let results = (outs AnyTensor);
 }
 
-// There the "HasParent" trait.
-def ParentOp : TEST_Op<"parent">;
+// HasParent trait
+def ParentOp : TEST_Op<"parent"> {
+let regions = (region AnyRegion);
+}
 def ChildOp : TEST_Op<"child", [HasParent<"ParentOp">]>;
 
+// ParentOneOf trait
+def ParentOp1 : TEST_Op<"parent1"> {
+  let regions = (region AnyRegion);
+}
+def ChildWithParentOneOf : TEST_Op<"child_with_parent_one_of",
+[ParentOneOf<["ParentOp", "ParentOp1"]>]>;
 
 def TerminatorOp : TEST_Op<"finish", [Terminator]>;
 def SingleBlockImplicitTerminatorOp : TEST_Op<"SingleBlockImplicitTerminator",
Index: mlir/test/IR/traits.mlir
===
--- mlir/test/IR/traits.mlir
+++ mlir/test/IR/traits.mlir
@@ -173,6 +173,39 @@
   }) : () -> ()
 }
 
+// -
+
+// CHECK: succeededParentOneOf
+func @succeededParentOneOf() {
+  "test.parent"() ({
+"test.child_with_parent_one_of"() : () -> ()
+"test.finish"() : () -> ()
+   }) : () -> ()
+  return
+}
+
+// -
+
+// CHECK: succeededParent1OneOf
+func @succeededParent1OneOf() {
+  "test.parent1"() ({
+"test.child_with_parent_one_of"() : () -> ()
+"test.finish"() : () -> ()
+   }) : () -> ()
+  return
+}
+
+// -
+
+func @failedParentOneOf_wrong_parent1() {
+  "some.otherop"() ({
+// expected-error@+1 {{'test.child_with_parent_one_of' op expects parent op to be one of 'test.parent, test.parent1'}}
+"test.child_with_parent_one_of"() : () -> ()
+"test.finish"() : () -> ()
+   }) : () -> ()
+}
+
+
 // -
 
 func @failedSingleBlockImplicitTerminator_empty_block() {
Index: mlir/include/mlir/IR/OpDefinition.h
===
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -1139,16 +1139,24 @@
   };
 };
 
-/// This class provides a verifier for ops that are expecting a specific parent.
-template  struct HasParent {
+/// This class provides a verifier for ops that are expecting their parent
+/// to be one of the given parent ops
+template 
+struct HasParent {
   template 
   class Impl : public TraitBase {
   public:
 static LogicalResult verifyTrait(Operation *op) {
-  if (isa(op->getParentOp()))
+  if (llvm::isa(op->getParentOp()))
 return success();
-  return op->emitOpError() << "expects parent op '"
-   << ParentOpType::getOperationName() << "'";
+
+  InFlightDiagnostic diag = op->emitOpError();
+  diag << "expects parent op to be "
+   << (sizeof...(ParentOpTypes) != 1 ? "one of '" : "'");
+  llvm::interleaveComma(
+  llvm::makeArrayRef({ParentOpTypes::getOperationName()...}), diag);
+  diag << "'";
+  return diag;
 }
   };
 };
Index: mlir/include/mlir/IR/OpBase.td
===
--- mlir/include/mlir/IR/OpBase.td
+++ mlir/include/mlir/IR/OpBase.td
@@ -1686,6 +1686,9 @@
 class HasParent
 : ParamNativeOpTrait<"HasParent", op>;
 
+class ParentOneOf ops>
+: ParamNativeOpTrait<"HasParent", StrJoin.result>;
+
 // Op result type is derived from the first attribute. If the attribute is an
 // subclass of `TypeAttrBase`, its value is used, otherwise, the type of the
 // attribute content is used.
Index: llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
===
--- llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
+++ llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
@@ -220,7 +220,7 @@
 auto Defs = findAllDefs(U);
 
 // If the values are all Constants or Arguments, don't bother
-if (llvm::none_of(Defs, isa))
+if (llvm::none_of(Defs, [](Value *V) { return isa(V); }))
   return false;
 
 // Presently, we only know how to handle PHINode, Constant, Arguments and
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3860,7 +3860,8 @@
   if (I != HasRecMap.end())
 return I->second;
 
-  bool FoundAddRec = SCEVExprContains(S, isa);
+  bool FoundAddRec =
+  SCEVE

[clang] 3aec298 - Revert "[WebAssembly] Improve clang diagnostics for wasm attributes"

2020-06-05 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2020-06-05T11:52:11-07:00
New Revision: 3aec298349fbc901a51b47004fb156090b3d6bce

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

LOG: Revert "[WebAssembly] Improve clang diagnostics for wasm attributes"

It broke clang-check.

This reverts commit 931fcd3ba011c27626a95e5e35b657763284882a.

Added: 


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

Removed: 
clang/test/AST/ast-dump-wasm-attr-export.c
clang/test/AST/ast-dump-wasm-attr-import.c
clang/test/Sema/attr-wasm.c



diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e4bdfe17471d..0a284b9a8906 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10770,12 +10770,6 @@ def err_matrix_separate_incomplete_index: Error<
 def err_matrix_subscript_comma: Error<
   "comma expressions are not allowed as indices in matrix subscript 
expressions">;
 
-def warn_mismatched_import : Warning<
-  "import %select{module|name}0 (%1) does not match the import 
%select{module|name}0 (%2) of the "
-  "previous declaration">;
-def warn_import_on_definition : Warning<
-  "import %select{module|name}0 cannot be applied to a function with a 
definition">;
-
 def err_preserve_field_info_not_field : Error<
   "__builtin_preserve_field_info argument %0 not a field access">;
 def err_preserve_field_info_not_const: Error<

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index cef25fc927aa..5f0a03b1c93f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2999,10 +2999,6 @@ class Sema final {
 const InternalLinkageAttr &AL);
   CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL);
   CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL);
-  WebAssemblyImportNameAttr *mergeImportNameAttr(
-  Decl *D, const WebAssemblyImportNameAttr &AL);
-  WebAssemblyImportModuleAttr *mergeImportModuleAttr(
-  Decl *D, const WebAssemblyImportModuleAttr &AL);
 
   void mergeDeclAttributes(NamedDecl *New, Decl *Old,
AvailabilityMergeKind AMK = AMK_Redeclaration);

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 025b09de0ad1..6e52c95ad488 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2598,10 +2598,6 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
 NewAttr = S.mergeSpeculativeLoadHardeningAttr(D, *SLHA);
   else if (const auto *SLHA = dyn_cast(Attr))
 NewAttr = S.mergeNoSpeculativeLoadHardeningAttr(D, *SLHA);
-  else if (const auto *IMA = dyn_cast(Attr))
-NewAttr = S.mergeImportModuleAttr(D, *IMA);
-  else if (const auto *INA = dyn_cast(Attr))
-NewAttr = S.mergeImportNameAttr(D, *INA);
   else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr))
 NewAttr = cast(Attr->clone(S.Context));
 

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 763db5b41bb8..df44b6fcf2af 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5892,75 +5892,45 @@ static void handleWebAssemblyExportNameAttr(Sema &S, 
Decl *D, const ParsedAttr &
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
-WebAssemblyImportModuleAttr *
-Sema::mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL) {
-  auto *FD = cast(D);
-
-  if (const auto *ExistingAttr = FD->getAttr()) {
-if (ExistingAttr->getImportModule() == AL.getImportModule())
-  return nullptr;
-Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
-  << ExistingAttr->getImportModule() << AL.getImportModule();
-Diag(AL.getLoc(), diag::note_previous_attribute);
-return nullptr;
-  }
-  if (FD->hasBody()) {
-Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
-return nullptr;
+static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
+  if (!isFunctionOrMethod(D)) {
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< "'import_module'" << ExpectedFunction;
+return;
   }
-  return ::new (Context) WebAssemblyImportModuleAttr(Context, AL,
- AL.getImportModule());
-}
 
-WebAssemblyImportNameAttr *
-Sema::mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL) {
   auto *FD = cast(D);
-
-  if (const auto *ExistingAttr = FD->getAttr()) {
-if (ExistingAttr->getImportName() == AL.getImportName())
-  return nullptr;
-Diag(ExistingAttr->getLocat

[PATCH] D81045: [MLIR] Modify HasParent trait to allow one of several op's as a parent

2020-06-05 Thread Rahul Joshi via Phabricator via cfe-commits
jurahul updated this revision to Diff 268905.
jurahul added a comment.

fix MLIR test failure due to change in error message. Reinstate the old message 
for a single parent case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81045

Files:
  clang/include/clang/AST/DeclBase.h
  llvm/include/llvm/Support/Casting.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
  mlir/include/mlir/IR/OpBase.td
  mlir/include/mlir/IR/OpDefinition.h
  mlir/test/IR/traits.mlir
  mlir/test/lib/Dialect/Test/TestOps.td

Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -439,10 +439,18 @@
   let results = (outs AnyTensor);
 }
 
-// There the "HasParent" trait.
-def ParentOp : TEST_Op<"parent">;
+// HasParent trait
+def ParentOp : TEST_Op<"parent"> {
+let regions = (region AnyRegion);
+}
 def ChildOp : TEST_Op<"child", [HasParent<"ParentOp">]>;
 
+// ParentOneOf trait
+def ParentOp1 : TEST_Op<"parent1"> {
+  let regions = (region AnyRegion);
+}
+def ChildWithParentOneOf : TEST_Op<"child_with_parent_one_of",
+[ParentOneOf<["ParentOp", "ParentOp1"]>]>;
 
 def TerminatorOp : TEST_Op<"finish", [Terminator]>;
 def SingleBlockImplicitTerminatorOp : TEST_Op<"SingleBlockImplicitTerminator",
Index: mlir/test/IR/traits.mlir
===
--- mlir/test/IR/traits.mlir
+++ mlir/test/IR/traits.mlir
@@ -173,6 +173,39 @@
   }) : () -> ()
 }
 
+// -
+
+// CHECK: succeededParentOneOf
+func @succeededParentOneOf() {
+  "test.parent"() ({
+"test.child_with_parent_one_of"() : () -> ()
+"test.finish"() : () -> ()
+   }) : () -> ()
+  return
+}
+
+// -
+
+// CHECK: succeededParent1OneOf
+func @succeededParent1OneOf() {
+  "test.parent1"() ({
+"test.child_with_parent_one_of"() : () -> ()
+"test.finish"() : () -> ()
+   }) : () -> ()
+  return
+}
+
+// -
+
+func @failedParentOneOf_wrong_parent1() {
+  "some.otherop"() ({
+// expected-error@+1 {{'test.child_with_parent_one_of' op expects parent op to be one of 'test.parent, test.parent1'}}
+"test.child_with_parent_one_of"() : () -> ()
+"test.finish"() : () -> ()
+   }) : () -> ()
+}
+
+
 // -
 
 func @failedSingleBlockImplicitTerminator_empty_block() {
Index: mlir/include/mlir/IR/OpDefinition.h
===
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -1139,16 +1139,24 @@
   };
 };
 
-/// This class provides a verifier for ops that are expecting a specific parent.
-template  struct HasParent {
+/// This class provides a verifier for ops that are expecting their parent
+/// to be one of the given parent ops
+template 
+struct HasParent {
   template 
   class Impl : public TraitBase {
   public:
 static LogicalResult verifyTrait(Operation *op) {
-  if (isa(op->getParentOp()))
+  if (llvm::isa(op->getParentOp()))
 return success();
-  return op->emitOpError() << "expects parent op '"
-   << ParentOpType::getOperationName() << "'";
+
+  InFlightDiagnostic diag = op->emitOpError();
+  diag << "expects parent op "
+   << (sizeof...(ParentOpTypes) != 1 ? "to be one of '" : "'");
+  llvm::interleaveComma(
+  llvm::makeArrayRef({ParentOpTypes::getOperationName()...}), diag);
+  diag << "'";
+  return diag;
 }
   };
 };
Index: mlir/include/mlir/IR/OpBase.td
===
--- mlir/include/mlir/IR/OpBase.td
+++ mlir/include/mlir/IR/OpBase.td
@@ -1686,6 +1686,9 @@
 class HasParent
 : ParamNativeOpTrait<"HasParent", op>;
 
+class ParentOneOf ops>
+: ParamNativeOpTrait<"HasParent", StrJoin.result>;
+
 // Op result type is derived from the first attribute. If the attribute is an
 // subclass of `TypeAttrBase`, its value is used, otherwise, the type of the
 // attribute content is used.
Index: llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
===
--- llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
+++ llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
@@ -220,7 +220,7 @@
 auto Defs = findAllDefs(U);
 
 // If the values are all Constants or Arguments, don't bother
-if (llvm::none_of(Defs, isa))
+if (llvm::none_of(Defs, [](Value *V) { return isa(V); }))
   return false;
 
 // Presently, we only know how to handle PHINode, Constant, Arguments and
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3860,7 +3860,8 @@
   if (I != HasRecMap.end())
 return I->second;
 

[PATCH] D81176: [HIP] Add default header and include path

2020-06-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This is still failing on Windows: http://45.33.8.238/win/16970/step_7.txt

Please take a look and revert for now if it takes a while to investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81176



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


[PATCH] D81176: [HIP] Add default header and include path

2020-06-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Also still failing on mac: http://45.33.8.238/mac/14992/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81176



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-05 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 268906.
aganea added a comment.

Fix tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Job.h
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Job.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  clang/tools/driver/cc1_main.cpp
  clang/tools/driver/driver.cpp
  lld/COFF/PDB.cpp
  lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
  lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
  lld/test/COFF/pdb-relative-source-lines.test
  llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/Support/Program.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
  llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
  llvm/lib/Support/Program.cpp

Index: llvm/lib/Support/Program.cpp
===
--- llvm/lib/Support/Program.cpp
+++ llvm/lib/Support/Program.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Program.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 using namespace llvm;
 using namespace sys;
@@ -73,6 +74,24 @@
   return commandLineFitsWithinSystemLimits(Program, StringRefArgs);
 }
 
+void sys::printArg(raw_ostream &OS, StringRef Arg, bool Quote) {
+  const bool Escape = Arg.find_first_of(" \"\\$") != StringRef::npos;
+
+  if (!Quote && !Escape) {
+OS << Arg;
+return;
+  }
+
+  // Quote and escape. This isn't really complete, but good enough.
+  OS << '"';
+  for (const auto c : Arg) {
+if (c == '"' || c == '\\' || c == '$')
+  OS << '\\';
+OS << c;
+  }
+  OS << '"';
+}
+
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/Program.inc"
Index: llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
===
--- llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
+++ llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
@@ -58,3 +58,8 @@
 uint32_t TypeTableCollection::size() { return Records.size(); }
 
 uint32_t TypeTableCollection::capacity() { return Records.size(); }
+
+bool TypeTableCollection::replaceType(TypeIndex &Index, CVType Data,
+  bool Stabilize) {
+  llvm_unreachable("Method cannot be called");
+}
Index: llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
===
--- llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
+++ llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
@@ -123,3 +123,30 @@
 TI = insertRecordBytes(C.RecordData);
   return TI;
 }
+
+bool MergingTypeTableBuilder::replaceType(TypeIndex &Index, CVType Data,
+  bool Stabilize) {
+  assert(Index.toArrayIndex() < SeenRecords.size() &&
+ "This function cannot be used to insert records!");
+
+  ArrayRef Record = Data.data();
+  assert(Record.size() < UINT32_MAX && "Record too big");
+  assert(Record.size() % 4 == 0 &&
+ "The type record size is not a multiple of 4 bytes which will cause "
+ "misalignment in the output TPI stream!");
+
+  LocallyHashedType WeakHash{hash_value(Record), Record};
+  auto Result = HashedRecords.try_emplace(WeakHash, Index.toArrayIndex());
+  if (!Result.second) {
+Index = Result.first->second;
+return false; // The record is already there, at a different location
+  }
+
+  if (Stabilize) {
+Record = stabilize(RecordStorage, Record);
+Result.first->first.RecordData = Record;
+  }
+
+  SeenRecords[Index.toArrayIndex()] = Record;
+  return true;
+}
Index: llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
===
--- llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
+++ llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
@@ -277,3 +277,8 @@
 ++RI;
   }
 }
+
+bool LazyRandomTypeCollection::replaceType(TypeIndex &Index, CVType Data,
+

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-05 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I feel the refactoring of Aliasing should be in its own PR, with this being a 
child of it.




Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:38
+  ifStmt(hasCondition(anyOf(
+ declRefExpr(hasDeclaration(varDecl().bind("cond_var"))),
+ binaryOperator(hasOperatorName("&&"),

Small nit, but using string literals for bound nodes is error prone. may I 
suggest defining some static strings and using those to prevent any typos.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:39
+ declRefExpr(hasDeclaration(varDecl().bind("cond_var"))),
+ binaryOperator(hasOperatorName("&&"),
+hasEitherOperand(declRefExpr(hasDeclaration(

Recursive matchers are a pain, but this will miss:
 ```
if (A && B && ... Y && Z)
```




Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:63
+  // Non-local variables may be changed by any call.
+  if (!CondVar->isLocalVarDeclOrParm())
+return;

This logic can be moved to the matcher.
```
varDecl(anyOf(parmVarDecl(), hasLocalStorage()))
```



Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:67
+  // Volatile variables may be changed by another thread.
+  if (CondVar->getType().isVolatileQualified())
+return;

Ditto:
```
varDecl(hasType(isVolatileQualified()))```



Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:71
+  // Class instances may be tricky, so restrict ourselves to integers.
+  if (!CondVar->getType().getTypePtr()->isIntegerType())
+return;

Ditto, you get the point



Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:87-88
+  if (isa(InnerIf->getCond()->IgnoreParenImpCasts()) ||
+  (isa(InnerIf->getCond()) &&
+   cast(InnerIf->getCond())->getOpcode() == BO_LOr)) {
+SourceLocation IfBegin = InnerIf->getBeginLoc();

use `llvm::dyn_cast`.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:97
+  CharSourceRange::getCharRange(IfBegin, IfEnd))
+   << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
+  Body->getEndLoc(), Body->getEndLoc().getLocWithOffset(1)));

Again `CharSourceRange::getTokenRange(Body->getEndLoc())`



Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:109
+const auto *CondOp = cast(InnerIf->getCond());
+if (isa(CondOp->getLHS()->IgnoreParenImpCasts()) &&
+cast(CondOp->getLHS()->IgnoreParenImpCasts())->getDecl() 
==

use `llvm::dyn_cast`.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:115
+} else {
+  // For some reason the end location of identifiers is identical to their
+  // begin location so add their length instead.

That's because you are getting the character range, if you get the token range 
it'll get the correct range: `CharSourceRange::getTokenRange`



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:135
`cppcoreguidelines-avoid-goto `_,
+   `cppcoreguidelines-avoid-non-const-global-variables 
`_,
`cppcoreguidelines-init-variables 
`_, "Yes"

baloghadamsoftware wrote:
> What are these changes? I surely did not make them? Maybe the check adder 
> Python script?
Yeah, just undo those unrelated changes, maybe one day the python script will 
get sorted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81272



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


[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:78
 ^^
+- New :doc:`misc-redundant-condition
+  ` check.

Please keep alphabetical order in new checks list.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:81
+
+  Finds condition variables in nested `if` statements that were also checked
+  in the outer `if` statement and were not changed.

Please use double back-ticks for language constructs. Same in documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81272



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-05 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

I have a couple of drive-by suggestions, up to @dang and @Bigcheese whether to 
incorporate them.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:137-142
+.Case("static", llvm::Reloc::Static)
+.Case("pic", llvm::Reloc::PIC_)
+.Case("ropi", llvm::Reloc::ROPI)
+.Case("rwpi", llvm::Reloc::RWPI)
+.Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
+.Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC)

I wonder if it's worth creating a `.def` file for the driver enums, something 
like:
```
#ifdef HANDLE_RELOCATION_MODEL
HANDLE_RELOCATION_MODEL("static", llvm::Reloc::Static)
HANDLE_RELOCATION_MODEL("pic", llvm::Reloc::PIC_)
HANDLE_RELOCATION_MODEL("ropi", llvm::Reloc::ROPI)
HANDLE_RELOCATION_MODEL("rwpi", llvm::Reloc::RWPI)
HANDLE_RELOCATION_MODEL("ropi-rwpio", llvm::Reloc::ROPI_RWPI)
HANDLE_RELOCATION_MODEL("dynamic-no-pic", llvm::Reloc::DynamicNoPIC)
#undef HANDLE_RELOCATION_MODEL
#endif // HANDLE_RELOCATION_MODEL

#ifdef HANDLE_DEBUG_INFO_KIND
HANDLE_DEBUG_INFO_KIND("line-tables-only", codegenoptions::DebugLineTablesOnly)
HANDLE_DEBUG_INFO_KIND("line-directives-only", 
codegenoptions::DebugDirectivesOnly)
HANDLE_DEBUG_INFO_KIND("limited", codegenoptions::LimitedDebugInfo)
HANDLE_DEBUG_INFO_KIND("standalone", codegenoptions::FullDebugInfo)
#undef HANDLE_DEBUG_INFO_KIND
#endif // HANDLE_DEBUG_INFO_KIND

// ...
```
Then you can use `HANDLE_RELOCATION_MODEL` in both `normalize` and 
`denormalize`, rather than duplicating the table.

Maybe we can go even further. Can you expand the `Values` array from the 
tablegen to include this info? Or rejigger the help text to leverage 
`HANDLE_RELOCATION_MODEL` (maybe pass in 
`ValuesDefine`)? The current patch adds a value table; 
my first suggestion leaves us even; but maybe we can get rid of one.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3647
+ DiagnosticsEngine &Diags) {
+#define OPTION_WITH_MARSHALLING
+#define OPTION_WITH_MARSHALLING_FLAG(PREFIX_TYPE, NAME, ID, KIND, GROUP,   
\

Seems like `Options.inc` could provide this as a default definition, not sure 
if that seems error-prone?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3665-3667
+#undef OPTION_WITH_MARSHALLING_STRING
+#undef OPTION_WITH_MARSHALLING_FLAG
+#undef OPTION_WITH_MARSHALLING

I prefer the style where the `.inc` file is responsible for the `#undef` calls. 
It avoids having to duplicate it everywhere (and the risk of forgetting it). 
WDYT?


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

https://reviews.llvm.org/D79796



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


[clang] 3928436 - Attempt to fix hip-include-path.hip

2020-06-05 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-05T15:31:53-04:00
New Revision: 392843617acbce5baf6ca7c7fff8dbac58bf853f

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

LOG: Attempt to fix hip-include-path.hip

Added: 


Modified: 
clang/test/Driver/hip-include-path.hip

Removed: 




diff  --git a/clang/test/Driver/hip-include-path.hip 
b/clang/test/Driver/hip-include-path.hip
index 12d6aa2a5216..8c0d317936b5 100644
--- a/clang/test/Driver/hip-include-path.hip
+++ b/clang/test/Driver/hip-include-path.hip
@@ -1,6 +1,8 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
+// REQUIRES: libgcc
+// UNSUPPORTED: system-windows
 
 // RUN: %clang -c -v -target x86_64-unknown-linux-gnu --cuda-gpu-arch=gfx900 \
 // RUN:   -std=c++11 --rocm-path=%S/Inputs/rocm -nogpulib %s 2>&1 \
@@ -14,7 +16,7 @@
 // RUN:   -std=c++11 --rocm-path=%S/Inputs/rocm -nogpuinc -nogpulib %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=COMMON,WRAP,NOHIP %s
 
-// COMMON-LABEL: clang{{.*}} -cc1 -triple amdgcn-amd-amdhsa
+// COMMON: "{{[^"]*}}clang{{[^"]*}}"
 // WRAP: clang/{{.*}}/include/cuda_wrappers
 // NOWRAP-NOT: clang/{{.*}}/include/cuda_wrappers
 // HIP: {{.*}}Inputs/rocm/include
@@ -22,7 +24,7 @@
 // skip check of standard C++ include path
 // COMMON: clang/{{.*}}/include
 
-// COMMON-LABEL: clang{{.*}} -cc1 -triple x86_64
+// COMMON: "{{[^"]*}}clang{{[^"]*}}"
 // WRAP: clang/{{.*}}/include/cuda_wrappers
 // NOWRAP-NOT: clang/{{.*}}/include/cuda_wrappers
 // HIP: {{.*}}Inputs/rocm/include



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


[clang] 672ed53 - [codeview] Put !heapallocsite on calls to operator new

2020-06-05 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-06-05T12:52:38-07:00
New Revision: 672ed5386024ba5cee53e19d637b7920a4889837

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

LOG: [codeview] Put !heapallocsite on calls to operator new

Clang marks calls to operator new as heap allocation sites, but the
operator declared at global scope returns a void pointer. There is no
explicit cast in the code, so the compiler has to write down the
allocated type itself.

Also generalize a cast to use CallBase, so that we mark heap alloc sites
when exceptions are enabled.

Reviewed By: MaskRay

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

Added: 
clang/test/CodeGenCXX/debug-info-codeview-heapallocsite.cpp

Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/debug-info-codeview-heapallocsite.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 6bde3124555b..136782fccf40 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4951,7 +4951,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   // Add metadata for calls to MSAllocator functions
   if (getDebugInfo() && TargetDecl &&
   TargetDecl->hasAttr())
-getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy, Loc);
+getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy->getPointeeType(), Loc);
 
   // 4. Finish the call.
 

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index cc50ec6a8c89..1737154d179a 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2146,16 +2146,14 @@ llvm::DIType 
*CGDebugInfo::getOrCreateStandaloneType(QualType D,
   return T;
 }
 
-void CGDebugInfo::addHeapAllocSiteMetadata(llvm::Instruction *CI,
-   QualType D,
+void CGDebugInfo::addHeapAllocSiteMetadata(llvm::CallBase *CI,
+   QualType AllocatedTy,
SourceLocation Loc) {
   llvm::MDNode *node;
-  if (D.getTypePtr()->isVoidPointerType()) {
+  if (AllocatedTy->isVoidType())
 node = llvm::MDNode::get(CGM.getLLVMContext(), None);
-  } else {
-QualType PointeeTy = D.getTypePtr()->getPointeeType();
-node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
-  }
+  else
+node = getOrCreateType(AllocatedTy, getOrCreateFile(Loc));
 
   CI->setMetadata("heapallocsite", node);
 }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 367047e79dc9..96ef6c7c1d27 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -509,7 +509,7 @@ class CGDebugInfo {
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
   /// Add heapallocsite metadata for MSAllocator calls.
-  void addHeapAllocSiteMetadata(llvm::Instruction *CallSite, QualType Ty,
+  void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType AllocatedTy,
 SourceLocation Loc);
 
   void completeType(const EnumDecl *ED);

diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index a68d5109baf8..5bca92470f6f 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1638,6 +1638,13 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const 
CXXNewExpr *E) {
 RValue RV =
   EmitNewDeleteCall(*this, allocator, allocatorType, allocatorArgs);
 
+// Set !heapallocsite metadata on the call to operator new.
+if (getDebugInfo()) {
+  if (auto *newCall = dyn_cast(RV.getScalarVal()))
+getDebugInfo()->addHeapAllocSiteMetadata(newCall, allocType,
+ E->getExprLoc());
+}
+
 // If this was a call to a global replaceable allocation function that does
 // not take an alignment argument, the allocator is known to produce
 // storage that's suitably aligned for any object that fits, up to a known

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index b169462f535a..612a2ecef843 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2065,11 +2065,15 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
   }
 }
 
-// Update heapallocsite metadata when there is an explicit cast.
-if (llvm::CallInst *CI = dyn_cast(Src))
-  if (CI->getMetadata("heapallocsite") && isa(CE))
-  CGF.getDebugInfo()->
-  addHeapAllocSiteMetadata(CI, CE->getType(), CE->getExprLoc());
+// Update heapallocsite metadata when there is an 

[PATCH] D81176: [HIP] Add default header and include path

2020-06-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D81176#2077254 , @thakis wrote:

> Also still failing on mac: http://45.33.8.238/mac/14992/step_7.txt


I will try to fix it one more time. If it still fails I will revert it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81176



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


[PATCH] D81176: [HIP] Add default header and include path

2020-06-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D81176#2077319 , @thakis wrote:

> Still broken: http://45.33.8.238/win/16976/summary.html


reverted.

The difficulty for fixing these failures is that they only show up on some 
systems I do not have access and cannot see the complete output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81176



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


[PATCH] D81176: [HIP] Add default header and include path

2020-06-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Still broken: http://45.33.8.238/win/16976/summary.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81176



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


  1   2   >