[PATCH] D70512: [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-11-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall planned changes to this revision.
sammccall added a comment.

No, this patch is busted, and the tests were too simple go catch it.

The issue is that with no exclusivity check, given `{{{ MACRO }}}` all the 
enclosing blocks get to count themselves selected.

We need an exclusivity check on the expanded token stream first. This will 
yield a sequence of slices of tokens not yet claimed. Then each slice gets 
partitioned by FileID, each partition gets mapped to spelled tokens and checked 
as in this patch.

I suspect the exclusivity/claiming at the spelled token level is no longer 
needed.




Comment at: clang-tools-extra/clangd/Selection.cpp:49
+Result = New;
+  else if (Result != New)
+Result = SelectionTree::Partial;

hokein wrote:
> I might be missing something, I don't understand why we set Partial if 
> `Result != New`.
Added a brief comment and an assertion.
Intuitive explanation: Consider `Complete` = black, `Unselected` = white, 
`Partial` = grey.
White + White -> white, Black + Black -> black, every other mixture is grey.

(But honestly I wrote up the state transition table first and then extracted 
the logic by staring at it)



Comment at: clang-tools-extra/clangd/Selection.cpp:446
+// Consider the macro expansion FLAG(x) -> int x = 0;
+// Neither S.getBegin() nor S.getEnd() are arg expansions, but x is.
+// The selection FLAG([[x]]) must partially select the VarDecl.

hokein wrote:
> what's S for this case?
S is the function parameter, the implication is that it's the range of the 
vardecl in the example. Expanded the comment a bit.



Comment at: clang-tools-extra/clangd/Selection.cpp:496
+  // Check if the macro name is selected, don't claim it exclusively.
+  auto Expansion = SM.getDecomposedExpansionLoc(S.getBegin());
+  if (Expansion.first == SelFile)

hokein wrote:
> not sure what's the rational behavior, but I think for the following case, we 
> just have the TUDecl in the selection tree, maybe use the whole macro range?
> 
> ```
> #define M() 123
> 
> int d = M(^); // now we only have the TUDecl in the selection tree.
> ```
This is definitely better, but isn't trivial to do, and isn't a very important 
case.
Added a FIXME rather than clutter/delay this patch with it.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:125
+return {};
+  const Token *Begin =
+  llvm::partition_point(expandedTokens(), [&](const syntax::Token &T) {

hokein wrote:
> nit: for code readability, I'd use `llvm::ArrayRef::iterator` 
> type here.
I think that hurts readability on two counts:
 - it obscures the actual type: a pointer is concrete and familiar, so it's 
easier to realize that e.g. `>` is well-defined here
 - it makes it harder to understand `return {Begin, End}` which relies on the 
fact that the actual type here is Token*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70512



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


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-25 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 231004.
awpandey added a comment.

Thanks @dblaikie. I have updated go and C bindings. I have also added the 
release note for why these APIs are changing.


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

https://reviews.llvm.org/D70111

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-align.cpp
  llvm/bindings/go/llvm/dibuilder.go
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/test/DebugInfo/X86/debug-info-template-align.ll
  llvm/tools/llvm-c-test/debuginfo.c

Index: llvm/tools/llvm-c-test/debuginfo.c
===
--- llvm/tools/llvm-c-test/debuginfo.c
+++ llvm/tools/llvm-c-test/debuginfo.c
@@ -69,7 +69,7 @@
   LLVMMetadataRef Int64Ty =
   LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
   LLVMMetadataRef Int64TypeDef =
-LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File);
+  LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0);
 
   LLVMMetadataRef GlobalVarValueExpr =
   LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-align.ll
@@ -0,0 +1,63 @@
+; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;typedef char  __attribute__((__aligned__(64))) alchar;
+
+;int main(){
+;alchar newChar;
+;}
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; CHECK: .debug_abbrev contents:
+
+; CHECK: [5] DW_TAG_typedef  DW_CHILDREN_no
+; CHECK:  DW_AT_alignment DW_FORM_udata
+
+; CHECK: .debug_info contents:
+
+;CHECK: DW_TAG_typedef [5]
+;CHECK: DW_AT_name {{.*}} "alchar"
+;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64)
+
+
+; ModuleID = '/dir/test.cpp'
+source_filename = "/dir/test.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noinline norecurse nounwind optnone uwtable
+define dso_local i32 @main() #0 !dbg !7 {
+entry:
+  %newChar = alloca i8, align 64
+  call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15
+  ret i32 0, !dbg !16
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline norecurse nounwind optnone uwtable }
+attributes #1 = { nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "/dir/test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 5}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 10.0.0 "}
+!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DIFile(filename: "test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab")
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13)
+!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512)
+!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!15 = !DILocation(line: 13, column: 10, scope: !7)
+!16 = !DILocation(line: 14, column: 1, scope: !7)
Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -1108,11 +1108,10 @@
 LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
const char *Name, size_t NameLen,
LLVMMetadataRef File, unsigned LineNo,
-   LLVMMetadataRef Scope) {
+   LLVMMetadataRef Scope, uint32_t AlignInBits) {
   return wrap(unwrap(Builder)->createTypedef(
-  unwrapDI(Type), {Name, NameLen},
-  unwrapDI(File), LineNo,
-  unwrapDI(Scope)));
+  unwrapDI(Type), {Name, NameLen}, unwrapDI(File), LineNo,
+  unwrapDI(Scope), AlignInBits

Re: [PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-25 Thread Eric Christopher via cfe-commits
Aha, found it in the revert. Bunch of tests use -O1 and probably have
something specific in O1 they wanted.

-eric

On Mon, Nov 25, 2019 at 8:55 PM Eric Christopher  wrote:
>
> Usually nice to give a link if there is one :)
>
> On Mon, Nov 25, 2019, 8:42 PM Muhammad Omair Javaid via Phabricator 
>  wrote:
>>
>> omjavaid reopened this revision.
>> omjavaid added a comment.
>> This revision is now accepted and ready to land.
>>
>> Re-opening this because I have reverted the commit due to failures seen on 
>> LLDB AArch64 buildbot with this commit.
>>
>>
>> Repository:
>>   rG LLVM Github Monorepo
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D65410/new/
>>
>> https://reviews.llvm.org/D65410
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-25 Thread Eric Christopher via cfe-commits
Usually nice to give a link if there is one :)

On Mon, Nov 25, 2019, 8:42 PM Muhammad Omair Javaid via Phabricator <
revi...@reviews.llvm.org> wrote:

> omjavaid reopened this revision.
> omjavaid added a comment.
> This revision is now accepted and ready to land.
>
> Re-opening this because I have reverted the commit due to failures seen on
> LLDB AArch64 buildbot with this commit.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D65410/new/
>
> https://reviews.llvm.org/D65410
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-25 Thread Muhammad Omair Javaid via Phabricator via cfe-commits
omjavaid reopened this revision.
omjavaid added a comment.
This revision is now accepted and ready to land.

Re-opening this because I have reverted the commit due to failures seen on LLDB 
AArch64 buildbot with this commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65410



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


[clang] c9ddb02 - Revert "As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there."

2019-11-25 Thread Muhammad Omair Javaid via cfe-commits

Author: Muhammad Omair Javaid
Date: 2019-11-26T09:32:13+05:00
New Revision: c9ddb02659e3ece7a0d9d6b4dac7ceea4ae46e6d

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

LOG: Revert "As a follow-up to my initial mail to llvm-dev here's a first pass 
at the O1 described there."

This reverts commit 8ff85ed905a7306977d07a5cd67ab4d5a56fafb4.

This commit introduced 9 new failures on lldb buildbot host at 
http://lab.llvm.org:8014/builders/lldb-aarch64-ubuntu

Following tests were failing:
lldb-api :: 
functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
lldb-api :: 
functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
lldb-api :: 
functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
lldb-api :: 
functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py
lldb-api :: 
functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py
lldb-api :: 
functionalities/tail_call_frames/inlining_and_tail_calls/TestInliningAndTailCalls.py
lldb-api :: 
functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py
lldb-api :: 
functionalities/tail_call_frames/thread_step_out_message/TestArtificialFrameStepOutMessage.py
lldb-api :: 
functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py
lldb-api :: 
functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py

Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65410

Added: 


Modified: 
clang/test/CodeGen/2008-07-30-implicit-initialization.c
clang/test/CodeGen/arm-fp16-arguments.c
clang/test/CodeGen/arm-vfp16-arguments2.cpp
clang/test/CodeGen/atomic-ops-libcall.c
clang/test/CodeGenCXX/atomicinit.cpp
clang/test/CodeGenCXX/auto-var-init.cpp
clang/test/CodeGenCXX/discard-name-values.cpp
clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
clang/test/CodeGenCXX/nrvo.cpp
clang/test/CodeGenCXX/stack-reuse.cpp
clang/test/CodeGenCXX/wasm-args-returns.cpp
clang/test/CodeGenObjCXX/arc-blocks.mm
clang/test/CodeGenObjCXX/nrvo.mm
clang/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
clang/test/PCH/no-escaping-block-tail-calls.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
llvm/test/Feature/optnone-opt.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Transforms/MemCpyOpt/lifetime.ll
llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll

Removed: 




diff  --git a/clang/test/CodeGen/2008-07-30-implicit-initialization.c 
b/clang/test/CodeGen/2008-07-30-implicit-initialization.c
index f2621f4560ec..e77c70a140f9 100644
--- a/clang/test/CodeGen/2008-07-30-implicit-initialization.c
+++ b/clang/test/CodeGen/2008-07-30-implicit-initialization.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -O2 -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -emit-llvm -o - %s | 
FileCheck %s
 // CHECK-LABEL: define i32 @f0()
 // CHECK:   ret i32 0
 // CHECK-LABEL: define i32 @f1()

diff  --git a/clang/test/CodeGen/arm-fp16-arguments.c 
b/clang/test/CodeGen/arm-fp16-arguments.c
index 34dc1a1cbf6a..d739f4b9c66a 100644
--- a/clang/test/CodeGen/arm-fp16-arguments.c
+++ b/clang/test/CodeGen/arm-fp16-arguments.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fallow-half-arguments-and-returns -emit-llvm -o - -O2 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=SOFT
-// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
hard -fallow-half-arguments-and-returns -emit-llvm -o - -O2 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=HARD
-// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fnative-half-arguments-and-returns -emit-llvm -o - -O2 %s | FileCheck %s 
--check-prefix=NATIVE
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fallow-half-arguments-and-returns -emit-llvm -o - -O1 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=SOFT
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
hard -fallow-half-arguments-and-returns -emit-llvm -o - -O1 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=HARD
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fna

[PATCH] D69620: Add AIX assembler support

2019-11-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan marked an inline comment as done.
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:28
+  const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;

stevewan wrote:
> stevewan wrote:
> > Xiangling_L wrote:
> > > The definition of `claimNoWarnArgs` is to suppress warnings for some 
> > > options if they are unused, can you explain a little bit about how did 
> > > you figure out that we don't want warnings for those?
> > > 
> > > Some context of `claimNoWarnArgs`:
> > > 
> > > ```
> > > // Claim options we don't want to warn if they are unused. We do this for
> > > // options that build systems might add but are unused when assembling or 
> > > only
> > > // running the preprocessor for example.
> > > void tools::claimNoWarnArgs(const ArgList &Args) {
> > >   // Don't warn about unused -f(no-)?lto.  This can happen when we're
> > >   // preprocessing, precompiling or assembling.
> > >   Args.ClaimAllArgs(options::OPT_flto_EQ);
> > >   Args.ClaimAllArgs(options::OPT_flto);
> > >   Args.ClaimAllArgs(options::OPT_fno_lto);
> > > }
> > > ```
> > > 
> > The original reason was that, since we are doing assembling here, and as 
> > stated in `claimNoWarnArgs`, there might be an unused `-f(no-)?lto` when 
> > we're assembling, and we'd like to suppress the warning(s) for that. 
> > 
> > Looking into it, the three options [[ 
> > https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
> >  | `flto`, `fno_lto` ]] , and [[ 
> > https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-flto
> >  | `flto_EQ` ]] are used to enable/disable link time optimization, but LTO 
> > is not supported by the AIX system linker. Driver would just throw error if 
> > the user passes it `-flto` or `-flto=` on AIX, so claiming them or not 
> > currently makes no actual difference as far as I'm concerned. 
> > 
> > That being said, I don't have a strong opinion either way. Let's see how 
> > other people think.
> It's probably also worth mentioning that, adding `claimNoWarnArgs` does not 
> affect those LTO options being parsed and consumed by the driver in 
> `Driver::setLTOMode`.
Turned out `Driver::BuildCompilation` would always call `Driver::setLTOMode`, 
which inherently sets the three LTO options to "claimed". This happens before 
the driver gets to assembler invocation, hence no need to call 
`claimNoWarnArgs` here.

For future reference, I'm also documenting here that `claimNoWarnArgs` was 
added in [[ https://reviews.llvm.org/rL225100 | rL225100 ]], which was 
originally posted to fix build bots that failed due to warnings from unused LTO 
options. `setLTOMode` was introduced months later in [[ 
https://reviews.llvm.org/rL250455 | rL250455 ]], which claims the three LTO 
options during `BuildCompilation`.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:61
+
+  // Specify assembler input file(s).
+  for (const auto &II : Inputs)

hubert.reinterpretcast wrote:
> The AIX assembler does not accept more than one input file. If the intent is 
> to let the assembler produce the error message, then I think we should at 
> least have a comment to acknowledge the situation.
Good point. I didn't intend to leave this to assembler. Looking into it, when 
presented multiple assembly sources, the driver would invoke `as` to assemble 
each of the input files individually. This behaviour also matches that of GCC 
and XL. In case something goes wrong and the driver attempts to pass multiple 
input files to `as`, adding a check to guard the number of inputs probably 
makes sense?



Comment at: clang/test/Driver/aix-as.c:31
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32-PTHREAD %s
+// CHECK-AS32-PTHREAD-NOT: warning:

hubert.reinterpretcast wrote:
> I am not getting how this block is related to "pthread".
Looks like I copy-pasted the wrong thing while rebasing. Good catch, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69620



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


[PATCH] D69620: Add AIX assembler support

2019-11-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 231000.
stevewan marked 12 inline comments as done.
stevewan added a comment.

Remove claimNoWarnArgs, limit the number of input files, and add more comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69620

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/aix-as.c

Index: clang/test/Driver/aix-as.c
===
--- /dev/null
+++ clang/test/Driver/aix-as.c
@@ -0,0 +1,52 @@
+// General tests that as(1) invocations on AIX targets are sane. Note that we
+// only test assembler functionalities in this suite.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32 %s
+// CHECK-AS32-NOT: warning:
+// CHECK-AS32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-AS32: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS32: "-a32" 
+// CHECK-AS32: "-u" 
+// CHECK-AS32: "-many" 
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS64 %s
+// CHECK-AS64-NOT: warning:
+// CHECK-AS64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-AS64: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS64: "-a64" 
+// CHECK-AS64: "-u" 
+// CHECK-AS64: "-many"
+
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. -Xassembler  option. 
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -Xassembler -w \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32-Xassembler %s
+// CHECK-AS32-Xassembler-NOT: warning:
+// CHECK-AS32-Xassembler: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-AS32-Xassembler: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS32-Xassembler: "-a32" 
+// CHECK-AS32-Xassembler: "-u" 
+// CHECK-AS32-Xassembler: "-many"
+// CHECK-AS32-Xassembler: "-w"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -Wa,, option.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -Wa,-v,-w \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS64-Wa %s
+// CHECK-AS64-Wa-NOT: warning:
+// CHECK-AS64-Wa: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-AS64-Wa: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS64-Wa: "-a64" 
+// CHECK-AS64-Wa: "-u" 
+// CHECK-AS64-Wa: "-many"
+// CHECK-AS64-Wa: "-v"
+// CHECK-AS64-Wa: "-w"
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -16,10 +16,21 @@
 namespace driver {
 namespace tools {
 
-/// aix -- Directly call system default linker.
-// TODO: Enable direct call to system default assembler.
+/// aix -- Directly call system default assembler and linker.
 namespace aix {
 
+class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
+public:
+  Assembler(const ToolChain &TC) : Tool("aix::Assembler", "assembler", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 public:
   Linker(const ToolChain &TC) : Tool("aix::Linker", "linker", TC) {}
@@ -53,6 +64,7 @@
   bool isPICDefaultForced() const override { return true; }
 
 protected:
+  Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
 };
 
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -20,6 +20,60 @@
 
 using namespace llvm::opt;
 
+void aix::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
+  const InputInfo &Output,
+  const InputInfoList &Inputs,
+  const ArgList &Args,
+  const char *LinkingOutput) const {
+  ArgStringList CmdArgs;
+
+  const bool IsArch32Bit = getToolChain().getTriple().isArch32Bit();
+  const bool IsArch64Bit = getToolChain().getTriple().isArch64Bit();
+  // Only support 32 and 64 bit.
+  if (!IsArch32Bit && !IsArch64Bit)
+llvm_unreachable("Unsupported bit width value.");
+
+  // Specify the mode in which the as(1) command operates.
+  if (IsArch32Bit) {
+CmdArgs.push_back("-a32");
+  } else {
+// Must be 64-bit, otherwise a

[PATCH] D70671: [clang][CodeGen] Fix wrong memcpy size of no_unique_address in FieldMemcpyizer

2019-11-25 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01d8e09fdba0: [clang][CodeGen] Fix wrong memcpy size of 
no_unique_address in FieldMemcpyizer (authored by zsrkmyn, committed by 
MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D70671?vs=230991&id=230994#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70671

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/no-unique-address-2.cpp


Index: clang/test/CodeGenCXX/no-unique-address-2.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no-unique-address-2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++2a %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s
+
+struct TriviallyCopyable {};
+
+struct NonTriviallyCopyable {
+  NonTriviallyCopyable() = default;
+  NonTriviallyCopyable(const NonTriviallyCopyable&) = default;
+  NonTriviallyCopyable(NonTriviallyCopyable &&) {}
+};
+
+struct Foo {
+  int i;
+  [[no_unique_address]] TriviallyCopyable m;
+  [[no_unique_address]] NonTriviallyCopyable n;
+};
+
+void call() {
+  Foo foo;
+  Foo foo2(static_cast(foo));
+}
+
+// The memcpy call should copy exact 4 bytes for member 'int i'
+// CHECK: define {{.*}} void @_ZN3FooC2EOS_
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.+}}, i8* {{.+}}, i64 4, 
i1 false)
+// CHECK:  call void @_ZN20NonTriviallyCopyableC2EOS_
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -914,6 +914,8 @@
 }
 
 void addMemcpyableField(FieldDecl *F) {
+  if (F->isZeroSize(CGF.getContext()))
+return;
   if (!FirstField)
 addInitialField(F);
   else


Index: clang/test/CodeGenCXX/no-unique-address-2.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no-unique-address-2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++2a %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
+
+struct TriviallyCopyable {};
+
+struct NonTriviallyCopyable {
+  NonTriviallyCopyable() = default;
+  NonTriviallyCopyable(const NonTriviallyCopyable&) = default;
+  NonTriviallyCopyable(NonTriviallyCopyable &&) {}
+};
+
+struct Foo {
+  int i;
+  [[no_unique_address]] TriviallyCopyable m;
+  [[no_unique_address]] NonTriviallyCopyable n;
+};
+
+void call() {
+  Foo foo;
+  Foo foo2(static_cast(foo));
+}
+
+// The memcpy call should copy exact 4 bytes for member 'int i'
+// CHECK: define {{.*}} void @_ZN3FooC2EOS_
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.+}}, i8* {{.+}}, i64 4, i1 false)
+// CHECK:  call void @_ZN20NonTriviallyCopyableC2EOS_
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -914,6 +914,8 @@
 }
 
 void addMemcpyableField(FieldDecl *F) {
+  if (F->isZeroSize(CGF.getContext()))
+return;
   if (!FirstField)
 addInitialField(F);
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 01d8e09 - [clang][CodeGen] Fix wrong memcpy size of no_unique_address in FieldMemcpyizer

2019-11-25 Thread Fangrui Song via cfe-commits

Author: Senran Zhang
Date: 2019-11-25T18:15:34-08:00
New Revision: 01d8e09fdba0c9d3fe316a86e5ce4481e6ed71d1

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

LOG: [clang][CodeGen] Fix wrong memcpy size of no_unique_address in 
FieldMemcpyizer

When generating ctor, FieldMemcpyizer wrongly treated zero-sized class members
as what should be copied, and generated wrong memcpy size under some special
circumstances. This patch tries to fix it.

Reviewed By: MaskRay, rjmccall

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

Added: 
clang/test/CodeGenCXX/no-unique-address-2.cpp

Modified: 
clang/lib/CodeGen/CGClass.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 04ef912b18bd..d07b1c665cc4 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -914,6 +914,8 @@ namespace {
 }
 
 void addMemcpyableField(FieldDecl *F) {
+  if (F->isZeroSize(CGF.getContext()))
+return;
   if (!FirstField)
 addInitialField(F);
   else

diff  --git a/clang/test/CodeGenCXX/no-unique-address-2.cpp 
b/clang/test/CodeGenCXX/no-unique-address-2.cpp
new file mode 100644
index ..aa0c67758a19
--- /dev/null
+++ b/clang/test/CodeGenCXX/no-unique-address-2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++2a %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s
+
+struct TriviallyCopyable {};
+
+struct NonTriviallyCopyable {
+  NonTriviallyCopyable() = default;
+  NonTriviallyCopyable(const NonTriviallyCopyable&) = default;
+  NonTriviallyCopyable(NonTriviallyCopyable &&) {}
+};
+
+struct Foo {
+  int i;
+  [[no_unique_address]] TriviallyCopyable m;
+  [[no_unique_address]] NonTriviallyCopyable n;
+};
+
+void call() {
+  Foo foo;
+  Foo foo2(static_cast(foo));
+}
+
+// The memcpy call should copy exact 4 bytes for member 'int i'
+// CHECK: define {{.*}} void @_ZN3FooC2EOS_
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.+}}, i8* {{.+}}, i64 4, 
i1 false)
+// CHECK:  call void @_ZN20NonTriviallyCopyableC2EOS_



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


[clang] 6f77320 - Revert "Use InitLLVM to setup a pretty stack printer"

2019-11-25 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2019-11-25T21:06:56-05:00
New Revision: 6f773205cd05e47912096d7c4091f03c28255ab2

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

LOG: Revert "Use InitLLVM to setup a pretty stack printer"

This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea.
Breaks at least these tests on Windows:
Clang :: Driver/clang-offload-bundler.c
Clang :: Driver/clang-offload-wrapper.c

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/clang-move/tool/ClangMove.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/indexer/IndexerMain.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/tool-template/ToolTemplate.cpp
clang/tools/arcmt-test/arcmt-test.cpp
clang/tools/c-index-test/core_main.cpp
clang/tools/clang-check/ClangCheck.cpp
clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
clang/utils/TableGen/TableGen.cpp
llvm/utils/KillTheDoctor/KillTheDoctor.cpp
llvm/utils/TableGen/TableGen.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
index a567d7f82dea..a97be99b0bd8 100644
--- a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
@@ -37,7 +37,6 @@
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/YAMLTraits.h"
 
@@ -99,7 +98,7 @@ llvm::ErrorOr> 
GetWhiteListedSymbolPatterns() {
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv,
  ChangeNamespaceCategory);
   const auto &Files = OptionsParser.getSourcePathList();

diff  --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index d27a012b78ff..38b781ed39f4 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -36,7 +36,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
@@ -180,7 +179,7 @@ llvm::Expected> 
getInfoOutputFile(StringRef Root,
 }
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   std::error_code OK;
 
   ExecutorName.setInitialValue("all-TUs");

diff  --git a/clang-tools-extra/clang-move/tool/ClangMove.cpp 
b/clang-tools-extra/clang-move/tool/ClangMove.cpp
index fdf83ab4604b..2df7df7fe3a7 100644
--- a/clang-tools-extra/clang-move/tool/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/tool/ClangMove.cpp
@@ -15,7 +15,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
@@ -95,7 +94,7 @@ cl::opt DumpDecls(
 } // namespace
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv, ClangMoveCategory);
 
   if (OldDependOnNew && NewDependOnOld) {

diff  --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp 
b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
index 56a1e25e1447..80e1c602796c 100644
--- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -33,7 +33,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include 
@@ -82,7 +81,7 @@ bool runCommandsInFile(const char *ExeName, std::string const 
&FileName,
 }
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  l

[PATCH] D70702: Use InitLLVM to setup a pretty stack printer

2019-11-25 Thread Rui Ueyama via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f76260dc067: Use InitLLVM to setup a pretty stack printer 
(authored by ruiu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70702

Files:
  clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/tool-template/ToolTemplate.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  clang/tools/c-index-test/core_main.cpp
  clang/tools/clang-check/ClangCheck.cpp
  clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/utils/TableGen/TableGen.cpp
  llvm/utils/KillTheDoctor/KillTheDoctor.cpp
  llvm/utils/TableGen/TableGen.cpp

Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -12,6 +12,7 @@
 
 #include "TableGenBackends.h" // Declares all backends.
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -266,8 +267,7 @@
 }
 
 int main(int argc, char **argv) {
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
-  PrettyStackTraceProgram X(argc, argv);
+  llvm::InitLLVM X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
 
   llvm_shutdown_obj Y;
Index: llvm/utils/KillTheDoctor/KillTheDoctor.cpp
===
--- llvm/utils/KillTheDoctor/KillTheDoctor.cpp
+++ llvm/utils/KillTheDoctor/KillTheDoctor.cpp
@@ -36,6 +36,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
@@ -295,8 +296,7 @@
 
 int main(int argc, char **argv) {
   // Print a stack trace if we signal out.
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
-  PrettyStackTraceProgram X(argc, argv);
+  llvm::InitLLVM X(argc, argv);
   llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   ToolName = argv[0];
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -10,9 +10,10 @@
 //
 //===--===//
 
-#include "TableGenBackends.h" // Declares all backends.
 #include "ClangASTEmitters.h"
+#include "TableGenBackends.h" // Declares all backends.
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/TableGen/Error.h"
@@ -349,8 +350,7 @@
 }
 
 int main(int argc, char **argv) {
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
-  PrettyStackTraceProgram X(argc, argv);
+  llvm::InitLLVM X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
 
   llvm_shutdown_obj Y;
Index: clang/tools/clang-refactor/ClangRefactor.cpp
===
--- clang/tools/clang-refactor/ClangRefactor.cpp
+++ clang/tools/clang-refactor/ClangRefactor.cpp
@@ -24,6 +24,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -608,7 +609,7 @@
 } // end anonymous namespace
 
 int main(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
 
   ClangRefactorTool RefactorTool;
 
Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -303,7 +304,7 @@
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::In

[clang] 3f76260 - Use InitLLVM to setup a pretty stack printer

2019-11-25 Thread Rui Ueyama via cfe-commits

Author: Rui Ueyama
Date: 2019-11-26T10:56:10+09:00
New Revision: 3f76260dc0674cc0acb25f550a0f0c594cf537ea

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

LOG: Use InitLLVM to setup a pretty stack printer

InitLLVM does not only save a few lines from main() but also makes the
commands do the right thing for multibyte character pathnames on
Windows (i.e. canonicalize argv's to UTF-8) because of the code we
have in this file:

https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32

For many LLVM commands, we already have calls of InitLLVM, but there
are still remainings.

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

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/clang-move/tool/ClangMove.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/indexer/IndexerMain.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/tool-template/ToolTemplate.cpp
clang/tools/arcmt-test/arcmt-test.cpp
clang/tools/c-index-test/core_main.cpp
clang/tools/clang-check/ClangCheck.cpp
clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
clang/utils/TableGen/TableGen.cpp
llvm/utils/KillTheDoctor/KillTheDoctor.cpp
llvm/utils/TableGen/TableGen.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
index a97be99b0bd8..a567d7f82dea 100644
--- a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
@@ -37,6 +37,7 @@
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/YAMLTraits.h"
 
@@ -98,7 +99,7 @@ llvm::ErrorOr> 
GetWhiteListedSymbolPatterns() {
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
   tooling::CommonOptionsParser OptionsParser(argc, argv,
  ChangeNamespaceCategory);
   const auto &Files = OptionsParser.getSourcePathList();

diff  --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 38b781ed39f4..d27a012b78ff 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
@@ -179,7 +180,7 @@ llvm::Expected> 
getInfoOutputFile(StringRef Root,
 }
 
 int main(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
   std::error_code OK;
 
   ExecutorName.setInitialValue("all-TUs");

diff  --git a/clang-tools-extra/clang-move/tool/ClangMove.cpp 
b/clang-tools-extra/clang-move/tool/ClangMove.cpp
index 2df7df7fe3a7..fdf83ab4604b 100644
--- a/clang-tools-extra/clang-move/tool/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/tool/ClangMove.cpp
@@ -15,6 +15,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
@@ -94,7 +95,7 @@ cl::opt DumpDecls(
 } // namespace
 
 int main(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
   tooling::CommonOptionsParser OptionsParser(argc, argv, ClangMoveCategory);
 
   if (OldDependOnNew && NewDependOnOld) {

diff  --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp 
b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
index 80e1c602796c..56a1e25e1447 100644
--- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -33,6 +33,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #incl

[PATCH] D70671: [clang][CodeGen] Fix wrong memcpy size of no_unique_address in FieldMemcpyizer

2019-11-25 Thread Senran Zhang via Phabricator via cfe-commits
zsrkmyn updated this revision to Diff 230991.
zsrkmyn added a comment.

Thanks for reviewing! Would you mind helping me commit this patch? Thanks :-D


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

https://reviews.llvm.org/D70671

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/no-unique-address-2.cpp


Index: clang/test/CodeGenCXX/no-unique-address-2.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no-unique-address-2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++2a %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s
+
+struct TriviallyCopyable {};
+
+struct NonTriviallyCopyable {
+  NonTriviallyCopyable() = default;
+  NonTriviallyCopyable(const NonTriviallyCopyable&) = default;
+  NonTriviallyCopyable(NonTriviallyCopyable &&) {}
+};
+
+struct Foo {
+  int i;
+  [[no_unique_address]] TriviallyCopyable m;
+  [[no_unique_address]] NonTriviallyCopyable n;
+};
+
+void call() {
+  Foo foo;
+  Foo foo2(static_cast(foo));
+}
+
+// The memcpy call should copy exact 4 bytes for member 'int i'
+// CHECK: define {{.*}} void @_ZN3FooC2EOS_
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.+}}, i8* {{.+}}, i64 4, 
i1 false)
+// CHECK:  call void @_ZN20NonTriviallyCopyableC2EOS_
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -914,6 +914,8 @@
 }
 
 void addMemcpyableField(FieldDecl *F) {
+  if (F->isZeroSize(CGF.getContext()))
+return;
   if (!FirstField)
 addInitialField(F);
   else


Index: clang/test/CodeGenCXX/no-unique-address-2.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no-unique-address-2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++2a %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
+
+struct TriviallyCopyable {};
+
+struct NonTriviallyCopyable {
+  NonTriviallyCopyable() = default;
+  NonTriviallyCopyable(const NonTriviallyCopyable&) = default;
+  NonTriviallyCopyable(NonTriviallyCopyable &&) {}
+};
+
+struct Foo {
+  int i;
+  [[no_unique_address]] TriviallyCopyable m;
+  [[no_unique_address]] NonTriviallyCopyable n;
+};
+
+void call() {
+  Foo foo;
+  Foo foo2(static_cast(foo));
+}
+
+// The memcpy call should copy exact 4 bytes for member 'int i'
+// CHECK: define {{.*}} void @_ZN3FooC2EOS_
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.+}}, i8* {{.+}}, i64 4, i1 false)
+// CHECK:  call void @_ZN20NonTriviallyCopyableC2EOS_
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -914,6 +914,8 @@
 }
 
 void addMemcpyableField(FieldDecl *F) {
+  if (F->isZeroSize(CGF.getContext()))
+return;
   if (!FirstField)
 addInitialField(F);
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70702: Use InitLLVM to setup a pretty stack printer

2019-11-25 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu created this revision.
ruiu added a reviewer: MaskRay.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added projects: clang, LLVM.

InitLLVM does not only save a few lines from main() but also makes the
commands do the right thing for multibyte character pathnames on
Windows (i.e. canonicalize argv's to UTF-8) because of the code we
have in this file:

https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32

For many LLVM commands, we already have calls of InitLLVM, but there
are still remainings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70702

Files:
  clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/tool-template/ToolTemplate.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  clang/tools/c-index-test/core_main.cpp
  clang/tools/clang-check/ClangCheck.cpp
  clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/utils/TableGen/TableGen.cpp
  llvm/utils/KillTheDoctor/KillTheDoctor.cpp
  llvm/utils/TableGen/TableGen.cpp

Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -12,6 +12,7 @@
 
 #include "TableGenBackends.h" // Declares all backends.
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -266,8 +267,7 @@
 }
 
 int main(int argc, char **argv) {
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
-  PrettyStackTraceProgram X(argc, argv);
+  llvm::InitLLVM X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
 
   llvm_shutdown_obj Y;
Index: llvm/utils/KillTheDoctor/KillTheDoctor.cpp
===
--- llvm/utils/KillTheDoctor/KillTheDoctor.cpp
+++ llvm/utils/KillTheDoctor/KillTheDoctor.cpp
@@ -36,6 +36,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
@@ -295,8 +296,7 @@
 
 int main(int argc, char **argv) {
   // Print a stack trace if we signal out.
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
-  PrettyStackTraceProgram X(argc, argv);
+  llvm::InitLLVM X(argc, argv);
   llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   ToolName = argv[0];
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -10,9 +10,10 @@
 //
 //===--===//
 
-#include "TableGenBackends.h" // Declares all backends.
 #include "ClangASTEmitters.h"
+#include "TableGenBackends.h" // Declares all backends.
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/TableGen/Error.h"
@@ -349,8 +350,7 @@
 }
 
 int main(int argc, char **argv) {
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
-  PrettyStackTraceProgram X(argc, argv);
+  llvm::InitLLVM X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
 
   llvm_shutdown_obj Y;
Index: clang/tools/clang-refactor/ClangRefactor.cpp
===
--- clang/tools/clang-refactor/ClangRefactor.cpp
+++ clang/tools/clang-refactor/ClangRefactor.cpp
@@ -24,6 +24,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -608,7 +609,7 @@
 } // end anonymous namespace
 
 int main(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
 
   ClangRefactorTool RefactorTool;
 
Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"

[PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-25 Thread Eric Christopher via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ff85ed905a7: As a follow-up to my initial mail to llvm-dev 
here's a first pass at the O1… (authored by echristo).

Changed prior to commit:
  https://reviews.llvm.org/D65410?vs=228339&id=230987#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65410

Files:
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/atomic-ops-libcall.c
  clang/test/CodeGenCXX/atomicinit.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/discard-name-values.cpp
  clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/stack-reuse.cpp
  clang/test/CodeGenCXX/wasm-args-returns.cpp
  clang/test/CodeGenObjCXX/arc-blocks.mm
  clang/test/CodeGenObjCXX/nrvo.mm
  clang/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
  clang/test/PCH/no-escaping-block-tail-calls.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
  llvm/test/Feature/optnone-opt.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Transforms/MemCpyOpt/lifetime.ll
  llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
  llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll

Index: llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
===
--- llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
+++ llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
@@ -74,7 +74,7 @@
 define i32 @two_shifts_by_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
@@ -101,7 +101,7 @@
 define i32 @two_shifts_by_same_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_same_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
Index: llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
===
--- llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
+++ llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
@@ -7,7 +7,7 @@
 
 define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
 ; ALL-LABEL: @PR33605(
-; ALL-NEXT:  for.body:
+; ALL-NEXT:  entry:
 ; ALL-NEXT:[[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
 ; ALL-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
 ; ALL-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
@@ -15,16 +15,16 @@
 ; ALL-NEXT:br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
 ; ALL:   if.then:
 ; ALL-NEXT:store i32 [[OR]], i32* [[ARRAYIDX]], align 4
-; ALL-NEXT:tail call void @foo()
+; ALL-NEXT:call void @foo()
 ; ALL-NEXT:br label [[IF_END]]
 ; ALL:   if.end:
-; ALL-NEXT:[[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
+; ALL-NEXT:[[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[ENTRY:%.*]] ]
 ; ALL-NEXT:[[TMP1:%.*]] = load i32, i32* [[C]], align 4
 ; ALL-NEXT:[[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
 ; ALL-NEXT:br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
 ; ALL:   if.then.1:
 ; ALL-NEXT:store i32 [[OR]], i32* [[C]], align 4
-; ALL-NEXT:tail call void @foo()
+; ALL-NEXT:call void @foo()
 ; ALL-NEXT:br label [[IF_END_1]]
 ; ALL:   if.end.1:
 ; ALL-NEXT:[[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ]
Index: llvm/test/Transforms/MemCpyOpt/lifetime.ll
===
--- llvm/test/Transforms/MemCpyOpt/lifetime.ll
+++ llvm/test/Transforms/MemCpyOpt/lifetime.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -O1 -S | FileCheck %s
+; RUN: opt < %s -O2 -S | FileCheck %s
 
 ; performCallSlotOptzn in MemCpy should not exchange the calls to
 ; @llvm.lifetime.start and @llvm.memcpy.
Index: llvm/test/Other/new-pm-thinlto-defaults.ll
==

[clang] 8ff85ed - As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.

2019-11-25 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2019-11-25T17:16:46-08:00
New Revision: 8ff85ed905a7306977d07a5cd67ab4d5a56fafb4

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

LOG: As a follow-up to my initial mail to llvm-dev here's a first pass at the 
O1 described there.

This change doesn't include any change to move from selection dag to fast isel
and that will come with other numbers that should help inform that decision.
There also haven't been any real debuggability studies with this pipeline yet,
this is just the initial start done so that people could see it and we could 
start
tweaking after.

Test updates: Outside of the newpm tests most of the updates are coming from 
either
optimization passes not run anymore (and without a compelling argument at the 
moment)
that were largely used for canonicalization in clang.

Original post:

http://lists.llvm.org/pipermail/llvm-dev/2019-April/131494.html

Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65410

Added: 


Modified: 
clang/test/CodeGen/2008-07-30-implicit-initialization.c
clang/test/CodeGen/arm-fp16-arguments.c
clang/test/CodeGen/arm-vfp16-arguments2.cpp
clang/test/CodeGen/atomic-ops-libcall.c
clang/test/CodeGenCXX/atomicinit.cpp
clang/test/CodeGenCXX/auto-var-init.cpp
clang/test/CodeGenCXX/discard-name-values.cpp
clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
clang/test/CodeGenCXX/nrvo.cpp
clang/test/CodeGenCXX/stack-reuse.cpp
clang/test/CodeGenCXX/wasm-args-returns.cpp
clang/test/CodeGenObjCXX/arc-blocks.mm
clang/test/CodeGenObjCXX/nrvo.mm
clang/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
clang/test/PCH/no-escaping-block-tail-calls.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
llvm/test/Feature/optnone-opt.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Transforms/MemCpyOpt/lifetime.ll
llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll

Removed: 




diff  --git a/clang/test/CodeGen/2008-07-30-implicit-initialization.c 
b/clang/test/CodeGen/2008-07-30-implicit-initialization.c
index e77c70a140f9..f2621f4560ec 100644
--- a/clang/test/CodeGen/2008-07-30-implicit-initialization.c
+++ b/clang/test/CodeGen/2008-07-30-implicit-initialization.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O2 -emit-llvm -o - %s | 
FileCheck %s
 // CHECK-LABEL: define i32 @f0()
 // CHECK:   ret i32 0
 // CHECK-LABEL: define i32 @f1()

diff  --git a/clang/test/CodeGen/arm-fp16-arguments.c 
b/clang/test/CodeGen/arm-fp16-arguments.c
index d739f4b9c66a..34dc1a1cbf6a 100644
--- a/clang/test/CodeGen/arm-fp16-arguments.c
+++ b/clang/test/CodeGen/arm-fp16-arguments.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fallow-half-arguments-and-returns -emit-llvm -o - -O1 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=SOFT
-// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
hard -fallow-half-arguments-and-returns -emit-llvm -o - -O1 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=HARD
-// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fnative-half-arguments-and-returns -emit-llvm -o - -O1 %s | FileCheck %s 
--check-prefix=NATIVE
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fallow-half-arguments-and-returns -emit-llvm -o - -O2 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=SOFT
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
hard -fallow-half-arguments-and-returns -emit-llvm -o - -O2 %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=HARD
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fnative-half-arguments-and-returns -emit-llvm -o - -O2 %s | FileCheck %s 
--check-prefix=NATIVE
 
 __fp16 g;
 

diff  --git a/clang/test/CodeGen/arm-vfp16-arguments2.cpp 
b/clang/test/CodeGen/arm-vfp16-arguments2.cpp
index 4f75971d8327..e436a5ecd6ab 100644
--- a/clang/test/CodeGen/arm-vfp16-arguments2.cpp
+++ b/clang/test/CodeGen/arm-vfp16-arguments2.cpp
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs \
-// RUN:   -mfloat-abi soft -target-feature +neon -emit-llvm -o - -O1 %s \
+// RUN:   -mfloat-abi soft -target-feature +neon -emit-llvm -o - -O2 %s \
 // RUN:   | FileCheck %s --check-prefix=CHECK-SOF

[PATCH] D70671: [clang][CodeGen] Fix wrong memcpy size of no_unique_address in FieldMemcpyizer

2019-11-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/test/CodeGenCXX/no-unique-address-2.cpp:17
+
+void call()
+{

`{` on the same line of `call()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70671



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


[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:336-338
+ProgramStateRef FuchsiaHandleChecker::evalAssume(ProgramStateRef State,
+ SVal Cond,
+ bool Assumption) const {

xazax.hun wrote:
> NoQ wrote:
> > Ok, so you're basically saying that whenever the code under analysis does 
> > anything to check the return value, this callback will fire immediately? 
> > Thus guaranteeing that whenever the Schrödinger state is accessed, it's 
> > either already collapsed or indeed not checked yet?
> > 
> > This sounds right but i wish i had your confidence :D
> > 
> > My usual approach to Schrödinger states will be to do the same thing but in 
> > `checkDeadSymbols()`. I.e., when the return value symbol dies, see if it's 
> > constrained and collapse the state accordingly. If the access occurs 
> > earlier than symbol death, update the state according to the current 
> > constraints and forget about the symbol. If current constraints are 
> > insufficient, conservatively mark it as a successful release (as that's how 
> > non-paranoid code under analysis would behave).
> > 
> > Regardless of the approach, you still need to update the state upon access 
> > as if the release has succeeded (when the current state is a Schrödinger 
> > state). But with your approach you can avoid checking the constraints upon 
> > access, and instead blindly assume that the symbol is underconstrained.
> > 
> > I like this! Can we prove that it works by adding an assertion that the 
> > return value symbol is underconstrained upon every access to the 
> > potentially Schrödinger state?
> Yeah, you got my intention right! I was also thinking about doing this in 
> `checkDeadSymbols`, but I was wondering if that is ultimately the right thing 
> to do. It might be possible to write code where the symbol for the error code 
> becomes dead too late, so we keep the Schrödinger state longer than 
> necessary. Redoing this when we access the handle makes sense though! I think 
> that could probably perform better compared to my approach with `evalAssume`.
> 
> My only problem at this point do not really know when is a handle in a 
> Schrödinger state.  Do you recommend specifying a distinct state for that?
Hmm, `evalAssume` does not get a `CheckerContext`, so it cannot really use 
`SValBuilder` to do more complicated queries, like check if a symbol is greater 
or equal to zero rather than just equal to.

I wonder, is this intentional? Should I just use the `checkDeadSymbol` method 
instead or should I add `CheckerContext` to `evalAssume`?


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

https://reviews.llvm.org/D70470



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


[PATCH] D70671: [clang][CodeGen] Fix wrong memcpy size of no_unique_address in FieldMemcpyizer

2019-11-25 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall 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/D70671/new/

https://reviews.llvm.org/D70671



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


[PATCH] D70605: [OpenCL] Fix address space for implicit conversion (PR43145)

2019-11-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Is there a similar problem with reference parameters?


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

https://reviews.llvm.org/D70605



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


[clang] 890c6ef - [X86] Remove forward declaration of _invpcid from intrin.h. Rely on inline version from immintrin.h

2019-11-25 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2019-11-25T16:27:39-08:00
New Revision: 890c6ef1fb1350dd8e6b7b25da411cffbeaf6553

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

LOG: [X86] Remove forward declaration of _invpcid from intrin.h. Rely on inline 
version from immintrin.h

The forward declaration had a cdecl calling convention, but the
inline version did not. This leads to a conflict if the default
calling convention is not cdecl. Fix this by just removing the
forward declaration.

Fixes PR41503

Added: 


Modified: 
clang/lib/Headers/intrin.h

Removed: 




diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index a73a576bc7a3..f85f7a2beb49 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -169,7 +169,6 @@ long _InterlockedExchangeAdd_HLEAcquire(long volatile *, 
long);
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-void __cdecl _invpcid(unsigned int, void *);
 static __inline__ void
 __attribute__((__deprecated__("use other intrinsics or C++11 atomics 
instead")))
 _ReadBarrier(void);



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


[PATCH] D70701: Fix more VFS tests on Windows

2019-11-25 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth created this revision.
amccarth added reviewers: rnk, vsapsai, arphaman, Bigcheese.
Herald added subscribers: dexonsmith, hiraditya.
Herald added a project: LLVM.

Since VFS paths can be in either Posix or Windows style, we have to use a more 
flexible definition of "absolute" path.

The key here is that FileSystem::makeAbsolute is now virtual, and the 
RedirectingFileSystem override checks for either concept of absolute before 
trying to make the path absolute by combining it with the current directory.


https://reviews.llvm.org/D70701

Files:
  clang/test/VFS/vfsroot-include.c
  clang/test/VFS/vfsroot-module.m
  clang/test/VFS/vfsroot-with-overlay.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp

Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1073,6 +1073,19 @@
   return ExternalFS->isLocal(Path, Result);
 }
 
+std::error_code RedirectingFileSystem::makeAbsolute(SmallVectorImpl &Path) const {
+  if (llvm::sys::path::is_absolute(Path, llvm::sys::path::Style::posix) ||
+  llvm::sys::path::is_absolute(Path, llvm::sys::path::Style::windows))
+return {};
+
+  auto WorkingDir = getCurrentWorkingDirectory();
+  if (!WorkingDir)
+return WorkingDir.getError();
+
+  llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
+  return {};
+}
+
 directory_iterator RedirectingFileSystem::dir_begin(const Twine &Dir,
 std::error_code &EC) {
   ErrorOr E = lookupPath(Dir);
@@ -1428,21 +1441,31 @@
   return nullptr;
 }
 
-if (IsRootEntry && !sys::path::is_absolute(Name)) {
-  assert(NameValueNode && "Name presence should be checked earlier");
-  error(NameValueNode,
-"entry with relative path at the root level is not discoverable");
-  return nullptr;
+sys::path::Style path_style = sys::path::Style::native;
+if (IsRootEntry) {
+  // VFS root entries may be in either Posix or Windows style.  Figure out
+  // which style we have, and use it consistently.
+  if (sys::path::is_absolute(Name, sys::path::Style::posix)) {
+path_style = sys::path::Style::posix;
+  } else if (sys::path::is_absolute(Name, sys::path::Style::windows)) {
+path_style = sys::path::Style::windows;
+  } else {
+assert(NameValueNode && "Name presence should be checked earlier");
+error(NameValueNode,
+  "entry with relative path at the root level is not discoverable");
+return nullptr;
+  }
 }
 
 // Remove trailing slash(es), being careful not to remove the root path
 StringRef Trimmed(Name);
-size_t RootPathLen = sys::path::root_path(Trimmed).size();
+size_t RootPathLen = sys::path::root_path(Trimmed, path_style).size();
 while (Trimmed.size() > RootPathLen &&
-   sys::path::is_separator(Trimmed.back()))
+   sys::path::is_separator(Trimmed.back(), path_style))
   Trimmed = Trimmed.slice(0, Trimmed.size() - 1);
+
 // Get the last component
-StringRef LastComponent = sys::path::filename(Trimmed);
+StringRef LastComponent = sys::path::filename(Trimmed, path_style);
 
 std::unique_ptr Result;
 switch (Kind) {
@@ -1460,12 +1483,12 @@
   break;
 }
 
-StringRef Parent = sys::path::parent_path(Trimmed);
+StringRef Parent = sys::path::parent_path(Trimmed, path_style);
 if (Parent.empty())
   return Result;
 
 // if 'name' contains multiple components, create implicit directory entries
-for (sys::path::reverse_iterator I = sys::path::rbegin(Parent),
+for (sys::path::reverse_iterator I = sys::path::rbegin(Parent, path_style),
  E = sys::path::rend(Parent);
  I != E; ++I) {
   std::vector> Entries;
Index: llvm/include/llvm/Support/VirtualFileSystem.h
===
--- llvm/include/llvm/Support/VirtualFileSystem.h
+++ llvm/include/llvm/Support/VirtualFileSystem.h
@@ -293,7 +293,7 @@
   /// \param Path A path that is modified to be an absolute path.
   /// \returns success if \a path has been made absolute, otherwise a
   ///  platform-specific error_code.
-  std::error_code makeAbsolute(SmallVectorImpl &Path) const;
+  virtual std::error_code makeAbsolute(SmallVectorImpl &Path) const;
 };
 
 /// Gets an \p vfs::FileSystem for the 'real' file system, as seen by
@@ -749,6 +749,8 @@
 
   std::error_code isLocal(const Twine &Path, bool &Result) override;
 
+  std::error_code makeAbsolute(SmallVectorImpl &Path) const override;
+
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
 
   void setExternalContentsPrefixDir(StringRef PrefixDir);
Index: clang/test/VFS/vfsroot-with-overlay.c
===
--- cl

Re: [clang] d930ed1 - Disallow use of __has_c_attribute in C++ mode.

2019-11-25 Thread Aaron Ballman via cfe-commits
On Mon, Nov 25, 2019 at 5:59 PM James Y Knight  wrote:
>
> Isn't this unnecessarily annoying to users? You have the same syntax to use 
> the attributes, and the attributes are expected to be compatible when named 
> the same way, but you can't use the same #if conditional to check for 
> availability, when writing a header intended to work in both modes?

Yes, I do think it's needlessly annoying to users.

WG21 adopted __has_cpp_attribute for C++2a based on the existing Clang
implementation. WG14 is looking to add a similar feature testing
macro, but cannot use __has_cpp_attribute due to the name and so I
proposed __has_c_attribute for parity with __has_cpp_attribute and
implemented it in Clang. After a lot of discussions with users,
committee members, and other implementers, I realized this is silly:
we could have a single macro that handles both C and C++ depending on
the language mode being compiled for. Because of that, as a liaison I
filed an NB comment with WG21 to have them reconsider the name
__has_cpp_attribute before it shipped in a standard so that we could
use a language-neutral name for both languages. In Belfast, EWG
reaffirmed that they want the name __has_cpp_attribute. They found my
arguments to be unpersuasive and didn't think it would be possible for
the semantics of attributes to align between the languages, or to
commit to such a guarantee (despite WG14 having a chartered mandate to
be compatible with features adopted from C++).

Rather than leaving C out in the cold because EWG came to the decision
they did, we're kind of stuck with __has_c_attribute.

One problem this does solve is that __has_cpp_attribute and
__has_c_attribute both return a numeric value that is date-like for
standard attributes, but those standard attributes are adopted into
different standards at different times. Because returned values are
different, it makes use harder when dealing with attribute
modifications over time. This isn't impossible to solve, we could
introduce macros for the return values and base their values on which
language mode is being preprocessed, but we no longer have to.

~Aaron

>
> On Mon, Nov 25, 2019 at 5:35 PM Aaron Ballman via cfe-commits 
>  wrote:
>>
>>
>> Author: Aaron Ballman
>> Date: 2019-11-25T17:35:12-05:00
>> New Revision: d930ed1acc0ea49d4b3aae7e95b4c6d9cd310578
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/d930ed1acc0ea49d4b3aae7e95b4c6d9cd310578
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/d930ed1acc0ea49d4b3aae7e95b4c6d9cd310578.diff
>>
>> LOG: Disallow use of __has_c_attribute in C++ mode.
>>
>> __has_cpp_attribute is not available in C mode, and __has_c_attribute
>> should not be available in C++ mode. This also adds a test to
>> demonstrate that we properly handle scoped attribute tokens even in C
>> mode.
>>
>> Added:
>> clang/test/Preprocessor/has_c_attribute.cpp
>>
>> Modified:
>> clang/lib/Lex/PPMacroExpansion.cpp
>> clang/test/Preprocessor/has_c_attribute.c
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
>> b/clang/lib/Lex/PPMacroExpansion.cpp
>> index e6e00b1c1700..a69c4dbb3a2a 100644
>> --- a/clang/lib/Lex/PPMacroExpansion.cpp
>> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
>> @@ -370,7 +370,11 @@ void Preprocessor::RegisterBuiltinMacros() {
>>Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
>>Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
>>Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
>> -  Ident__has_c_attribute  = RegisterBuiltinMacro(*this, 
>> "__has_c_attribute");
>> +  if (!LangOpts.CPlusPlus)
>> +Ident__has_c_attribute = RegisterBuiltinMacro(*this, 
>> "__has_c_attribute");
>> +  else
>> +Ident__has_c_attribute = nullptr;
>> +
>>Ident__has_declspec = RegisterBuiltinMacro(*this, 
>> "__has_declspec_attribute");
>>Ident__has_include  = RegisterBuiltinMacro(*this, "__has_include");
>>Ident__has_include_next = RegisterBuiltinMacro(*this, 
>> "__has_include_next");
>>
>> diff  --git a/clang/test/Preprocessor/has_c_attribute.c 
>> b/clang/test/Preprocessor/has_c_attribute.c
>> index 843a67a2646c..f8b0b364faa5 100644
>> --- a/clang/test/Preprocessor/has_c_attribute.c
>> +++ b/clang/test/Preprocessor/has_c_attribute.c
>> @@ -1,4 +1,5 @@
>>  // RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | 
>> FileCheck %s
>> +// RUN: %clang_cc1 -std=c2x -E %s -o - | FileCheck %s
>>
>>  // CHECK: has_fallthrough
>>  #if __has_c_attribute(fallthrough)
>> @@ -14,3 +15,8 @@
>>  #if __has_c_attribute(__nodiscard__)
>>int has_nodiscard_underscore();
>>  #endif
>> +
>> +// CHECK: has_clang_annotate
>> +#if __has_c_attribute(clang::annotate)
>> +  int has_clang_annotate();
>> +#endif
>>
>> diff  --git a/clang/test/Preprocessor/has_c_attribute.cpp 
>> b/clang/test/Preprocessor/has_c_attribute.cpp
>> ne

[PATCH] D70700: [WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`

2019-11-25 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
Herald added subscribers: llvm-commits, dexonsmith, aheejin, jgravelle-google, 
sbc100, mehdi_amini, dschuff.
Herald added projects: clang, LLVM.

WebAssembly enforces a rule that caller and callee signatures must
match. This means that the traditional technique of passing `main`
`argc` and `argv` even when it doesn't need them doesn't work.

Currently the backend renames `main` to `__original_main`, however this
doesn't interact well with LTO'ing libc, and the name isn't intuitive.
This patch allows us to transition to `__main_argc_argv` instead.

This is currently being discussed in 
https://github.com/WebAssembly/tool-conventions/pull/134.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70700

Files:
  clang/lib/AST/Mangle.cpp
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/CodeGen/wasm-call-main.c
  clang/test/CodeGen/wasm-main.c
  clang/test/CodeGen/wasm-main_argc_argv.c
  llvm/include/llvm/ADT/Triple.h

Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -730,6 +730,11 @@
 return getArch() == Triple::riscv32 || getArch() == Triple::riscv64;
   }
 
+  /// Tests whether the target is wasm (32- and 64-bit).
+  bool isWasm() const {
+return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
+  }
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !isOSBinFormatMachO();
Index: clang/test/CodeGen/wasm-main_argc_argv.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-main_argc_argv.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Mangle the argc/argv form of main.
+
+int main(int argc, char **argv) {
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @__main_argc_argv(i32 %argc, i8** %argv)
Index: clang/test/CodeGen/wasm-main.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-main.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Don't mangle the no-arg form of main.
+
+int main(void) {
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @main()
Index: clang/test/CodeGen/wasm-call-main.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-call-main.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Mangle argc/argv main even when it's not defined in this TU.
+
+#include 
+
+int main(int argc, char *argv[]);
+
+int foo(void) {
+return main(0, NULL);
+}
+
+// CHECK: call i32 @__main_argc_argv(
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -435,8 +435,7 @@
 break;
 
   case llvm::Triple::UnknownOS:
-if (triple.getArch() == llvm::Triple::wasm32 ||
-triple.getArch() == llvm::Triple::wasm64)
+if (triple.isWasm())
   return;
 break;
   }
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -50,7 +50,8 @@
   CCM_Fast,
   CCM_RegCall,
   CCM_Vector,
-  CCM_Std
+  CCM_Std,
+  CCM_WasmMainArgcArgv
 };
 
 static bool isExternC(const NamedDecl *ND) {
@@ -63,6 +64,14 @@
  const NamedDecl *ND) {
   const TargetInfo &TI = Context.getTargetInfo();
   const llvm::Triple &Triple = TI.getTriple();
+
+  // On wasm, the argc/argv form of "main" is renamed so that the startup code
+  // can call it with the correct function signature.
+  if (Triple.isWasm())
+if (const FunctionDecl *FD = dyn_cast(ND))
+  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+return CCM_WasmMainArgcArgv;
+
   if (!Triple.isOSWindows() ||
   !(Triple.getArch() == llvm::Triple::x86 ||
 Triple.getArch() == llvm::Triple::x86_64))
@@ -145,6 +154,12 @@
 
   const ASTContext &ASTContext = getASTContext();
   CCMangling CC = getCallingConvMangling(ASTContext, D);
+
+  if (CC == CCM_WasmMainArgcArgv) {
+Out << "__main_argc_argv";
+return;
+  }
+
   bool MCXX = shouldMangleCXXName(D);
   const TargetInfo &TI = Context.getTargetInfo();
   if (CC == CCM_Other || (MCXX && TI.getCXXABI() == TargetCXXABI::Microsoft)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] e807569 - Fix an unused variable warning where a variable was only used in an assert.

2019-11-25 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2019-11-25T15:29:33-08:00
New Revision: e8075692589dc1274585bd7445f3e3b830b96c69

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

LOG: Fix an unused variable warning where a variable was only used in an assert.

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index cd6a682007f2..e4d808921c01 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -457,8 +457,10 @@ std::string getQualification(ASTContext &Context,
  const DeclContext *DestContext,
  SourceLocation InsertionPoint, const NamedDecl 
*ND,
  llvm::ArrayRef VisibleNamespaces) {
-  for (llvm::StringRef NS : VisibleNamespaces)
+  for (llvm::StringRef NS : VisibleNamespaces) {
 assert(NS.endswith("::"));
+(void)NS;
+  }
   return getQualification(
   Context, DestContext, ND->getDeclContext(),
   [&](NestedNameSpecifier *NNS) {



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


[PATCH] D70692: IRGen: Call SetLLVMFunctionAttributes{, ForDefinition} on __cfi_check_fail.

2019-11-25 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90b8bc003caa: IRGen: Call 
SetLLVMFunctionAttributes{,ForDefinition} on __cfi_check_fail. (authored by 
pcc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70692

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/cfi-check-fail-attrs.c


Index: clang/test/CodeGen/cfi-check-fail-attrs.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-check-fail-attrs.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux -fsanitize-cfi-cross-dso 
-target-feature +reserve-x18 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define weak_odr hidden void @__cfi_check_fail{{.*}} [[ATTR:#[0-9]*]]
+
+// CHECK: attributes [[ATTR]] = {{.*}} "target-features"="+reserve-x18"
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3200,6 +3200,9 @@
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {VoidPtrTy, VoidPtrTy}, false),
   llvm::GlobalValue::WeakODRLinkage, "__cfi_check_fail", &CGM.getModule());
+
+  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, F);
+  CGM.SetLLVMFunctionAttributesForDefinition(nullptr, F);
   F->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args,


Index: clang/test/CodeGen/cfi-check-fail-attrs.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-check-fail-attrs.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux -fsanitize-cfi-cross-dso -target-feature +reserve-x18 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define weak_odr hidden void @__cfi_check_fail{{.*}} [[ATTR:#[0-9]*]]
+
+// CHECK: attributes [[ATTR]] = {{.*}} "target-features"="+reserve-x18"
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3200,6 +3200,9 @@
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {VoidPtrTy, VoidPtrTy}, false),
   llvm::GlobalValue::WeakODRLinkage, "__cfi_check_fail", &CGM.getModule());
+
+  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, F);
+  CGM.SetLLVMFunctionAttributesForDefinition(nullptr, F);
   F->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70693: [scan-build-py] Set of small fixes

2019-11-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Sorry, there was a brain hiccup on my side. We just do not generate HTMLs for 
every translation units (which is the case for plists).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70693



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


[clang] 90b8bc0 - IRGen: Call SetLLVMFunctionAttributes{, ForDefinition} on __cfi_check_fail.

2019-11-25 Thread Peter Collingbourne via cfe-commits

Author: Peter Collingbourne
Date: 2019-11-25T15:16:43-08:00
New Revision: 90b8bc003caacd165dedbb9cafc32de10d610ea7

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

LOG: IRGen: Call SetLLVMFunctionAttributes{,ForDefinition} on __cfi_check_fail.

This has the main effect of causing target-cpu and target-features to be set
on __cfi_check_fail, causing the function to become ABI-compatible with other
functions in the case where these attributes affect ABI (e.g. reserve-x18).

Technically we only need to call SetLLVMFunctionAttributes to get the target-*
attributes set, but since we're creating a definition we probably ought to
call the ForDefinition function as well.

Fixes PR44094.

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

Added: 
clang/test/CodeGen/cfi-check-fail-attrs.c

Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 214378a966f0..04c6504910b8 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3200,6 +3200,9 @@ void CodeGenFunction::EmitCfiCheckFail() {
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {VoidPtrTy, VoidPtrTy}, false),
   llvm::GlobalValue::WeakODRLinkage, "__cfi_check_fail", &CGM.getModule());
+
+  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, F);
+  CGM.SetLLVMFunctionAttributesForDefinition(nullptr, F);
   F->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args,

diff  --git a/clang/test/CodeGen/cfi-check-fail-attrs.c 
b/clang/test/CodeGen/cfi-check-fail-attrs.c
new file mode 100644
index ..77ba29a5581c
--- /dev/null
+++ b/clang/test/CodeGen/cfi-check-fail-attrs.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux -fsanitize-cfi-cross-dso 
-target-feature +reserve-x18 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define weak_odr hidden void @__cfi_check_fail{{.*}} [[ATTR:#[0-9]*]]
+
+// CHECK: attributes [[ATTR]] = {{.*}} "target-features"="+reserve-x18"



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


Re: [clang] d930ed1 - Disallow use of __has_c_attribute in C++ mode.

2019-11-25 Thread James Y Knight via cfe-commits
Isn't this unnecessarily annoying to users? You have the same syntax to use
the attributes, and the attributes are expected to be compatible when named
the same way, but you can't use the same #if conditional to check for
availability, when writing a header intended to work in both modes?

On Mon, Nov 25, 2019 at 5:35 PM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Aaron Ballman
> Date: 2019-11-25T17:35:12-05:00
> New Revision: d930ed1acc0ea49d4b3aae7e95b4c6d9cd310578
>
> URL:
> https://github.com/llvm/llvm-project/commit/d930ed1acc0ea49d4b3aae7e95b4c6d9cd310578
> DIFF:
> https://github.com/llvm/llvm-project/commit/d930ed1acc0ea49d4b3aae7e95b4c6d9cd310578.diff
>
> LOG: Disallow use of __has_c_attribute in C++ mode.
>
> __has_cpp_attribute is not available in C mode, and __has_c_attribute
> should not be available in C++ mode. This also adds a test to
> demonstrate that we properly handle scoped attribute tokens even in C
> mode.
>
> Added:
> clang/test/Preprocessor/has_c_attribute.cpp
>
> Modified:
> clang/lib/Lex/PPMacroExpansion.cpp
> clang/test/Preprocessor/has_c_attribute.c
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp
> b/clang/lib/Lex/PPMacroExpansion.cpp
> index e6e00b1c1700..a69c4dbb3a2a 100644
> --- a/clang/lib/Lex/PPMacroExpansion.cpp
> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
> @@ -370,7 +370,11 @@ void Preprocessor::RegisterBuiltinMacros() {
>Ident__has_extension= RegisterBuiltinMacro(*this,
> "__has_extension");
>Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
>Ident__has_attribute= RegisterBuiltinMacro(*this,
> "__has_attribute");
> -  Ident__has_c_attribute  = RegisterBuiltinMacro(*this,
> "__has_c_attribute");
> +  if (!LangOpts.CPlusPlus)
> +Ident__has_c_attribute = RegisterBuiltinMacro(*this,
> "__has_c_attribute");
> +  else
> +Ident__has_c_attribute = nullptr;
> +
>Ident__has_declspec = RegisterBuiltinMacro(*this,
> "__has_declspec_attribute");
>Ident__has_include  = RegisterBuiltinMacro(*this, "__has_include");
>Ident__has_include_next = RegisterBuiltinMacro(*this,
> "__has_include_next");
>
> diff  --git a/clang/test/Preprocessor/has_c_attribute.c
> b/clang/test/Preprocessor/has_c_attribute.c
> index 843a67a2646c..f8b0b364faa5 100644
> --- a/clang/test/Preprocessor/has_c_attribute.c
> +++ b/clang/test/Preprocessor/has_c_attribute.c
> @@ -1,4 +1,5 @@
>  // RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o -
> | FileCheck %s
> +// RUN: %clang_cc1 -std=c2x -E %s -o - | FileCheck %s
>
>  // CHECK: has_fallthrough
>  #if __has_c_attribute(fallthrough)
> @@ -14,3 +15,8 @@
>  #if __has_c_attribute(__nodiscard__)
>int has_nodiscard_underscore();
>  #endif
> +
> +// CHECK: has_clang_annotate
> +#if __has_c_attribute(clang::annotate)
> +  int has_clang_annotate();
> +#endif
>
> diff  --git a/clang/test/Preprocessor/has_c_attribute.cpp
> b/clang/test/Preprocessor/has_c_attribute.cpp
> new file mode 100644
> index ..0bde73067178
> --- /dev/null
> +++ b/clang/test/Preprocessor/has_c_attribute.cpp
> @@ -0,0 +1,8 @@
> +// RUN: %clang_cc1 -std=c++11 %s -verify
> +
> +#if __has_c_attribute(fallthrough) // expected-error {{function-like
> macro '__has_c_attribute' is not defined}}
> +#endif
> +
> +#if __has_c_attribute(gnu::transparent_union) // expected-error
> {{function-like macro '__has_c_attribute' is not defined}}
> +#endif
> +
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d930ed1 - Disallow use of __has_c_attribute in C++ mode.

2019-11-25 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2019-11-25T17:35:12-05:00
New Revision: d930ed1acc0ea49d4b3aae7e95b4c6d9cd310578

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

LOG: Disallow use of __has_c_attribute in C++ mode.

__has_cpp_attribute is not available in C mode, and __has_c_attribute
should not be available in C++ mode. This also adds a test to
demonstrate that we properly handle scoped attribute tokens even in C
mode.

Added: 
clang/test/Preprocessor/has_c_attribute.cpp

Modified: 
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Preprocessor/has_c_attribute.c

Removed: 




diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index e6e00b1c1700..a69c4dbb3a2a 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -370,7 +370,11 @@ void Preprocessor::RegisterBuiltinMacros() {
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
   Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
-  Ident__has_c_attribute  = RegisterBuiltinMacro(*this, "__has_c_attribute");
+  if (!LangOpts.CPlusPlus)
+Ident__has_c_attribute = RegisterBuiltinMacro(*this, "__has_c_attribute");
+  else
+Ident__has_c_attribute = nullptr;
+
   Ident__has_declspec = RegisterBuiltinMacro(*this, 
"__has_declspec_attribute");
   Ident__has_include  = RegisterBuiltinMacro(*this, "__has_include");
   Ident__has_include_next = RegisterBuiltinMacro(*this, "__has_include_next");

diff  --git a/clang/test/Preprocessor/has_c_attribute.c 
b/clang/test/Preprocessor/has_c_attribute.c
index 843a67a2646c..f8b0b364faa5 100644
--- a/clang/test/Preprocessor/has_c_attribute.c
+++ b/clang/test/Preprocessor/has_c_attribute.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -std=c2x -E %s -o - | FileCheck %s
 
 // CHECK: has_fallthrough
 #if __has_c_attribute(fallthrough)
@@ -14,3 +15,8 @@
 #if __has_c_attribute(__nodiscard__)
   int has_nodiscard_underscore();
 #endif
+
+// CHECK: has_clang_annotate
+#if __has_c_attribute(clang::annotate)
+  int has_clang_annotate();
+#endif

diff  --git a/clang/test/Preprocessor/has_c_attribute.cpp 
b/clang/test/Preprocessor/has_c_attribute.cpp
new file mode 100644
index ..0bde73067178
--- /dev/null
+++ b/clang/test/Preprocessor/has_c_attribute.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+#if __has_c_attribute(fallthrough) // expected-error {{function-like macro 
'__has_c_attribute' is not defined}}
+#endif
+
+#if __has_c_attribute(gnu::transparent_union) // expected-error 
{{function-like macro '__has_c_attribute' is not defined}}
+#endif
+



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


[PATCH] D70627: [AST] Split out Attrs.h for table generated *Attr classes

2019-11-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk marked an inline comment as done.
rnk added inline comments.



Comment at: clang/include/clang/AST/Attrs.h:1
+//===--- Attr.h - Classes for representing attributes --*- C++ -*-===//
+//

aaron.ballman wrote:
> rnk wrote:
> > aaron.ballman wrote:
> > > rnk wrote:
> > > > aaron.ballman wrote:
> > > > > This should read `Attrs.h` instead, but I find the naming distinction 
> > > > > to be a bit too subtle. How about `AttrSubclasses.h` or 
> > > > > `ConcreteAttrs.h` (other suggestions welcome too).
> > > > WDYT about following Decl.h / DeclBase.h? So, rename Attr.h to 
> > > > AttrBase.h, update all current includers of Attr.h to AttrBase.h, then 
> > > > add in new includes of Attr.h. Perhaps staged as two commits, one to do 
> > > > the rename, one to introduce the new header.
> > > > 
> > > > Otherwise, I guess I like AttrSubclasses.h from your list, or 
> > > > AttrClasses.h as an alternative.
> > > I think AttrBase.h for the `Attr` base class makes a lot of sense -- it 
> > > makes it more clear that you only get the base class. WDYT about 
> > > `Attrs.h` for the subclasses instead of `Attr.h` -- might make it a bit 
> > > more clear that you're getting all of the attributes, not just the base 
> > > class?
> > That makes sense. Do you mind if I land this first, and then do the Attr.h 
> > -> AttrBase.h rename? That way I don't have to make a new patch, put it up 
> > for review, and rebase this patch over it. I'll send a review assuming the 
> > answer is yes and then reorder them if you have concerns.
> Totally fine with that approach, thanks for checking!
Hm, I just realized that this will create a lot of churn for out of tree 
includers of Attr.h. Chrome's plugins have three hits:
https://cs.chromium.org/search/?q=include.*AST/Attr%5C.h&sq=package:chromium&type=cs
Other users will have more.

Clang doesn't promise API stability, so we can certainly do this, but it 
creates a fair volume of work.

Now I'm considering splitting out AttrBase.h on its own and updating as many 
includes of Attr.h to use that as possible. That'll end up being a much less 
disruptive and much smaller change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70627



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


[PATCH] D70627: [AST] Split out Attrs.h for table generated *Attr classes

2019-11-25 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 with the follow-up plan.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70627



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-11-25 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

The corresponding BPF patch to consume the debuginfo 
https://reviews.llvm.org/D70697.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[PATCH] D70625: [DebugInfo][BPF] Support to emit debugInfo for extern variables

2019-11-25 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song abandoned this revision.
yonghong-song added a comment.

@dblaikie As suggested, just submitted two separate patches:

- https://reviews.llvm.org/D70696 for clang/llvm change to generate debuginfo 
for extern variables
- https://reviews.llvm.org/D70697 for BPF backend to consume such debuginfo.

Please help take a look. Thanks!

I will abandon this patch to avoid confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70625



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


[PATCH] D70627: [AST] Split out Attrs.h for table generated *Attr classes

2019-11-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Attrs.h:1
+//===--- Attr.h - Classes for representing attributes --*- C++ -*-===//
+//

rnk wrote:
> aaron.ballman wrote:
> > rnk wrote:
> > > aaron.ballman wrote:
> > > > This should read `Attrs.h` instead, but I find the naming distinction 
> > > > to be a bit too subtle. How about `AttrSubclasses.h` or 
> > > > `ConcreteAttrs.h` (other suggestions welcome too).
> > > WDYT about following Decl.h / DeclBase.h? So, rename Attr.h to 
> > > AttrBase.h, update all current includers of Attr.h to AttrBase.h, then 
> > > add in new includes of Attr.h. Perhaps staged as two commits, one to do 
> > > the rename, one to introduce the new header.
> > > 
> > > Otherwise, I guess I like AttrSubclasses.h from your list, or 
> > > AttrClasses.h as an alternative.
> > I think AttrBase.h for the `Attr` base class makes a lot of sense -- it 
> > makes it more clear that you only get the base class. WDYT about `Attrs.h` 
> > for the subclasses instead of `Attr.h` -- might make it a bit more clear 
> > that you're getting all of the attributes, not just the base class?
> That makes sense. Do you mind if I land this first, and then do the Attr.h -> 
> AttrBase.h rename? That way I don't have to make a new patch, put it up for 
> review, and rebase this patch over it. I'll send a review assuming the answer 
> is yes and then reorder them if you have concerns.
Totally fine with that approach, thanks for checking!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70627



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


[PATCH] D70627: [AST] Split out Attrs.h for table generated *Attr classes

2019-11-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk marked an inline comment as done.
rnk added inline comments.



Comment at: clang/include/clang/AST/Attrs.h:1
+//===--- Attr.h - Classes for representing attributes --*- C++ -*-===//
+//

aaron.ballman wrote:
> rnk wrote:
> > aaron.ballman wrote:
> > > This should read `Attrs.h` instead, but I find the naming distinction to 
> > > be a bit too subtle. How about `AttrSubclasses.h` or `ConcreteAttrs.h` 
> > > (other suggestions welcome too).
> > WDYT about following Decl.h / DeclBase.h? So, rename Attr.h to AttrBase.h, 
> > update all current includers of Attr.h to AttrBase.h, then add in new 
> > includes of Attr.h. Perhaps staged as two commits, one to do the rename, 
> > one to introduce the new header.
> > 
> > Otherwise, I guess I like AttrSubclasses.h from your list, or AttrClasses.h 
> > as an alternative.
> I think AttrBase.h for the `Attr` base class makes a lot of sense -- it makes 
> it more clear that you only get the base class. WDYT about `Attrs.h` for the 
> subclasses instead of `Attr.h` -- might make it a bit more clear that you're 
> getting all of the attributes, not just the base class?
That makes sense. Do you mind if I land this first, and then do the Attr.h -> 
AttrBase.h rename? That way I don't have to make a new patch, put it up for 
review, and rebase this patch over it. I'll send a review assuming the answer 
is yes and then reorder them if you have concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70627



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-11-25 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: dblaikie, aprantl, RKSimon.
yonghong-song added a project: debug-info.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Extern variable usage in BPF is different from traditional
pure user space application. Recent discussion in linux bpf 
mailing list has two use cases where debug info types are 
required to use extern variables:

- extern types are required to have a suitable interface in libbpf (bpf loader) 
to provide kernel config parameters to bpf programs. 
https://lore.kernel.org/bpf/CAEf4BzYCNo5GeVGMhp3fhysQ=_axAf=23ptwazs-yayafmx...@mail.gmail.com/T/#t
- extern types are required so kernel bpf verifier can verify program which 
uses external functions more precisely. This will make later link with actual 
external function no need to reverify. 
https://lore.kernel.org/bpf/87eez4odqp@toke.dk/T/#m8d5c3e87ffe7f2764e02d722cb0d8cbc136880ed

This patch added clang support to emit debuginfo for extern variables
with a TargetInfo hook to enable it. Currently, only BPF target enables
to generate debug info for extern variables. The emission of
such debuginfo is disabled for C++ at this moment since BPF only
supports a subset of C language. Emission with C++ can be enabled
later if an appropriate use case is identified.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70696

Files:
  clang/include/clang/AST/ASTConsumer.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/Targets/BPF.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/debug-info-extern-duplicate-2.c
  clang/test/CodeGenCXX/debug-info-extern-duplicate.c
  clang/test/CodeGenCXX/debug-info-extern-unused.c
  clang/test/CodeGenCXX/debug-info-extern-var-char-2.c
  clang/test/CodeGenCXX/debug-info-extern-var-char.c
  clang/test/CodeGenCXX/debug-info-extern-var-func.c
  clang/test/CodeGenCXX/debug-info-extern-var-multi.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/unittests/Transforms/Utils/CloningTest.cpp

Index: llvm/unittests/Transforms/Utils/CloningTest.cpp
===
--- llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -764,7 +764,7 @@
 
 DBuilder.createGlobalVariableExpression(
 Subprogram, "unattached", "unattached", File, 1,
-DBuilder.createNullPtrType(), false, Expr);
+DBuilder.createNullPtrType(), false, true, Expr);
 
 auto *Entry = BasicBlock::Create(C, "", F);
 IBuilder.SetInsertPoint(Entry);
Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -1290,7 +1290,7 @@
   return wrap(unwrap(Builder)->createGlobalVariableExpression(
   unwrapDI(Scope), {Name, NameLen}, {Linkage, LinkLen},
   unwrapDI(File), LineNo, unwrapDI(Ty), LocalToUnit,
-  unwrap(Expr), unwrapDI(Decl),
+  true, unwrap(Expr), unwrapDI(Decl),
   nullptr, AlignInBits));
 }
 
Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -639,13 +639,14 @@
 
 DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression(
 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
-unsigned LineNumber, DIType *Ty, bool isLocalToUnit, DIExpression *Expr,
+unsigned LineNumber, DIType *Ty, bool isLocalToUnit,
+bool isDefined, DIExpression *Expr,
 MDNode *Decl, MDTuple *templateParams, uint32_t AlignInBits) {
   checkGlobalVariableScope(Context);
 
   auto *GV = DIGlobalVariable::getDistinct(
   VMContext, cast_or_null(Context), Name, LinkageName, F,
-  LineNumber, Ty, isLocalToUnit, true, cast_or_null(Decl),
+  LineNumber, Ty, isLocalToUnit, isDefined, cast_or_null(Decl),
   templateParams, AlignInBits);
   if (!Expr)
 Expr = createExpression();
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -581,7 +581,7 @@
 ///specified)
 DIGlobalVariableExpression *createGlobalVariableExpression(
 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
-unsigned LineNo, DIType *Ty, bool isLocalToUnit,
+unsigned LineNo, DIType *Ty, bool isLocalToUnit, bool isDefined = true,
 DIExpression *Expr = nullptr, MDNode *Decl = nullptr,
 MDTuple *templateParams = nullptr, uint32_

[PATCH] D69938: [OpenCL] Use __generic addr space when generating internal representation of lambda

2019-11-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:891
+if (getLangOpts().OpenCL)
+  EPI.TypeQuals.addAddressSpace(LangAS::opencl_generic);
+

This should probably check that there isn't already an address space, right?


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

https://reviews.llvm.org/D69938



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


[PATCH] D70692: IRGen: Call SetLLVMFunctionAttributes{, ForDefinition} on __cfi_check_fail.

2019-11-25 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70692



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


[clang] 0e12815 - Revert "[Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy"

2019-11-25 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2019-11-25T13:19:57-08:00
New Revision: 0e12815566b2f8dd2d3bfe2319e55b3ffb9767ae

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

LOG: Revert "[Diagnostics] Put "deprecated copy" warnings into 
-Wdeprecated-copy"

This reverts commit 9353c5dd0664ea444236e527bf93566e11dc34df.

This commit introduced bot falures for multi-stage bots with -Werror.

Added: 


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

Removed: 
clang/test/SemaCXX/deprecated-copy.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 666193e074f0..086e57778051 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -128,8 +128,6 @@ def CXX11CompatDeprecatedWritableStr :
 
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
-def DeprecatedCopy : DiagGroup<"deprecated-copy">;
-def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
@@ -149,8 +147,6 @@ def DeprecatedWritableStr : 
DiagGroup<"deprecated-writable-strings",
 // FIXME: Why is DeprecatedImplementations not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
   DeprecatedCommaSubscript,
-  DeprecatedCopy,
-  DeprecatedCopyDtor,
   DeprecatedDeclarations,
   DeprecatedDynamicExceptionSpec,
   DeprecatedIncrementBool,
@@ -817,7 +813,6 @@ def Move : DiagGroup<"move", [
   ]>;
 
 def Extra : DiagGroup<"extra", [
-DeprecatedCopy,
 MissingFieldInitializers,
 IgnoredQualifiers,
 InitializerOverrides,

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c19862addec9..799b3ed2ea92 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -551,13 +551,9 @@ def err_access_decl : Error<
   "use using declarations instead">;
 def warn_deprecated_copy_operation : Warning<
   "definition of implicit copy %select{constructor|assignment operator}1 "
-  "for %0 is deprecated because it has a user-declared copy "
-  "%select{assignment operator|constructor}1">,
-  InGroup, DefaultIgnore;
-def warn_deprecated_copy_dtor_operation : Warning<
-  "definition of implicit copy %select{constructor|assignment operator}1 "
-  "for %0 is deprecated because it has a user-declared destructor">,
-  InGroup, DefaultIgnore;
+  "for %0 is deprecated because it has a user-declared "
+  "%select{copy %select{assignment operator|constructor}1|destructor}2">,
+  InGroup, DefaultIgnore;
 def warn_cxx17_compat_exception_spec_in_signature : Warning<
   "mangled name of %0 will change in C++17 due to non-throwing exception "
   "specification in function signature">, InGroup;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9c220efebe60..e3ea9788ad5d 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -12435,10 +12435,9 @@ static void diagnoseDeprecatedCopyOperation(Sema &S, 
CXXMethodDecl *CopyOp) {
 
   if (UserDeclaredOperation && UserDeclaredOperation->isUserProvided()) {
 S.Diag(UserDeclaredOperation->getLocation(),
-   isa(UserDeclaredOperation)
-   ? diag::warn_deprecated_copy_dtor_operation
-   : diag::warn_deprecated_copy_operation)
-<< RD << /*copy assignment*/ !isa(CopyOp);
+ diag::warn_deprecated_copy_operation)
+  << RD << /*copy assignment*/!isa(CopyOp)
+  << /*destructor*/isa(UserDeclaredOperation);
   }
 }
 

diff  --git a/clang/test/SemaCXX/deprecated-copy.cpp 
b/clang/test/SemaCXX/deprecated-copy.cpp
deleted file mode 100644
index 4d3e798d912b..
--- a/clang/test/SemaCXX/deprecated-copy.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
-// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -DDEPRECATED_COPY_DTOR 
-verify
-// RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
-
-#ifdef DEPRECATED_COPY_DTOR
-struct A {
-  int *ptr;
-  ~A() { delete ptr; } // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a 

[clang] 3c51425 - Revert "[Diagnostic] add a warning which warns about misleading indentation"

2019-11-25 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2019-11-25T13:19:57-08:00
New Revision: 3c5142597a451a03db21c2ffe8f6520c7eacce59

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

LOG: Revert "[Diagnostic] add a warning which warns about misleading 
indentation"

This reverts commit 7b86188b50bf6e537fe98b326f258fbd23108b83.

This commit introduced bot falures for multi-stage bots with -Werror.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseStmt.cpp
clang/test/Index/pragma-diag-reparse.c
clang/test/Misc/warning-wall.c
clang/test/Preprocessor/pragma_diagnostic_sections.cpp

Removed: 
clang/test/SemaCXX/warn-misleading-indentation.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 086e57778051..6b83bf59ea89 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -689,7 +689,6 @@ def ZeroLengthArray : DiagGroup<"zero-length-array">;
 def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
 def GNUZeroVariadicMacroArguments : 
DiagGroup<"gnu-zero-variadic-macro-arguments">;
 def Fallback : DiagGroup<"fallback">;
-def MisleadingIndentation : DiagGroup<"misleading-indentation">;
 
 // This covers both the deprecated case (in C++98)
 // and the extension case (in C++11 onwards).
@@ -880,7 +879,7 @@ def Consumed   : DiagGroup<"consumed">;
 // Note that putting warnings in -Wall will not disable them by default. If a
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
-def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, 
MisleadingIndentation]>;
+def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index e6aa92eddef7..c94d1b99d0e8 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -61,13 +61,6 @@ def warn_null_statement : Warning<
   "remove unnecessary ';' to silence this warning">,
   InGroup, DefaultIgnore;
 
-def warn_misleading_indentation : Warning<
-  "misleading indentation; %select{statement|declaration}0 is not part of "
-  "the previous '%select{if|else|for|while}1'">,
-  InGroup, DefaultIgnore;
-def note_previous_statement : Note<
-  "previous statement is here">;
-
 def ext_thread_before : Extension<"'__thread' before '%0'">;
 def ext_keyword_as_ident : ExtWarn<
   "keyword '%0' will be made available as an identifier "

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index edd31e3ff7e8..ea1116ff7a23 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2266,13 +2266,11 @@ class Parser : public CodeCompletionHandler {
 return isTypeSpecifierQualifier();
   }
 
-public:
   /// isCXXDeclarationStatement - C++-specialized function that disambiguates
   /// between a declaration or an expression statement, when parsing function
   /// bodies. Returns true for declaration, false for expression.
   bool isCXXDeclarationStatement();
 
-private:
   /// isCXXSimpleDeclaration - C++-specialized function that disambiguates
   /// between a simple-declaration or an expression-statement.
   /// If during the disambiguation process a parsing error is encountered,

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index ce8aa7574b9b..727ab75adae8 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1191,27 +1191,6 @@ bool Parser::ParseParenExprOrCondition(StmtResult 
*InitStmt,
   return false;
 }
 
-enum MisleadingStatementKind { MSK_if, MSK_else, MSK_for, MSK_while };
-
-static void
-MaybeDiagnoseMisleadingIndentation(Parser &P, SourceLocation PrevLoc,
-   SourceLocation StmtLoc,
-   MisleadingStatementKind StmtKind) {
-  Token Tok = P.getCurToken();
-  if (Tok.is(tok::semi))
-return;
-  SourceManager &SM = P.getPreprocessor().getSourceManager();
-  unsigned PrevColNum = SM.getSpellingColumnNumber(PrevLoc);
-  unsigned CurColNum = SM.getSpellingColumnNumber(Tok.getLocation());
-  unsigned StmtColNum = SM.getSpellingColumnNumber(StmtLoc);
-  if (!Tok.isAtStartOfLine() ||
-  (PrevColNum != 0 && CurColNum != 0 && StmtColNum != 0 &&
-   PrevColNum > StmtColNum && PrevColNum == CurColNum)) {
-P.Diag(Tok.getLocation(), diag::warn_misleading_inde

[PATCH] D70627: [AST] Split out Attrs.h for table generated *Attr classes

2019-11-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Attrs.h:1
+//===--- Attr.h - Classes for representing attributes --*- C++ -*-===//
+//

rnk wrote:
> aaron.ballman wrote:
> > This should read `Attrs.h` instead, but I find the naming distinction to be 
> > a bit too subtle. How about `AttrSubclasses.h` or `ConcreteAttrs.h` (other 
> > suggestions welcome too).
> WDYT about following Decl.h / DeclBase.h? So, rename Attr.h to AttrBase.h, 
> update all current includers of Attr.h to AttrBase.h, then add in new 
> includes of Attr.h. Perhaps staged as two commits, one to do the rename, one 
> to introduce the new header.
> 
> Otherwise, I guess I like AttrSubclasses.h from your list, or AttrClasses.h 
> as an alternative.
I think AttrBase.h for the `Attr` base class makes a lot of sense -- it makes 
it more clear that you only get the base class. WDYT about `Attrs.h` for the 
subclasses instead of `Attr.h` -- might make it a bit more clear that you're 
getting all of the attributes, not just the base class?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70627



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


[PATCH] D70424: clang/AMDGPU: Fix default for frame-pointer attribute

2019-11-25 Thread Tony Tye via Phabricator via cfe-commits
t-tye added a comment.

@scott.linder can answer about the -g question, but I would expect that the CFI 
is capable of describing the address of the CFA regardless of whether there is 
a frame pointer by simply knowing the constant offset from the stack pointer.

For AMDGPU it seems to me what we really have is an FP and we optimize away the 
SP since the stack grows low address to high address, and S32 points to the 
base of the frame, and not the top of the stack.


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

https://reviews.llvm.org/D70424



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


[PATCH] D70627: [AST] Split out Attrs.h for table generated *Attr classes

2019-11-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk marked an inline comment as done.
rnk added a comment.

Thanks!




Comment at: clang/include/clang/AST/Attrs.h:1
+//===--- Attr.h - Classes for representing attributes --*- C++ -*-===//
+//

aaron.ballman wrote:
> This should read `Attrs.h` instead, but I find the naming distinction to be a 
> bit too subtle. How about `AttrSubclasses.h` or `ConcreteAttrs.h` (other 
> suggestions welcome too).
WDYT about following Decl.h / DeclBase.h? So, rename Attr.h to AttrBase.h, 
update all current includers of Attr.h to AttrBase.h, then add in new includes 
of Attr.h. Perhaps staged as two commits, one to do the rename, one to 
introduce the new header.

Otherwise, I guess I like AttrSubclasses.h from your list, or AttrClasses.h as 
an alternative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70627



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


[PATCH] D70693: [scan-build-py] Set of small fixes

2019-11-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: NoQ, haowei, rizsotto.mailinglist.
Herald added subscribers: Charusso, gamesh411, Szelethus, dkrupp, rnkovacs, 
whisperity.
Herald added a project: clang.
xazax.hun added a subscriber: phosek.

This patch fix some small errors in scan-build-py, including:

- When invoking clang with `-###` and parsing error add 
`-fno-color-diagnostics` to the invocation to avoid problems parsing potential 
errors. This might be sub-optimal for users expecting to see the results in the 
command line and expecting to have colors. If we really want this to work I can 
either make the regex more forgiving or try to restore the 
`-fcolor-diagnostics`flag to its original state after the `-###` invocation.
- If a file was missing from a compilation database the whole analysis was 
stopped due to an unhandled exception.
- Fix two typos: analyzis -> analysis


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70693

Files:
  clang/tools/scan-build-py/libscanbuild/analyze.py
  clang/tools/scan-build-py/libscanbuild/clang.py


Index: clang/tools/scan-build-py/libscanbuild/clang.py
===
--- clang/tools/scan-build-py/libscanbuild/clang.py
+++ clang/tools/scan-build-py/libscanbuild/clang.py
@@ -19,6 +19,11 @@
 ACTIVE_CHECKER_PATTERN = re.compile(r'^-analyzer-checker=(.*)$')
 
 
+class ClangErrorException(Exception):
+def __init__(self, error):
+self.error = error
+
+
 def get_version(clang):
 """ Returns the compiler version as string.
 
@@ -39,13 +44,14 @@
 
 cmd = command[:]
 cmd.insert(1, '-###')
+cmd.append('-fno-color-diagnostics')
 
 output = run_command(cmd, cwd=cwd)
 # The relevant information is in the last line of the output.
 # Don't check if finding last line fails, would throw exception anyway.
 last_line = output[-1]
 if re.search(r'clang(.*): error:', last_line):
-raise Exception(last_line)
+raise ClangErrorException(last_line)
 return decode(last_line)
 
 
Index: clang/tools/scan-build-py/libscanbuild/analyze.py
===
--- clang/tools/scan-build-py/libscanbuild/analyze.py
+++ clang/tools/scan-build-py/libscanbuild/analyze.py
@@ -33,7 +33,8 @@
 from libscanbuild.report import document
 from libscanbuild.compilation import split_command, classify_source, \
 compiler_language
-from libscanbuild.clang import get_version, get_arguments, get_triple_arch
+from libscanbuild.clang import get_version, get_arguments, get_triple_arch, \
+ClangErrorException
 from libscanbuild.shell import decode
 
 __all__ = ['scan_build', 'analyze_build', 'analyze_compiler_wrapper']
@@ -435,7 +436,7 @@
 of the compilation database.
 
 This complex task is decomposed into smaller methods which are calling
-each other in chain. If the analyzis is not possible the given method
+each other in chain. If the analysis is not possible the given method
 just return and break the chain.
 
 The passed parameter is a python dictionary. Each method first check
@@ -451,7 +452,7 @@
 
 return arch_check(opts)
 except Exception:
-logging.error("Problem occurred during analyzis.", exc_info=1)
+logging.error("Problem occurred during analysis.", exc_info=1)
 return None
 
 
@@ -490,10 +491,13 @@
 os.close(handle)
 # Execute Clang again, but run the syntax check only.
 cwd = opts['directory']
-cmd = get_arguments(
-[opts['clang'], '-fsyntax-only', '-E'
- ] + opts['flags'] + [opts['file'], '-o', name], cwd)
-run_command(cmd, cwd=cwd)
+cmd = [opts['clang'], '-fsyntax-only', '-E'] + opts['flags'] + \
+[opts['file'], '-o', name]
+try:
+cmd = get_arguments(cmd, cwd)
+run_command(cmd, cwd=cwd)
+except ClangErrorException:
+pass
 # write general information about the crash
 with open(name + '.info.txt', 'w') as handle:
 handle.write(opts['file'] + os.linesep)
@@ -542,6 +546,12 @@
 opts.update(result)
 continuation(opts)
 return result
+except ClangErrorException as ex:
+result = {'error_output': ex.error, 'exit_code': 0}
+if opts.get('output_failures', False):
+opts.update(result)
+continuation(opts)
+return result
 
 
 def extdef_map_list_src_to_ast(extdef_src_list):


Index: clang/tools/scan-build-py/libscanbuild/clang.py
===
--- clang/tools/scan-build-py/libscanbuild/clang.py
+++ clang/tools/scan-build-py/libscanbuild/clang.py
@@ -19,6 +19,11 @@
 ACTIVE_CHECKER_PATTERN = re.compile(r'^-analyzer-checker=(.*)$')
 
 
+class ClangErrorException(Exception):
+def __init__(self, error):
+self.error = error
+
+
 def get_version(clang):
 """ Returns the compiler version as string.
 
@@ -39,13 +44,

Github build status reporting

2019-11-25 Thread Galina Kistanova via cfe-commits
Hello everyone,

I have configured buildbot to report build statuses to github. It is
running in a pilot mode. Only the following 4 builders annotate revisions
they build for now:

* llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
* llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
* llvm-clang-x86_64-expensive-checks-ubuntu
* llvm-clang-x86_64-win-fast

Please let me know if you have any questions, concerns, or see any issues.

Thanks

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


[PATCH] D70692: IRGen: Call SetLLVMFunctionAttributes{, ForDefinition} on __cfi_check_fail.

2019-11-25 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.
pcc added a reviewer: eugenis.
Herald added a project: clang.

This has the main effect of causing target-cpu and target-features to be set
on __cfi_check_fail, causing the function to become ABI-compatible with other
functions in the case where these attributes affect ABI (e.g. reserve-x18).

Technically we only need to call SetLLVMFunctionAttributes to get the target-*
attributes set, but since we're creating a definition we probably ought to
call the ForDefinition function as well.

Fixes PR44094.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70692

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/cfi-check-fail-attrs.c


Index: clang/test/CodeGen/cfi-check-fail-attrs.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-check-fail-attrs.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux -fsanitize-cfi-cross-dso 
-target-feature +reserve-x18 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define weak_odr hidden void @__cfi_check_fail{{.*}} [[ATTR:#[0-9]*]]
+
+// CHECK: attributes [[ATTR]] = {{.*}} "target-features"="+reserve-x18"
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3200,6 +3200,9 @@
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {VoidPtrTy, VoidPtrTy}, false),
   llvm::GlobalValue::WeakODRLinkage, "__cfi_check_fail", &CGM.getModule());
+
+  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, F);
+  CGM.SetLLVMFunctionAttributesForDefinition(nullptr, F);
   F->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args,


Index: clang/test/CodeGen/cfi-check-fail-attrs.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-check-fail-attrs.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux -fsanitize-cfi-cross-dso -target-feature +reserve-x18 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define weak_odr hidden void @__cfi_check_fail{{.*}} [[ATTR:#[0-9]*]]
+
+// CHECK: attributes [[ATTR]] = {{.*}} "target-features"="+reserve-x18"
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3200,6 +3200,9 @@
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {VoidPtrTy, VoidPtrTy}, false),
   llvm::GlobalValue::WeakODRLinkage, "__cfi_check_fail", &CGM.getModule());
+
+  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, F);
+  CGM.SetLLVMFunctionAttributesForDefinition(nullptr, F);
   F->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2019-11-25 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

Thanks for the review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70638



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


[PATCH] D70549: [OPENMP]Fix PR41826: symbols visibility in device code.

2019-11-25 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbc328c62430: [OPENMP]Fix PR41826: symbols visibility in 
device code. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70549

Files:
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Index: clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -34,18 +34,18 @@
 #pragma omp declare target
 T a = T();
 T f = a;
-// CHECK: define{{ dso_local | }}void @{{.+}}foo{{.+}}([[T]]* byval([[T]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo{{.+}}([[T]]* byval([[T]]) align {{.+}})
 void foo(T a = T()) {
   return;
 }
-// CHECK: define{{ dso_local | }}[6 x i64] @{{.+}}bar{{.+}}()
+// CHECK: define{{ hidden | }}[6 x i64] @{{.+}}bar{{.+}}()
 T bar() {
 // CHECK:  bitcast [[T]]* %{{.+}} to [6 x i64]*
 // CHECK-NEXT: load [6 x i64], [6 x i64]* %{{.+}},
 // CHECK-NEXT: ret [6 x i64]
   return T();
 }
-// CHECK: define{{ dso_local | }}void @{{.+}}baz{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz{{.+}}()
 void baz() {
 // CHECK:  call [6 x i64] @{{.+}}bar{{.+}}()
 // CHECK-NEXT: bitcast [[T]]* %{{.+}} to [6 x i64]*
@@ -54,17 +54,17 @@
 }
 T1 a1 = T1();
 T1 f1 = a1;
-// CHECK: define{{ dso_local | }}void @{{.+}}foo1{{.+}}([[T1]]* byval([[T1]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo1{{.+}}([[T1]]* byval([[T1]]) align {{.+}})
 void foo1(T1 a = T1()) {
   return;
 }
-// CHECK: define{{ dso_local | }}[[T1]] @{{.+}}bar1{{.+}}()
+// CHECK: define{{ hidden | }}[[T1]] @{{.+}}bar1{{.+}}()
 T1 bar1() {
 // CHECK:  load [[T1]], [[T1]]*
 // CHECK-NEXT: ret [[T1]]
   return T1();
 }
-// CHECK: define{{ dso_local | }}void @{{.+}}baz1{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz1{{.+}}()
 void baz1() {
 // CHECK: call [[T1]] @{{.+}}bar1{{.+}}()
   T1 t = bar1();
Index: clang/test/OpenMP/nvptx_target_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_codegen.cpp
@@ -573,7 +573,7 @@
   // CHECK: [[EXIT]]
   // CHECK: ret void
 
-  // CHECK: define{{ dso_local | }}i32 [[BAZ]](i32 [[F:%.*]], double* dereferenceable{{.*}})
+  // CHECK: define{{ hidden | }}i32 [[BAZ]](i32 [[F:%.*]], double* dereferenceable{{.*}})
   // CHECK: alloca i32,
   // CHECK: [[LOCAL_F_PTR:%.+]] = alloca i32,
   // CHECK: [[ZERO_ADDR:%.+]] = alloca i32,
Index: clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
===
--- clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -16,9 +16,9 @@
 // SIMD-ONLY-NOT: {{__kmpc|__tgt}}
 
 // DEVICE-DAG: [[C_ADDR:.+]] = internal global i32 0,
-// DEVICE-DAG: [[CD_ADDR:@.+]] ={{ dso_local | }}global %struct.S zeroinitializer,
+// DEVICE-DAG: [[CD_ADDR:@.+]] ={{ hidden | }}global %struct.S zeroinitializer,
 // HOST-DAG: @[[C_ADDR:.+]] = internal global i32 0,
-// HOST-DAG: @[[CD_ADDR:.+]] ={{ dso_local | }}global %struct.S zeroinitializer,
+// HOST-DAG: @[[CD_ADDR:.+]] ={{ hidden | }}global %struct.S zeroinitializer,
 
 #pragma omp declare target
 int foo() { return 0; }
@@ -34,12 +34,12 @@
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ dso_local | }}i32 [[FOO:@.*foo.*]]()
-// DEVICE-DAG: define{{ dso_local | }}i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ dso_local | }}i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ dso_local | }}i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ dso_local | }}i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ dso_local | }}i32 [[CAZ:@.*caz.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[BAR:@.*bar.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[DOO:@.*doo.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[CAR:@.*car.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[CAZ:@.*caz.*]]()
 
 static int c = foo() + bar() + baz();
 #pragma omp declare target (c)
Index: clang/test/OpenMP/nvptx_allocate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_allocate_codegen.cpp
+++ clang/test/OpenMP/nvptx_allocate_codegen.cpp
@@ -17,11 +17,11 @@
 extern const omp_allocator_handle_t omp_thread_mem_alloc;
 
 // CHECK-DAG: @{{.+}}St1{{.+}}b{{.

[clang] bbc328c - [OPENMP]Fix PR41826: symbols visibility in device code.

2019-11-25 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-11-25T15:01:28-05:00
New Revision: bbc328c62430dd3e2e72973ca85c5c6fb550b227

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

LOG: [OPENMP]Fix PR41826: symbols visibility in device code.

Summary:
Currently, we ignore all locality attributes/info when building for
the device and thus all symblos are externally visible and can be
preemted at the runtime. It may lead to incorrect results. We need to
follow the same logic, compiler uses for static/pie builds. But in some
cases changing of dso locality may lead to problems with codegen, so
instead mark external symbols as hidden instead in the device code.

Reviewers: jdoerfert

Subscribers: guansong, caomhin, kkwli0, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/OpenMP/declare_target_codegen.cpp
clang/test/OpenMP/nvptx_allocate_codegen.cpp
clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
clang/test/OpenMP/nvptx_target_codegen.cpp
clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 66446626c2eb..3723c868004f 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -901,6 +901,10 @@ LinkageComputer::getLVForNamespaceScopeDecl(const 
NamedDecl *D,
   if (!isExternallyVisible(LV.getLinkage()))
 return LinkageInfo(LV.getLinkage(), DefaultVisibility, false);
 
+  // Mark the symbols as hidden when compiling for the device.
+  if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice)
+LV.mergeVisibility(HiddenVisibility, /*newExplicit=*/false);
+
   return LV;
 }
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 25268efff61b..9793a5ef4729 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -815,7 +815,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
   const auto &CGOpts = CGM.getCodeGenOpts();
   llvm::Reloc::Model RM = CGOpts.RelocationModel;
   const auto &LOpts = CGM.getLangOpts();
-  if (RM != llvm::Reloc::Static && !LOpts.PIE && !LOpts.OpenMPIsDevice)
+  if (RM != llvm::Reloc::Static && !LOpts.PIE)
 return false;
 
   // A definition cannot be preempted from an executable.

diff  --git a/clang/test/OpenMP/declare_target_codegen.cpp 
b/clang/test/OpenMP/declare_target_codegen.cpp
index f1074ee5b294..165ba097b95e 100644
--- a/clang/test/OpenMP/declare_target_codegen.cpp
+++ b/clang/test/OpenMP/declare_target_codegen.cpp
@@ -27,22 +27,22 @@
 // CHECK-DAG: Bake
 // CHECK-NOT: @{{hhh|ggg|fff|eee}} =
 // CHECK-DAG: @aaa = external global i32,
-// CHECK-DAG: @bbb ={{ dso_local | }}global i32 0,
+// CHECK-DAG: @bbb ={{ hidden | }}global i32 0,
 // CHECK-DAG: weak constant %struct.__tgt_offload_entry { i8* bitcast (i32* 
@bbb to i8*),
 // CHECK-DAG: @ccc = external global i32,
-// CHECK-DAG: @ddd ={{ dso_local | }}global i32 0,
+// CHECK-DAG: @ddd ={{ hidden | }}global i32 0,
 // CHECK-DAG: @hhh_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @ggg_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @fff_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @eee_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
-// CHECK-DAG: @b ={{ dso_local | }}global i32 15,
-// CHECK-DAG: @d ={{ dso_local | }}global i32 0,
+// CHECK-DAG: @b ={{ hidden | }}global i32 15,
+// CHECK-DAG: @d ={{ hidden | }}global i32 0,
 // CHECK-DAG: @c = external global i32,
-// CHECK-DAG: @globals ={{ dso_local | }}global %struct.S zeroinitializer,
+// CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
-// CHECK-DAG: @out_decl_target ={{ dso_local | }}global i32 0,
+// CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
 // CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(%struct.S** [[STAT_REF]] to i8*)],
 

diff  --git a/clang/test/OpenMP/nvptx_allocate_codegen.cpp 
b/clang/test/OpenMP/nvptx_allocate_codegen.cpp
index 647bc1d96efc..e8352b85fbcd 100644
--- a/clang/test/OpenMP/nvptx_allocate_codegen.cpp
+++ b/clang/test/OpenMP/nvptx_allocate_codegen.cpp
@@ -17,11 +17,11 @@ extern const omp_allocator_handle_t omp_pteam_mem_alloc;
 extern const omp_allocator_handle_t omp_

[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2019-11-25 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b86188b50bf: [Diagnostic] add a warning which warns about 
misleading indentation (authored by Tyker).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70638

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmt.cpp
  clang/test/Index/pragma-diag-reparse.c
  clang/test/Misc/warning-wall.c
  clang/test/Preprocessor/pragma_diagnostic_sections.cpp
  clang/test/SemaCXX/warn-misleading-indentation.cpp

Index: clang/test/SemaCXX/warn-misleading-indentation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-misleading-indentation.cpp
@@ -0,0 +1,184 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wmisleading-indentation -DWITH_WARN %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -DWITH_WARN -DCXX17 %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -Wno-misleading-indentation -DCXX17 %s
+
+#ifndef WITH_WARN
+// expected-no-diagnostics
+#endif
+
+void f0(int i) {
+  if (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1;
+int x = 0;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; declaration is not part of the previous 'if'}}
+#endif
+  return;
+#ifdef CXX17
+  if constexpr (false)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = 0;
+i += 1;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+#endif
+}
+
+void f1(int i) {
+  for (;i;)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1;
+i *= 2;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'for'}}
+#endif
+  return;
+}
+
+void f2(int i) {
+  while (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1; i *= 2;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'while'}}
+#endif
+  return;
+}
+
+void f3(int i) {
+  if (i)
+i = i + 1;
+  else
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+const int x = 0;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; declaration is not part of the previous 'else'}}
+#endif
+}
+
+#ifdef CXX17
+struct Range {
+  int *begin() {return nullptr;}
+  int *end() {return nullptr;}
+};
+#endif
+
+void f4(int i) {
+  if (i)
+  i *= 2;
+  return;
+  if (i)
+i *= 2;
+;
+  if (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+typedef int Int;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; declaration is not part of the previous 'if'}}
+#endif
+#ifdef CXX17
+  Range R;
+  for (auto e : R)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+using Int2 = int;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; declaration is not part of the previous 'for'}}
+#endif
+#endif
+}
+
+int bar(void);
+
+int foo(int* dst)
+{   
+if (dst)
+   return
+bar();
+  if (dst)
+dst = dst + \
+bar();
+  return 0;
+}
+
+// No diagnostics from GCC on this
+void g(int i) {
+  if (1)
+i = 2;
+  else
+ if (i == 3)
+i = 4;
+i = 5;
+}
+
+// Or this
+#define TEST i = 5
+void g0(int i) {
+  if (1)
+i = 2;
+  else
+i = 5;
+TEST;
+}
+
+void g1(int i) {
+  if (1)
+i = 2;
+  else
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+if (i == 3)
+i = 4;
+i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'else'}}
+#endif
+}
+
+void g2(int i) {
+  if (1)
+i = 2;
+  else
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+if (i == 3)
+{i = 4;}
+i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'else'}}
+#endif
+}
+
+void g6(int i) {
+if (1)
+  if (i == 3)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = 4;
+i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+}
Index: clang/test/Preprocessor/pragma_diagnostic_sections.cpp
===
--- clang/test/Preprocessor/pragma_diagnostic_sections.cpp
+++ clang/test/Preprocessor/pragma_diagnostic_sections.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall

[clang] 7b86188 - [Diagnostic] add a warning which warns about misleading indentation

2019-11-25 Thread via cfe-commits

Author: Tyker
Date: 2019-11-25T20:46:32+01:00
New Revision: 7b86188b50bf6e537fe98b326f258fbd23108b83

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

LOG: [Diagnostic] add a warning which warns about misleading indentation

Summary: Add a warning for misleading indentation similar to GCC's 
-Wmisleading-indentation

Reviewers: aaron.ballman, xbolva00

Reviewed By: aaron.ballman, xbolva00

Subscribers: arphaman, Ka-Ka, thakis

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

Added: 
clang/test/SemaCXX/warn-misleading-indentation.cpp

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseStmt.cpp
clang/test/Index/pragma-diag-reparse.c
clang/test/Misc/warning-wall.c
clang/test/Preprocessor/pragma_diagnostic_sections.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 5bfb3de86a47..666193e074f0 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -693,6 +693,7 @@ def ZeroLengthArray : DiagGroup<"zero-length-array">;
 def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
 def GNUZeroVariadicMacroArguments : 
DiagGroup<"gnu-zero-variadic-macro-arguments">;
 def Fallback : DiagGroup<"fallback">;
+def MisleadingIndentation : DiagGroup<"misleading-indentation">;
 
 // This covers both the deprecated case (in C++98)
 // and the extension case (in C++11 onwards).
@@ -884,7 +885,7 @@ def Consumed   : DiagGroup<"consumed">;
 // Note that putting warnings in -Wall will not disable them by default. If a
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
-def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
+def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, 
MisleadingIndentation]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c94d1b99d0e8..e6aa92eddef7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -61,6 +61,13 @@ def warn_null_statement : Warning<
   "remove unnecessary ';' to silence this warning">,
   InGroup, DefaultIgnore;
 
+def warn_misleading_indentation : Warning<
+  "misleading indentation; %select{statement|declaration}0 is not part of "
+  "the previous '%select{if|else|for|while}1'">,
+  InGroup, DefaultIgnore;
+def note_previous_statement : Note<
+  "previous statement is here">;
+
 def ext_thread_before : Extension<"'__thread' before '%0'">;
 def ext_keyword_as_ident : ExtWarn<
   "keyword '%0' will be made available as an identifier "

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index ea1116ff7a23..edd31e3ff7e8 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2266,11 +2266,13 @@ class Parser : public CodeCompletionHandler {
 return isTypeSpecifierQualifier();
   }
 
+public:
   /// isCXXDeclarationStatement - C++-specialized function that disambiguates
   /// between a declaration or an expression statement, when parsing function
   /// bodies. Returns true for declaration, false for expression.
   bool isCXXDeclarationStatement();
 
+private:
   /// isCXXSimpleDeclaration - C++-specialized function that disambiguates
   /// between a simple-declaration or an expression-statement.
   /// If during the disambiguation process a parsing error is encountered,

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 727ab75adae8..ce8aa7574b9b 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1191,6 +1191,27 @@ bool Parser::ParseParenExprOrCondition(StmtResult 
*InitStmt,
   return false;
 }
 
+enum MisleadingStatementKind { MSK_if, MSK_else, MSK_for, MSK_while };
+
+static void
+MaybeDiagnoseMisleadingIndentation(Parser &P, SourceLocation PrevLoc,
+   SourceLocation StmtLoc,
+   MisleadingStatementKind StmtKind) {
+  Token Tok = P.getCurToken();
+  if (Tok.is(tok::semi))
+return;
+  SourceManager &SM = P.getPreprocessor().getSourceManager();
+  unsigned PrevColNum = SM.getSpellingColumnNumber(PrevLoc);
+  unsigned CurColNum = SM.getSpellingColumnNumber(Tok.getLocation());
+  unsigned StmtColNum = SM.getSpellingColumnNumber(StmtLoc);
+  if (!Tok.isAtStartOfLine() ||
+  (PrevColNum != 0 && CurColNum != 0 && StmtColNum != 0 &&
+   P

[PATCH] D70512: [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-11-25 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: fail - 60299 tests passed, 1 failed and 732 were skipped.

  failed: Clangd Unit Tests._/ClangdTests/SelectionTest.PathologicalPreprocessor

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70512



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


[PATCH] D70689: [analyzer] Fix SARIF column locations

2019-11-25 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech created this revision.
jranieri-grammatech added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

This fixes SARIF column locations to be end-exclusive and be counted in terms 
of Unicode characters.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70689

Files:
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  
clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
  
clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
  clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c

Index: clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
===
--- clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
+++ clang/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
@@ -30,11 +30,18 @@
   return 0;
 }
 
+int unicode()
+{
+  int løçål = 0;
+  /* ☃ */ return 1 / løçål; // expected-warning {{Division by zero}}
+}
+
 int main(void) {
   f();
   g();
   h(0);
   leak(0);
+  unicode();
   return 0;
 }
 
Index: clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
===
--- clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
+++ clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
@@ -4,7 +4,7 @@
 {
   "artifacts": [
 {
-  "length": 951,
+  "length": 1077,
   "location": {
   },
   "mimeType": "text/plain",
@@ -13,6 +13,7 @@
   ]
 }
   ],
+  "columnKind": "unicodeCodePoints",
   "results": [
 {
   "codeFlows": [
@@ -32,9 +33,9 @@
   },
   "region": {
 "endColumn": 6,
-"endLine": 34,
+"endLine": 40,
 "startColumn": 3,
-"startLine": 34
+"startLine": 40
   }
 }
   }
@@ -102,9 +103,9 @@
   },
   "region": {
 "endColumn": 6,
-"endLine": 35,
+"endLine": 41,
 "startColumn": 3,
-"startLine": 35
+"startLine": 41
   }
 }
   }
@@ -120,7 +121,7 @@
 "index": 0,
   },
   "region": {
-"endColumn": 11,
+"endColumn": 12,
 "endLine": 15,
 "startColumn": 3,
 "startLine": 15
@@ -363,6 +364,74 @@
   },
   "ruleId": "unix.Malloc",
   "ruleIndex": 3
+},
+{
+  "codeFlows": [
+{
+  "threadFlows": [
+{
+  "locations": [
+{
+  "importance": "essential",
+  "location": {
+"message": {
+  "text": "'løçål' initialized to 0"
+},
+"physicalLocation": {
+  "artifactLocation": {
+"index": 0,
+  },
+  "region": {
+"endColumn": 12,
+"endLine": 35,
+"startColumn": 3,
+"startLine": 35
+  }
+}
+  }
+},
+{
+  "importance": "essential",
+  "location": {
+"message": {
+  "text": "Division by zero"
+},
+"physicalLocation": {
+  "artifactLocation": {
+"index": 0,
+  },
+  "region": {
+"endColumn": 20,
+"startColumn": 20,
+"startLine": 36
+  }
+}
+  }
+}
+  ]
+}
+  ]
+}
+  ],
+  "locations": [
+{
+  "physic

[PATCH] D70512: [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-11-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 230948.
sammccall marked 10 inline comments as done.
sammccall added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70512

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/Annotations.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
+#include "gmock/gmock.h"
 #include 
 #include 
 #include 
@@ -663,6 +664,20 @@
   ValueIs(SameRange(findSpelled("not_mapped";
 }
 
+TEST_F(TokenBufferTest, ExpandedTokensForRange) {
+  recordTokens(R"cpp(
+#define SIGN(X) X##_washere
+A SIGN(B) C SIGN(D) E SIGN(F) G
+  )cpp");
+
+  SourceRange R(findExpanded("C").front().location(),
+findExpanded("F_washere").front().location());
+  // Sanity check: expanded and spelled tokens are stored separately.
+  EXPECT_THAT(Buffer.expandedTokens(R),
+  SameRange(findExpanded("C D_washere E F_washere")));
+  EXPECT_THAT(Buffer.expandedTokens(SourceRange()), testing::IsEmpty());
+}
+
 TEST_F(TokenBufferTest, ExpansionStartingAt) {
   // Object-like macro expansions.
   recordTokens(R"cpp(
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -119,6 +119,22 @@
   return Text.substr(Begin, length());
 }
 
+llvm::ArrayRef TokenBuffer::expandedTokens(SourceRange R) const {
+  if (R.isInvalid())
+return {};
+  const Token *Begin =
+  llvm::partition_point(expandedTokens(), [&](const syntax::Token &T) {
+return SourceMgr->isBeforeInTranslationUnit(T.location(), R.getBegin());
+  });
+  const Token *End =
+  llvm::partition_point(expandedTokens(), [&](const syntax::Token &T) {
+return !SourceMgr->isBeforeInTranslationUnit(R.getEnd(), T.location());
+  });
+  if (Begin > End)
+return {};
+  return {Begin, End};
+}
+
 std::pair
 TokenBuffer::spelledForExpandedToken(const syntax::Token *Expanded) const {
   assert(Expanded);
Index: clang/include/clang/Tooling/Syntax/Tokens.h
===
--- clang/include/clang/Tooling/Syntax/Tokens.h
+++ clang/include/clang/Tooling/Syntax/Tokens.h
@@ -175,6 +175,7 @@
   /// All tokens produced by the preprocessor after all macro replacements,
   /// directives, etc. Source locations found in the clang AST will always
   /// point to one of these tokens.
+  /// Tokens are in TU order (per SourceManager::isBeforeInTranslationUnit()).
   /// FIXME: figure out how to handle token splitting, e.g. '>>' can be split
   ///into two '>' tokens by the parser. However, TokenBuffer currently
   ///keeps it as a single '>>' token.
@@ -182,6 +183,10 @@
 return ExpandedTokens;
   }
 
+  /// Returns the subrange of expandedTokens() corresponding to the closed
+  /// token range R.
+  llvm::ArrayRef expandedTokens(SourceRange R) const;
+
   /// Find the subrange of spelled tokens that produced the corresponding \p
   /// Expanded tokens.
   ///
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -269,7 +269,7 @@
   EXPECT_UNAVAILABLE(UnavailableCases);
 
   // vector of pairs of input and output strings
-  const std::vector>
+  const std::vector>
   InputOutputs = {
   // extraction from variable declaration/assignment
   {R"cpp(void varDecl() {
@@ -321,17 +321,10 @@
if(1)
 LOOP(5 + [[3]])
  })cpp",
-   /*FIXME: It should be extracted like this. SelectionTree needs to be
- * fixed for macros.
 R"cpp(#define LOOP(x) while (1) {a = x;}
-void f(int a) {
-  auto dummy = 3; if(1)
-   LOOP(5 + dummy)
-})cpp"},*/
-   R"cpp(#define LOOP(x) while (1) {a = x;}
  void f(int a) {
-   auto dummy = LOOP(5 + 3); if(1)
-dummy
+   auto dummy = 3; if(1)
+LOOP(5 + dummy)
  })cpp"},
   {R"cpp(#define LOOP(x) do {x;} while(1);
   

[PATCH] D69938: [OpenCL] Use __generic addr space when generating internal representation of lambda

2019-11-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D69938#1755709 , @rjmccall wrote:

> In D69938#1754894 , @Anastasia wrote:
>
> > In D69938#1752024 , @rjmccall 
> > wrote:
> >
> > > Yes, in that case copy-elision into the global variable is guaranteed.  
> > > You can write arbitrary expressions in global initializers, however, and 
> > > those can use temporary lambdas.
> >
> >
> > I guess you mean something like this?
> >
> >   auto glambda = []() { return 1; }();
> >   
>
>
> Yes, or just passing it as an argument to something.
>
> > I don't see a way to change the address space of a lambda object however. 
> > It would only be possible to specify addr space qualifiers for a call 
> > operator of such lambdas.
>
> Yes, I think the language has to say what address space the lambda temporary 
> is in.  Among other things, this can affect how captures are initialized, 
> since some constructors are only usable in certain address spaces.  (Lambdas 
> in global contexts can't capture surrounding local variables, but they can 
> still have explicitly-initialized captures, like `[x=foo()] { ... }`.)  That 
> language rule could be that lambda temporaries are always in the private 
> address space, or it could be that lambdas in global contexts are in the 
> global address space.  The latter might be easier because it's compatible 
> with lifetime-extension: we don't necessarily know when processing the lambda 
> whether its temporary will be lifetime-extended, and if it is, it needs to be 
> in the global address space.  The only disadvantage of that is that we'd have 
> to use global memory even for non-extended temporaries in global initializers.
>
> Richard might have thoughts about this.  I don't know if there's been any 
> language work around copy-elision and/or lifetime-extension that might be 
> stretchable to allow us to delay the address-space decision until later.


Ok, I see. Thanks! I agree for OpenCL `__global` might make more sense for the 
program scope lambdas. I will look into this. However, would it be ok to 
proceed with this patch adding `__generic` address space as a qualifier to 
lambda call operators by default. Is there anything that should be added to 
complete it?


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

https://reviews.llvm.org/D69938



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


[PATCH] D70684: [clangd] Shutdown cleanly on signals.

2019-11-25 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.
Herald added a subscriber: dexonsmith.

Build result: fail - 60239 tests passed, 1 failed and 732 were skipped.

  failed: Clangd.Clangd/exit-signal.test

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70684



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


[PATCH] D70687: [WebAssembly] Add an llvm-lto path for compiler-rt.

2019-11-25 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
Herald added subscribers: cfe-commits, dexonsmith, aheejin, jgravelle-google, 
inglorion, sbc100, mehdi_amini, dberris, dschuff.
Herald added a project: clang.

This allows LTO-enabled builds of compiler-rt to be used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70687

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -71,6 +71,7 @@
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
+  std::string getCompilerRTPath() const;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -155,6 +155,19 @@
   }
 }
 
+std::string WebAssembly::getCompilerRTPath() const {
+  // If we're doing LTO and we have an LTO library available, use it.
+  const auto &D = getDriver();
+  if (D.isUsingLTO()) {
+auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath());
+if (llvm::sys::fs::exists(Dir))
+  return Dir;
+  }
+
+  // Otherwise just use the default.
+  return ToolChain::getCompilerRTPath();
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -71,6 +71,7 @@
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
+  std::string getCompilerRTPath() const;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -155,6 +155,19 @@
   }
 }
 
+std::string WebAssembly::getCompilerRTPath() const {
+  // If we're doing LTO and we have an LTO library available, use it.
+  const auto &D = getDriver();
+  if (D.isUsingLTO()) {
+auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath());
+if (llvm::sys::fs::exists(Dir))
+  return Dir;
+  }
+
+  // Otherwise just use the default.
+  return ToolChain::getCompilerRTPath();
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70684: [clangd] Shutdown cleanly on signals.

2019-11-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, jfb, arphaman, jkorous, 
MaskRay, ilya-biryukov, mgorny.
Herald added a reviewer: jfb.
Herald added a project: clang.

This avoids leaking PCH files if editors don't use the LSP shutdown protocol.

This is one fix for https://github.com/clangd/clangd/issues/209
(Though I think we should *also* be unlinking the files)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70684

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/Shutdown.cpp
  clang-tools-extra/clangd/Shutdown.h
  clang-tools-extra/clangd/test/exit-eof.test
  clang-tools-extra/clangd/test/exit-signal.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -11,6 +11,7 @@
 #include "Features.inc"
 #include "Path.h"
 #include "Protocol.h"
+#include "Shutdown.h"
 #include "Trace.h"
 #include "Transport.h"
 #include "index/Background.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#ifndef _WIN32
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace {
@@ -435,6 +440,7 @@
 
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::sys::SetInterruptFunction(&requestShutdown);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << clang::getClangToolFullVersion("clangd") << "\n";
   });
@@ -531,6 +537,10 @@
   LoggingSession LoggingSession(Logger);
   // Write some initial logs before we start doing any real work.
   log("{0}", clang::getClangToolFullVersion("clangd"));
+// FIXME: abstract this better, and print PID on windows too.
+#ifndef _WIN32
+  log("PID: {0}", getpid());
+#endif
   {
 SmallString<128> CWD;
 if (auto Err = llvm::sys::fs::current_path(CWD))
@@ -683,12 +693,7 @@
   // However if a bug causes them to run forever, we want to ensure the process
   // eventually exits. As clangd isn't directly user-facing, an editor can
   // "leak" clangd processes. Crashing in this case contains the damage.
-  //
-  // This is more portable than sys::WatchDog, and yields a stack trace.
-  std::thread([] {
-std::this_thread::sleep_for(std::chrono::minutes(5));
-std::abort();
-  }).detach();
+  abortAfterTimeout(std::chrono::minutes(5));
 
   return ExitCode;
 }
Index: clang-tools-extra/clangd/test/exit-signal.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-signal.test
@@ -0,0 +1,31 @@
+# This is a fiddly signal test, we need POSIX and a real shell.
+UNSUPPORTED: win32
+REQUIRES: shell
+
+# Our goal is:
+#  1) spawn clangd
+#  2) wait for it to start up (install signal handlers)
+#  3) send SIGTERM
+#  4) wait for clangd to shut down (nonzero exit for a signal)
+#  4) verify the shutdown was clean
+
+RUN: rm %t.err
+ # To keep clangd running, we need to hold its input stream open.
+ # We redirect its input to a subshell that waits for it to start up.
+RUN: not clangd 2> %t.err < <( \
+   # Loop waiting for clangd to start up, so signal handlers are installed.
+   # Reading the PID line ensures this, and lets us send a signal.
+RUN:   while true; do \
+ # Relevant log line is I[timestamp] PID: 
+RUN: CLANGD_PID=$(grep -a -m 1 "PID:" %t.err | cut -d' ' -f 3); \
+RUN: [ ! -z "$CLANGD_PID" ] && break; \
+RUN:   done; \
+RUN:   kill $CLANGD_PID \
+ # Now wait for clangd to exit.
+RUN: )
+
+# Check that clangd caught the signal and shut down cleanly.
+RUN: FileCheck %s < %t.err
+CHECK: Transport error: Got signal
+CHECK: LSP finished
+
Index: clang-tools-extra/clangd/test/exit-eof.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-eof.test
@@ -0,0 +1,7 @@
+# RUN: not clangd -sync < %s 2> %t.err
+# RUN: FileCheck %s < %t.err
+#
+# No LSP messages here, just let clangd see the end-of-file
+# CHECK: Transport error:
+# (Typically "Transport error: Input/output error" but platform-dependent).
+
Index: clang-tools-extra/clangd/Shutdown.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Shutdown.h
@@ -0,0 +1,84 @@
+//===--- Shutdown.h - Unclean exit scenarios *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+//
+// LSP specifies a protocol for shutting down: a `shutdown` request followed
+// by an `exit` notification. If this protocol is fol

[PATCH] D70677: [WebAssembly] Change the llvm-lto dir to use the LLVM Version

2019-11-25 Thread sunfishcode via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG872a53ef9489: [WebAssembly] Change the llvm-lto dir to use 
the LLVM Version (authored by sunfishcode).

Changed prior to commit:
  https://reviews.llvm.org/D70677?vs=230919&id=230934#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70677

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -118,6 +118,14 @@
   }
 }
 
+/// Given a base library directory, append path components to form the
+/// LTO directory.
+static std::string AppendLTOLibDir(const std::string &Dir) {
+// The version allows the path to be keyed to the specific version of
+// LLVM in used, as the bitcode format is not stable.
+return Dir + "/llvm-lto/" LLVM_VERSION_STRING;
+}
+
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
  const llvm::opt::ArgList &Args)
 : ToolChain(D, Triple, Args) {
@@ -126,26 +134,24 @@
 
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
+  auto SysRoot = getDriver().SysRoot;
   if (getTriple().getOS() == llvm::Triple::UnknownOS) {
 // Theoretically an "unknown" OS should mean no standard libraries, however
 // it could also mean that a custom set of libraries is in use, so just add
 // /lib to the search path. Disable multiarch in this case, to discourage
 // paths containing "unknown" from acquiring meanings.
-getFilePaths().push_back(getDriver().SysRoot + "/lib");
+getFilePaths().push_back(SysRoot + "/lib");
   } else {
 const std::string MultiarchTriple =
-getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
+getMultiarchTriple(getDriver(), Triple, SysRoot);
 if (D.isUsingLTO()) {
-  auto LLVMRevision = getLLVMRevision();
-  if (!LLVMRevision.empty()) {
-// For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
-// Note that the directory is keyed to the LLVM revision, as LLVM's
-// bitcode format is not stable.
-getFilePaths().push_back(getDriver().SysRoot + "/lib/" + 
MultiarchTriple +
- "/llvm-lto/" + LLVMRevision);
-  }
+  // For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
+  // Note that the directory is keyed to the LLVM revision, as LLVM's
+  // bitcode format is not stable.
+  auto Dir = AppendLTOLibDir(SysRoot + "/lib/" + MultiarchTriple);
+  getFilePaths().push_back(Dir);
 }
-getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple);
+getFilePaths().push_back(SysRoot + "/lib/" + MultiarchTriple);
   }
 }
 


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -118,6 +118,14 @@
   }
 }
 
+/// Given a base library directory, append path components to form the
+/// LTO directory.
+static std::string AppendLTOLibDir(const std::string &Dir) {
+// The version allows the path to be keyed to the specific version of
+// LLVM in used, as the bitcode format is not stable.
+return Dir + "/llvm-lto/" LLVM_VERSION_STRING;
+}
+
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
  const llvm::opt::ArgList &Args)
 : ToolChain(D, Triple, Args) {
@@ -126,26 +134,24 @@
 
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
+  auto SysRoot = getDriver().SysRoot;
   if (getTriple().getOS() == llvm::Triple::UnknownOS) {
 // Theoretically an "unknown" OS should mean no standard libraries, however
 // it could also mean that a custom set of libraries is in use, so just add
 // /lib to the search path. Disable multiarch in this case, to discourage
 // paths containing "unknown" from acquiring meanings.
-getFilePaths().push_back(getDriver().SysRoot + "/lib");
+getFilePaths().push_back(SysRoot + "/lib");
   } else {
 const std::string MultiarchTriple =
-getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
+getMultiarchTriple(getDriver(), Triple, SysRoot);
 if (D.isUsingLTO()) {
-  auto LLVMRevision = getLLVMRevision();
-  if (!LLVMRevision.empty()) {
-// For LTO, enable use of lto-enabled sysroot libraries too, if available.
-// Note that the directory is keyed to the LLVM revision, as LLVM's
-// bitcode format is not stable.
-getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple +
- "/llvm-lto/" + LLVMRevision);
-  }
+  // For LTO, enable use of lto-en

[PATCH] D69628: [Clang] Pragma vectorize_width() implies vectorize(enable), take 3

2019-11-25 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D69628



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


[clang] 872a53e - [WebAssembly] Change the llvm-lto dir to use the LLVM Version

2019-11-25 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2019-11-25T10:29:51-08:00
New Revision: 872a53ef9489fcfbb48c6f8dd30bd9a9a026934f

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

LOG: [WebAssembly] Change the llvm-lto dir to use the LLVM Version

Using the version instead of the VCS revision, which isn't available
when LLVM_APPEND_VC_REV is set. The bitcode format should be
backwards-compatible at least within a minor version, so the version
string should be sufficient.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index a2a9dff79e52..55b82592c09f 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -118,6 +118,14 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 }
 
+/// Given a base library directory, append path components to form the
+/// LTO directory.
+static std::string AppendLTOLibDir(const std::string &Dir) {
+// The version allows the path to be keyed to the specific version of
+// LLVM in used, as the bitcode format is not stable.
+return Dir + "/llvm-lto/" LLVM_VERSION_STRING;
+}
+
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
  const llvm::opt::ArgList &Args)
 : ToolChain(D, Triple, Args) {
@@ -126,26 +134,24 @@ WebAssembly::WebAssembly(const Driver &D, const 
llvm::Triple &Triple,
 
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
+  auto SysRoot = getDriver().SysRoot;
   if (getTriple().getOS() == llvm::Triple::UnknownOS) {
 // Theoretically an "unknown" OS should mean no standard libraries, however
 // it could also mean that a custom set of libraries is in use, so just add
 // /lib to the search path. Disable multiarch in this case, to discourage
 // paths containing "unknown" from acquiring meanings.
-getFilePaths().push_back(getDriver().SysRoot + "/lib");
+getFilePaths().push_back(SysRoot + "/lib");
   } else {
 const std::string MultiarchTriple =
-getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
+getMultiarchTriple(getDriver(), Triple, SysRoot);
 if (D.isUsingLTO()) {
-  auto LLVMRevision = getLLVMRevision();
-  if (!LLVMRevision.empty()) {
-// For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
-// Note that the directory is keyed to the LLVM revision, as LLVM's
-// bitcode format is not stable.
-getFilePaths().push_back(getDriver().SysRoot + "/lib/" + 
MultiarchTriple +
- "/llvm-lto/" + LLVMRevision);
-  }
+  // For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
+  // Note that the directory is keyed to the LLVM revision, as LLVM's
+  // bitcode format is not stable.
+  auto Dir = AppendLTOLibDir(SysRoot + "/lib/" + MultiarchTriple);
+  getFilePaths().push_back(Dir);
 }
-getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple);
+getFilePaths().push_back(SysRoot + "/lib/" + MultiarchTriple);
   }
 }
 



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 230928.
jdoerfert marked 4 inline comments as done.
jdoerfert added a comment.

use streams, remove caching


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785

Files:
  llvm/include/llvm/Frontend/OpenMPConstants.h
  llvm/include/llvm/Frontend/OpenMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMPKinds.def
  llvm/lib/Frontend/CMakeLists.txt
  llvm/lib/Frontend/OpenMPConstants.cpp
  llvm/lib/Frontend/OpenMPIRBuilder.cpp
  llvm/unittests/CMakeLists.txt
  llvm/unittests/Frontend/CMakeLists.txt
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- /dev/null
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -0,0 +1,178 @@
+//===- llvm/unittest/IR/OpenMPIRBuilderTest.cpp - OpenMPIRBuilder tests ---===//
+//
+// 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
+//
+//===--===//
+
+#include "llvm/Frontend/OpenMPIRBuilder.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Frontend/OpenMPConstants.h"
+#include "llvm/IR/Verifier.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace omp;
+using namespace types;
+
+namespace {
+
+class OpenMPIRBuilderTest : public testing::Test {
+protected:
+  void SetUp() override {
+M.reset(new Module("MyModule", Ctx));
+FunctionType *FTy =
+FunctionType::get(Type::getVoidTy(Ctx), {Type::getInt32Ty(Ctx)},
+  /*isVarArg=*/false);
+F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
+BB = BasicBlock::Create(Ctx, "", F);
+
+DIBuilder DIB(*M);
+auto File = DIB.createFile("test.dbg", "/");
+auto CU =
+DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
+auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
+auto SP = DIB.createFunction(
+CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
+DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
+F->setSubprogram(SP);
+auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
+DIB.finalize();
+DL = DebugLoc::get(3, 7, Scope);
+  }
+
+  void TearDown() override {
+BB = nullptr;
+M.reset();
+uninitializeTypes();
+  }
+
+  LLVMContext Ctx;
+  std::unique_ptr M;
+  Function *F;
+  BasicBlock *BB;
+  DebugLoc DL;
+};
+
+TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  IRBuilder<> Builder(BB);
+
+  OMPBuilder.CreateBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
+  EXPECT_TRUE(M->global_empty());
+  EXPECT_EQ(M->size(), 1U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 0U);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 3U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 2U);
+
+  CallInst *GTID = dyn_cast(&BB->front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+  EXPECT_FALSE(GTID->getCalledFunction()->doesNotAccessMemory());
+  EXPECT_FALSE(GTID->getCalledFunction()->doesNotFreeMemory());
+
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_NE(Barrier, nullptr);
+  EXPECT_EQ(Barrier->getNumArgOperands(), 2U);
+  EXPECT_EQ(Barrier->getCalledFunction()->getName(), "__kmpc_barrier");
+  EXPECT_FALSE(Barrier->getCalledFunction()->doesNotAccessMemory());
+  EXPECT_FALSE(Barrier->getCalledFunction()->doesNotFreeMemory());
+
+  EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
+
+  Builder.CreateUnreachable();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
+TEST_F(OpenMPIRBuilderTest, CreateCancelBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  BasicBlock *CBB = BasicBlock::Create(Ctx, "", F);
+  new UnreachableInst(Ctx, CBB);
+  OMPBuilder.setCancellationBlock(CBB);
+
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  auto NewIP = OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  Builder.restoreIP(NewIP);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 3U);
+  EXPECT_EQ(F->size(), 3U);
+  EXPECT_EQ(BB->size(), 4U);
+
+  CallInst *GTID = dyn_cast(&BB->front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+  EXPECT_FALSE(GTID->getCalledFunction()->doesNotAccessMemory(

[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

@ABataev  @JonChesterfield  anything else blocking this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-11-25 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

I still have to try out the patch.

In D61446#1756211 , @serge-sans-paille 
wrote:

> @Meinersbur to make your reviewer job easier, I've setup validation for that 
> patch, see https://github.com/serge-sans-paille/llvm-project/pull/2/checks
>  It build and validates fine.


Thanks!

[suggestion] Also add `-DPOLLY_ENABLE_GPGPU_CODEGEN=ON` and 
`-DLLVM_ENABLE_ASSERTIONS=ON`, and run `ninja check-polly`. It currently does 
not run any polly code, just compiles it.




Comment at: llvm/docs/WritingAnLLVMPass.rst:1200
+
+- ``LLVM_${NAME}_LINK_INTO_TOOLS``, when sets to ``ON``, turns the project into
+  a statically linked extension

[typo] when set~~s~~ to



Comment at: llvm/test/Feature/load_extension.ll:1-2
+; RUN: opt %s %loadbye -goodbye -wave-goodbye -disable-output > %t.log
+; RUN: FileCheck %s < %t.log
+; REQUIRES: plugins, examples

[suggestion] The established pattern is to pipe the output to FileCheck without 
using a temporary file.



Comment at: llvm/tools/bugpoint/bugpoint.cpp:230-232
+// Needed to pull in symbols from statically linked extensions, including 
static
+// registration. It is unused otherwise because bugpoint has no support for
+// NewPM.

Nice!



Comment at: polly/include/polly/RegisterPasses.h:26
 void initializePollyPasses(llvm::PassRegistry &Registry);
-void registerPollyPasses(llvm::legacy::PassManagerBase &PM);
+void RegisterPollyPasses(llvm::PassBuilder &PB);
 } // namespace polly

[style] [[ 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
 | Start function names with lower case letters ]]



Comment at: polly/lib/Plugin/Polly.cpp:17-30
+/// Initialize Polly passes when library is loaded.
+///
+/// We use the constructor of a statically declared object to initialize the
+/// different Polly passes right after the Polly library is loaded. This 
ensures
+/// that the Polly passes are available e.g. in the 'opt' tool.
+class StaticInitializer {
+public:

[serious] Since `opt`, ... etc. don't call `initializePollyPasses` directly 
anymore, I think the static initializer has to moved to `RegisterPasses.cpp`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D70549: [OPENMP]Fix PR41826: symbols visibility in device code.

2019-11-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert 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/D70549/new/

https://reviews.llvm.org/D70549



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


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2019-11-25 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

I've now posted https://reviews.llvm.org/D70677 which should fix the test 
failure when `LLVM_APPEND_VC_REV=NO` is set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500



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


[PATCH] D70677: [WebAssembly] Change the llvm-lto dir to use the LLVM Version

2019-11-25 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
sunfish added reviewers: sbc100, dschuff.
Herald added subscribers: cfe-commits, dexonsmith, aheejin, jgravelle-google, 
inglorion.
Herald added a project: clang.

Using the version instead of the VCS revision, which isn't available when 
LLVM_APPEND_VC_REV is set. The bitcode format should be backwards-compatible at 
least within a minor version, so the version string should be sufficient.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70677

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -119,14 +119,11 @@
 }
 
 /// Given a base library directory, append path components to form the
-/// LTO directory. The LLVMRevision allows the path to be keyed to the
-/// specific version of LLVM in used, as the bitcode format is not stable.
-static std::string AppendLTOLibDir(const std::string &Dir,
-   const std::string &LLVMRevision) {
-if (LLVMRevision.empty()) {
-return Dir;
-}
-return Dir + "/llvm-lto/" + LLVMRevision;
+/// LTO directory.
+static std::string AppendLTOLibDir(const std::string &Dir) {
+// The version allows the path to be keyed to the specific version of
+// LLVM in used, as the bitcode format is not stable.
+return Dir + "/llvm-lto/" LLVM_VERSION_STRING;
 }
 
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
@@ -148,15 +145,11 @@
 getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
 auto Sysroot = getDriver().SysRoot;
 if (D.isUsingLTO()) {
-  auto LLVMRevision = getLLVMRevision();
-  if (!LLVMRevision.empty()) {
-// For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
-// Note that the directory is keyed to the LLVM revision, as LLVM's
-// bitcode format is not stable.
-auto Dir = AppendLTOLibDir(Sysroot + "/lib/" + MultiarchTriple,
-   LLVMRevision);
-getFilePaths().push_back(Dir);
-  }
+  // For LTO, enable use of lto-enabled sysroot libraries too, if 
available.
+  // Note that the directory is keyed to the LLVM revision, as LLVM's
+  // bitcode format is not stable.
+  auto Dir = AppendLTOLibDir(Sysroot + "/lib/" + MultiarchTriple);
+  getFilePaths().push_back(Dir);
 }
 getFilePaths().push_back(Sysroot + "/lib/" + MultiarchTriple);
   }
@@ -166,12 +159,9 @@
   // If we're doing LTO and we have an LTO library available, use it.
   const auto &D = getDriver();
   if (D.isUsingLTO()) {
-auto LLVMRevision = getLLVMRevision();
-if (!LLVMRevision.empty()) {
-  auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath(), LLVMRevision);
-  if (llvm::sys::fs::exists(Dir))
-return Dir;
-}
+auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath());
+if (llvm::sys::fs::exists(Dir))
+  return Dir;
   }
 
   // Otherwise just use the default.


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -119,14 +119,11 @@
 }
 
 /// Given a base library directory, append path components to form the
-/// LTO directory. The LLVMRevision allows the path to be keyed to the
-/// specific version of LLVM in used, as the bitcode format is not stable.
-static std::string AppendLTOLibDir(const std::string &Dir,
-   const std::string &LLVMRevision) {
-if (LLVMRevision.empty()) {
-return Dir;
-}
-return Dir + "/llvm-lto/" + LLVMRevision;
+/// LTO directory.
+static std::string AppendLTOLibDir(const std::string &Dir) {
+// The version allows the path to be keyed to the specific version of
+// LLVM in used, as the bitcode format is not stable.
+return Dir + "/llvm-lto/" LLVM_VERSION_STRING;
 }
 
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
@@ -148,15 +145,11 @@
 getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
 auto Sysroot = getDriver().SysRoot;
 if (D.isUsingLTO()) {
-  auto LLVMRevision = getLLVMRevision();
-  if (!LLVMRevision.empty()) {
-// For LTO, enable use of lto-enabled sysroot libraries too, if available.
-// Note that the directory is keyed to the LLVM revision, as LLVM's
-// bitcode format is not stable.
-auto Dir = AppendLTOLibDir(Sysroot + "/lib/" + MultiarchTriple,
-   LLVMRevision);
-getFilePaths().push_back(Dir);
-  }
+  // For LTO, enable use of lto-enabled sysroot libraries too, if available.
+  // Note that the directory is keyed to the LLVM revision, as LLVM's
+  // bitcode format is 

[PATCH] D70675: [AIX] Disable clang python binding tests

2019-11-25 Thread David Tenty via Phabricator via cfe-commits
daltenty created this revision.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

The Python ctypes FFI interface is broken on AIX, it cannot properly pass
structures containing  arrays ( https://bugs.python.org/issue38628). So
disable the clang python binding tests on AIX till this is resolved.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70675

Files:
  clang/bindings/python/tests/CMakeLists.txt


Index: clang/bindings/python/tests/CMakeLists.txt
===
--- clang/bindings/python/tests/CMakeLists.txt
+++ clang/bindings/python/tests/CMakeLists.txt
@@ -32,6 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
+# The Python FFI interface is broken on AIX: 
https://bugs.python.org/issue38628.
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:


Index: clang/bindings/python/tests/CMakeLists.txt
===
--- clang/bindings/python/tests/CMakeLists.txt
+++ clang/bindings/python/tests/CMakeLists.txt
@@ -32,6 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
+# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2019-11-25 Thread Dan Gohman via Phabricator via cfe-commits
sunfish marked an inline comment as done.
sunfish added a comment.

In D70500#1757735 , @thakis wrote:

> Please don't add code to the driver that runs programs off PATH. Nothing else 
> does this.


Clang's normal `GetProgramPath` does do this: 
https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/Driver.cpp#L4719

> If you need to run an external program, look for it next to the compiler, 
> like we do for gas with -fno-integrated-as, linker, etc. People can use the 
> existing -B flag to make clang look elsewhere if they need that.

Unfortunately, wasm-opt isn't typically installed alongside the compiler. It's 
also not a typical system tool like an assembler, which is why it didn't seem 
right to search the -B paths.

The first version of my patch used a dedicated environment variable, WASM_OPT, 
rather than PATH, but I changed it to PATH after review feedback. If people 
feel using -B paths, and COMPILER_PATH, are appropriate, we can use 
`GetProgramPath` itself, though note that that still does have a PATH fallback.




Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:137
+  getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple 
+
+   "/llvm-lto");
+}

thakis wrote:
> sunfish wrote:
> > sbc100 wrote:
> > > Is there any kind of president here?   i.e. do any other platforms have 
> > > support for this kind thing?  Seems like good idea I'd just like to be 
> > > sure we follow existing practices.
> > I looked around, but didn't see anything similar.
> One immediate problem of this approach is that if HAVE_VCS_VERSION_INC is not 
> set, then the test fails, but if it is set, `clang --version` reports a 
> current git hash, which is either out of date or requires a pretty big 
> rebuild on every single git commit (i.e. not just after `git pull` but also 
> after local commits). Neither's great.
> 
> Do you expected that sysroots will ship 3-4 LTO folders, to support ~2 years 
> of clang releases? Or do you expect that a sysroot will always support a 
> single clang/llvm revision? If so, maybe the LLVM version is enough?
Yes, I think we can switch from the VCS string to the LLVM_VERSION string. The 
documentation says LLVM guarantees bitcode backwards compatibility between 
minor versions, so this should be sufficient. I'll post a new patch for that, 
which should also fix the test when HAVE_VCS_VERSION_INC is false.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500



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


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-25 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0619r4.html#3.2

So C++20 or C++23.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D70342#1758832 , @xbolva00 wrote:

> Add copy ctor/op= manually.


Does the warning mean that the implicitly defined copy ctor is not going to 
work in some later version of the language?

I'm just trying to understand what it's warning about. If it's pointing out 
bugs in our code, we should fix them obviously.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2019-11-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks for the feedback Russell!

Can you possibly try again with `/MT`? (ie. `-DLLVM_USE_CRT_RELEASE=MT`)

In the `abba_test.ps1` script, `ninja check-all` is only used for preparing 
clang.exe with the patch. The A/B loop //does not// use `check-all`.

I've modified the `abba_test.ps1` script to only build `llvm/`, with the same 
options as you do. There was also a bug in the timespan calculation, the test 
would last a lot more than you specified.

I also found out that on some of our multi-socket servers, Ninja defaulted to 
only the # threads from the first socket. If you had a 2x 18-core system, Ninja 
would default to 38 threads (18 x 2 + 2) instead of 74 threads (2 x 18 x 2 + 
2). This behavior seems to be random,  depending on the system. This has been 
fixed by Ninja PR 1674 , I've 
tested all our systems with this patch and they now all default to the proper # 
of threads.

I'm doing a new round of tests, I'll get back with updated figures.


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

https://reviews.llvm.org/D69825



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


[PATCH] D70539: [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/derement (PR44054)

2019-11-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for the review!
I'll hold this off for a bit in case anyone else wants to comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70539



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


[PATCH] D70424: clang/AMDGPU: Fix default for frame-pointer attribute

2019-11-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM. But I am wondering how it affects -g. Do we need to keep frame pointer 
when -g is specified? Should we add a test for -O3 -g?


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

https://reviews.llvm.org/D70424



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


[PATCH] D70480: [clangd] Use expansion location when the ref is inside macros.

2019-11-25 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60296 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70480



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


[PATCH] D70480: [clangd] Use expansion location when the ref is inside macros.

2019-11-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:280
   (Roles & static_cast(index::SymbolRole::Reference)) &&
-  SM.getFileID(SpellingLoc) == SM.getMainFileID())
+  SM.getFileID(SM.getSpellingLoc(Loc)) == SM.getMainFileID())
 ReferencedDecls.insert(ND);

ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > We're using `getSpellingLoc` here and `getFileLoc` later. Why not use 
> > > `getFileLoc` everywhere?
> > > 
> > > Having a variable (similar to the `SpellingLoc` we had before) and 
> > > calling `getFileLoc` only once also seems preferable.
> > > We're using getSpellingLoc here and getFileLoc later. Why not use 
> > > getFileLoc everywhere?
> > 
> > There are two things in SymbolCollector:
> > - symbols & ranking signals, we use spelling location for them, the code is 
> > part of this, `ReferencedDecls` is used to calculate the ranking
> > - references
> > 
> > this patch only targets the reference part (changing the loc here would 
> > break many assumptions I think, and there was a failure test).
> - What are the assumptions that it will break?
> - What is rationale for using spelling locations for ranking and file 
> location for references?
> 
> It would be nice to have this spelled out somewhere in the code, too. 
> Currently this looks like an accidental inconsistency. Especially given that 
> `getFileLoc` and `getSpellingLoc` are often the same.
Added comments to clarify the difference between references and other fields. 



Comment at: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:659
+  TYPE(TYPE([[Foo]])) foo3;
+  [[CAT]](Fo, o) foo4;
+}

ilya-biryukov wrote:
> Previously we would not report any location at all in that case, right?
> Not sure how common this is, hope this won't blow up our index size too much. 
> No need to change anything now, but we should be ready to revert if needed.
> 
> Worth putting a comment here that AST-based XRefs behave in the same way. 
> (And maybe adding a test there, if there isn't one already)
Yes, I measure the memory usage before vs after, it increased ~5% memory usage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70480



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


[PATCH] D70480: [clangd] Use expansion location when the ref is inside macros.

2019-11-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 230905.
hokein marked 2 inline comments as done.
hokein added a comment.

address comments

- add related test for ast-based xrefs
- add comments to clarify using different location for symbols/references.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70480

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -796,6 +796,19 @@
 } // namespace ns
 int main() { [[^ns]]::Foo foo; }
   )cpp",
+
+  R"cpp(// Macros
+#define TYPE(X) X
+#define FOO Foo
+#define CAT(X, Y) X##Y
+class [[Fo^o]] {};
+void test() {
+  TYPE([[Foo]]) foo;
+  [[FOO]] foo2;
+  TYPE(TYPE([[Foo]])) foo3;
+  [[CAT]](Fo, o) foo4;
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -644,6 +644,29 @@
   HaveRanges(Header.ranges();
 }
 
+TEST_F(SymbolCollectorTest, RefsOnMacros) {
+  // Refs collected from SymbolCollector behave in the same way as
+  // AST-based xrefs.
+  CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.RefsInHeaders = true;
+  Annotations Header(R"(
+#define TYPE(X) X
+#define FOO Foo
+#define CAT(X, Y) X##Y
+class [[Foo]] {};
+void test() {
+  TYPE([[Foo]]) foo;
+  [[FOO]] foo2;
+  TYPE(TYPE([[Foo]])) foo3;
+  [[CAT]](Fo, o) foo4;
+}
+  )");
+  CollectorOpts.RefFilter = RefKind::All;
+  runSymbolCollector(Header.code(), "");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Foo").ID,
+  HaveRanges(Header.ranges();
+}
+
 TEST_F(SymbolCollectorTest, HeaderAsMainFile) {
   CollectorOpts.RefFilter = RefKind::All;
   Annotations Header(R"(
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -275,10 +275,9 @@
   // Mark D as referenced if this is a reference coming from the main file.
   // D may not be an interesting symbol, but it's cheaper to check at the end.
   auto &SM = ASTCtx->getSourceManager();
-  auto SpellingLoc = SM.getSpellingLoc(Loc);
   if (Opts.CountReferences &&
   (Roles & static_cast(index::SymbolRole::Reference)) &&
-  SM.getFileID(SpellingLoc) == SM.getMainFileID())
+  SM.getFileID(SM.getSpellingLoc(Loc)) == SM.getMainFileID())
 ReferencedDecls.insert(ND);
 
   auto ID = getSymbolID(ND);
@@ -311,9 +310,13 @@
   !shouldCollectSymbol(*ND, *ASTCtx, Opts, IsMainFileOnly))
 return true;
   // Do not store references to main-file symbols.
+  // Unlike other fields, e.g. Symbols (which use spelling locations), we use
+  // expansion locations for references comming from macros (as it aligns the
+  // behavior of clangd's AST-based xref).
   if (CollectRef && !IsMainFileOnly && !isa(ND) &&
-  (Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
-DeclRefs[ND].emplace_back(SpellingLoc, Roles);
+  (Opts.RefsInHeaders ||
+   SM.getFileID(SM.getFileLoc(Loc)) == SM.getMainFileID()))
+DeclRefs[ND].emplace_back(SM.getFileLoc(Loc), Roles);
   // Don't continue indexing if this is a mere reference.
   if (IsOnlyRef)
 return true;


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -796,6 +796,19 @@
 } // namespace ns
 int main() { [[^ns]]::Foo foo; }
   )cpp",
+
+  R"cpp(// Macros
+#define TYPE(X) X
+#define FOO Foo
+#define CAT(X, Y) X##Y
+class [[Fo^o]] {};
+void test() {
+  TYPE([[Foo]]) foo;
+  [[FOO]] foo2;
+  TYPE(TYPE([[Foo]])) foo3;
+  [[CAT]](Fo, o) foo4;
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests

[PATCH] D70539: [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/derement (PR44054)

2019-11-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70539



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


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2019-11-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

The test also break in our internal integrate.
Relying on having programs in path and ignoring the `-B` and sysroot is 
definitely a bad idea.

I would suggest reverting this patch and re-landing after doing another round 
of review and fixing those issues.
@thakis, @sunfish, any objections or thoughts on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500



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


[PATCH] D69618: NeonEmitter: clean up prototype modifiers

2019-11-25 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Sorry about the delay investigating this, your e-mail bypassed my inbox for 
some reason and I only noticed the issue when Hans reverted the change this 
afternoon. I'm looking into it now.


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

https://reviews.llvm.org/D69618



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


Re: [clang] 21f2647 - Revert 3f91705ca54 "ARM-NEON: make type modifiers orthogonal and allow multiple modifiers."

2019-11-25 Thread Hans Wennborg via cfe-commits
+Tim, I've reverted this since it seems to have broken the vector
initialization intrinsics.

(I would have replied to the llvm-commits email for the original
change, but it seems it didn't reach the list?)

On Mon, Nov 25, 2019 at 4:35 PM Hans Wennborg via cfe-commits
 wrote:
>
>
> Author: Hans Wennborg
> Date: 2019-11-25T16:27:53+01:00
> New Revision: 21f26470e9747c472d3c18654e676cbea8393635
>
> URL: 
> https://github.com/llvm/llvm-project/commit/21f26470e9747c472d3c18654e676cbea8393635
> DIFF: 
> https://github.com/llvm/llvm-project/commit/21f26470e9747c472d3c18654e676cbea8393635.diff
>
> LOG: Revert 3f91705ca54 "ARM-NEON: make type modifiers orthogonal and allow 
> multiple modifiers."
>
> This broke the vcreate_u64 intrinsic. Example:
>
>   $ cat /tmp/a.cc
>   #include 
>
>   void g() {
> auto v = vcreate_u64(0);
>   }
>   $ bin/clang -c /tmp/a.cc --target=arm-linux-androideabi16 -march=armv7-a
>   /tmp/a.cc:4:12: error: C-style cast from scalar 'int' to vector 
> 'uint64x1_t' (vector of 1 'uint64_t' value) of different size
> auto v = vcreate_u64(0);
>  ^~
>   
> /work/llvm.monorepo/build.release/lib/clang/10.0.0/include/arm_neon.h:4144:11:
>  note: expanded from macro 'vcreate_u64'
> __ret = (uint64x1_t)(__p0); \
> ^~
>
> Reverting until this can be investigated.
>
> > The modifier system used to mutate types on NEON intrinsic definitions had a
> > separate letter for all kinds of transformations that might be needed, and 
> > we
> > were quite quickly running out of letters to use. This patch converts to a 
> > much
> > smaller set of orthogonal modifiers that can be applied together to achieve 
> > the
> > desired effect.
> >
> > When merging with downstream it is likely to cause a conflict with any local
> > modifications to the .td files. There is a new script in
> > utils/convert_arm_neon.py that was used to convert all .td definitions and I
> > would suggest running it on the last downstream version of those files 
> > before
> > this commit rather than resolving conflicts manually.
>
> Added:
>
>
> Modified:
> clang/include/clang/Basic/arm_fp16.td
> clang/include/clang/Basic/arm_neon.td
> clang/include/clang/Basic/arm_neon_incl.td
> clang/test/CodeGen/aarch64-neon-intrinsics.c
> clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
> clang/utils/TableGen/NeonEmitter.cpp
>
> Removed:
> clang/utils/convert_arm_neon.py
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-25 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Add copy ctor/op= manually.

If you have a lot of warnings, you can use -Wno-deprecated-copy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2019-11-25 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@sylvestre.ledru backport for  release/9.x branch: 
https://sergesanspaille.fedorapeople.org/0001-Stack-clash-mir-attempt.patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D70671: [clang][CodeGen] Fix wrong memcpy size of no_unique_address in FieldMemcpyizer

2019-11-25 Thread Senran Zhang via Phabricator via cfe-commits
zsrkmyn created this revision.
zsrkmyn added reviewers: erichkeane, aaron.ballman, MaskRay, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When generating ctor, FieldMemcpyizer wrongly treated zero-sized class members
as what should be copied, and generated wrong memcpy size under some special
circumstances. This patch tries to fix it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70671

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/no-unique-address-2.cpp


Index: clang/test/CodeGenCXX/no-unique-address-2.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no-unique-address-2.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++2a %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s
+
+struct TriviallyCopyable {};
+
+struct NonTriviallyCopyable {
+  NonTriviallyCopyable() = default;
+  NonTriviallyCopyable(const NonTriviallyCopyable&) = default;
+  NonTriviallyCopyable(NonTriviallyCopyable &&) {}
+};
+
+struct Foo {
+  int i;
+  [[no_unique_address]] TriviallyCopyable m;
+  [[no_unique_address]] NonTriviallyCopyable n;
+};
+
+void call()
+{
+  Foo foo;
+  Foo foo2(static_cast(foo));
+}
+
+// The memcpy call should copy exact 4 bytes for member 'int i'
+// CHECK: define {{.*}} void @_ZN3FooC2EOS_
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.+}}, i8* {{.+}}, i64 4, 
i1 false)
+// CHECK:  call void @_ZN20NonTriviallyCopyableC2EOS_
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -914,6 +914,8 @@
 }
 
 void addMemcpyableField(FieldDecl *F) {
+  if (F->isZeroSize(CGF.getContext()))
+return;
   if (!FirstField)
 addInitialField(F);
   else


Index: clang/test/CodeGenCXX/no-unique-address-2.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no-unique-address-2.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++2a %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
+
+struct TriviallyCopyable {};
+
+struct NonTriviallyCopyable {
+  NonTriviallyCopyable() = default;
+  NonTriviallyCopyable(const NonTriviallyCopyable&) = default;
+  NonTriviallyCopyable(NonTriviallyCopyable &&) {}
+};
+
+struct Foo {
+  int i;
+  [[no_unique_address]] TriviallyCopyable m;
+  [[no_unique_address]] NonTriviallyCopyable n;
+};
+
+void call()
+{
+  Foo foo;
+  Foo foo2(static_cast(foo));
+}
+
+// The memcpy call should copy exact 4 bytes for member 'int i'
+// CHECK: define {{.*}} void @_ZN3FooC2EOS_
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.+}}, i8* {{.+}}, i64 4, i1 false)
+// CHECK:  call void @_ZN20NonTriviallyCopyableC2EOS_
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -914,6 +914,8 @@
 }
 
 void addMemcpyableField(FieldDecl *F) {
+  if (F->isZeroSize(CGF.getContext()))
+return;
   if (!FirstField)
 addInitialField(F);
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-25 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 230896.
MarkMurrayARM added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vandq.c
  clang/test/CodeGen/arm-mve-intrinsics/vbicq.c
  clang/test/CodeGen/arm-mve-intrinsics/veorq.c
  clang/test/CodeGen/arm-mve-intrinsics/vornq.c
  clang/test/CodeGen/arm-mve-intrinsics/vorrq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vandq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vbicq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/veorq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vornq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <16 x i8> %b, %a
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vorrq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <8 x i16> %b, %a
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vorrq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = or <4 x i32> %1, %0
+  %3 = bitcast <4 x i32> %2 to <4 x float>
+  ret <4 x float> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+; Function Attrs: nounwind readnone
+define arm_aapcs_vfpcc <8 x half> @test_vorrq_m_f32(<4 x float> %inactive, <4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = zext i16 %p to i32
+  %3 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %2)
+  %4 = bitcast <4 x float> %inactive to <4 x i32>
+  %5 = tail call <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32> %0, <4 x i32> %1, <4 x i1> %3, <4 x i32> %4)
+  %6 = bitcast <4 x i32> %5 to <8 x half>
+  ret <8 x half> %6
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>, <4 x i1>, <4 x i32>)

[PATCH] D69092: [CodeGen] #pragma clang transform

2019-11-25 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69092



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


[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-25 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 230895.
MarkMurrayARM added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vandq.c
  clang/test/CodeGen/arm-mve-intrinsics/vbicq.c
  clang/test/CodeGen/arm-mve-intrinsics/veorq.c
  clang/test/CodeGen/arm-mve-intrinsics/vornq.c
  clang/test/CodeGen/arm-mve-intrinsics/vorrq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vandq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vbicq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/veorq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vornq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <16 x i8> %b, %a
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vorrq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <8 x i16> %b, %a
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vorrq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = or <4 x i32> %1, %0
+  %3 = bitcast <4 x i32> %2 to <4 x float>
+  ret <4 x float> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+; Function Attrs: nounwind readnone
+define arm_aapcs_vfpcc <8 x half> @test_vorrq_m_f32(<4 x float> %inactive, <4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = zext i16 %p to i32
+  %3 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %2)
+  %4 = bitcast <4 x float> %inactive to <4 x i32>
+  %5 = tail call <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32> %0, <4 x i32> %1, <4 x i1> %3, <4 x i32> %4)
+  %6 = bitcast <4 x i32> %5 to <8 x half>
+  ret <8 x half> %6
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>, <4 x i1>, <4 x i32>)

[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

We're now getting a ton of warnings about this in Chromium. 
(https://crbug.com/1028110)

And I'm not really sure what the warning wants us to do?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-25 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 230891.
MarkMurrayARM added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vandq.c
  clang/test/CodeGen/arm-mve-intrinsics/vbicq.c
  clang/test/CodeGen/arm-mve-intrinsics/veorq.c
  clang/test/CodeGen/arm-mve-intrinsics/vornq.c
  clang/test/CodeGen/arm-mve-intrinsics/vorrq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vandq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vbicq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/veorq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vornq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <16 x i8> %b, %a
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vorrq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <8 x i16> %b, %a
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vorrq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = or <4 x i32> %1, %0
+  %3 = bitcast <4 x i32> %2 to <4 x float>
+  ret <4 x float> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+; Function Attrs: nounwind readnone
+define arm_aapcs_vfpcc <8 x half> @test_vorrq_m_f32(<4 x float> %inactive, <4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = zext i16 %p to i32
+  %3 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %2)
+  %4 = bitcast <4 x float> %inactive to <4 x i32>
+  %5 = tail call <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32> %0, <4 x i32> %1, <4 x i1> %3, <4 x i32> %4)
+  %6 = bitcast <4 x i32> %5 to <8 x half>
+  ret <8 x half> %6
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>, <4 x i1>, <4 x i32>)

[PATCH] D70545: [ARM][MVE][Intrinsics] Add MVE VABD intrinsics.

2019-11-25 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 230890.
MarkMurrayARM added a comment.

Merge all VABD intrinis types under T.Usual instead of doing the floats
separately.

Add more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70545

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vabdq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @test_vabdq_u32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vabdq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.s32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>%a, <4 x i32>%b)
+  ret <4 x i32> %0
+}
+
+declare <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>, <4 x i32>)
+
+define arm_aapcs_vfpcc <4 x float> @test_vabdq_f32(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vabdq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.f32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>%a, <4 x float>%b)
+  ret <4 x float> %0
+}
+
+declare <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>, <4 x float>)
+
+define arm_aapcs_vfpcc <16 x i8> @test_vabdq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.s8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+declare <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>)
+
+define arm_aapcs_vfpcc <8 x half> @test_vabdq_m_f16(<8 x half> %inactive, <8 x half> %a, <8 x half> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1, <8 x half> %inactive)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+
+declare <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>, <8 x half>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -1664,8 +1664,9 @@
 }
 
 
-class MVE_VABD_int size, list pattern=[]>
-  : MVE_int<"vabd", suffix, size, pattern> {
+class MVE_VABD_int size,
+ list pattern=[]>
+  : MVE_int {
 
   let Inst{28} = U;
   let Inst{25-23} = 0b110;
@@ -1676,12 +1677,35 @@
   let validForTailPredication = 1;
 }
 
-def MVE_VABDs8  : MVE_VABD_int<"s8", 0b0, 0b00>;
-def MVE_VABDs16 : MVE_VABD_int<"s16", 0b0, 0b01>;
-def MVE_VABDs32 : MVE_VABD_int<"s32", 0b0, 0b10>;
-def MVE_VABDu8  : MVE_VABD_int<"u8", 0b1, 0b00>;
-def MVE_VABDu16 : MVE_VABD_int<"u16", 0b1, 0b01>;
-def MVE_VABDu32 : MVE_VABD_int<"u32", 0b1, 0b10>;
+multiclass MVE_VABD_m {
+  def "" : MVE_VABD_int;
+
+  let Predicates = [HasMVEInt] in {
+// Unpredicated absolute difference
+def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+
+// Predicated absolute difference
+def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(i32 1), (VTI.Pred VCCR:$mask),
+(VTI.Vec MQPR:$inactive)))>;
+  }
+}
+
+multiclass MVE_VABD
+  : MVE_VABD_m<"vabd", VTI, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
+
+defm MVE_VABDs8  : MVE_VABD;
+defm MVE_VABDs16 : MVE_VABD;
+defm MVE_VABDs32 : MVE_VABD;
+defm MVE_VABDu8  : MVE_VABD;
+defm MVE_VABDu16 : MVE_VABD;
+defm MVE_VABDu32 : MVE_

[PATCH] D70664: update string comparison in clang-format.py

2019-11-25 Thread Paul Seyfert via Phabricator via cfe-commits
pseyfert added a comment.

PS: I do not have commit access, so someone with the rights would need to land 
this for me. Thanks in advance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70664



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


[PATCH] D70440: [Driver] Use VFS to check if sanitizer blacklists exist

2019-11-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D70440#1756262 , @thakis wrote:

> Do we need to add a dep on Frontend to DriverTests here? That's a heavy 
> dependency (it pulls in Sema etc). If it is needed, maybe the test is in the 
> wrong binary?


We need it solely for `TextDiagnosticPrinter`. Very handy to see the errors in 
case of failures.
There are probably no reasons it cannot live outside frontend, should be a 
manageable refactoring. (I haven't checked though, might be wrong)

Logically, the tests seem to be in the right place.

I agree it's not perfect, but there are probably more useful things one can 
spend their time on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70440



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


[PATCH] D70052: [clang-tidy] Add misc-mutating-copy check

2019-11-25 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze marked 5 inline comments as done.
gbencze added a comment.

Mark comments as Done.


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

https://reviews.llvm.org/D70052



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


[PATCH] D69298: [clangd] Define out-of-line initial apply logic

2019-11-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

looks good.




Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:53
+// template keyword for templated functions.
+// FIXME: This is shared with define inline, move them to a common header once
+// we have a place for such.

this function seems trivial, I'd inline them into call sides for both define 
inline and outline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69298



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


[PATCH] D70664: update string comparison in clang-format.py

2019-11-25 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70664



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


[PATCH] D70633: clang-format-vs : Fix Unicode formatting

2019-11-25 Thread empty2fill via Phabricator via cfe-commits
empty2fill added a comment.

In D70633#1758372 , @hans wrote:

> klimek, What do you think?
>
> empty2fill: Do you have an example input that I could use to hit the 
> "Specified argument was out of the range of valid values." error?


F10867396: Main.cpp 

Encoded Windows code page 949 for the Korean language.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70633



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


[PATCH] D70632: clang-format-vs : Fix typo NUGET_EXE_DIR on README

2019-11-25 Thread empty2fill via Phabricator via cfe-commits
empty2fill added a comment.

In D70632#1758572 , @hans wrote:

> Thanks!
>
> Do you have commit access, or if not would you like me to commit on your 
> behalf?


Commit on my behalf please. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70632



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


[PATCH] D69266: [clangd] Define out-of-line availability checks

2019-11-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

still lgtm.




Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:72
+// definition even if we are inside a source file.
+if (!Sel.AST.getASTContext().getLangOpts().IsHeaderFile)
+  return false;

nit: we have the `isHeaderFile` helper in the `SourceCode.h`, please use it (it 
is more precise).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69266



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


  1   2   >