[PATCH] D70572: [Serialization] #pragma clang transform

2019-12-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 234663.
Meinersbur added a comment.

- Adapt for refactored ASTRecordReader/Writer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70572

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTRecordReader.h
  clang/include/clang/Serialization/ASTRecordWriter.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/PCH/transform-distribute.cpp
  clang/test/PCH/transform-interleave.cpp
  clang/test/PCH/transform-unroll.cpp
  clang/test/PCH/transform-unrollandjam.cpp
  clang/test/PCH/transform-vectorize.cpp

Index: clang/test/PCH/transform-vectorize.cpp
===
--- /dev/null
+++ clang/test/PCH/transform-vectorize.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -include-pch %t.pch %s -ast-dump-all -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+void vectorize_heuristic(int n) {
+#pragma clang transform vectorize
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported vectorize_heuristic
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: ForStmt
+
+
+void vectorize_width(int n) {
+#pragma clang transform vectorize width(4)
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported vectorize_width
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: WidthClause
+// CHECK-NEXT:   IntegerLiteral {{.*}} 'int' 4
+// CHECK-NEXT: ForStmt
+
+#endif /* HEADER */
Index: clang/test/PCH/transform-unrollandjam.cpp
===
--- /dev/null
+++ clang/test/PCH/transform-unrollandjam.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -include-pch %t.pch %s -ast-dump-all -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+void  unrollandjam_heuristic(int n) {
+#pragma clang transform unrollandjam
+  for (int i = 0; i < n; i+=1)
+for (int j = 0; j < n; j+=1)
+  ;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unrollandjam_heuristic
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: ForStmt
+
+
+void unrollandjam_partial(int n) {
+#pragma clang transform unrollandjam partial(4)
+  for (int i = 0; i < n; i+=1)
+for (int j = 0; j < n; j+=1)
+  ;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unrollandjam_partial
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   IntegerLiteral {{.*}} 'int' 4
+// CHECK-NEXT: ForStmt
+
+#endif /* HEADER */
Index: clang/test/PCH/transform-unroll.cpp
===
--- /dev/null
+++ clang/test/PCH/transform-unroll.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexperimental-transform-pragma -include-pch %t.pch %s -ast-dump-all -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+void  unroll_heuristic(int n) {
+#pragma clang transform unroll
+  for (int i = 0; i < 4; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_heuristic
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: ForStmt
+
+
+void unroll_full(int n) {
+#pragma clang transform unroll full
+  for (int i = 0; i < 4; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_full
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: FullClause
+// CHECK-NEXT: ForStmt
+
+
+void unroll_partial(int n) {
+#pragma clang transform unroll partial(4)
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_partial
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   IntegerLiteral {{.*}} 'int' 4
+// CHECK-NEXT: ForStmt
+
+
+template
+void unroll_template_function(int n) {
+#pragma clang transform unroll partial(FACTOR)
+  for (int i = 0; i < n; i+=1)
+;
+}
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_template_function
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   DeclRefExpr {{.*}} 'FACTOR' 'int'
+// CHECK-NEXT: ForStmt
+
+
+template void unroll_template_function<5>(int);
+// CHECK-LABEL: FunctionDecl {{.*}} imported unroll_template_function
+// CHECK: TransformExecutableDirective
+// CHECK-NEXT: PartialClause
+// CHECK-NEXT:   SubstNonTypeTemplateParmExpr
+// 

[PATCH] D69091: [Sema] #pragma clang transform

2019-12-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 234659.
Meinersbur added a comment.

- Rework TransformedTree a bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69091

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtTransform.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Analysis/AnalysisTransform.h
  clang/include/clang/Analysis/TransformedTree.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaTransform.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/StmtTransform.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTransform.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-transform-unroll.c
  clang/test/AST/ast-dump-transform-unrollandjam.c
  clang/test/AST/ast-print-pragma-transform-distribute.cpp
  clang/test/AST/ast-print-pragma-transform-interleave.cpp
  clang/test/AST/ast-print-pragma-transform-unroll.cpp
  clang/test/AST/ast-print-pragma-transform-unrollandjam.cpp
  clang/test/AST/ast-print-pragma-transform-vectorize.cpp
  clang/test/SemaCXX/pragma-transform-interleave.cpp
  clang/test/SemaCXX/pragma-transform-legacymix.cpp
  clang/test/SemaCXX/pragma-transform-unroll.cpp
  clang/test/SemaCXX/pragma-transform-unrollandjam.cpp
  clang/test/SemaCXX/pragma-transform-vectorize.cpp
  clang/test/SemaCXX/pragma-transform-wrongorder.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -735,6 +735,9 @@
 break;
   case Stmt::BuiltinBitCastExprClass:
 K = CXCursor_BuiltinBitCastExpr;
+break;
+  case Stmt::TransformExecutableDirectiveClass:
+llvm_unreachable("not implemented");
   }
 
   CXCursor C = { K, 0, { Parent, S, TU } };
Index: clang/test/SemaCXX/pragma-transform-wrongorder.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pragma-transform-wrongorder.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 -fexperimental-transform-pragma -fsyntax-only -verify %s
+
+void wrongorder(int *List, int Length, int Value) {
+
+/* expected-warning@+1 {{the LLVM pass structure currently is not able to apply the transformations in this order}} */
+#pragma clang transform distribute
+#pragma clang transform vectorize
+  for (int i = 0; i < 8; i++)
+List[i] = Value;
+
+/* expected-warning@+1 {{the LLVM pass structure currently is not able to apply the transformations in this order}} */
+#pragma clang transform vectorize
+#pragma clang transform unrollandjam
+  for (int i = 0; i < 8; i++)
+for (int j = 0; j < 8; j++)
+  List[i] += j;
+
+}
Index: clang/test/SemaCXX/pragma-transform-vectorize.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pragma-transform-vectorize.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -fexperimental-transform-pragma -fsyntax-only -verify %s
+
+void vectorize(int *List, int Length, int Value) {
+/* expected-error@+1 {{the width clause can be specified at most once}} */
+#pragma clang transform vectorize width(4) width(4)
+  for (int i = 0; i < Length; i++)
+  List[i] = Value;
+
+/* expected-error@+1 {{clause argument must me at least 2}} */
+#pragma clang transform vectorize width(-42)
+  for (int i = 0; i < Length; i++)
+List[i] = Value;
+
+}
Index: clang/test/SemaCXX/pragma-transform-unrollandjam.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pragma-transform-unrollandjam.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -fexperimental-transform-pragma -fsyntax-only -verify %s
+
+void unrollandjam(int *List, int Length, int Value) {
+/* expected-error@+1 {{the partial clause can be specified at most once}} */
+#pragma clang transform unrollandjam partial(4) partial(4)
+  for (int i = 0; i < Length; i++)
+for (int j = 0; j < Length; j++)
+  List[i] += j*Value;
+
+/* expected-error@+1 {{unroll-and-jam requires exactly one nested loop}} */
+#pragma clang transform unrollandjam
+  for (int i = 0; i < Length; i++)
+  List[i] = Value;
+
+/* expected-error@+1 {{unroll-and-jam requires exactly one nested loop}} */
+#pragma clang transform unrollandjam
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++)
+  List[i] += j*Value;
+

[PATCH] D71541: [NFC] [Clang]: fix spelling mistake in assert message

2019-12-18 Thread Jim Lin via Phabricator via cfe-commits
Jim added a comment.

Do you need someone to commit this change for you?


Repository:
  rC Clang

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

https://reviews.llvm.org/D71541



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


[PATCH] D71314: Emit a warning if a variable is uninitialized in indirect ASM goto destination.

2019-12-18 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 234657.
void added a comment.

Check that the use isn't in the fallthrough block.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71314

Files:
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/Analysis/uninit-asm-goto.cpp

Index: clang/test/Analysis/uninit-asm-goto.cpp
===
--- clang/test/Analysis/uninit-asm-goto.cpp
+++ clang/test/Analysis/uninit-asm-goto.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -Wuninitialized -verify %s
-// expected-no-diagnostics
 
+// test1: Expect no diagnostics
 int test1(int x) {
 int y;
 asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : err);
@@ -8,3 +8,52 @@
   err:
 return -1;
 }
+
+int test2(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  if (x < 42)
+asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2);
+  else
+asm volatile goto("testl %0, %1; testl %2, %3; jne %l5" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2);
+  return x + y;
+indirect_1:
+  return -42;
+indirect_2:
+  return y; // expected-note {{uninitialized use occurs here}}
+}
+
+int test3(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  asm goto("xorl %1, %0; jmp %l2" : "="(y) : "r"(x) : : fail);
+normal:
+  y += x;
+  return y;
+  if (x) {
+fail:
+return y; // expected-note {{uninitialized use occurs here}}
+  }
+  return 0;
+}
+
+int test4(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  goto forward;
+backward:
+  return y; // expected-note {{uninitialized use occurs here}}
+forward:
+  asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : backward);
+  return y;
+}
+
+// test5: Expect no diagnostics
+int test5(int x) {
+  int y;
+  asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough);
+fallthrough:
+  return y;
+indirect:
+  return -2;
+}
Index: clang/lib/Analysis/UninitializedValues.cpp
===
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -637,6 +637,28 @@
   continue;
 }
 
+if (AtPredExit == MayUninitialized) {
+  // If the predecessor's terminator is an "asm goto" that initializes
+  // the variable, then it won't be counted as "initialized" on the
+  // non-fallthrough paths.
+  CFGTerminator term = Pred->getTerminator();
+  if (GCCAsmStmt *as = dyn_cast_or_null(term.getStmt())) {
+const CFGBlock *fallthrough = *Pred->succ_begin();
+if (as->isAsmGoto() &&
+llvm::any_of(as->outputs(), [&](const Expr *output) {
+return vd == findVar(output).getDecl() &&
+llvm::any_of(as->labels(),
+ [&](const AddrLabelExpr *label) {
+  return label->getLabel()->getStmt() == B->Label &&
+  B != fallthrough;
+});
+})) {
+  Use.setUninitAfterDecl();
+  continue;
+}
+  }
+}
+
 unsigned  = SuccsVisited[Pred->getBlockID()];
 if (!SV) {
   // When visiting the first successor of a block, mark all NULL
@@ -829,7 +851,8 @@
 
   for (const auto  : as->outputs())
 if (const VarDecl *VD = findVar(o).getDecl())
-  vals[VD] = Initialized;
+  if (vals[VD] != Initialized)
+vals[VD] = MayUninitialized;
 }
 
 void TransferFunctions::VisitObjCMessageExpr(ObjCMessageExpr *ME) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

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

{icon check-circle color=green} Unit tests: pass. 61011 tests passed, 0 failed 
and 728 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687



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


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

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

{icon check-circle color=green} Unit tests: pass. 61011 tests passed, 0 failed 
and 728 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687



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


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2019-12-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo created this revision.
echristo added reviewers: chandlerc, hfinkel, asbirlea.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, mcrosier.
Herald added projects: clang, LLVM.
echristo updated this revision to Diff 234656.
echristo added a comment.

Formatting and parens changes.


Last we looked at this and couldn't come up with a reason to change it, but 
with a pragma for full loop unrolling we bypass every other loop unroll and 
then fail to fully unroll a loop when the pragma is set.

Move the OnlyWhenForced out of the check and into the initialization of the 
full unroll pass in the new pass manager. This doesn't show up with the old 
pass manager.

Tested with check-clang and check-llvm.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71687

Files:
  clang/test/Misc/loop-opt-setup.c
  llvm/lib/Passes/PassBuilder.cpp


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -478,10 +478,10 @@
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
-LPM2.addPass(LoopFullUnrollPass(Level, /*OnlyWhenForced=*/false,
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
+LPM2.addPass(LoopFullUnrollPass(Level,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto  : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -8,5 +8,13 @@
 a[i] = b += 2;
   return b;
 }
+
+int B(void) {
+#pragma clang loop unroll(full)
+  for (int i = 0; i < 16; ++i)
+a[i] = b += 2;
+  return b;
+}
+
 // CHECK-NOT: br i1
 


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -478,10 +478,10 @@
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
-LPM2.addPass(LoopFullUnrollPass(Level, /*OnlyWhenForced=*/false,
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
+LPM2.addPass(LoopFullUnrollPass(Level,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto  : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -8,5 +8,13 @@
 a[i] = b += 2;
   return b;
 }
+
+int B(void) {
+#pragma clang loop unroll(full)
+  for (int i = 0; i < 16; ++i)
+a[i] = b += 2;
+  return b;
+}
+
 // CHECK-NOT: br i1
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2019-12-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo updated this revision to Diff 234656.
echristo added a comment.

Formatting and parens changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687

Files:
  clang/test/Misc/loop-opt-setup.c
  llvm/lib/Passes/PassBuilder.cpp


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -478,10 +478,10 @@
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
-LPM2.addPass(LoopFullUnrollPass(Level, /*OnlyWhenForced=*/false,
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
+LPM2.addPass(LoopFullUnrollPass(Level,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto  : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -8,5 +8,13 @@
 a[i] = b += 2;
   return b;
 }
+
+int B(void) {
+#pragma clang loop unroll(full)
+  for (int i = 0; i < 16; ++i)
+a[i] = b += 2;
+  return b;
+}
+
 // CHECK-NOT: br i1
 


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -478,10 +478,10 @@
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
-LPM2.addPass(LoopFullUnrollPass(Level, /*OnlyWhenForced=*/false,
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
+LPM2.addPass(LoopFullUnrollPass(Level,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto  : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -8,5 +8,13 @@
 a[i] = b += 2;
   return b;
 }
+
+int B(void) {
+#pragma clang loop unroll(full)
+  for (int i = 0; i < 16; ++i)
+a[i] = b += 2;
+  return b;
+}
+
 // CHECK-NOT: br i1
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71686: Fix false positive in magic number checker

2019-12-18 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- marked an inline comment as done.
0x8000- added inline comments.



Comment at: clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp:127
+
+// Ignore this instance, because this matches an
+// expanded class enumeration value.

127-130 are the new lines. The rest were moved about by clang-format. Please 
let me know if I should revert the format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71686



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


[PATCH] D71686: Fix false positive in magic number checker

2019-12-18 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- created this revision.
0x8000- added a reviewer: aaron.ballman.
0x8000- added a project: clang-tools-extra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix false positive in magic number checker

https://bugs.llvm.org/show_bug.cgi?id=40640: 
cppcoreguidelines-avoid-magic-numbers should not warn about enum class


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71686

Files:
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
@@ -215,3 +215,14 @@
 
   return Total;
 }
+
+// prove that using enumerations values don't produce warnings (code by Pavel 
Kryukov)
+enum class Letter : unsigned {
+A, B, C, D, E, F, G, H, I, J
+};
+
+template struct holder  { Letter letter = x;  };
+template struct wrapper { using h_type = holder;  };
+
+template struct wrapper;
+template struct wrapper;
Index: clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -34,7 +34,7 @@
 return AsDecl->isImplicit();
   }
 
-  if (Node.get() != nullptr)
+  if (Node.get())
 return true;
 
   return llvm::any_of(Result.Context->getParents(Node),
@@ -119,25 +119,31 @@
 
 bool MagicNumbersCheck::isConstant(const MatchFinder::MatchResult ,
const Expr ) const {
-  return llvm::any_of(
-  Result.Context->getParents(ExprResult),
-  [](const DynTypedNode ) {
-if (isUsedToInitializeAConstant(Result, Parent))
-  return true;
-
-// Ignore this instance, because this match reports the location
-// where the template is defined, not where it is instantiated.
-if (Parent.get())
-  return true;
-
-// Don't warn on string user defined literals:
-// std::string s = "Hello World"s;
-if (const auto *UDL = Parent.get())
-  if (UDL->getLiteralOperatorKind() == UserDefinedLiteral::LOK_String)
-return true;
-
-return false;
-  });
+  return llvm::any_of(Result.Context->getParents(ExprResult),
+  [](const DynTypedNode ) {
+if (isUsedToInitializeAConstant(Result, Parent))
+  return true;
+
+// Ignore this instance, because this matches an
+// expanded class enumeration value.
+if (Parent.get())
+  return true;
+
+// Ignore this instance, because this match reports the
+// location where the template is defined, not where it
+// is instantiated.
+if (Parent.get())
+  return true;
+
+// Don't warn on string user defined literals:
+// std::string s = "Hello World"s;
+if (const auto *UDL = Parent.get())
+  if (UDL->getLiteralOperatorKind() ==
+  UserDefinedLiteral::LOK_String)
+return true;
+
+return false;
+  });
 }
 
 bool MagicNumbersCheck::isIgnoredValue(const IntegerLiteral *Literal) const {


Index: clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp
@@ -215,3 +215,14 @@
 
   return Total;
 }
+
+// prove that using enumerations values don't produce warnings (code by Pavel Kryukov)
+enum class Letter : unsigned {
+A, B, C, D, E, F, G, H, I, J
+};
+
+template struct holder  { Letter letter = x;  };
+template struct wrapper { using h_type = holder;  };
+
+template struct wrapper;
+template struct wrapper;
Index: clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -34,7 +34,7 @@
 return AsDecl->isImplicit();
   }
 
-  if (Node.get() != nullptr)
+  if (Node.get())
 return true;
 
   return llvm::any_of(Result.Context->getParents(Node),
@@ -119,25 +119,31 @@
 
 bool MagicNumbersCheck::isConstant(const 

[PATCH] D70157: Align branches within 32-Byte boundary(NOP padding)

2019-12-18 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 234650.
skan added a comment.

move the code that checks if we can reuse the current `MCBoundaryAlignFragment` 
 into the function `X86AsmBackend::getOrCreateBoundaryAlignFragment`


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

https://reviews.llvm.org/D70157

Files:
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCAssembler.h
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MCFragment.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-32-1a.s
  llvm/test/MC/X86/align-branch-64-1a.s
  llvm/test/MC/X86/align-branch-64-1b.s
  llvm/test/MC/X86/align-branch-64-1c.s
  llvm/test/MC/X86/align-branch-64-1d.s
  llvm/test/MC/X86/align-branch-64-2a.s
  llvm/test/MC/X86/align-branch-64-2b.s
  llvm/test/MC/X86/align-branch-64-2c.s
  llvm/test/MC/X86/align-branch-64-3a.s
  llvm/test/MC/X86/align-branch-64-4a.s
  llvm/test/MC/X86/align-branch-64-5a.s

Index: llvm/test/MC/X86/align-branch-64-5a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-5a.s
@@ -0,0 +1,63 @@
+# Check no nop or prefix is inserted if no branch cross or is against the boundary
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret  %s | llvm-objdump -d  - > %t1
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t2
+# RUN: cmp %t1 %t2
+# RUN: FileCheck --input-file=%t1 %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:3: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:6: 89 d1movl%edx, %ecx
+# CHECK-NEXT:8: 31 c0xorl%eax, %eax
+# CHECK-NEXT:a: 31 c8xorl%ecx, %eax
+# CHECK-NEXT:c: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:f: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   12: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   15: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   18: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   1b: f3 abrep stosl%eax, %es:(%rdi)
+# CHECK-NEXT:   1d: 75 e4jne {{.*}}
+# CHECK-NEXT:   1f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   21: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   24: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   27: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   2a: 89 d1movl%edx, %ecx
+# CHECK-NEXT:   2c: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   2e: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   31: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   34: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   37: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   3a: e8 00 00 00 00   callq   {{.*}}
+# CHECK-NEXT:   3f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   41: 75 e1jne {{.*}}
+
+.text
+.p2align 4,,15
+foo:
+shrl$2, %ecx
+.L1:
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+xorl%ecx, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+rep stosl
+jne.L1
+xorl%eax, %eax
+shrl$2, %ecx
+.L2:
+shrl$2, %ecx
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+callbar
+xorl%eax, %eax
+jne.L2
Index: llvm/test/MC/X86/align-branch-64-4a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-4a.s
@@ -0,0 +1,63 @@
+# Check rets are not aligned with option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp %s | llvm-objdump -d  - >%t2
+# RUN: cmp %t %t2
+
+# Check only rets are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=ret
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-objdump -d  - | FileCheck %s
+
+# 

[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

2019-12-18 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 234652.
kamleshbhalui added a comment.

added assert.


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

https://reviews.llvm.org/D71619

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/pr43983.cpp


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,8 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S, Anon, Dc);
+
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
@@ -5033,6 +5035,7 @@
   SC = SC_None;
 }
 
+assert(DS.getAttributes().empty() && "No attribute expected");
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,8 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S, Anon, Dc);
+
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
@@ -5033,6 +5035,7 @@
   SC = SC_None;
 }
 
+assert(DS.getAttributes().empty() && "No attribute expected");
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70836: [analysis] Fix value tracking for pointers to qualified types

2019-12-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D70836#1789059 , @xazax.hun wrote:

> Will this also work as intended with sugared types?  (e.g. typedefs)
>  I believe this might be one of the main reason why the original author used 
> canonical types in the first place.


Whoops, indeed. Fxd in rGf0ced2ddb44e 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70836



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


[clang] f0ced2d - [analysis] Re-discard type sugar when casting values retrieved from the Store.

2019-12-18 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-12-18T18:00:57-08:00
New Revision: f0ced2ddb44e4bd970fec310591891a0cdb4462c

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

LOG: [analysis] Re-discard type sugar when casting values retrieved from the 
Store.

Canonicalization was accidentally omitted in 6d3f43ec.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/Store.cpp
clang/test/Analysis/uninit-val-const-likeness.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/Store.cpp 
b/clang/lib/StaticAnalyzer/Core/Store.cpp
index 20660d1c2d67..b33129c88cea 100644
--- a/clang/lib/StaticAnalyzer/Core/Store.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -394,8 +394,8 @@ SVal StoreManager::attemptDownCast(SVal Base, QualType 
TargetType,
 }
 
 static bool hasSameUnqualifiedPointeeType(QualType ty1, QualType ty2) {
-  return ty1->getPointeeType().getTypePtr() == 
-ty2->getPointeeType().getTypePtr();
+  return ty1->getPointeeType().getCanonicalType().getTypePtr() ==
+ ty2->getPointeeType().getCanonicalType().getTypePtr();
 }
 
 /// CastRetrievedVal - Used by subclasses of StoreManager to implement
@@ -427,7 +427,7 @@ SVal StoreManager::CastRetrievedVal(SVal V, const 
TypedValueRegion *R,
   // correctly every time we need it.
   if (castTy->isPointerType() && !castTy->isVoidPointerType())
 if (const auto *SR = dyn_cast_or_null(V.getAsRegion())) {
-  QualType sr = SR->getSymbol()->getType(); 
+  QualType sr = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(sr, castTy))
   return loc::MemRegionVal(castRegion(SR, castTy));
 }

diff  --git a/clang/test/Analysis/uninit-val-const-likeness.c 
b/clang/test/Analysis/uninit-val-const-likeness.c
index 1ee1aefe8dba..013ab7882755 100644
--- a/clang/test/Analysis/uninit-val-const-likeness.c
+++ b/clang/test/Analysis/uninit-val-const-likeness.c
@@ -54,3 +54,21 @@ int work3(const Params * const params) {
 sum += fooList[i]; // no-warning
   return sum;
 }
+
+typedef Params ParamsTypedef;
+typedef const ParamsTypedef *ConstParamsTypedef;
+
+static void create4(ConstParamsTypedef const params, int fooList[]) {
+  int tmpList[SIZE] = {0};
+  for (int i = 0; i < params->noOfSymbols; i++)
+fooList[i] = tmpList[i];
+}
+
+int work4(Params * const params) {
+  int fooList[SIZE];
+  create4(params, fooList);
+  int sum = 0;
+  for (int i = 0; i < params->noOfSymbols; i++)
+sum += fooList[i]; // no-warning
+  return sum;
+}



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


[PATCH] D71635: [clang] Rename -frounding-math to -fexperimental-rounding-math and add -frounding-math back as a gcc-compat arg.

2019-12-18 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

In D71635#1790611 , @MaskRay wrote:

> Before:
>
>   % clang -frounding-math -fsyntax-only -x c /dev/null
>   clang-10: warning: Support for floating point control option frounding-math 
> is incomplete and experimental [-Wexperimental-float-control]
>
>
> CC1 will do rounding math things.
>
> After
>
>   % clang -frounding-math -fsyntax-only -x c /dev/null
>   clang-10: warning: optimization flag '-frounding-math' is not supported 
> [-Wignored-optimization-argument]
>
>
> CC1 will not do rounding math things. -fexperimental-rounding-math if the 
> user really wants to use the feature.
>
> Is my understanding correct? If yes, this patch seems pretty reasonable to 
> me, because -frounding-math is currently incomplete/unsafe.
>
> You may consider not changing CC1 options as they are not user facing.


My understanding is this:

Before D62731 :

  % clang -frounding-math -fsyntax-only -x c /dev/null
  clang-10: warning: optimization flag '-frounding-math' is not supported 
[-Wignored-optimization-argument]

After D62731 :

  % clang -frounding-math -fsyntax-only -x c /dev/null
  clang-10: warning: Support for floating point control option frounding-math 
is incomplete and experimental [-Wexperimental-float-control]

After D71671 :

  % clang -frounding-math -fsyntax-only -x c /dev/null
  

I suppose this patch would be updated to put us back where we were before 
D62731  in terms of the warning and require an 
additional option for anyone who wants to use the rounding math implementation 
as it is currently implemented.

The support for -frounding-math is incomplete, but I'm not sure it's unsafe. 
It's no more unsafe than not using the flag at all. The same reasoning applies 
to -ftrapping-math which was accepted without warning well before D62731 
 and has never been completely implemented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71635



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


[PATCH] D71635: [clang] Rename -frounding-math to -fexperimental-rounding-math and add -frounding-math back as a gcc-compat arg.

2019-12-18 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht abandoned this revision.
rupprecht added a comment.

In D71635#1790611 , @MaskRay wrote:

> Before:
>
>   % clang -frounding-math -fsyntax-only -x c /dev/null
>   clang-10: warning: Support for floating point control option frounding-math 
> is incomplete and experimental [-Wexperimental-float-control]
>
>
> CC1 will do rounding math things.
>
> After
>
>   % clang -frounding-math -fsyntax-only -x c /dev/null
>   clang-10: warning: optimization flag '-frounding-math' is not supported 
> [-Wignored-optimization-argument]
>
>
> CC1 will not do rounding math things. -fexperimental-rounding-math if the 
> user really wants to use the feature.
>
> Is my understanding correct? If yes, this patch seems pretty reasonable to 
> me, because -frounding-math is currently incomplete/unsafe.
>
> You may consider not changing CC1 options as they are not user facing.


I landed D71671  instead, as apparently the 
-frounding-math option is safe, although perhaps incomplete


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71635



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


[PATCH] D71682: Relax the rules around objc_alloc and objc_alloc_init optimizations.

2019-12-18 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder created this revision.
MadCoder added reviewers: rjmccall, arphaman, erik.pilkington, ahatanak.
MadCoder added a project: clang.
Herald added subscribers: cfe-commits, dexonsmith.
MadCoder edited the summary of this revision.

Today the optimization is limited to:

- `[ClassName alloc]`
- `[self alloc] when within a class method`

However it means that when code is written this way:

  @interface MyObject
  - (id)copyWithZone:(NSZone *)zone
  {
  return [[self.class alloc] _initWith...];
  }
  @end

... then the optimization doesn't kick in and +[NSObject alloc] ends up in IMP 
caches where it could have been avoided.

It turns out that +alloc -> +[NSObject alloc] is the most cached SEL/IMP pair 
in the entire platform which is rather silly).

There's two theoretical risks allowing this optimization:

1. if the receiver is nil (which it can't be today), but it turns out that 
objc_alloc()/objc_alloc_init() cope with a nil receiver,
2. if the `Class` type for the receiver is a lie. However, for such a code to 
work today (and not fail witn an unrecognized selector anyway) you'd have to 
have implemented the -alloc *instance method*.

  Fortunately, objc_alloc() doesn't assume that the receiver is a Class, it 
basically starts with a test that is similar to `if (receiver->isa->bits & 
hasDefaultAWZ) { /* fastpath */ }`. This bit is only set on metaclasses by the 
runtime, so if an instance is passed to this function by accident, its isa will 
fail this test, and objc_alloc() will gracefully fallback to objc_msgSend().

  The one thing objc_alloc() doesn't support is tagged pointer instances. None 
of the tagged pointer classes implement an instance method called 'alloc' 
(actually there's a single class in the entire Apple codebase that has such a 
method).

Radar-Id: rdar://problem/58058316


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71682

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/objc-alloc-init.m

Index: clang/test/CodeGenObjC/objc-alloc-init.m
===
--- clang/test/CodeGenObjC/objc-alloc-init.m
+++ clang/test/CodeGenObjC/objc-alloc-init.m
@@ -22,21 +22,30 @@
 }
 
 @interface Y : X
++(Class)class;
 +(void)meth;
 -(void)instanceMeth;
 @end
 
 @implementation Y
++(Class)class {
+  return self;
+}
 +(void)meth {
   [[self alloc] init];
   // OPTIMIZED: call i8* @objc_alloc_init(
   // NOT_OPTIMIZED: call i8* @objc_alloc(
 }
++ (void)meth2 {
+  [[[self class] alloc] init];
+  // OPTIMIZED: call i8* @objc_alloc_init(
+  // NOT_OPTIMIZED: call i8* @objc_alloc(
+}
 -(void)instanceMeth {
   // EITHER-NOT: call i8* @objc_alloc
   // EITHER: call {{.*}} @objc_msgSend
   // EITHER: call {{.*}} @objc_msgSend
-  [[self alloc] init];
+  [[(id)self alloc] init];
 }
 @end
 
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -461,38 +461,39 @@
   Sel.getNameForSlot(0) != "init")
 return None;
 
-  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]' or
-  // we are in an ObjC class method and 'receiver' is '[self alloc]'.
+  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'
+  // with 'cls' a Class.
   auto *SubOME =
   dyn_cast(OME->getInstanceReceiver()->IgnoreParenCasts());
   if (!SubOME)
 return None;
   Selector SubSel = SubOME->getSelector();
 
-  // Check if we are in an ObjC class method and the receiver expression is
-  // 'self'.
-  const Expr *SelfInClassMethod = nullptr;
-  if (const auto *CurMD = dyn_cast_or_null(CGF.CurFuncDecl))
-if (CurMD->isClassMethod())
-  if ((SelfInClassMethod = SubOME->getInstanceReceiver()))
-if (!SelfInClassMethod->isObjCSelfExpr())
-  SelfInClassMethod = nullptr;
-
-  if ((SubOME->getReceiverKind() != ObjCMessageExpr::Class &&
-   !SelfInClassMethod) || !SubOME->getType()->isObjCObjectPointerType() ||
+  if (!SubOME->getType()->isObjCObjectPointerType() ||
   !SubSel.isUnarySelector() || SubSel.getNameForSlot(0) != "alloc")
 return None;
 
-  llvm::Value *Receiver;
-  if (SelfInClassMethod) {
-Receiver = CGF.EmitScalarExpr(SelfInClassMethod);
-  } else {
+  llvm::Value *Receiver = nullptr;
+  switch (SubOME->getReceiverKind()) {
+  case ObjCMessageExpr::Instance:
+if (!SubOME->getInstanceReceiver()->getType()->isObjCClassType())
+  return None;
+Receiver = CGF.EmitScalarExpr(SubOME->getInstanceReceiver());
+break;
+
+  case ObjCMessageExpr::Class: {
 QualType ReceiverType = SubOME->getClassReceiver();
 const ObjCObjectType *ObjTy = ReceiverType->getAs();
 const ObjCInterfaceDecl *ID = ObjTy->getInterface();
 assert(ID && "null interface should be impossible here");
 Receiver = CGF.CGM.getObjCRuntime().GetClass(CGF, ID);
+break;
+  }
+  case ObjCMessageExpr::SuperInstance:
+  case 

[PATCH] D71635: [clang] Rename -frounding-math to -fexperimental-rounding-math and add -frounding-math back as a gcc-compat arg.

2019-12-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Before:

  % clang -frounding-math -fsyntax-only -x c /dev/null
  clang-10: warning: Support for floating point control option frounding-math 
is incomplete and experimental [-Wexperimental-float-control]

CC1 will do rounding math things.

After

  % clang -frounding-math -fsyntax-only -x c /dev/null
  clang-10: warning: optimization flag '-frounding-math' is not supported 
[-Wignored-optimization-argument]

CC1 will not do rounding math things. -fexperimental-rounding-math if the user 
really wants to use the feature.

Is my understanding correct? If yes, this patch seems pretty reasonable to me, 
because -frounding-math is currently incomplete/unsafe.

You may consider not changing CC1 options as they are not user facing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71635



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


[PATCH] D71671: [clang] Remove -Wexperimental-float-control.

2019-12-18 Thread Jordan Rupprecht via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG553a727f5f64: [clang] Remove -Wexperimental-float-control. 
(authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71671

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2440,15 +2440,7 @@
 switch (optID) {
 default:
   break;
-case options::OPT_frounding_math:
-case options::OPT_ftrapping_math:
-case options::OPT_ffp_exception_behavior_EQ:
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
-  break;
 case options::OPT_ffp_model_EQ: {
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
   // If -ffp-model= is seen, reset to fno-fast-math
   HonorINFs = true;
   HonorNaNs = true;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1137,9 +1137,6 @@
 // Warning for the experimental-isel options.
 def ExperimentalISel : DiagGroup<"experimental-isel">;
 
-// Warning for the experimental float control options.
-def ExperimentalFloatControl : DiagGroup<"experimental-float-control">;
-
 // A warning group specifically for warnings related to function
 // multiversioning.
 def FunctionMultiVersioning : DiagGroup<"function-multiversion">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -441,10 +441,6 @@
   "-fexperimental-isel support is incomplete for this architecture at the 
current optimization level">,
   InGroup;
 
-def warn_drv_experimental_fp_control_incomplete_opt : Warning<
-  "Support for floating point control option %0 is incomplete and 
experimental">,
-  InGroup;
-
 def warn_drv_moutline_unsupported_opt : Warning<
   "The '%0' architecture does not support -moutline; flag ignored">,
   InGroup;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2440,15 +2440,7 @@
 switch (optID) {
 default:
   break;
-case options::OPT_frounding_math:
-case options::OPT_ftrapping_math:
-case options::OPT_ffp_exception_behavior_EQ:
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
-  break;
 case options::OPT_ffp_model_EQ: {
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
   // If -ffp-model= is seen, reset to fno-fast-math
   HonorINFs = true;
   HonorNaNs = true;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1137,9 +1137,6 @@
 // Warning for the experimental-isel options.
 def ExperimentalISel : DiagGroup<"experimental-isel">;
 
-// Warning for the experimental float control options.
-def ExperimentalFloatControl : DiagGroup<"experimental-float-control">;
-
 // A warning group specifically for warnings related to function
 // multiversioning.
 def FunctionMultiVersioning : DiagGroup<"function-multiversion">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -441,10 +441,6 @@
   "-fexperimental-isel support is incomplete for this architecture at the current optimization level">,
   InGroup;
 
-def warn_drv_experimental_fp_control_incomplete_opt : Warning<
-  "Support for floating point control option %0 is incomplete and experimental">,
-  InGroup;
-
 def warn_drv_moutline_unsupported_opt : Warning<
   "The '%0' architecture does not support -moutline; flag ignored">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 553a727 - [clang] Remove -Wexperimental-float-control.

2019-12-18 Thread Jordan Rupprecht via cfe-commits

Author: Jordan Rupprecht
Date: 2019-12-18T16:51:55-08:00
New Revision: 553a727f5f6407fb6db7ac2dae5f5b2a536d38fc

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

LOG: [clang] Remove -Wexperimental-float-control.

Summary: Per D62731, the behavior of clang with `-frounding-math` is no worse 
than when the rounding flag was completely ignored, so remove this unnecessary 
warning.

Reviewers: mibintc, chandlerc, echristo, rjmccall, kpn, erichkeane, rsmith, 
andrew.w.kaylor

Reviewed By: mibintc

Subscribers: merge_guards_bot, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 67faa872e57c..39242c972ea2 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -441,10 +441,6 @@ def warn_drv_experimental_isel_incomplete_opt : Warning<
   "-fexperimental-isel support is incomplete for this architecture at the 
current optimization level">,
   InGroup;
 
-def warn_drv_experimental_fp_control_incomplete_opt : Warning<
-  "Support for floating point control option %0 is incomplete and 
experimental">,
-  InGroup;
-
 def warn_drv_moutline_unsupported_opt : Warning<
   "The '%0' architecture does not support -moutline; flag ignored">,
   InGroup;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 8aa93d4138a2..5b2183531a44 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1137,9 +1137,6 @@ def SpirCompat : DiagGroup<"spir-compat">;
 // Warning for the experimental-isel options.
 def ExperimentalISel : DiagGroup<"experimental-isel">;
 
-// Warning for the experimental float control options.
-def ExperimentalFloatControl : DiagGroup<"experimental-float-control">;
-
 // A warning group specifically for warnings related to function
 // multiversioning.
 def FunctionMultiVersioning : DiagGroup<"function-multiversion">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5c7572fb12be..3dbe78c5b10f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2440,15 +2440,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 switch (optID) {
 default:
   break;
-case options::OPT_frounding_math:
-case options::OPT_ftrapping_math:
-case options::OPT_ffp_exception_behavior_EQ:
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
-  break;
 case options::OPT_ffp_model_EQ: {
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
   // If -ffp-model= is seen, reset to fno-fast-math
   HonorINFs = true;
   HonorNaNs = true;



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


[clang] 07b8f8e - [Remarks][Driver] Place temporary remark files next to temporary object files

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T16:42:02-08:00
New Revision: 07b8f8e5f5cad9c4d92c39a4bea50e21e9f0e9f1

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

LOG: [Remarks][Driver] Place temporary remark files next to temporary object 
files

On Darwin, when used for generating a linked binary from a source file
(through an intermediate object file), the driver will invoke `cc1` to
generate a temporary object file. The temporary remark file will now be
emitted next to the object file, which will then be picked up by
`dsymutil` and emitted in the .dSYM bundle.

This is available for all formats except YAML since by default, YAML
doesn't need a section and the remark file will be lost.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/darwin-opt-record.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 307507388ff6..07201f0d8616 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -355,21 +355,14 @@ output format of the diagnostics that it generates.
 
where  is based on the output file of the compilation (whether
it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
-   In other cases, it's based on the input file's stem. For example:
+   For example:
 
* ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
  ``out.opt.yaml``
 
-   * ``clang -fsave-optimization-record in.c -o out`` will generate
+   * ``clang -fsave-optimization-record -c in.c `` will generate
  ``in.opt.yaml``
 
-   Compiling for multiple architectures will use the following scheme:
-
-   ``-.opt.``
-
-   Note that this is only allowed on Darwin platforms and is incompatible with
-   passing multiple ``-arch `` options.
-
When targeting (Thin)LTO, the base is derived from the output filename, and
the extension is not dropped.
 
@@ -377,6 +370,32 @@ output format of the diagnostics that it generates.
 
``.opt..thin..``
 
+   Darwin-only: when used for generating a linked binary from a source file
+   (through an intermediate object file), the driver will invoke `cc1` to
+   generate a temporary object file. The temporary remark file will be emitted
+   next to the object file, which will then be picked up by `dsymutil` and
+   emitted in the .dSYM bundle. This is available for all formats except YAML.
+
+   For example:
+
+   ``clang -fsave-optimization-record=bitstream in.c -o out`` will generate
+
+   * ``/var/folders/43/9y164hh52tv_2nrdxrj31nywgn/T/a-9be59b.o``
+
+   * 
``/var/folders/43/9y164hh52tv_2nrdxrj31nywgn/T/a-9be59b.opt.bitstream``
+
+   * ``out``
+
+   * ``out.dSYM/Contents/Resources/Remarks/out``
+
+   Darwin-only: compiling for multiple architectures will use the following
+   scheme:
+
+   ``-.opt.``
+
+   Note that this is incompatible with passing the
+   :ref:`-foptimization-record-file ` option.
+
 .. _opt_foptimization-record-file:
 
 **-foptimization-record-file**

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9840acafd6ea..5c7572fb12be 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1444,7 +1444,12 @@ static bool checkRemarksOptions(const Driver , const 
ArgList ,
 
 static void renderRemarksOptions(const ArgList , ArgStringList ,
  const llvm::Triple ,
- const InputInfo , const JobAction ) {
+ const InputInfo ,
+ const InputInfo , const JobAction ) 
{
+  StringRef Format = "yaml";
+  if (const Arg *A = 
Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+Format = A->getValue();
+
   CmdArgs.push_back("-opt-record-file");
 
   const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
@@ -1454,11 +1459,17 @@ static void renderRemarksOptions(const ArgList , 
ArgStringList ,
 bool hasMultipleArchs =
 Triple.isOSDarwin() && // Only supported on Darwin platforms.
 Args.getAllArgValues(options::OPT_arch).size() > 1;
+
 SmallString<128> F;
 
 if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
   if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
 F = FinalOutput->getValue();
+} else {
+  if (Format != "yaml" && // For YAML, keep the original behavior.
+  Triple.isOSDarwin() && // Enable this only on darwin, since it's the 
only platform supporting .dSYM bundles.
+  Output.isFilename())
+F = Output.getFilename();
 }
 
 if (F.empty()) {
@@ -1494,12 +1505,9 @@ static void renderRemarksOptions(const ArgList , 
ArgStringList ,

[clang] f550961 - [Docs] Fix indentation in remarks section

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T16:41:52-08:00
New Revision: f550961c6e833cb828416f1bdee904f4aadbf37d

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

LOG: [Docs] Fix indentation in remarks section

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 87434200e777..307507388ff6 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -346,36 +346,36 @@ output format of the diagnostics that it generates.
   ``-fsave-optimization-record=bitstream``: A binary format based on LLVM
   Bitstream.
 
-The output file is controlled by :ref:`-foptimization-record-file 
`.
+   The output file is controlled by :ref:`-foptimization-record-file 
`.
 
-In the absence of an explicit output file, the file is chosen using the
-following scheme:
+   In the absence of an explicit output file, the file is chosen using the
+   following scheme:
 
-``.opt.``
+   ``.opt.``
 
-where  is based on the output file of the compilation (whether
-it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
-In other cases, it's based on the input file's stem. For example:
+   where  is based on the output file of the compilation (whether
+   it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
+   In other cases, it's based on the input file's stem. For example:
 
-* ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
-  ``out.opt.yaml``
+   * ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
+ ``out.opt.yaml``
 
-* ``clang -fsave-optimization-record in.c -o out`` will generate
-  ``in.opt.yaml``
+   * ``clang -fsave-optimization-record in.c -o out`` will generate
+ ``in.opt.yaml``
 
-Compiling for multiple architectures will use the following scheme:
+   Compiling for multiple architectures will use the following scheme:
 
-``-.opt.``
+   ``-.opt.``
 
-Note that this is only allowed on Darwin platforms and is incompatible with
-passing multiple ``-arch `` options.
+   Note that this is only allowed on Darwin platforms and is incompatible with
+   passing multiple ``-arch `` options.
 
-When targeting (Thin)LTO, the base is derived from the output filename, and
-the extension is not dropped.
+   When targeting (Thin)LTO, the base is derived from the output filename, and
+   the extension is not dropped.
 
-When targeting ThinLTO, the following scheme is used:
+   When targeting ThinLTO, the following scheme is used:
 
-``.opt..thin..``
+   ``.opt..thin..``
 
 .. _opt_foptimization-record-file:
 



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


[PATCH] D71680: Customize simplified dumping and matching of LambdaExpr

2019-12-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 234636.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71680

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1751,6 +1751,17 @@
   return c;
 }
 
+void func13() {
+  int a = 0;
+  int c = 0;
+
+  [a, b = c](int d) { int e = d; };
+}
+
+void func14() {
+  []  (TemplateType t, TemplateType u) { int e = t + u; };
+}
+
 )cpp";
 
   EXPECT_TRUE(matches(
@@ -1821,6 +1832,23 @@
  returnStmt(forFunction(functionDecl(hasName("func12"))),
 hasReturnValue(
 declRefExpr(to(varDecl(hasName("c");
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(
+  ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+  lambdaExpr(forFunction(functionDecl(hasName("func13"))),
+ has(compoundStmt(hasDescendant(varDecl(hasName("e"),
+ has(declRefExpr(to(varDecl(hasName("a"),
+ has(varDecl(hasName("b"), hasInitializer(declRefExpr(to(
+   varDecl(hasName("c"))),
+ has(parmVarDecl(hasName("d")));
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ lambdaExpr(
+ forFunction(functionDecl(hasName("func14"))),
+ has(templateTypeParmDecl(hasName("TemplateType")));
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {
Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -30,14 +30,14 @@
   void Visit(const Decl *D) {
 OS << D->getDeclKindName() << "Decl";
 if (auto *ND = dyn_cast(D)) {
-  OS << " '" << ND->getDeclName() << "'";
+  OS << " '" << ND->getNameAsString() << "'";
 }
   }
 
   void Visit(const Stmt *S) {
 OS << S->getStmtClassName();
 if (auto *E = dyn_cast(S)) {
-  OS << " '" << E->getDecl()->getDeclName() << "'";
+  OS << " '" << E->getDecl()->getNameAsString() << "'";
 }
   }
 
@@ -479,4 +479,123 @@
 )cpp");
 }
 
+TEST(Traverse, LambdaUnlessSpelledInSource) {
+
+  auto AST =
+  buildASTFromCodeWithArgs(R"cpp(
+
+void captures() {
+  int a = 0;
+  int b = 0;
+  int d = 0;
+  int f = 0;
+
+  [a, , c = d,  = f](int g, int h = 42) {};
+}
+
+void templated() {
+  int a = 0;
+  [a](T t) {};
+}
+
+struct SomeStruct {
+int a = 0;
+void capture_this() {
+[this]() {};
+}
+void capture_this_copy() {
+[self = *this]() {};
+}
+};
+)cpp",
+   {"-Wno-unused-value", "-Wno-c++2a-extensions"});
+
+  auto getLambdaNode = [](const std::string ) {
+auto BN = ast_matchers::match(
+lambdaExpr(hasAncestor(functionDecl(hasName(name.bind("lambda"),
+AST->getASTContext());
+EXPECT_EQ(BN.size(), 1u);
+return BN[0].getNodeAs("lambda");
+  };
+
+  {
+auto L = getLambdaNode("captures");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-DeclRefExpr 'b'
+|-VarDecl 'c'
+| `-DeclRefExpr 'd'
+|-VarDecl 'e'
+| `-DeclRefExpr 'f'
+|-ParmVarDecl 'g'
+|-ParmVarDecl 'h'
+| `-IntegerLiteral
+`-CompoundStmt
+)cpp");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_AsIs, L),
+  R"cpp(
+LambdaExpr
+|-CXXRecordDecl ''
+| |-CXXMethodDecl 'operator()'
+| | |-ParmVarDecl 'g'
+| | |-ParmVarDecl 'h'
+| | | `-IntegerLiteral
+| | `-CompoundStmt
+| |-FieldDecl ''
+| |-FieldDecl ''
+| |-FieldDecl ''
+| |-FieldDecl ''
+| `-CXXDestructorDecl '~'
+|-ImplicitCastExpr
+| `-DeclRefExpr 'a'
+|-DeclRefExpr 'b'
+|-ImplicitCastExpr
+| `-DeclRefExpr 'd'
+|-DeclRefExpr 'f'
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("templated");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-TemplateTypeParmDecl 'T'
+|-ParmVarDecl 't'
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-CXXThisExpr
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this_copy");
+
+

[PATCH] D71680: Customize simplified dumping and matching of LambdaExpr

2019-12-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 234635.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71680

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1751,6 +1751,17 @@
   return c;
 }
 
+void func13() {
+  int a = 0;
+  int c = 0;
+
+  [a, b = c](int d) { int e = d; };
+}
+
+void func14() {
+  []  (TemplateType t, TemplateType u) { int e = t + u; };
+}
+
 )cpp";
 
   EXPECT_TRUE(matches(
@@ -1821,6 +1832,23 @@
  returnStmt(forFunction(functionDecl(hasName("func12"))),
 hasReturnValue(
 declRefExpr(to(varDecl(hasName("c");
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(
+  ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+  lambdaExpr(forFunction(functionDecl(hasName("func13"))),
+ has(compoundStmt(hasDescendant(varDecl(hasName("e"),
+ has(declRefExpr(to(varDecl(hasName("a"),
+ has(varDecl(hasName("b"), hasInitializer(declRefExpr(to(
+   varDecl(hasName("c"))),
+ has(parmVarDecl(hasName("d")));
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ lambdaExpr(
+ forFunction(functionDecl(hasName("func14"))),
+ has(templateTypeParmDecl(hasName("TemplateType")));
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {
Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -30,14 +30,14 @@
   void Visit(const Decl *D) {
 OS << D->getDeclKindName() << "Decl";
 if (auto *ND = dyn_cast(D)) {
-  OS << " '" << ND->getDeclName() << "'";
+  OS << " '" << ND->getNameAsString() << "'";
 }
   }
 
   void Visit(const Stmt *S) {
 OS << S->getStmtClassName();
 if (auto *E = dyn_cast(S)) {
-  OS << " '" << E->getDecl()->getDeclName() << "'";
+  OS << " '" << E->getDecl()->getNameAsString() << "'";
 }
   }
 
@@ -479,4 +479,116 @@
 )cpp");
 }
 
+TEST(Traverse, LambdaUnlessSpelledInSource) {
+
+  auto AST =
+  buildASTFromCodeWithArgs(R"cpp(
+
+void captures() {
+  int a = 0;
+  int b = 0;
+  int d = 0;
+  int f = 0;
+
+  [a, , c = d,  = f](int g, int h = 42) {};
+}
+
+void templated() {
+  int a = 0;
+  [a](T t) {};
+}
+
+struct SomeStruct {
+int a = 0;
+void capture_this() {
+[this]() {};
+}
+void capture_this_copy() {
+[self = *this]() {};
+}
+};
+)cpp",
+   {"-Wno-unused-value", "-Wno-c++2a-extensions"});
+
+  auto getLambdaNode = [](const std::string ) {
+auto BN = ast_matchers::match(
+lambdaExpr(hasAncestor(functionDecl(hasName(name.bind("lambda"),
+AST->getASTContext());
+EXPECT_EQ(BN.size(), 1u);
+return BN[0].getNodeAs("lambda");
+  };
+
+  {
+auto L = getLambdaNode("captures");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-DeclRefExpr 'b'
+|-VarDecl 'c'
+| `-DeclRefExpr 'd'
+|-VarDecl 'e'
+| `-DeclRefExpr 'f'
+|-ParmVarDecl 'g'
+|-ParmVarDecl 'h'
+| `-IntegerLiteral
+`-CompoundStmt
+)cpp");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_AsIs, L),
+  R"cpp(
+LambdaExpr
+`-CXXRecordDecl ''
+  |-CXXMethodDecl 'operator()'
+  | |-ParmVarDecl 'g'
+  | |-ParmVarDecl 'h'
+  | | `-IntegerLiteral
+  | `-CompoundStmt
+  |-FieldDecl ''
+  |-FieldDecl ''
+  |-FieldDecl ''
+  |-FieldDecl ''
+  `-CXXDestructorDecl '~'
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("templated");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-TemplateTypeParmDecl 'T'
+|-ParmVarDecl 't'
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-CXXThisExpr
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this_copy");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-VarDecl 'self'
+| `-UnaryOperator
+|   `-CXXThisExpr
+`-CompoundStmt

[PATCH] D71648: [WebAssembly] Add avgr_u intrinsics and require nuw in patterns

2019-12-18 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71eb8023d85e: [WebAssembly] Add avgr_u intrinsics and 
require nuw in patterns (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71648

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-arith.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -65,6 +65,16 @@
   ret <16 x i8> %a
 }
 
+; CHECK-LABEL: avgr_u_v16i8:
+; SIMD128-NEXT: .functype avgr_u_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i8x16.avgr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.avgr.unsigned.v16i8(<16 x i8>, <16 x i8>)
+define <16 x i8> @avgr_u_v16i8(<16 x i8> %x, <16 x i8> %y) {
+  %a = call <16 x i8> @llvm.wasm.avgr.unsigned.v16i8(<16 x i8> %x, <16 x i8> %y)
+  ret <16 x i8> %a
+}
+
 ; CHECK-LABEL: any_v16i8:
 ; SIMD128-NEXT: .functype any_v16i8 (v128) -> (i32){{$}}
 ; SIMD128-NEXT: i8x16.any_true $push[[R:[0-9]+]]=, $0{{$}}
@@ -168,6 +178,16 @@
   ret <8 x i16> %a
 }
 
+; CHECK-LABEL: avgr_u_v8i16:
+; SIMD128-NEXT: .functype avgr_u_v8i16 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i16x8.avgr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <8 x i16> @llvm.wasm.avgr.unsigned.v8i16(<8 x i16>, <8 x i16>)
+define <8 x i16> @avgr_u_v8i16(<8 x i16> %x, <8 x i16> %y) {
+  %a = call <8 x i16> @llvm.wasm.avgr.unsigned.v8i16(<8 x i16> %x, <8 x i16> %y)
+  ret <8 x i16> %a
+}
+
 ; CHECK-LABEL: any_v8i16:
 ; SIMD128-NEXT: .functype any_v8i16 (v128) -> (i32){{$}}
 ; SIMD128-NEXT: i16x8.any_true $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/test/CodeGen/WebAssembly/simd-arith.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-arith.ll
+++ llvm/test/CodeGen/WebAssembly/simd-arith.ll
@@ -97,6 +97,19 @@
 ; SIMD128-NEXT: i8x16.avgr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
 define <16 x i8> @avgr_u_v16i8(<16 x i8> %x, <16 x i8> %y) {
+  %a = add nuw <16 x i8> %x, %y
+  %b = add nuw <16 x i8> %a, 
+  %c = udiv <16 x i8> %b, 
+  ret <16 x i8> %c
+}
+
+; CHECK-LABEL: avgr_u_v16i8_wrap:
+; NO-SIMD128-NOT: i8x16
+; SIMD128-NEXT: .functype avgr_u_v16i8_wrap (v128, v128) -> (v128){{$}}
+; SIMD128-NOT: i8x16.avgr_u
+define <16 x i8> @avgr_u_v16i8_wrap(<16 x i8> %x, <16 x i8> %y) {
   %a = add <16 x i8> %x, %y
   %b = add <16 x i8> %a, 
@@ -401,6 +414,17 @@
 ; SIMD128-NEXT: i16x8.avgr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
 define <8 x i16> @avgr_u_v8i16(<8 x i16> %x, <8 x i16> %y) {
+  %a = add nuw <8 x i16> %x, %y
+  %b = add nuw <8 x i16> %a, 
+  %c = udiv <8 x i16> %b, 
+  ret <8 x i16> %c
+}
+
+; CHECK-LABEL: avgr_u_v8i16_wrap:
+; NO-SIMD128-NOT: i16x8
+; SIMD128-NEXT: .functype avgr_u_v8i16_wrap (v128, v128) -> (v128){{$}}
+; SIMD128-NOT: i16x8.avgr_u
+define <8 x i16> @avgr_u_v8i16_wrap(<8 x i16> %x, <8 x i16> %y) {
   %a = add <8 x i16> %x, %y
   %b = add <8 x i16> %a, 
   %c = udiv <8 x i16> %b, 
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -739,23 +739,24 @@
 } // isCommutable = 1
 
 // Integer unsigned rounding average: avgr_u
-def avgr_u_v16i8 :
-  PatFrag<(ops node:$lhs, node:$rhs),
-  (srl
-(add (add node:$lhs, node:$rhs), (splat16 (i32 1))),
-(v16i8 (splat16 (i32 1)))
-  )>;
-def avgr_u_v8i16 :
-  PatFrag<(ops node:$lhs, node:$rhs),
-  (srl
-(add (add node:$lhs, node:$rhs), (splat8 (i32 1))),
-(v8i16 (splat8 (i32 1)))
-  )>;
-
 let isCommutable = 1, Predicates = [HasUnimplementedSIMD128] in {
-defm AVGR_U : SIMDBinary;
-defm AVGR_U : SIMDBinary;
-}
+defm AVGR_U : SIMDBinary;
+defm AVGR_U : SIMDBinary;
+}
+
+def add_nuw : PatFrag<(ops node:$lhs, node:$rhs),
+  (add node:$lhs, node:$rhs),
+  "return N->getFlags().hasNoUnsignedWrap();">;
+
+foreach nodes = [[v16i8, splat16], [v8i16, splat8]] in
+def : Pat<(srl
+(add_nuw
+  (add_nuw (nodes[0] V128:$lhs), (nodes[0] V128:$rhs)),
+  (nodes[1] (i32 1))
+),
+(nodes[0] (nodes[1] (i32 1)))
+  ),
+  (!cast("AVGR_U_"#nodes[0]) V128:$lhs, V128:$rhs)>;
 
 // Widening dot 

[clang] 71eb802 - [WebAssembly] Add avgr_u intrinsics and require nuw in patterns

2019-12-18 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2019-12-18T15:31:38-08:00
New Revision: 71eb8023d85e5201d32ea24194ec5bc07db23527

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

LOG: [WebAssembly] Add avgr_u intrinsics and require nuw in patterns

Summary:
The vector pattern `(a + b + 1) / 2` was previously selected to an
avgr_u instruction regardless of nuw flags, but this is incorrect in
the case where either addition may have an unsigned wrap. This CL
changes the existing pattern to require both adds to have nuw flags
and adds builtin functions and intrinsics for the avgr_u instructions
because the corrected pattern is not representable in C.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-arith.ll
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 5b4fee421a20..38a2441b5fd4 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -98,6 +98,9 @@ TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i8x16, 
"V16cV16cV16c", "nc", "simd1
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 
+TARGET_BUILTIN(__builtin_wasm_avgr_u_i8x16, "V16cV16cV16c", "nc", 
"unimplemented-simd128")
+TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8sV8sV8s", "nc", 
"unimplemented-simd128")
+
 TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_any_true_i8x16, "iV16c", "nc", "simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2e6c95c02c3f..37aca09bff5b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14496,6 +14496,14 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_avgr_u_i8x16:
+  case WebAssembly::BI__builtin_wasm_avgr_u_i16x8: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_avgr_unsigned,
+ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_bitselect: {
 Value *V1 = EmitScalarExpr(E->getArg(0));
 Value *V2 = EmitScalarExpr(E->getArg(1));

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 7ea32feb0512..e8e5ba3fbe09 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -352,6 +352,20 @@ i16x8 sub_saturate_u_i16x8(i16x8 x, i16x8 y) {
   // WEBASSEMBLY-NEXT: ret
 }
 
+i8x16 avgr_u_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_avgr_u_i8x16(x, y);
+  // WEBASSEMBLY: call <16 x i8> @llvm.wasm.avgr.unsigned.v16i8(
+  // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+i16x8 avgr_u_i16x8(i16x8 x, i16x8 y) {
+  return __builtin_wasm_avgr_u_i16x8(x, y);
+  // WEBASSEMBLY: call <8 x i16> @llvm.wasm.avgr.unsigned.v8i16(
+  // WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 i32x4 dot_i16x8_s(i16x8 x, i16x8 y) {
   return __builtin_wasm_dot_s_i32x4_i16x8(x, y);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y)

diff  --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td 
b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
index 99c4eec1e0a3..e97700ad724a 100644
--- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -112,6 +112,10 @@ def int_wasm_sub_saturate_unsigned :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
+def int_wasm_avgr_unsigned :
+  Intrinsic<[llvm_anyvector_ty],
+[LLVMMatchType<0>, LLVMMatchType<0>],
+[IntrNoMem, IntrSpeculatable]>;
 
 def int_wasm_bitselect :
   Intrinsic<[llvm_anyvector_ty],

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 

[PATCH] D71467: [FPEnv] Generate constrained FP comparisons from clang

2019-12-18 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

Ping?


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

https://reviews.llvm.org/D71467



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


Re: [clang] 12038be - [Concepts] Fix crash in D41910

2019-12-18 Thread Vedant Kumar via cfe-commits
I've temporarily reverted the D41910 patchset in order to get the lldb bot 
unstuck (5094e6dad64).

vedant

> On Dec 18, 2019, at 1:34 PM, Vedant Kumar  wrote:
> 
> Hey Saar,
> Do you expect this to address this crash seen on the lldb bot after D41910 
> landed?
> 
> Assertion failed: (Idx < size() && "Out-of-bounds Bit access."), function 
> operator[], file 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/ADT/SmallBitVector.h,
>  line 452.
> 
> Stack dump:
> 0.Program arguments: 
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-10 -cc1 
> -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
> -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free 
> -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model 
> posix -mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
> -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
> -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
> -target-linker-version 409.12 -resource-dir 
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lib/clang/10.0.99 
> -isysroot 
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
>  -include 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h
>  -I 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../../include
>  -I 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant
>  -I 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make
>  -D LLDB_USING_LIBCPP -stdlib=libc++ -internal-isystem 
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/../include/c++/v1
>  -internal-isystem 
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/v1
>  -internal-isystem 
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/local/include
>  -internal-isystem 
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lib/clang/10.0.99/include
>  -internal-externc-isystem 
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
>  -O0 -std=c++17 -fdeprecated-macro -fdebug-compilation-dir 
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.test_with_run_command_dsym
>  -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fno-builtin -fblocks 
> -fencode-extended-block-signature -fregister-global-dtors-with-atexit 
> -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.14.0 -fcxx-exceptions 
> -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o main.o -x c++ 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp
>  
> 1.
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp:26:39:
>  current parser token ';'
> 2.
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp:20:1:
>  parsing function body 'main'
> 3.
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp:20:1:
>  in compound statement ('{}')
> 4.
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/../include/c++/v1/variant:1192:13:
>  instantiating function definition 'std::__1::variant char>::variant'
> 5.
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/../include/c++/v1/variant:684:22:
>  instantiating function definition 
> 'std::__1::__variant_detail::__base  int, double, char>::__base<0>'
> 0  clang-10 0x0001077ed1a5 
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
> 1  clang-10 0x0001077ec0a8 llvm::sys::RunSignalHandlers() 
> + 248
> 2  clang-10 0x0001077ed796 SignalHandler(int) + 262
> 3  libsystem_platform.dylib 0x7fff66bc3b3d _sigtramp + 29
> 4  libsystem_platform.dylib 0x7ffeea2a2150 _sigtramp + 
> 18446744071619601968
> 5  libsystem_c.dylib0x7fff66a821c9 abort + 127
> 6  libsystem_c.dylib0x7fff66a4a868 basename_r + 0
> 7  clang-10 0x0001094b79d9 
> isAtLeastAsSpecializedAs(clang::Sema&, clang::SourceLocation, 
> clang::FunctionTemplateDecl*, 

[PATCH] D57660: [Sema] SequenceChecker: Handle references, members and structured bindings.

2019-12-18 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 234627.
riccibruno added a comment.

Add missing patch context


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57660

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-unsequenced.cpp

Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -279,17 +279,21 @@
   void member_f(S1 );
 };
 
+class SomeClass { public: static int x; };
+union SomeUnion { public: static int x; };
+
 void S1::member_f(S1 ) {
-  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
- // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
-  a + ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to member 'a'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'a'}}
+  a + ++a; // cxx11-warning {{unsequenced modification and access to member 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'a'}}
   ++a + ++b; // no-warning
   a + ++b; // no-warning
 
-  // TODO: Warn here.
-  ++s.a + ++s.a; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.a + ++s.a; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.a + ++s.a; // cxx11-warning {{multiple unsequenced modifications to member 'a' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'a' of 's'}}
+  s.a + ++s.a; // cxx11-warning {{unsequenced modification and access to member 'a' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'a' of 's'}}
   ++s.a + ++s.b; // no-warning
   s.a + ++s.b; // no-warning
 
@@ -299,16 +303,18 @@
   a + ++s.b; // no-warning
 
   // TODO Warn here for bit-fields in the same memory location.
-  ++bf1 + ++bf1; // cxx11-warning {{multiple unsequenced modifications to 'bf1'}}
- // cxx17-warning@-1 {{multiple unsequenced modifications to 'bf1'}}
-  bf1 + ++bf1; // cxx11-warning {{unsequenced modification and access to 'bf1'}}
-   // cxx17-warning@-1 {{unsequenced modification and access to 'bf1'}}
+  ++bf1 + ++bf1; // cxx11-warning {{multiple unsequenced modifications to member 'bf1'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'bf1'}}
+  bf1 + ++bf1; // cxx11-warning {{unsequenced modification and access to member 'bf1'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'bf1'}}
   ++bf1 + ++bf2; // no-warning TODO {{multiple unsequenced modifications to}}
   bf1 + ++bf2; // no-warning TODO {{unsequenced modification and access to}}
 
   // TODO Warn here for bit-fields in the same memory location.
-  ++s.bf1 + ++s.bf1; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.bf1 + ++s.bf1; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.bf1 + ++s.bf1; // cxx11-warning {{multiple unsequenced modifications to member 'bf1' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'bf1' of 's'}}
+  s.bf1 + ++s.bf1; // cxx11-warning {{unsequenced modification and access to member 'bf1' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'bf1' of 's'}}
   ++s.bf1 + ++s.bf2; // no-warning TODO {{multiple unsequenced modifications to}}
   s.bf1 + ++s.bf2; // no-warning TODO {{unsequenced modification and access to}}
 
@@ -322,19 +328,29 @@
   Der _ref = d;
   S1 _ref = d_ref;
 
-  ++s1_ref.a + ++d_ref.a; // no-warning TODO {{multiple unsequenced modifications to member 'a' of 'd'}}
-  ++s1_ref.a + d_ref.a; // no-warning TODO {{unsequenced modification and access to member 'a' of 'd'}}
+  ++s1_ref.a + ++d_ref.a; // cxx11-warning {{multiple unsequenced modifications to member 'a' of 'd'}}
+  // cxx17-warning@-1 {{multiple unsequenced modifications to member 'a' of 'd'}}
+  ++s1_ref.a + d_ref.a; // cxx11-warning {{unsequenced modification and access to member 'a' of 'd'}}
+// cxx17-warning@-1 {{unsequenced modification and access to member 'a' of 'd'}}
   ++s1_ref.a + ++d_ref.b; // no-warning
   ++s1_ref.a + d_ref.b; // no-warning
 
-  ++x + ++x; // cxx11-warning {{multiple unsequenced modifications to 'x'}}
- // cxx17-warning@-1 {{multiple unsequenced modifications to 'x'}}
-  ++x + x; // cxx11-warning {{unsequenced modification and access to 'x'}}
-   // cxx17-warning@-1 {{unsequenced modification and access to 'x'}}
-  ++s.x + x; // no-warning TODO {{unsequenced 

[PATCH] D71680: Customize simplified dumping and matching of LambdaExpr

2019-12-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71680

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1751,6 +1751,17 @@
   return c;
 }
 
+void func13() {
+  int a = 0;
+  int c = 0;
+
+  [a, b = c](int d) { int e = d; };
+}
+
+void func14() {
+  []  (TemplateType t, TemplateType u) { int e = t + u; };
+}
+
 )cpp";
 
   EXPECT_TRUE(matches(
@@ -1821,6 +1832,23 @@
  returnStmt(forFunction(functionDecl(hasName("func12"))),
 hasReturnValue(
 declRefExpr(to(varDecl(hasName("c");
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(
+  ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+  lambdaExpr(forFunction(functionDecl(hasName("func13"))),
+ has(compoundStmt(hasDescendant(varDecl(hasName("e"),
+ has(declRefExpr(to(varDecl(hasName("a"),
+ has(varDecl(hasName("b"), hasInitializer(declRefExpr(to(
+   varDecl(hasName("c"))),
+ has(parmVarDecl(hasName("d")));
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ lambdaExpr(
+ forFunction(functionDecl(hasName("func14"))),
+ has(templateTypeParmDecl(hasName("TemplateType")));
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {
Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -30,14 +30,14 @@
   void Visit(const Decl *D) {
 OS << D->getDeclKindName() << "Decl";
 if (auto *ND = dyn_cast(D)) {
-  OS << " '" << ND->getDeclName() << "'";
+  OS << " '" << ND->getNameAsString() << "'";
 }
   }
 
   void Visit(const Stmt *S) {
 OS << S->getStmtClassName();
 if (auto *E = dyn_cast(S)) {
-  OS << " '" << E->getDecl()->getDeclName() << "'";
+  OS << " '" << E->getDecl()->getNameAsString() << "'";
 }
   }
 
@@ -479,4 +479,116 @@
 )cpp");
 }
 
+TEST(Traverse, LambdaUnlessSpelledInSource) {
+
+  auto AST =
+  buildASTFromCodeWithArgs(R"cpp(
+
+void captures() {
+  int a = 0;
+  int b = 0;
+  int d = 0;
+  int f = 0;
+
+  [a, , c = d,  = f](int g, int h = 42) {};
+}
+
+void templated() {
+  int a = 0;
+  [a](T t) {};
+}
+
+struct SomeStruct {
+int a = 0;
+void capture_this() {
+[this]() {};
+}
+void capture_this_copy() {
+[self = *this]() {};
+}
+};
+)cpp",
+   {"-Wno-unused-value", "-Wno-c++2a-extensions"});
+
+  auto getLambdaNode = [](const std::string ) {
+auto BN = ast_matchers::match(
+lambdaExpr(hasAncestor(functionDecl(hasName(name.bind("lambda"),
+AST->getASTContext());
+EXPECT_EQ(BN.size(), 1u);
+return BN[0].getNodeAs("lambda");
+  };
+
+  {
+auto L = getLambdaNode("captures");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-DeclRefExpr 'b'
+|-VarDecl 'c'
+| `-DeclRefExpr 'd'
+|-VarDecl 'e'
+| `-DeclRefExpr 'f'
+|-ParmVarDecl 'g'
+|-ParmVarDecl 'h'
+| `-IntegerLiteral
+`-CompoundStmt
+)cpp");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_AsIs, L),
+  R"cpp(
+LambdaExpr
+`-CXXRecordDecl ''
+  |-CXXMethodDecl 'operator()'
+  | |-ParmVarDecl 'g'
+  | |-ParmVarDecl 'h'
+  | | `-IntegerLiteral
+  | `-CompoundStmt
+  |-FieldDecl ''
+  |-FieldDecl ''
+  |-FieldDecl ''
+  |-FieldDecl ''
+  `-CXXDestructorDecl '~'
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("templated");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-DeclRefExpr 'a'
+|-TemplateTypeParmDecl 'T'
+|-ParmVarDecl 't'
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-CXXThisExpr
+`-CompoundStmt
+)cpp");
+  }
+
+  {
+auto L = getLambdaNode("capture_this_copy");
+
+EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
+  R"cpp(
+LambdaExpr
+|-VarDecl 'self'
+| `-UnaryOperator
+|   `-CXXThisExpr
+`-CompoundStmt

[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

2019-12-18 Thread Eric Astor via Phabricator via cfe-commits
epastor added a comment.

In D71677#1790458 , @rnk wrote:

> Where is {0:P} actually documented? I don't see it in LangRef, but I do see 
> it in the code.


https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers, under X86; 
specifically documented to be used on the operands of `call` instructions.




Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2871
+  // differently when referenced in MS-style inline assembly.
+  if (Name.startswith("call") || Name.startswith("lcall")) {
+for (size_t i = 1; i < Operands.size(); ++i) {

rnk wrote:
> I'm trying to think of other edge cases where we'd want the same treatment. 
> In theory, we'd want to do this for every control flow instruction that takes 
> a PC-relative operand, jmp, jcc, jecxz, that might be all. You know, it 
> actually seems reasonable to set up a naked function that contains an asm 
> blob which conditionally branches to another function, so I guess we should 
> support it. In that case, maybe this should be named something like 
> "isBranchTarget" instead of isCallTarget.
That would be a valid option, but currently the "P" modifier is documented for 
LLVM as to-be-used on the operands of `call` instructions. [[ 
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers | GNU 
as ]]) adds it more generally to be applied to functions - and occasionally 
constants, if you need a constant to avoid all syntax-specific prefixes.

We could use this for any branch target operand... but we'd need to restrict it 
to apply only to the specific PC-relative operand, which I think means 
augmenting the X86 target tables to annotate which operands of which 
instructions are PC-relative? Also, I'm not sure if that would break 
pre-existing code in enough cases to be worrying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677



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


[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

2019-12-18 Thread Kanglei Fang via Phabricator via cfe-commits
ghvg1313 marked 2 inline comments as done.
ghvg1313 added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:869
   State.Stack[i].BreakBeforeParameter = true;
 
   if (PreviousNonComment &&

ghvg1313 wrote:
> MyDeveloperDay wrote:
> > I'm a little confused by the code, this feels to me like its covering 
> > something more than a specific than just the ObjectiveC case, what is meant 
> > here by a nestedblockspecialcase? this feels like we are turning off 
> > BreakBeforeParameter by another method?
> > 
> > I get the code below, just wondering why this is also needed.
> I think you are right, bin packing is already avoided as the comment says so 
> I don't have to do anything extra.
> 
> Was trying to handle linebreaking within block as well. Not needed indeed.
Notice I get this back again, it's actually to avoid parameter break in between 
blocks, so we don't get inconsistent parameter break between blocks, for 
example: 
```
- (void)_aMethod
{
[self.test1 t:self
w:self
 callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
 u = c;
 } x:self callback2:^(typeof(self) self, NSNumber *u, NSNumber *v) {
 u = c;
 }]
}
```

Originally, the second block will trigger the parameter break in between itself 
and the previous block.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70926



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


[PATCH] D70613: Add method to ignore invisible AST nodes

2019-12-18 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG98e8f774eb6c: Add method to ignore invisible AST nodes 
(authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D70613?vs=233183=234623#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70613

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Expr.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1680,6 +1680,149 @@
  functionDecl(hasDescendant(Matcher)));
 }
 
+TEST(Traversal, traverseUnlessSpelledInSource) {
+
+  StringRef Code = R"cpp(
+
+struct A
+{
+};
+
+struct B
+{
+  B(int);
+  B(A const& a);
+  B();
+};
+
+struct C
+{
+  operator B();
+};
+
+B func1() {
+  return 42;
+}
+
+B func2() {
+  return B{42};
+}
+
+B func3() {
+  return B(42);
+}
+
+B func4() {
+  return B();
+}
+
+B func5() {
+  return B{};
+}
+
+B func6() {
+  return C();
+}
+
+B func7() {
+  return A();
+}
+
+B func8() {
+  return C{};
+}
+
+B func9() {
+  return A{};
+}
+
+B func10() {
+  A a;
+  return a;
+}
+
+B func11() {
+  B b;
+  return b;
+}
+
+B func12() {
+  C c;
+  return c;
+}
+
+)cpp";
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func1"))),
+hasReturnValue(integerLiteral(equals(42)));
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   returnStmt(forFunction(functionDecl(hasName("func2"))),
+  hasReturnValue(cxxTemporaryObjectExpr(
+  hasArgument(0, integerLiteral(equals(42);
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func3"))),
+hasReturnValue(
+cxxFunctionalCastExpr(hasSourceExpression(
+integerLiteral(equals(42);
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func4"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func5"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func6"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func7"))),
+hasReturnValue(cxxTemporaryObjectExpr());
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func8"))),
+hasReturnValue(cxxFunctionalCastExpr(
+hasSourceExpression(initListExpr(;
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func9"))),
+hasReturnValue(cxxFunctionalCastExpr(
+hasSourceExpression(initListExpr(;
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func10"))),
+hasReturnValue(
+declRefExpr(to(varDecl(hasName("a");
+
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ returnStmt(forFunction(functionDecl(hasName("func11"))),
+hasReturnValue(
+declRefExpr(to(varDecl(hasName("b");
+
+  EXPECT_TRUE(matches(
+  Code, 

[PATCH] D71675: [Remarks][Driver] Run dsymutil when remarks are enabled

2019-12-18 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd79b11fefb8e: [Remarks][Driver] Run dsymutil when remarks 
are enabled (authored by thegameg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71675

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-opt-record.c


Index: clang/test/Driver/darwin-opt-record.c
===
--- clang/test/Driver/darwin-opt-record.c
+++ clang/test/Driver/darwin-opt-record.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MULTIPLE-ARCH
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-foptimization-record-file=tmp -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck 
%s --check-prefix=CHECK-MULTIPLE-ARCH-ERROR
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-NO-G
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -g0 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-G0
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
@@ -9,3 +11,14 @@
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"
 //
 // CHECK-MULTIPLE-ARCH-ERROR: cannot use '-foptimization-record-file' output 
with multiple -arch options
+//
+// CHECK-DSYMUTIL-NO-G: "-cc1"
+// CHECK-DSYMUTIL-NO-G: ld
+// CHECK-DSYMUTIL-NO-G: dsymutil
+//
+// Even in the presence of -g0, -fsave-optimization-record implies
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"
+// CHECK-DSYMUTIL-G0: ld
+// CHECK-DSYMUTIL-G0: dsymutil
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1990,8 +1990,9 @@
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
-if (A && !A->getOption().matches(options::OPT_g0) &&
-!A->getOption().matches(options::OPT_gstabs) &&
+bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+!A->getOption().matches(options::OPT_gstabs);
+if ((enablesDebugInfo || willEmitRemarks(Args)) &&
 ContainsCompileOrAssembleAction(Actions.back())) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we


Index: clang/test/Driver/darwin-opt-record.c
===
--- clang/test/Driver/darwin-opt-record.c
+++ clang/test/Driver/darwin-opt-record.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO -fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO -foptimization-record-file=tmp -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH-ERROR
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-NO-G
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -g0 -fsave-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-G0
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
@@ -9,3 +11,14 @@
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"
 //
 // CHECK-MULTIPLE-ARCH-ERROR: cannot use '-foptimization-record-file' output with multiple -arch options
+//
+// CHECK-DSYMUTIL-NO-G: "-cc1"
+// CHECK-DSYMUTIL-NO-G: ld
+// CHECK-DSYMUTIL-NO-G: dsymutil
+//
+// Even in the presence of -g0, -fsave-optimization-record implies
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"
+// CHECK-DSYMUTIL-G0: ld
+// CHECK-DSYMUTIL-G0: dsymutil
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1990,8 +1990,9 @@
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
-if (A && !A->getOption().matches(options::OPT_g0) &&
-!A->getOption().matches(options::OPT_gstabs) &&
+bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+!A->getOption().matches(options::OPT_gstabs);
+if ((enablesDebugInfo || willEmitRemarks(Args)) &&
 ContainsCompileOrAssembleAction(Actions.back())) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we
___
cfe-commits mailing 

[PATCH] D70527: [clang] Fix the canonicalization of paths in -fdiagnostics-absolute-paths

2019-12-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: clang/lib/Basic/FileManager.cpp:551
 StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
   // FIXME: use llvm::sys::fs::canonical() when it gets implemented
+  llvm::DenseMap::iterator Known

These FIXMEs look stale. We are already using VFS getRealPath which ultimately 
probably boils down to whatever the original author thought sys::fs::canonical 
would be.



Comment at: clang/lib/Basic/FileManager.cpp:568
+StringRef FileManager::getCanonicalName(const FileEntry *File) {
+  // FIXME: use llvm::sys::fs::canonical() when it gets implemented
+  llvm::DenseMap::iterator Known

I don't think we need to carry this FIXME here.



Comment at: clang/lib/Basic/FileManager.cpp:570
+  llvm::DenseMap::iterator Known
+= CanonicalNames.find(File);
+  if (Known != CanonicalNames.end())

uber nit: use the .insert get-or-create pattern



Comment at: clang/test/Frontend/absolute-paths-symlinks.c:15
+
+// REQUIRES: shell

I wish we had a more precise feature to indicate symlink support, but this is 
what we do elsewhere, so there's nothing to do here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70527



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


[clang] a9f597b - Output names in the AST in tests

2019-12-18 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2019-12-18T22:33:23Z
New Revision: a9f597b62ebdb670392fec2d5a5154e43b6398aa

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

LOG: Output names in the AST in tests

Added: 


Modified: 
clang/unittests/AST/ASTTraverserTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index 69812cb8d21c..99d4589c48a3 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -27,9 +27,19 @@ class NodeTreePrinter : public TextTreeStructure {
   NodeTreePrinter(llvm::raw_ostream )
   : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
 
-  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
+  void Visit(const Decl *D) {
+OS << D->getDeclKindName() << "Decl";
+if (auto *ND = dyn_cast(D)) {
+  OS << " '" << ND->getDeclName() << "'";
+}
+  }
 
-  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
+  void Visit(const Stmt *S) {
+OS << S->getStmtClassName();
+if (auto *E = dyn_cast(S)) {
+  OS << " '" << E->getDecl()->getDeclName() << "'";
+}
+  }
 
   void Visit(QualType QT) {
 OS << "QualType " << QT.split().Quals.getAsString();
@@ -147,7 +157,7 @@ void parmvardecl_attr(struct A 
__attribute__((address_space(19)))*);
 
   verifyWithDynNode(Func,
 R"cpp(
-CXXMethodDecl
+CXXMethodDecl 'func'
 |-CompoundStmt
 | `-ReturnStmt
 |   `-IntegerLiteral



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


[clang] 84fd2be - Trim trailing whitespace

2019-12-18 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2019-12-18T22:33:23Z
New Revision: 84fd2bedf4096e78b892165138051b8563169fe3

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

LOG: Trim trailing whitespace

Added: 


Modified: 
clang/unittests/AST/ASTTraverserTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index 99d4589c48a3..6debdf10eda2 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -141,12 +141,12 @@ struct A {
 
 template
 struct templ
-{ 
+{
 };
 
 template<>
 struct templ
-{ 
+{
 };
 
 void parmvardecl_attr(struct A __attribute__((address_space(19)))*);



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


[clang] a8c678c - [Remarks][Driver][NFC] Make shouldEmitRemarks more available in the Driver

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T14:31:41-08:00
New Revision: a8c678cb9a90c4f82505f573e9b9fa23fec93a64

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

LOG: [Remarks][Driver][NFC] Make shouldEmitRemarks more available in the Driver

Move the function to Driver.h so that it can be re-used in other places.

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 64f1eb8cb5d7..d667fcb1efef 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -620,6 +620,9 @@ class Driver {
 /// And False otherwise.
 bool isOptimizationLevelFast(const llvm::opt::ArgList );
 
+/// \return True if the argument combination will end up generating remarks.
+bool willEmitRemarks(const llvm::opt::ArgList );
+
 } // end namespace driver
 } // end namespace clang
 

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f2b234315512..35e7998bf22f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -5060,3 +5060,26 @@ Driver::getIncludeExcludeOptionFlagMasks(bool 
IsClCompatMode) const {
 bool clang::driver::isOptimizationLevelFast(const ArgList ) {
   return Args.hasFlag(options::OPT_Ofast, options::OPT_O_Group, false);
 }
+
+bool clang::driver::willEmitRemarks(const ArgList ) {
+  // -fsave-optimization-record enables it.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -fsave-optimization-record= enables it as well.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -foptimization-record-file alone enables it too.
+  if (Args.hasFlag(options::OPT_foptimization_record_file_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -foptimization-record-passes alone enables it too.
+  if (Args.hasFlag(options::OPT_foptimization_record_passes_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+  return false;
+}

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5bf0efcf0503..9840acafd6ea 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1415,29 +1415,6 @@ static bool isNoCommonDefault(const llvm::Triple 
) {
   }
 }
 
-static bool shouldEmitRemarks(const ArgList ) {
-  // -fsave-optimization-record enables it.
-  if (Args.hasFlag(options::OPT_fsave_optimization_record,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-
-  // -fsave-optimization-record= enables it as well.
-  if (Args.hasFlag(options::OPT_fsave_optimization_record_EQ,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-
-  // -foptimization-record-file alone enables it too.
-  if (Args.hasFlag(options::OPT_foptimization_record_file_EQ,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-
-  // -foptimization-record-passes alone enables it too.
-  if (Args.hasFlag(options::OPT_foptimization_record_passes_EQ,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-  return false;
-}
-
 static bool hasMultipleInvocations(const llvm::Triple ,
const ArgList ) {
   // Supported only on Darwin where we invoke the compiler multiple times
@@ -3718,7 +3695,7 @@ static void RenderDebugOptions(const ToolChain , const 
Driver ,
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
   // When emitting remarks, we need at least debug lines in the output.
-  if (shouldEmitRemarks(Args) &&
+  if (willEmitRemarks(Args) &&
   DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
 DebugInfoKind = codegenoptions::DebugLineTablesOnly;
 
@@ -5546,7 +5523,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 CmdArgs.push_back("-fapple-pragma-pack");
 
   // Remarks can be enabled with any of the `-f.*optimization-record.*` flags.
-  if (shouldEmitRemarks(Args) && checkRemarksOptions(D, Args, Triple))
+  if (willEmitRemarks(Args) && checkRemarksOptions(D, Args, Triple))
 renderRemarksOptions(Args, CmdArgs, Triple, Input, JA);
 
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,



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


[clang] d79b11f - [Remarks][Driver] Run dsymutil when remarks are enabled

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T14:31:41-08:00
New Revision: d79b11fefb8e92660893b8ccf9e21d23668a6c73

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

LOG: [Remarks][Driver] Run dsymutil when remarks are enabled

When clang is invoked with a source file without -c or -S, it creates a
cc1 job, a linker job and if debug info is requested, a dsymutil job. In
case of remarks, we should also create a dsymutil job to avoid losing
the remarks that will be generated in a tempdir that gets removed.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/darwin-opt-record.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 35e7998bf22f..e718b8366df0 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1990,8 +1990,9 @@ void Driver::BuildUniversalActions(Compilation , const 
ToolChain ,
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
-if (A && !A->getOption().matches(options::OPT_g0) &&
-!A->getOption().matches(options::OPT_gstabs) &&
+bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+!A->getOption().matches(options::OPT_gstabs);
+if ((enablesDebugInfo || willEmitRemarks(Args)) &&
 ContainsCompileOrAssembleAction(Actions.back())) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we

diff  --git a/clang/test/Driver/darwin-opt-record.c 
b/clang/test/Driver/darwin-opt-record.c
index 2238dfc6baf4..477307c8022f 100644
--- a/clang/test/Driver/darwin-opt-record.c
+++ b/clang/test/Driver/darwin-opt-record.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MULTIPLE-ARCH
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-foptimization-record-file=tmp -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck 
%s --check-prefix=CHECK-MULTIPLE-ARCH-ERROR
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-NO-G
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -g0 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-G0
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
@@ -9,3 +11,14 @@
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"
 //
 // CHECK-MULTIPLE-ARCH-ERROR: cannot use '-foptimization-record-file' output 
with multiple -arch options
+//
+// CHECK-DSYMUTIL-NO-G: "-cc1"
+// CHECK-DSYMUTIL-NO-G: ld
+// CHECK-DSYMUTIL-NO-G: dsymutil
+//
+// Even in the presence of -g0, -fsave-optimization-record implies
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"
+// CHECK-DSYMUTIL-G0: ld
+// CHECK-DSYMUTIL-G0: dsymutil



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


[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

2019-12-18 Thread Kanglei Fang via Phabricator via cfe-commits
ghvg1313 updated this revision to Diff 234621.
ghvg1313 added a comment.

- Handle parameter break between blocks
- Fix test cases and move them to objcTest
- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70926

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestObjC.cpp

Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -1398,6 +1398,32 @@
   "}");
 }
 
+TEST_F(FormatTestObjC, BreakLineBeforeNestedBlockParam) {
+  Style = getGoogleStyle(FormatStyle::LK_ObjC);
+  Style.ObjCBreakBeforeNestedBlockParam = false;
+  Style.ColumnLimit = 0;
+
+  verifyFormat("[self.test1 t:self callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {\n"
+   "  u = v;\n"
+   "}]");
+
+  verifyFormat("[self.test1 t:self w:self callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {\n"
+   "  u = v;\n"
+   "}]");
+
+  verifyFormat("[self.test1 t:self w:self callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {\n"
+   "  u = c;\n"
+   "} w:self callback2:^(typeof(self) self, NSNumber *a, NSNumber *b, NSNumber *c) {\n"
+   "  b = c;\n"
+   "}]");
+
+  Style.ColumnLimit = 80;
+  verifyFormat("[self.test_method a:self b:self\n"
+   "   callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {\n"
+   " u = v;\n"
+   "   }]");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -497,6 +497,8 @@
 IO.mapOptional("NamespaceMacros", Style.NamespaceMacros);
 IO.mapOptional("ObjCBinPackProtocolList", Style.ObjCBinPackProtocolList);
 IO.mapOptional("ObjCBlockIndentWidth", Style.ObjCBlockIndentWidth);
+IO.mapOptional("ObjCBreakBeforeNestedBlockParam",
+   Style.ObjCBreakBeforeNestedBlockParam);
 IO.mapOptional("ObjCSpaceAfterProperty", Style.ObjCSpaceAfterProperty);
 IO.mapOptional("ObjCSpaceBeforeProtocolList",
Style.ObjCSpaceBeforeProtocolList);
@@ -794,6 +796,7 @@
   LLVMStyle.NamespaceIndentation = FormatStyle::NI_None;
   LLVMStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Auto;
   LLVMStyle.ObjCBlockIndentWidth = 2;
+  LLVMStyle.ObjCBreakBeforeNestedBlockParam = true;
   LLVMStyle.ObjCSpaceAfterProperty = false;
   LLVMStyle.ObjCSpaceBeforeProtocolList = true;
   LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -861,8 +861,10 @@
   // Any break on this level means that the parent level has been broken
   // and we need to avoid bin packing there.
   bool NestedBlockSpecialCase =
-  !Style.isCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 &&
-  State.Stack[State.Stack.size() - 2].NestedBlockInlined;
+  (!Style.isCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 &&
+  State.Stack[State.Stack.size() - 2].NestedBlockInlined) ||
+  (Style.Language == FormatStyle::LK_ObjC && Current.is(tok::r_brace)
+   && State.Stack.size() > 1 && !Style.ObjCBreakBeforeNestedBlockParam);
   if (!NestedBlockSpecialCase)
 for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i)
   State.Stack[i].BreakBeforeParameter = true;
@@ -1380,7 +1382,8 @@
   (!BinPackInconclusiveFunctions &&
Current.PackingKind == PPK_Inconclusive)));
 
-if (Current.is(TT_ObjCMethodExpr) && Current.MatchingParen) {
+if (Current.is(TT_ObjCMethodExpr) && Current.MatchingParen &&
+Style.ObjCBreakBeforeNestedBlockParam) {
   if (Style.ColumnLimit) {
 // If this '[' opens an ObjC call, determine whether all parameters fit
 // into one line and put one per line if they don't.
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1646,6 +1646,28 @@
   /// ``@property (readonly)`` instead of ``@property(readonly)``.
   bool ObjCSpaceAfterProperty;
 
+  /// Break parameters list into lines when there is nested block
+  /// parameters in a fuction call.
+  /// \code
+  ///   false:
+  ///- (void)_aMethod
+  ///{
+  ///[self.test1 t:self w:self callback:^(typeof(self) self, 

[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

2019-12-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Where is {0:P} actually documented? I don't see it in LangRef, but I do see it 
in the code.




Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2871
+  // differently when referenced in MS-style inline assembly.
+  if (Name.startswith("call") || Name.startswith("lcall")) {
+for (size_t i = 1; i < Operands.size(); ++i) {

I'm trying to think of other edge cases where we'd want the same treatment. In 
theory, we'd want to do this for every control flow instruction that takes a 
PC-relative operand, jmp, jcc, jecxz, that might be all. You know, it actually 
seems reasonable to set up a naked function that contains an asm blob which 
conditionally branches to another function, so I guess we should support it. In 
that case, maybe this should be named something like "isBranchTarget" instead 
of isCallTarget.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677



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


[clang] bce1cce - [analyzer] Teach MismatchedDealloc about initWithBytesNoCopy with deallocator.

2019-12-18 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-12-18T14:19:17-08:00
New Revision: bce1cce6bf1286541c57690ab1129fbc02c60f93

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

LOG: [analyzer] Teach MismatchedDealloc about initWithBytesNoCopy with 
deallocator.

MallocChecker warns when memory is passed into -[NSData initWithBytesNoCopy]
but isn't allocated by malloc(), because it will be deallocated by free().
However, initWithBytesNoCopy has an overload that takes an arbitrary block
for deallocating the object. If such overload is used, it is no longer
necessary to make sure that the memory is allocated by malloc().

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/test/Analysis/Inputs/system-header-simulator-objc.h
clang/test/Analysis/malloc.mm

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 01c7afe52041..09306383d53f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1469,6 +1469,9 @@ void MallocChecker::checkPostObjCMessage(const 
ObjCMethodCall ,
 if (!*FreeWhenDone)
   return;
 
+  if (Call.hasNonZeroCallbackArg())
+return;
+
   bool IsKnownToBeAllocatedMemory;
   ProgramStateRef State =
   FreeMemAux(C, Call.getArgExpr(0), Call.getOriginExpr(), C.getState(),

diff  --git a/clang/test/Analysis/Inputs/system-header-simulator-objc.h 
b/clang/test/Analysis/Inputs/system-header-simulator-objc.h
index df751d03e642..0dc6b369b015 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator-objc.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator-objc.h
@@ -117,7 +117,10 @@ typedef double NSTimeInterval;
 + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length 
freeWhenDone:(BOOL)b;
 - (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
 - (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length 
freeWhenDone:(BOOL)b;
-- (id)initWithBytes:(void *)bytes length:(NSUInteger) length;
+- (id)initWithBytesNoCopy:(void *)bytes
+   length:(NSUInteger)length
+  deallocator:(void (^)(void *bytes, NSUInteger 
length))deallocator;
+- (id)initWithBytes:(void *)bytes length:(NSUInteger)length;
 @end
 
 typedef struct {

diff  --git a/clang/test/Analysis/malloc.mm b/clang/test/Analysis/malloc.mm
index e84644b9dd73..1b7dd2756e1b 100644
--- a/clang/test/Analysis/malloc.mm
+++ b/clang/test/Analysis/malloc.mm
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=core,unix.Malloc 
-analyzer-store=region -verify -fblocks %s
+// RUN: %clang_analyze_cc1 -std=c++14 \
+// RUN: -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete \
+// RUN: -analyzer-checker=unix.MismatchedDeallocator \
+// RUN: -verify -fblocks %s
+
 #import "Inputs/system-header-simulator-objc.h"
 #import "Inputs/system-header-simulator-for-malloc.h"
 
@@ -61,6 +65,23 @@ void testNSStringFreeWhenDoneNO(NSUInteger dataLength) {
   NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data 
length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:0]; // 
expected-warning{{leak}}
 }
 
+void testNSStringFreeWhenDoneNewDelete(NSUInteger dataLength) {
+  unsigned char *data = new unsigned char(42);
+  NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data
+   length:dataLength freeWhenDone:1];
+  // expected-warning@-2{{-initWithBytesNoCopy:length:freeWhenDone: cannot 
take ownership of memory allocated by 'new'}}
+}
+
+void testNSStringFreeWhenDoneNewDelete2(NSUInteger dataLength) {
+  unsigned char *data = new unsigned char(42);
+  NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data
+length:dataLength
+   deallocator:^(void *bytes,
+ NSUInteger length) {
+ delete (unsigned char *)bytes;
+   }]; // no-warning
+}
+
 void testNSStringFreeWhenDoneNO2(NSUInteger dataLength) {
   unichar *data = (unichar*)malloc(42);
   NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data 
length:dataLength freeWhenDone:0]; // expected-warning{{leak}}



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


[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

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

{icon check-circle color=green} Unit tests: pass. 60853 tests passed, 0 failed 
and 726 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677



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


[PATCH] D71625: [CMake] Added remote test execution support into CrossWinToARMLinux CMake cache file.

2019-12-18 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka updated this revision to Diff 234617.
vvereschaka edited the summary of this revision.
vvereschaka added a comment.

Renamed configuration arguments to REMOTE_TEST_HOST and REMOTE_TEST_USER


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71625

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -14,6 +14,8 @@
 #   -DDEFAULT_SYSROOT= ^
 #   -DLLVM_AR=/bin/llvm-ar[.exe] ^
 #   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -DREMOTE_TEST_HOST="" ^
+#   -DREMOTE_TEST_USER="" ^
 #   
-C/llvm-project/clang/cmake/caches/CrossWinToARMLinux.cmake ^
 #   /llvm-project/llvm
 # Build:
@@ -82,7 +84,33 @@
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 
-set(LLVM_INSTALL_TOOLCHAIN_ONLYON CACHE BOOL "")
+# Remote test configuration.
+if(DEFINED REMOTE_TEST_HOST)
+  set(DEFAULT_TEST_EXECUTOR 
"SSHExecutor('${REMOTE_TEST_HOST}', '${REMOTE_TEST_USER}')")
+  set(DEFAULT_TEST_TARGET_INFO  
"libcxx.test.target_info.LinuxLocalTI")
+
+  # Allow override with the custom values.
+  if(NOT DEFINED LIBUNWIND_TARGET_INFO)
+set(LIBUNWIND_TARGET_INFO   "${DEFAULT_TEST_TARGET_INFO}" 
CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBUNWIND_EXECUTOR)
+set(LIBUNWIND_EXECUTOR  "${DEFAULT_TEST_EXECUTOR}" CACHE 
STRING "")
+  endif()
+  if(NOT DEFINED LIBCXXABI_TARGET_INFO)
+set(LIBCXXABI_TARGET_INFO   "${DEFAULT_TEST_TARGET_INFO}" 
CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBCXXABI_EXECUTOR)
+set(LIBCXXABI_EXECUTOR  "${DEFAULT_TEST_EXECUTOR}" CACHE 
STRING "")
+  endif()
+  if(NOT DEFINED LIBCXX_TARGET_INFO)
+set(LIBCXX_TARGET_INFO  "${DEFAULT_TEST_TARGET_INFO}" 
CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBCXX_EXECUTOR)
+set(LIBCXX_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE 
STRING "")
+  endif()
+endif()
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
   llvm-ar
   llvm-cov


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -14,6 +14,8 @@
 #   -DDEFAULT_SYSROOT= ^
 #   -DLLVM_AR=/bin/llvm-ar[.exe] ^
 #   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -DREMOTE_TEST_HOST="" ^
+#   -DREMOTE_TEST_USER="" ^
 #   -C/llvm-project/clang/cmake/caches/CrossWinToARMLinux.cmake ^
 #   /llvm-project/llvm
 # Build:
@@ -82,7 +84,33 @@
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 
-set(LLVM_INSTALL_TOOLCHAIN_ONLY 			ON CACHE BOOL "")
+# Remote test configuration.
+if(DEFINED REMOTE_TEST_HOST)
+  set(DEFAULT_TEST_EXECUTOR "SSHExecutor('${REMOTE_TEST_HOST}', '${REMOTE_TEST_USER}')")
+  set(DEFAULT_TEST_TARGET_INFO  "libcxx.test.target_info.LinuxLocalTI")
+
+  # Allow override with the custom values.
+  if(NOT DEFINED LIBUNWIND_TARGET_INFO)
+set(LIBUNWIND_TARGET_INFO   "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBUNWIND_EXECUTOR)
+set(LIBUNWIND_EXECUTOR  "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBCXXABI_TARGET_INFO)
+set(LIBCXXABI_TARGET_INFO   "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBCXXABI_EXECUTOR)
+set(LIBCXXABI_EXECUTOR  "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBCXX_TARGET_INFO)
+set(LIBCXX_TARGET_INFO  "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
+  endif()
+  if(NOT DEFINED LIBCXX_EXECUTOR)
+set(LIBCXX_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
+  endif()
+endif()
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
   llvm-ar
   llvm-cov
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71378: Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton

2019-12-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 234619.
shafik marked 3 inline comments as done.
shafik added a comment.

- Fix typo
- Adjust error handing
- clang-format test


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

https://reviews.llvm.org/D71378

Files:
  clang/lib/AST/ASTImporter.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py

Index: lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
@@ -1,4 +1,4 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIf(bugnumber="rdar://53756116")])
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
@@ -0,0 +1,39 @@
+// This is a reproducer for a crash in codegen. It happens when we have a
+// RecordDecl used in an expression and one of the FieldDecl are not complete.
+// This case happens when:
+// - A RecordDecl (E) has a FieldDecl which is a reference member variable
+// - The underlying type of the FieldDec is a TypedefDecl
+// - The typedef refers to a ClassTemplateSpecialization (DWrapper)
+// - The typedef is not present in the DeclContext of B
+// - The typedef shows up as a return value of a member function of E (f())
+template  struct DWrapper {};
+
+struct D {};
+
+namespace NS {
+typedef DWrapper DW;
+}
+
+struct B {
+  NS::DW spd;
+  int a = 0;
+};
+
+struct E {
+  E(B ) : b_ref(b) {}
+  NS::DW f() { return {}; };
+  void g() {
+return; //%self.expect("p b_ref", substrs=['(B) $0 =', '(spd = NS::DW', 'a = 0)'])
+  }
+
+  B _ref;
+};
+
+int main() {
+  B b;
+  E e(b);
+
+  e.g();
+
+  return 0;
+}
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1683,7 +1683,34 @@
   Error ChildErrors = Error::success();
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
-if (!ImportedOrErr) {
+
+// If we are in the process of ImportDefinition(...) for a RecordDecl we
+// want to make sure that we are also completing each FieldDecl. There
+// are currently cases where this does not happen and this is correctness
+// fix since operations such as code generation will expect this to be so.
+if (ImportedOrErr) {
+  FieldDecl *FieldFrom = dyn_cast_or_null(From);
+  Decl *ImportedDecl = (Decl*)*ImportedOrErr;
+  FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl);
+  if (FieldFrom && FieldTo) {
+const RecordType *RecordFrom = FieldFrom->getType()->getAs();
+const RecordType *RecordTo = FieldTo->getType()->getAs();
+if (RecordFrom && RecordTo) {
+  RecordDecl *FromRecordDecl = RecordFrom->getDecl();
+  RecordDecl *ToRecordDecl = RecordTo->getDecl();
+
+  if (FromRecordDecl->isCompleteDefinition() &&
+  !ToRecordDecl->isCompleteDefinition()) {
+Error Err = ImportDefinition(FromRecordDecl, ToRecordDecl);
+
+if (Err && AccumulateChildErrors)
+  ChildErrors =  joinErrors(std::move(ChildErrors), std::move(Err));
+else
+  consumeError(std::move(Err));
+  }
+}
+  }
+} else {
   if (AccumulateChildErrors)
 ChildErrors =
 joinErrors(std::move(ChildErrors), ImportedOrErr.takeError());

[clang] 3ced239 - Refactor CompareReferenceRelationship and its callers in preparation for

2019-12-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-12-18T14:05:57-08:00
New Revision: 3ced23976aa8a86a17017c87821c873b4ca80bc2

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

LOG: Refactor CompareReferenceRelationship and its callers in preparation for
implementing the resolution of CWG2352.

No functionality change, except that we now convert the referent of a
reference binding to the underlying type of the reference in more cases;
we used to happen to preserve the type sugar from the referent if the
only type change was in the cv-qualifiers.

This exposed a bug in how we generate code for trivial assignment
operators: if the type sugar (particularly the may_alias attribute)
got lost during reference binding, we'd use the "wrong" TBAA information
for the load during the assignment.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/AST/ast-dump-expr-json.cpp
clang/test/Index/print-type.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2730eef0bdd8..07eba0306c98 100755
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -31,6 +31,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeOrdering.h"
+#include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/OpenMPKinds.h"
@@ -10703,11 +10704,26 @@ class Sema final {
 Ref_Compatible
   };
 
+  // Fake up a scoped enumeration that still contextually converts to bool.
+  struct ReferenceConversionsScope {
+/// The conversions that would be performed on an lvalue of type T2 when
+/// binding a reference of type T1 to it, as determined when evaluating
+/// whether T1 is reference-compatible with T2.
+enum ReferenceConversions {
+  Qualification = 0x1,
+  Function = 0x2,
+  DerivedToBase = 0x4,
+  ObjC = 0x8,
+  ObjCLifetime = 0x10,
+
+  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
+};
+  };
+  using ReferenceConversions = ReferenceConversionsScope::ReferenceConversions;
+
   ReferenceCompareResult
   CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2,
-   bool , bool ,
-   bool ,
-   bool );
+   ReferenceConversions *Conv = nullptr);
 
   ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
  Expr *CastExpr, CastKind ,

diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 269b80b43403..3fc86136c529 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -241,16 +241,28 @@ RValue 
CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(
 }
   }
 
+  bool TrivialForCodegen =
+  MD->isTrivial() || (MD->isDefaulted() && MD->getParent()->isUnion());
+  bool TrivialAssignment =
+  TrivialForCodegen &&
+  (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) &&
+  !MD->getParent()->mayInsertExtraPadding();
+
   // C++17 demands that we evaluate the RHS of a (possibly-compound) assignment
   // operator before the LHS.
   CallArgList RtlArgStorage;
   CallArgList *RtlArgs = nullptr;
+  LValue TrivialAssignmentRHS;
   if (auto *OCE = dyn_cast(CE)) {
 if (OCE->isAssignmentOp()) {
-  RtlArgs = 
-  EmitCallArgs(*RtlArgs, MD->getType()->castAs(),
-   drop_begin(CE->arguments(), 1), CE->getDirectCallee(),
-   /*ParamsToSkip*/0, EvaluationOrder::ForceRightToLeft);
+  if (TrivialAssignment) {
+TrivialAssignmentRHS = EmitLValue(CE->getArg(1));
+  } else {
+RtlArgs = 
+EmitCallArgs(*RtlArgs, MD->getType()->castAs(),
+ drop_begin(CE->arguments(), 1), CE->getDirectCallee(),
+ /*ParamsToSkip*/0, EvaluationOrder::ForceRightToLeft);
+  }
 }
   }
 
@@ -281,22 +293,25 @@ RValue 
CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(
 return RValue::get(nullptr);
   }
 
-  if (MD->isTrivial() || (MD->isDefaulted() && MD->getParent()->isUnion())) {
-if (isa(MD)) return RValue::get(nullptr);
-if (!MD->getParent()->mayInsertExtraPadding()) {
-  if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) {
-// We don't like to generate the trivial copy/move assignment operator
-// when it isn't necessary; just produce the proper effect here.
-LValue RHS = isa(CE)
- 

[PATCH] D71387: pass -mabi to LTO linker only in RISC-V targets, enable RISC-V LTO

2019-12-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> But in RISCV clang emits the same IR for different ABI (-mabi),

This is not true.  For simple cases, it does, yes, but there are some weird 
edge cases for functions with many arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71387



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


[clang] a6d57a8 - Use hasOffsetApplied to initialize member HasOffsetApplied

2019-12-18 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2019-12-18T13:56:59-08:00
New Revision: a6d57a8cd4cfa2a8395eaa6599fc12f7509f98f0

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

LOG: Use hasOffsetApplied to initialize member HasOffsetApplied

This is NFC since none of the constructor calls in trunk pass
hasOffsetApplied=true.

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 55745e088f99..46ed90a20264 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1729,7 +1729,7 @@ struct ConstantLValue {
 
   /*implicit*/ ConstantLValue(llvm::Constant *value,
   bool hasOffsetApplied = false)
-: Value(value), HasOffsetApplied(false) {}
+: Value(value), HasOffsetApplied(hasOffsetApplied) {}
 
   /*implicit*/ ConstantLValue(ConstantAddress address)
 : ConstantLValue(address.getPointer()) {}



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


[PATCH] D71427: Move TypeSourceInfo to Type.h

2019-12-18 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71f9c30b5348: Move TypeSourceInfo to Type.h (authored by 
rnk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71427

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/AST/TypeLoc.cpp

Index: clang/lib/AST/TypeLoc.cpp
===
--- clang/lib/AST/TypeLoc.cpp
+++ clang/lib/AST/TypeLoc.cpp
@@ -294,6 +294,12 @@
   return TSTChecker().Visit(TL);
 }
 
+bool TagTypeLoc::isDefinition() const {
+  TagDecl *D = getDecl();
+  return D->isCompleteDefinition() &&
+ (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
+}
+
 // Reimplemented to account for GNU/C++ extension
 // typeof unary-expression
 // where there are no parentheses.
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_AST_TYPELOC_H
 #define LLVM_CLANG_AST_TYPELOC_H
 
-#include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -39,6 +38,7 @@
 class ObjCInterfaceDecl;
 class ObjCProtocolDecl;
 class ObjCTypeParamDecl;
+class ParmVarDecl;
 class TemplateTypeParmDecl;
 class UnqualTypeLoc;
 class UnresolvedUsingTypenameDecl;
@@ -704,11 +704,7 @@
   TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
 
   /// True if the tag was defined in this type specifier.
-  bool isDefinition() const {
-TagDecl *D = getDecl();
-return D->isCompleteDefinition() &&
-   (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
-  }
+  bool isDefinition() const;
 };
 
 /// Wrapper for source info for record types.
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6179,6 +6179,33 @@
   QualType apply(const ASTContext , const Type* T) const;
 };
 
+/// A container of type source information.
+///
+/// A client can read the relevant info using TypeLoc wrappers, e.g:
+/// @code
+/// TypeLoc TL = TypeSourceInfo->getTypeLoc();
+/// TL.getBeginLoc().print(OS, SrcMgr);
+/// @endcode
+class alignas(8) TypeSourceInfo {
+  // Contains a memory block after the class, used for type source information,
+  // allocated by ASTContext.
+  friend class ASTContext;
+
+  QualType Ty;
+
+  TypeSourceInfo(QualType ty) : Ty(ty) {}
+
+public:
+  /// Return the type wrapped by this type source info.
+  QualType getType() const { return Ty; }
+
+  /// Return the TypeLoc wrapper for the type source info.
+  TypeLoc getTypeLoc() const; // implemented in TypeLoc.h
+
+  /// Override the type stored in this TypeSourceInfo. Use with caution!
+  void overrideType(QualType T) { Ty = T; }
+};
+
 // Inline function definitions.
 
 inline SplitQualType SplitQualType::getSingleStepDesugaredType() const {
Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -78,33 +78,6 @@
 class UnresolvedSetImpl;
 class VarTemplateDecl;
 
-/// A container of type source information.
-///
-/// A client can read the relevant info using TypeLoc wrappers, e.g:
-/// @code
-/// TypeLoc TL = TypeSourceInfo->getTypeLoc();
-/// TL.getBeginLoc().print(OS, SrcMgr);
-/// @endcode
-class alignas(8) TypeSourceInfo {
-  // Contains a memory block after the class, used for type source information,
-  // allocated by ASTContext.
-  friend class ASTContext;
-
-  QualType Ty;
-
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
-
-public:
-  /// Return the type wrapped by this type source info.
-  QualType getType() const { return Ty; }
-
-  /// Return the TypeLoc wrapper for the type source info.
-  TypeLoc getTypeLoc() const; // implemented in TypeLoc.h
-
-  /// Override the type stored in this TypeSourceInfo. Use with caution!
-  void overrideType(QualType T) { Ty = T; }
-};
-
 /// The top declaration context.
 class TranslationUnitDecl : public Decl, public DeclContext {
   ASTContext 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Pushing code review approval button.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


[PATCH] D71677: Summary:Use "P" modifier on operands to call instructions in inline X86 assembly.

2019-12-18 Thread Eric Astor via Phabricator via cfe-commits
epastor created this revision.
epastor added a reviewer: rnk.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This is documented as the appropriate template modifier for call operands.
Fixes PR44272, and adds a regression test.

Also adds support for operand modifiers in Intel-style inline assembly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71677

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/mozilla-ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.cpp
  llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86Operand.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll

Index: llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll
@@ -0,0 +1,18 @@
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
+
+define void @func() {
+entry:
+  ret void
+}
+
+define void @main() {
+entry:
+  call void asm sideeffect inteldialect "call ${0:P}", "*m,~{dirflag},~{fpsr},~{flags}"(void ()* @func)
+  ret void
+; CHECK-LABEL: main:
+; CHECK: {{## InlineAsm Start|#APP}}
+; CHECK: call{{l|q}} func
+; CHECK: {{## InlineAsm End|#NO_APP}}
+; CHECK: ret{{l|q}}
+}
\ No newline at end of file
Index: llvm/lib/Target/X86/X86AsmPrinter.h
===
--- llvm/lib/Target/X86/X86AsmPrinter.h
+++ llvm/lib/Target/X86/X86AsmPrinter.h
@@ -112,7 +112,7 @@
   void PrintMemReference(const MachineInstr *MI, unsigned OpNo, raw_ostream ,
  const char *Modifier);
   void PrintIntelMemReference(const MachineInstr *MI, unsigned OpNo,
-  raw_ostream );
+  raw_ostream , const char *Modifier);
 
 public:
   X86AsmPrinter(TargetMachine , std::unique_ptr Streamer);
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
===
--- llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -337,14 +337,22 @@
   PrintLeaMemReference(MI, OpNo, O, Modifier);
 }
 
+
 void X86AsmPrinter::PrintIntelMemReference(const MachineInstr *MI,
-   unsigned OpNo, raw_ostream ) {
+   unsigned OpNo, raw_ostream ,
+   const char *Modifier) {
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrBaseReg);
   unsigned ScaleVal = MI->getOperand(OpNo + X86::AddrScaleAmt).getImm();
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrIndexReg);
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrDisp);
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrSegmentReg);
 
+  // If we really don't want to print out (rip), don't.
+  bool HasBaseReg = BaseReg.getReg() != 0;
+  if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
+  BaseReg.getReg() == X86::RIP)
+HasBaseReg = false;
+
   // If this has a segment register, print it.
   if (SegReg.getReg()) {
 PrintOperand(MI, OpNo + X86::AddrSegmentReg, O);
@@ -354,7 +362,7 @@
   O << '[';
 
   bool NeedPlus = false;
-  if (BaseReg.getReg()) {
+  if (HasBaseReg) {
 PrintOperand(MI, OpNo + X86::AddrBaseReg, O);
 NeedPlus = true;
   }
@@ -372,7 +380,7 @@
 PrintOperand(MI, OpNo + X86::AddrDisp, O);
   } else {
 int64_t DispVal = DispSpec.getImm();
-if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
+if (DispVal || (!IndexReg.getReg() && !HasBaseReg)) {
   if (NeedPlus) {
 if (DispVal > 0)
   O << " + ";
@@ -525,11 +533,6 @@
 bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
   const char *ExtraCode,
   raw_ostream ) {
-  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
-PrintIntelMemReference(MI, OpNo, O);
-return false;
-  }
-
   if (ExtraCode && ExtraCode[0]) {
 if (ExtraCode[1] != 0) return true; // Unknown modifier.
 
@@ -543,14 +546,26 @@
   // These only apply to registers, ignore on mem.
   break;
 case 'H':
-  PrintMemReference(MI, OpNo, O, "H");
+  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
+return true;  // Unsupported modifier in Intel inline assembly.
+  } else {
+PrintMemReference(MI, OpNo, O, "H");
+  }
   return false;
 case 'P': // Don't print @PLT, but do print as memory.
-  PrintMemReference(MI, OpNo, O, "no-rip");
+ 

[clang] 71f9c30 - Move TypeSourceInfo to Type.h

2019-12-18 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-12-18T13:47:00-08:00
New Revision: 71f9c30b5348bbb2b41d4ffa6c7688dec8e0074a

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

LOG: Move TypeSourceInfo to Type.h

TypeSourceInfo is a thin wrapper around TypeLocs. Notionally, the best
place for it to live would be TypeLoc.h, but Decl.h requires it to be
complete, so it needs to be lower in the dependency graph. Type.h seems
like the next best place.

By itself, this change has no impact on build time, because it doesn't
remove a single dependency edge from a .cpp file to a .h file, but it is
an incremental step towards making the AST headers less interdependent.

Reviewers: rsmith

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

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeLoc.h
clang/lib/AST/TypeLoc.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 90e8d19b17fa..de1cfe940005 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -78,33 +78,6 @@ class TypeLoc;
 class UnresolvedSetImpl;
 class VarTemplateDecl;
 
-/// A container of type source information.
-///
-/// A client can read the relevant info using TypeLoc wrappers, e.g:
-/// @code
-/// TypeLoc TL = TypeSourceInfo->getTypeLoc();
-/// TL.getBeginLoc().print(OS, SrcMgr);
-/// @endcode
-class alignas(8) TypeSourceInfo {
-  // Contains a memory block after the class, used for type source information,
-  // allocated by ASTContext.
-  friend class ASTContext;
-
-  QualType Ty;
-
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
-
-public:
-  /// Return the type wrapped by this type source info.
-  QualType getType() const { return Ty; }
-
-  /// Return the TypeLoc wrapper for the type source info.
-  TypeLoc getTypeLoc() const; // implemented in TypeLoc.h
-
-  /// Override the type stored in this TypeSourceInfo. Use with caution!
-  void overrideType(QualType T) { Ty = T; }
-};
-
 /// The top declaration context.
 class TranslationUnitDecl : public Decl, public DeclContext {
   ASTContext 

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 942564756c93..f5955c45fafc 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6179,6 +6179,33 @@ class QualifierCollector : public Qualifiers {
   QualType apply(const ASTContext , const Type* T) const;
 };
 
+/// A container of type source information.
+///
+/// A client can read the relevant info using TypeLoc wrappers, e.g:
+/// @code
+/// TypeLoc TL = TypeSourceInfo->getTypeLoc();
+/// TL.getBeginLoc().print(OS, SrcMgr);
+/// @endcode
+class alignas(8) TypeSourceInfo {
+  // Contains a memory block after the class, used for type source information,
+  // allocated by ASTContext.
+  friend class ASTContext;
+
+  QualType Ty;
+
+  TypeSourceInfo(QualType ty) : Ty(ty) {}
+
+public:
+  /// Return the type wrapped by this type source info.
+  QualType getType() const { return Ty; }
+
+  /// Return the TypeLoc wrapper for the type source info.
+  TypeLoc getTypeLoc() const; // implemented in TypeLoc.h
+
+  /// Override the type stored in this TypeSourceInfo. Use with caution!
+  void overrideType(QualType T) { Ty = T; }
+};
+
 // Inline function definitions.
 
 inline SplitQualType SplitQualType::getSingleStepDesugaredType() const {

diff  --git a/clang/include/clang/AST/TypeLoc.h 
b/clang/include/clang/AST/TypeLoc.h
index 618e462d0971..c3baaa3e4174 100644
--- a/clang/include/clang/AST/TypeLoc.h
+++ b/clang/include/clang/AST/TypeLoc.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_AST_TYPELOC_H
 #define LLVM_CLANG_AST_TYPELOC_H
 
-#include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -39,6 +38,7 @@ class Expr;
 class ObjCInterfaceDecl;
 class ObjCProtocolDecl;
 class ObjCTypeParamDecl;
+class ParmVarDecl;
 class TemplateTypeParmDecl;
 class UnqualTypeLoc;
 class UnresolvedUsingTypenameDecl;
@@ -704,11 +704,7 @@ class TagTypeLoc : public 
InheritingConcreteTypeLocgetDecl(); }
 
   /// True if the tag was defined in this type specifier.
-  bool isDefinition() const {
-TagDecl *D = getDecl();
-return D->isCompleteDefinition() &&
-   (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
-  }
+  bool isDefinition() const;
 };
 
 /// Wrapper for source info for record types.

diff  --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index d6c992f9ab0f..6e67ca8e0af7 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -294,6 +294,12 @@ bool TypeSpecTypeLoc::isKind(const TypeLoc ) {
   return TSTChecker().Visit(TL);
 }
 
+bool TagTypeLoc::isDefinition() 

[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ok, so if you're in agreement on this one, can either of you give the stamp of 
approval? :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


[PATCH] D71674: [clang-tools-extra] Fix linking dylib for LLVMFrontendOpenMP

2019-12-18 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4121399c1229: [clang-tools-extra] Fix linking dylib for 
LLVMFrontendOpenMP (authored by mgorny).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71674

Files:
  clang-tools-extra/clang-tidy/openmp/CMakeLists.txt


Index: clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
@@ -1,4 +1,6 @@
-set(LLVM_LINK_COMPONENTS support)
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support)
 
 add_clang_library(clangTidyOpenMPModule
   ExceptionEscapeCheck.cpp
@@ -11,5 +13,4 @@
   clangBasic
   clangTidy
   clangTidyUtils
-  LLVMFrontendOpenMP
   )


Index: clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
@@ -1,4 +1,6 @@
-set(LLVM_LINK_COMPONENTS support)
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support)
 
 add_clang_library(clangTidyOpenMPModule
   ExceptionEscapeCheck.cpp
@@ -11,5 +13,4 @@
   clangBasic
   clangTidy
   clangTidyUtils
-  LLVMFrontendOpenMP
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 12038be - [Concepts] Fix crash in D41910

2019-12-18 Thread Vedant Kumar via cfe-commits
Hey Saar,
Do you expect this to address this crash seen on the lldb bot after D41910 
landed?

Assertion failed: (Idx < size() && "Out-of-bounds Bit access."), function 
operator[], file 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/ADT/SmallBitVector.h,
 line 452.

Stack dump:
0.  Program arguments: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-10 -cc1 
-triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free 
-main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model 
posix -mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
-target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
-debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
-target-linker-version 409.12 -resource-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lib/clang/10.0.99 
-isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 -include 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h
 -I 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../../include
 -I 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant
 -I 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make
 -D LLDB_USING_LIBCPP -stdlib=libc++ -internal-isystem 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/../include/c++/v1 
-internal-isystem 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/v1
 -internal-isystem 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/local/include
 -internal-isystem 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lib/clang/10.0.99/include
 -internal-externc-isystem 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
 -O0 -std=c++17 -fdeprecated-macro -fdebug-compilation-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.test_with_run_command_dsym
 -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fno-builtin -fblocks 
-fencode-extended-block-signature -fregister-global-dtors-with-atexit 
-fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.14.0 -fcxx-exceptions 
-fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o main.o -x c++ 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp
 
1.  
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp:26:39:
 current parser token ';'
2.  
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp:20:1:
 parsing function body 'main'
3.  
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp:20:1:
 in compound statement ('{}')
4.  
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/../include/c++/v1/variant:1192:13:
 instantiating function definition 'std::__1::variant::variant'
5.  
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/../include/c++/v1/variant:684:22:
 instantiating function definition 
'std::__1::__variant_detail::__base::__base<0>'
0  clang-10 0x0001077ed1a5 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  clang-10 0x0001077ec0a8 llvm::sys::RunSignalHandlers() + 
248
2  clang-10 0x0001077ed796 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x7fff66bc3b3d _sigtramp + 29
4  libsystem_platform.dylib 0x7ffeea2a2150 _sigtramp + 18446744071619601968
5  libsystem_c.dylib0x7fff66a821c9 abort + 127
6  libsystem_c.dylib0x7fff66a4a868 basename_r + 0
7  clang-10 0x0001094b79d9 
isAtLeastAsSpecializedAs(clang::Sema&, clang::SourceLocation, 
clang::FunctionTemplateDecl*, clang::FunctionTemplateDecl*, 
clang::TemplatePartialOrderingContext, unsigned int) + 1865
8  clang-10 0x0001094b7111 
clang::Sema::getMoreSpecializedTemplate(clang::FunctionTemplateDecl*, 
clang::FunctionTemplateDecl*, clang::SourceLocation, 
clang::TemplatePartialOrderingContext, unsigned int, unsigned int) + 97
9  clang-10  

[PATCH] D71675: [Remarks][Driver] Run dsymutil when remarks are enabled

2019-12-18 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D71675



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


[PATCH] D71675: [Remarks][Driver] Run dsymutil when remarks are enabled

2019-12-18 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: clang/test/Driver/darwin-opt-record.c:21
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"

thegameg wrote:
> The other choice would be honoring `-g0` and:
> 
> * not passing `debug-info-kind=` to `cc1`
> * not running `dsymutil`
> * possibly emit a warning/error that the options are incompatible
I think the current approach is the most intuitive. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D71675



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


[PATCH] D71674: [clang-tools-extra] Fix linking dylib for LLVMFrontendOpenMP

2019-12-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

LG
I think this is correct solution.


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

https://reviews.llvm.org/D71674



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


[PATCH] D71675: [Remarks][Driver] Run dsymutil when remarks are enabled

2019-12-18 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg marked an inline comment as done.
thegameg added inline comments.



Comment at: clang/test/Driver/darwin-opt-record.c:21
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"

The other choice would be honoring `-g0` and:

* not passing `debug-info-kind=` to `cc1`
* not running `dsymutil`
* possibly emit a warning/error that the options are incompatible


Repository:
  rC Clang

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

https://reviews.llvm.org/D71675



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


[PATCH] D71675: [Remarks][Driver] Run dsymutil when remarks are enabled

2019-12-18 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg created this revision.
thegameg added reviewers: friss, JDevlieghere, aprantl.
thegameg added projects: clang, debug-info.

When clang is invoked with a source file without -c or -S, it creates a cc1 
job, a linker job and if debug info is requested, a dsymutil job. In case of 
remarks, we should also create a dsymutil job to avoid losing the remarks that 
will be generated in a tempdir that gets removed.


Repository:
  rC Clang

https://reviews.llvm.org/D71675

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-opt-record.c


Index: clang/test/Driver/darwin-opt-record.c
===
--- clang/test/Driver/darwin-opt-record.c
+++ clang/test/Driver/darwin-opt-record.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MULTIPLE-ARCH
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-foptimization-record-file=tmp -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck 
%s --check-prefix=CHECK-MULTIPLE-ARCH-ERROR
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-NO-G
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -g0 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-G0
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
@@ -9,3 +11,14 @@
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"
 //
 // CHECK-MULTIPLE-ARCH-ERROR: cannot use '-foptimization-record-file' output 
with multiple -arch options
+//
+// CHECK-DSYMUTIL-NO-G: "-cc1"
+// CHECK-DSYMUTIL-NO-G: ld
+// CHECK-DSYMUTIL-NO-G: dsymutil
+//
+// Even in the presence of -g0, -fsave-optimization-record implies
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"
+// CHECK-DSYMUTIL-G0: ld
+// CHECK-DSYMUTIL-G0: dsymutil
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1990,8 +1990,9 @@
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
-if (A && !A->getOption().matches(options::OPT_g0) &&
-!A->getOption().matches(options::OPT_gstabs) &&
+bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+!A->getOption().matches(options::OPT_gstabs);
+if ((enablesDebugInfo || willEmitRemarks(Args)) &&
 ContainsCompileOrAssembleAction(Actions.back())) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we


Index: clang/test/Driver/darwin-opt-record.c
===
--- clang/test/Driver/darwin-opt-record.c
+++ clang/test/Driver/darwin-opt-record.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO -fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO -foptimization-record-file=tmp -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH-ERROR
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-NO-G
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -g0 -fsave-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-DSYMUTIL-G0
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
@@ -9,3 +11,14 @@
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"
 //
 // CHECK-MULTIPLE-ARCH-ERROR: cannot use '-foptimization-record-file' output with multiple -arch options
+//
+// CHECK-DSYMUTIL-NO-G: "-cc1"
+// CHECK-DSYMUTIL-NO-G: ld
+// CHECK-DSYMUTIL-NO-G: dsymutil
+//
+// Even in the presence of -g0, -fsave-optimization-record implies
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"
+// CHECK-DSYMUTIL-G0: ld
+// CHECK-DSYMUTIL-G0: dsymutil
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1990,8 +1990,9 @@
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
-if (A && !A->getOption().matches(options::OPT_g0) &&
-!A->getOption().matches(options::OPT_gstabs) &&
+bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+!A->getOption().matches(options::OPT_gstabs);
+if ((enablesDebugInfo || willEmitRemarks(Args)) &&
 ContainsCompileOrAssembleAction(Actions.back())) {

[PATCH] D71674: [clang-tools-extra] Fix linking dylib for LLVMFrontendOpenMP

2019-12-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: baloghadamsoftware, jdoerfert, ABataev.
Herald added subscribers: lebedev.ri, guansong, rnkovacs.
Herald added a reviewer: lebedev.ri.

Use LLVM_LINK_COMPONENTS to link the FrontendOpenMP library
instead of passing it explicitly to LINK_LIBS.  This fixes duplicating
the library when clang-tidy is linked to LLVM dylib.


https://reviews.llvm.org/D71674

Files:
  clang-tools-extra/clang-tidy/openmp/CMakeLists.txt


Index: clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
@@ -1,4 +1,6 @@
-set(LLVM_LINK_COMPONENTS support)
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support)
 
 add_clang_library(clangTidyOpenMPModule
   ExceptionEscapeCheck.cpp
@@ -11,5 +13,4 @@
   clangBasic
   clangTidy
   clangTidyUtils
-  LLVMFrontendOpenMP
   )


Index: clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
@@ -1,4 +1,6 @@
-set(LLVM_LINK_COMPONENTS support)
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support)
 
 add_clang_library(clangTidyOpenMPModule
   ExceptionEscapeCheck.cpp
@@ -11,5 +13,4 @@
   clangBasic
   clangTidy
   clangTidyUtils
-  LLVMFrontendOpenMP
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e3fa460 - Change triple in test case to not include triples the test shouldn't

2019-12-18 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2019-12-18T13:17:39-08:00
New Revision: e3fa4604076d01d2fe48d44d86fc2d6a48d4970c

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

LOG: Change triple in test case to not include triples the test shouldn't
pass.
This is fixes changes from a85f5efd9597d0036f5c347b362cb873bdf51f16.

Added: 


Modified: 
clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp 
b/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
index a7dfe526743c..a56b4550cad7 100644
--- a/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
+++ b/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fms-extensions -emit-llvm -triple %itanium_abi_triple -o - 
%s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -fms-extensions -emit-llvm -triple x86_64-linux-gnu -o - %s 
| FileCheck %s --check-prefixes=CHECK
 // RUN: %clang_cc1 -fms-extensions -emit-llvm -triple x86_64-windows-msvc -o - 
%s | FileCheck %s --check-prefixes=WIN
 
 // CHECK-LABEL: define {{.*}}void @_Z2f0PU10ptr32_sptri
@@ -13,6 +13,6 @@ void * __ptr32 __uptr f1(int * __ptr32 p) { return 0; }
 // WIN-LABEL: define {{.*}}void @"?f2@@YAXPEAH@Z"
 void f2(int * __ptr64 p) {}
 
-  // CHECK-LABEL: define {{.*}}i8* @_Z2f3Pi
+// CHECK-LABEL: define {{.*}}i8* @_Z2f3Pi
 // WIN-LABEL: define {{.*}}i8* @"?f3@@YAPEAXPEAH@Z"
 void * __ptr64 f3(int * __ptr64 p) { return 0; }



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


[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

2019-12-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:5037
 
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,

Should we apply the attributes to the variable in this case, or (if they're 
always syntactically invalid) assert that there aren't any?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71619



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


[PATCH] D71313: [AST] Split parent map traversal logic into ParentMapContext.h

2019-12-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk planned changes to this revision.
rnk marked an inline comment as done.
rnk added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:653
   template  DynTypedNodeList getParents(const NodeT ) {
 return getParents(ast_type_traits::DynTypedNode::create(Node));
   }

Turns out this only worked for me locally because of delayed template parsing. 
I will have to think harder about how to preserve the API while not requiring 
complete types here. I could make an overload set, but I worry it will be 
inconveniently large.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71313



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


[PATCH] D71039: Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr.

2019-12-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This seems to be failing on aarch64-linux-gnu:

   TEST 'Clang :: 
CodeGenCXX/mangle-ptr-size-address-space.cpp' FAILED 
  Script:
  --
  : 'RUN: at line 1';   
/b/s/w/ir/k/recipe_cleanup/clangdgOoVq/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangdgOoVq/llvm_build_dir/lib/clang/10.0.0/include 
-nostdsysteminc -fms-extensions -emit-llvm -triple aarch64-unknown-linux-gnu -o 
- 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
 | /b/s/w/ir/k/recipe_cleanup/clangdgOoVq/llvm_build_dir/bin/FileCheck 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
 --check-prefixes=CHECK
  : 'RUN: at line 2';   
/b/s/w/ir/k/recipe_cleanup/clangdgOoVq/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangdgOoVq/llvm_build_dir/lib/clang/10.0.0/include 
-nostdsysteminc -fms-extensions -emit-llvm -triple x86_64-windows-msvc -o - 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
 | /b/s/w/ir/k/recipe_cleanup/clangdgOoVq/llvm_build_dir/bin/FileCheck 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
 --check-prefixes=WIN
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp:8:17:
 error: CHECK-LABEL: expected string not found in input
  // CHECK-LABEL: define {{.*}}i8 addrspace(271)* @_Z2f1PU10ptr32_sptri
  ^
  :6:34: note: scanning from here
  define void @_Z2f0PU10ptr32_sptri(i32* %p) #0 {
   ^
  :13:1: note: possible intended match here
  define i8* @_Z2f1PU10ptr32_sptri(i32* %p) #0 {
  ^
  
  --
  
  

The full output is here: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8893704790849741184/+/steps/clang/0/steps/test/0/stdout


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71039



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


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-12-18 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Commited in: 9366397f057d18401e680b2cb28a0ee17c59d4a6 


Phabriactor might not update this because the patch was created on libunwind 
repo, not the monorepo.


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D69893



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


[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-18 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D62731#1790211 , @rupprecht wrote:

> In D62731#1789122 , @rupprecht wrote:
>
> > In D62731#1788902 , 
> > @andrew.w.kaylor wrote:
> >
> > > In D62731#1788838 , @rupprecht 
> > > wrote:
> > >
> > > > It seems the discussion of whether or not this is incomplete died out 
> > > > -- I'd prefer to assume it is incomplete if there is no consensus. 
> > > > Mailed D71635  to rename 
> > > > `-frounding-math` to `-fexperimental-rounding-math`.
> > > >
> > > > Alternatively we could remove the warning. I still don't see a good 
> > > > argument for the middle ground of having it called `-frounding-math` 
> > > > but also generate a warning.
> > >
> > >
> > > It's definitely incomplete but the results will not be any worse than you 
> > > get when -frounding-math is ignored.
> > >
> > > My preference would be to change the text of the warning that is issued 
> > > but allow -frounding-math to be enabled by this commit without requiring 
> > > an additional option.
> >
> >
> > If other reviewers agree, then let's just remove the warning. I can send a 
> > patch tomorrow unless someone else wants to do that.
>
>
> Mailed D71671  to do this.
>
> If neither patch is acceptable, then I would like to revert this commit 
> instead, as we are having issues with this patch.


I think we should stick with this patch and remove the warning like you 
proposed in D71671 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


[PATCH] D71671: [clang] Remove -Wexperimental-float-control.

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

{icon times-circle color=red} Unit tests: fail. 60990 tests passed, 1 failed 
and 727 were skipped.

  failed: lit.lit/shtest-format.py

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71671



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


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-12-18 Thread Steven Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9366397f057d (authored by steven_wu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69893

Files:
  libunwind/src/DwarfInstructions.hpp


Index: libunwind/src/DwarfInstructions.hpp
===
--- libunwind/src/DwarfInstructions.hpp
+++ libunwind/src/DwarfInstructions.hpp
@@ -433,7 +433,7 @@
   // pick from
   reg = addressSpace.get8(p);
   p += 1;
-  value = sp[-reg];
+  value = sp[-(int)reg];
   *(++sp) = value;
   if (log)
 fprintf(stderr, "duplicate %d in stack\n", reg);


Index: libunwind/src/DwarfInstructions.hpp
===
--- libunwind/src/DwarfInstructions.hpp
+++ libunwind/src/DwarfInstructions.hpp
@@ -433,7 +433,7 @@
   // pick from
   reg = addressSpace.get8(p);
   p += 1;
-  value = sp[-reg];
+  value = sp[-(int)reg];
   *(++sp) = value;
   if (log)
 fprintf(stderr, "duplicate %d in stack\n", reg);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] 9366397 - [libunwind] Fix evaluating DWARF operation DW_OP_pick

2019-12-18 Thread Steven Wu via cfe-commits

Author: Steven Wu
Date: 2019-12-18T12:22:21-08:00
New Revision: 9366397f057d18401e680b2cb28a0ee17c59d4a6

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

LOG: [libunwind] Fix evaluating DWARF operation DW_OP_pick

reg is unsigned type and used here for getting array element from the end by
negating it. negation of unsigned can result in large number and array access
with that index will result in segmentation fault.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=43872

Patched by: kamlesh kumar

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

Added: 


Modified: 
libunwind/src/DwarfInstructions.hpp

Removed: 




diff  --git a/libunwind/src/DwarfInstructions.hpp 
b/libunwind/src/DwarfInstructions.hpp
index 48ef1866d6e1..ee98f538d437 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -433,7 +433,7 @@ DwarfInstructions::evaluateExpression(pint_t 
expression, A ,
   // pick from
   reg = addressSpace.get8(p);
   p += 1;
-  value = sp[-reg];
+  value = sp[-(int)reg];
   *(++sp) = value;
   if (log)
 fprintf(stderr, "duplicate %d in stack\n", reg);



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


[PATCH] D71671: [clang] Remove -Wexperimental-float-control.

2019-12-18 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

thanks for taking care of this. looks good to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71671



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


[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-18 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

In D62731#1789122 , @rupprecht wrote:

> In D62731#1788902 , @andrew.w.kaylor 
> wrote:
>
> > In D62731#1788838 , @rupprecht 
> > wrote:
> >
> > > It seems the discussion of whether or not this is incomplete died out -- 
> > > I'd prefer to assume it is incomplete if there is no consensus. Mailed 
> > > D71635  to rename `-frounding-math` to 
> > > `-fexperimental-rounding-math`.
> > >
> > > Alternatively we could remove the warning. I still don't see a good 
> > > argument for the middle ground of having it called `-frounding-math` but 
> > > also generate a warning.
> >
> >
> > It's definitely incomplete but the results will not be any worse than you 
> > get when -frounding-math is ignored.
> >
> > My preference would be to change the text of the warning that is issued but 
> > allow -frounding-math to be enabled by this commit without requiring an 
> > additional option.
>
>
> If other reviewers agree, then let's just remove the warning. I can send a 
> patch tomorrow unless someone else wants to do that.


Mailed D71671  to do this.

If neither patch is acceptable, then I would like to revert this commit 
instead, as we are having issues with this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-12-18 Thread Steven Wu via Phabricator via cfe-commits
steven_wu accepted this revision.
steven_wu added a comment.

In D69893#1786222 , @kamleshbhalui 
wrote:

> In D69893#1786202 , @steven_wu wrote:
>
> > The fix LGTM. Do you have a reproducer that can be used as a test case? We 
> > should really add more tests for libunwind.
>
>
> I currently do not have a reproducer test case for this.


Ok. We will need to come back dealing with test coverage in the future. I can 
commit it for you.


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D69893



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


[PATCH] D71671: [clang] Remove -Wexperimental-float-control.

2019-12-18 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht created this revision.
rupprecht added reviewers: mibintc, chandlerc, echristo, rjmccall, kpn, 
erichkeane, rsmith, andrew.w.kaylor.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per D62731 , the behavior of clang with 
`-frounding-math` is no worse than when the rounding flag was completely 
ignored, so remove this unnecessary warning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71671

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2456,15 +2456,7 @@
 switch (optID) {
 default:
   break;
-case options::OPT_frounding_math:
-case options::OPT_ftrapping_math:
-case options::OPT_ffp_exception_behavior_EQ:
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
-  break;
 case options::OPT_ffp_model_EQ: {
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
   // If -ffp-model= is seen, reset to fno-fast-math
   HonorINFs = true;
   HonorNaNs = true;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1137,9 +1137,6 @@
 // Warning for the experimental-isel options.
 def ExperimentalISel : DiagGroup<"experimental-isel">;
 
-// Warning for the experimental float control options.
-def ExperimentalFloatControl : DiagGroup<"experimental-float-control">;
-
 // A warning group specifically for warnings related to function
 // multiversioning.
 def FunctionMultiVersioning : DiagGroup<"function-multiversion">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -441,10 +441,6 @@
   "-fexperimental-isel support is incomplete for this architecture at the 
current optimization level">,
   InGroup;
 
-def warn_drv_experimental_fp_control_incomplete_opt : Warning<
-  "Support for floating point control option %0 is incomplete and 
experimental">,
-  InGroup;
-
 def warn_drv_moutline_unsupported_opt : Warning<
   "The '%0' architecture does not support -moutline; flag ignored">,
   InGroup;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2456,15 +2456,7 @@
 switch (optID) {
 default:
   break;
-case options::OPT_frounding_math:
-case options::OPT_ftrapping_math:
-case options::OPT_ffp_exception_behavior_EQ:
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
-  break;
 case options::OPT_ffp_model_EQ: {
-  D.Diag(clang::diag::warn_drv_experimental_fp_control_incomplete_opt)
-  << A->getOption().getName();
   // If -ffp-model= is seen, reset to fno-fast-math
   HonorINFs = true;
   HonorNaNs = true;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1137,9 +1137,6 @@
 // Warning for the experimental-isel options.
 def ExperimentalISel : DiagGroup<"experimental-isel">;
 
-// Warning for the experimental float control options.
-def ExperimentalFloatControl : DiagGroup<"experimental-float-control">;
-
 // A warning group specifically for warnings related to function
 // multiversioning.
 def FunctionMultiVersioning : DiagGroup<"function-multiversion">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -441,10 +441,6 @@
   "-fexperimental-isel support is incomplete for this architecture at the current optimization level">,
   InGroup;
 
-def warn_drv_experimental_fp_control_incomplete_opt : Warning<
-  "Support for floating point control option %0 is incomplete and experimental">,
-  InGroup;
-
 def warn_drv_moutline_unsupported_opt : Warning<
   "The '%0' architecture does not support -moutline; flag ignored">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] badba51 - [analyzer] NonnullGlobalConstants: Add support for kCFNull.

2019-12-18 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-12-18T12:08:15-08:00
New Revision: badba5118ff5cc6d61aeca6ee2dc2ead5bb5286f

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

LOG: [analyzer] NonnullGlobalConstants: Add support for kCFNull.

It's a singleton in CoreFoundation that always contains a non-null CFNullRef.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
clang/test/Analysis/nonnull-global-constants.mm

Removed: 




diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
index 43dbe57b8432..6efba433eed2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
@@ -36,6 +36,7 @@ class NonnullGlobalConstantsChecker : public 
Checker {
   mutable IdentifierInfo *NSStringII = nullptr;
   mutable IdentifierInfo *CFStringRefII = nullptr;
   mutable IdentifierInfo *CFBooleanRefII = nullptr;
+  mutable IdentifierInfo *CFNullRefII = nullptr;
 
 public:
   NonnullGlobalConstantsChecker() {}
@@ -61,6 +62,7 @@ void 
NonnullGlobalConstantsChecker::initIdentifierInfo(ASTContext ) const {
   NSStringII = ("NSString");
   CFStringRefII = ("CFStringRef");
   CFBooleanRefII = ("CFBooleanRef");
+  CFNullRefII = ("CFNullRef");
 }
 
 /// Add an assumption that const string-like globals are non-null.
@@ -136,7 +138,7 @@ bool NonnullGlobalConstantsChecker::isNonnullType(QualType 
Ty) const {
   T->getInterfaceDecl()->getIdentifier() == NSStringII;
   } else if (auto *T = dyn_cast(Ty)) {
 IdentifierInfo* II = T->getDecl()->getIdentifier();
-return II == CFStringRefII || II == CFBooleanRefII;
+return II == CFStringRefII || II == CFBooleanRefII || II == CFNullRefII;
   }
   return false;
 }

diff  --git a/clang/test/Analysis/nonnull-global-constants.mm 
b/clang/test/Analysis/nonnull-global-constants.mm
index 9e1a588ba47a..8c174c48b30d 100644
--- a/clang/test/Analysis/nonnull-global-constants.mm
+++ b/clang/test/Analysis/nonnull-global-constants.mm
@@ -7,7 +7,11 @@
 
 @class NSString;
 typedef const struct __CFString *CFStringRef;
-typedef const struct __CFBoolean * CFBooleanRef;
+typedef const struct __CFBoolean *CFBooleanRef;
+
+#define CF_BRIDGED_TYPE(T) __attribute__((objc_bridge(T)))
+typedef const struct CF_BRIDGED_TYPE(NSNull) __CFNull *CFNullRef;
+extern const CFNullRef kCFNull;
 
 // Global NSString* is non-null.
 extern NSString *const StringConstGlobal;
@@ -113,3 +117,7 @@ void testNonnullNonconstCFString() {
 void testNonnullNonnullCFString() {
   clang_analyzer_eval(str4); // expected-warning{{TRUE}}
 }
+
+void test_kCFNull() {
+  clang_analyzer_eval(kCFNull); // expected-warning{{TRUE}}
+}



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


[PATCH] D69990: Populate CUDA flags on FreeBSD too, as many other toolchains do.

2019-12-18 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D69990#1790154 , @6yearold wrote:

> > It's somewhat old and misses few glue functions needed by CUDA-10, but it 
> > should work well enough for CUDA-9.
>
> Interesting, thanks for sharing. However, at quick look, it seems to require 
> other CUDA libraries (`libcuda`, `libcublas`, etc.), which also aren't 
> available for FreeBSD.


cuBLAS is only for testing. The runtime itself does not need it.

libcuda.so is normally part of the GPU *driver* not CUDA itself, at least it is 
on Linux. I didn't check if that's also the case on FreeBSD.
Looks like you're correct -- the driver archive only has 
NVIDIA-FreeBSD-x86_64-440.44/obj/linux/libcuda.so.440.44 in it.

:-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69990



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


[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

We do have a static assert.  I won't insist on the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


[PATCH] D69990: Populate CUDA flags on FreeBSD too, as many other toolchains do.

2019-12-18 Thread Gleb Popov via Phabricator via cfe-commits
6yearold added a comment.

In D69990#1790047 , @tra wrote:

> > ... I'm curious if it's particularly useful. Last time I checked NVIDIA 
> > didn't ship libcudart for FreeBSD and without it it's rather cumbersome to 
> > use CUDA in practice.
>
> FYI, I've just got our internal proof-of-concept runtime support library 
> which may get CUDA apps run on FreeBSD:
>  https://github.com/google/gpu-runtime
>
> It's somewhat old and misses few glue functions needed by CUDA-10, but it 
> should work well enough for CUDA-9.


Interesting, thanks for sharing. However, at quick look, it seems to require 
other CUDA libraries (`libcuda`, `libcublas`, etc.), which also aren't 
available for FreeBSD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69990



___
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-12-18 Thread Adrian McCarthy via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
amccarth marked an inline comment as done.
Closed by commit rG738b5c9639b4: Fix more VFS tests on Windows (authored by 
amccarth).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D70701?vs=230984=234592#toc

Repository:
  rG LLVM Github Monorepo

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

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 ) 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 ,
 std::error_code ) {
   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 ) const;
+  virtual std::error_code makeAbsolute(SmallVectorImpl ) const;
 };
 
 /// Gets an \p vfs::FileSystem for the 'real' file system, as seen by
@@ -749,6 +749,8 @@
 
   std::error_code isLocal(const Twine , bool ) override;
 
+  std::error_code makeAbsolute(SmallVectorImpl ) const override;
+
   directory_iterator dir_begin(const Twine , std::error_code ) override;
 
   void setExternalContentsPrefixDir(StringRef PrefixDir);
Index: clang/test/VFS/vfsroot-with-overlay.c
===
--- clang/test/VFS/vfsroot-with-overlay.c
+++ clang/test/VFS/vfsroot-with-overlay.c
@@ -1,6 +1,3 @@
-// FIXME: PR43272
-// XFAIL: system-windows
-
 

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > ABataev wrote:
> > > > > > > lildmh wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > lildmh wrote:
> > > > > > > > > > ABataev wrote:
> > > > > > > > > > > So, we're still going to use number of elements for 
> > > > > > > > > > > mappers? And pass it in the same parameter that in other 
> > > > > > > > > > > cases is used as size in bytes? If so, point to it 
> > > > > > > > > > > explicitly in the review for the runtime part so all are 
> > > > > > > > > > > informed about it.
> > > > > > > > > > From interface, the mapper function uses size in bytes now. 
> > > > > > > > > > Inside, it needs number of elements to iterate through all 
> > > > > > > > > > elements. This has no impact on the runtime part, since it 
> > > > > > > > > > looks like normal mapping from the interface. All 
> > > > > > > > > > conversion happens inside the mapper function which is 
> > > > > > > > > > completely generated by the compiler.
> > > > > > > > > Ok. Then why do we need to convert size in bytes to number of 
> > > > > > > > > elements here?
> > > > > > > > This is used to 1) see if we are going to map an array of 
> > > > > > > > elements with mapper, and 2) iterate all to map them 
> > > > > > > > individually.
> > > > > > > Could you point where we have this kind of analysis here? Because 
> > > > > > > I don't see anything affected by this change in the patch.
> > > > > > Is this a bug fix in the previous implementation?
> > > > > The previous implementation assumes the size is the number of 
> > > > > elements, and it works correctly under that assumption. Since we 
> > > > > change the meaning of size here, I add this line of code so the 
> > > > > previous implementation can work correctly in the new assumption that 
> > > > > the size is the size in bytes.
> > > > Ah, got it. Then, in general, looks good. Please, split the patches in 
> > > > to, possibly, 2 NFC (one with using of the new functions + another one 
> > > > for aggregating too many params into records) + another one with the 
> > > > new functionality.
> > > Okay, will do that. What do you think need to be done for the runtime 
> > > patch D68100?
> > Address comments and rebase, I think
> The only left comment is to split it into 2 patches, I think.
Do it.


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

https://reviews.llvm.org/D67833



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


[clang] 11d5fa6 - [Concepts] Fix incorrect move out of temporary in D41910

2019-12-18 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2019-12-18T21:43:53+02:00
New Revision: 11d5fa6e87e3584f72056ecc2b17f88c58323dde

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

LOG: [Concepts] Fix incorrect move out of temporary in D41910

Moves out of temporaries caused warnings that failed builds.

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index f9d54a811469..63b8e06a7aef 100755
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -653,7 +653,7 @@ static NormalForm makeCNF(const NormalizedConstraint 
) {
   if (Normalized.getCompoundKind() == NormalizedConstraint::CCK_Conjunction) {
 LCNF.reserve(LCNF.size() + RCNF.size());
 while (!RCNF.empty())
-  LCNF.push_back(std::move(RCNF.pop_back_val()));
+  LCNF.push_back(RCNF.pop_back_val());
 return LCNF;
   }
 
@@ -682,7 +682,7 @@ static NormalForm makeDNF(const NormalizedConstraint 
) {
   if (Normalized.getCompoundKind() == NormalizedConstraint::CCK_Disjunction) {
 LDNF.reserve(LDNF.size() + RDNF.size());
 while (!RDNF.empty())
-  LDNF.push_back(std::move(RDNF.pop_back_val()));
+  LDNF.push_back(RDNF.pop_back_val());
 return LDNF;
   }
 



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


[clang] 738b5c9 - Fix more VFS tests on Windows

2019-12-18 Thread Adrian McCarthy via cfe-commits

Author: Adrian McCarthy
Date: 2019-12-18T11:38:04-08:00
New Revision: 738b5c9639b4323f75b03e21494bef13d9adfa86

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

LOG: Fix more VFS tests on Windows

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.

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

Added: 


Modified: 
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

Removed: 




diff  --git a/clang/test/VFS/vfsroot-include.c 
b/clang/test/VFS/vfsroot-include.c
index 2564004ea4b1..eb641c58a650 100644
--- a/clang/test/VFS/vfsroot-include.c
+++ b/clang/test/VFS/vfsroot-include.c
@@ -1,6 +1,3 @@
-// FIXME: PR43272
-// XFAIL: system-windows
-
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: sed -e "s@TEST_DIR@%{/S:regex_replacement}@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsroot.yaml > %t.yaml

diff  --git a/clang/test/VFS/vfsroot-module.m b/clang/test/VFS/vfsroot-module.m
index 3ad3e19d4b37..787e2f513c55 100644
--- a/clang/test/VFS/vfsroot-module.m
+++ b/clang/test/VFS/vfsroot-module.m
@@ -1,6 +1,3 @@
-// FIXME: PR43272
-// XFAIL: system-windows
-
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: sed -e "s@TEST_DIR@%{/S:regex_replacement}@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsroot.yaml > %t.yaml

diff  --git a/clang/test/VFS/vfsroot-with-overlay.c 
b/clang/test/VFS/vfsroot-with-overlay.c
index 4a2c64cb8734..d181f4d8382c 100644
--- a/clang/test/VFS/vfsroot-with-overlay.c
+++ b/clang/test/VFS/vfsroot-with-overlay.c
@@ -1,6 +1,3 @@
-// FIXME: PR43272
-// XFAIL: system-windows
-
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: sed -e "s@TEST_DIR@%{/S:regex_replacement}@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsroot.yaml > %t.yaml

diff  --git a/llvm/include/llvm/Support/VirtualFileSystem.h 
b/llvm/include/llvm/Support/VirtualFileSystem.h
index 3b4c4aff9bdc..e45e6e756786 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -293,7 +293,7 @@ class FileSystem : public 
llvm::ThreadSafeRefCountedBase {
   /// \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 ) const;
+  virtual std::error_code makeAbsolute(SmallVectorImpl ) const;
 };
 
 /// Gets an \p vfs::FileSystem for the 'real' file system, as seen by
@@ -749,6 +749,8 @@ class RedirectingFileSystem : public vfs::FileSystem {
 
   std::error_code isLocal(const Twine , bool ) override;
 
+  std::error_code makeAbsolute(SmallVectorImpl ) const override;
+
   directory_iterator dir_begin(const Twine , std::error_code ) override;
 
   void setExternalContentsPrefixDir(StringRef PrefixDir);

diff  --git a/llvm/lib/Support/VirtualFileSystem.cpp 
b/llvm/lib/Support/VirtualFileSystem.cpp
index 2d5c04baa57e..edd4234fe501 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -1073,6 +1073,19 @@ std::error_code RedirectingFileSystem::isLocal(const 
Twine ,
   return ExternalFS->isLocal(Path, Result);
 }
 
+std::error_code RedirectingFileSystem::makeAbsolute(SmallVectorImpl 
) 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 ,
 std::error_code ) {
   ErrorOr E = lookupPath(Dir);
@@ -1428,21 +1441,31 @@ class llvm::vfs::RedirectingFileSystemParser {
   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 

[clang] 9d38fd8 - [NFC] Update FIXME for one VFS test

2019-12-18 Thread Adrian McCarthy via cfe-commits

Author: Adrian McCarthy
Date: 2019-12-18T11:38:04-08:00
New Revision: 9d38fd8d0be3074af036e9e3e36489f5b854faf4

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

LOG: [NFC] Update FIXME for one VFS test

The VFS/subframework-symlink.m test is still XFAIL on Windows, but for
a different reason than those fixed in PR43272, so I've updated the
PR number.

Added: 


Modified: 
clang/test/VFS/subframework-symlink.m

Removed: 




diff  --git a/clang/test/VFS/subframework-symlink.m 
b/clang/test/VFS/subframework-symlink.m
index 68cc063cfcfc..77e8572aa457 100644
--- a/clang/test/VFS/subframework-symlink.m
+++ b/clang/test/VFS/subframework-symlink.m
@@ -1,4 +1,4 @@
-// FIXME: PR43272
+// FIXME: PR44221
 // XFAIL: system-windows
 
 // Test that when a subframework is a symlink to another framework, we don't



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > lildmh wrote:
> > > > ABataev wrote:
> > > > > ABataev wrote:
> > > > > > lildmh wrote:
> > > > > > > ABataev wrote:
> > > > > > > > lildmh wrote:
> > > > > > > > > ABataev wrote:
> > > > > > > > > > So, we're still going to use number of elements for 
> > > > > > > > > > mappers? And pass it in the same parameter that in other 
> > > > > > > > > > cases is used as size in bytes? If so, point to it 
> > > > > > > > > > explicitly in the review for the runtime part so all are 
> > > > > > > > > > informed about it.
> > > > > > > > > From interface, the mapper function uses size in bytes now. 
> > > > > > > > > Inside, it needs number of elements to iterate through all 
> > > > > > > > > elements. This has no impact on the runtime part, since it 
> > > > > > > > > looks like normal mapping from the interface. All conversion 
> > > > > > > > > happens inside the mapper function which is completely 
> > > > > > > > > generated by the compiler.
> > > > > > > > Ok. Then why do we need to convert size in bytes to number of 
> > > > > > > > elements here?
> > > > > > > This is used to 1) see if we are going to map an array of 
> > > > > > > elements with mapper, and 2) iterate all to map them individually.
> > > > > > Could you point where we have this kind of analysis here? Because I 
> > > > > > don't see anything affected by this change in the patch.
> > > > > Is this a bug fix in the previous implementation?
> > > > The previous implementation assumes the size is the number of elements, 
> > > > and it works correctly under that assumption. Since we change the 
> > > > meaning of size here, I add this line of code so the previous 
> > > > implementation can work correctly in the new assumption that the size 
> > > > is the size in bytes.
> > > Ah, got it. Then, in general, looks good. Please, split the patches in 
> > > to, possibly, 2 NFC (one with using of the new functions + another one 
> > > for aggregating too many params into records) + another one with the new 
> > > functionality.
> > Okay, will do that. What do you think need to be done for the runtime patch 
> > D68100?
> Address comments and rebase, I think
The only left comment is to split it into 2 patches, I think.


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

https://reviews.llvm.org/D67833



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


[PATCH] D41910: [Concepts] Constrained partial specializations and function overloads.

2019-12-18 Thread Saar Raz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG12038be20ee6: [Concepts] Fix crash in D41910 (authored by 
saar.raz).

Changed prior to commit:
  https://reviews.llvm.org/D41910?vs=232457=234587#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D41910

Files:
  clang/lib/Sema/SemaConcept.cpp


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -558,7 +558,7 @@
 Atomic.ParameterMapping.emplace();
 Atomic.ParameterMapping->reserve(OccurringIndices.size());
 for (unsigned I = 0, C = TemplateParams->size(); I != C; ++I)
-  if (OccurringIndices[I])
+  if (I < OccurringIndices.size() && OccurringIndices[I])
 Atomic.ParameterMapping->push_back(
 S.getIdentityTemplateArgumentLoc(TemplateParams->begin()[I],
 // Here we assume we do not support things like


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -558,7 +558,7 @@
 Atomic.ParameterMapping.emplace();
 Atomic.ParameterMapping->reserve(OccurringIndices.size());
 for (unsigned I = 0, C = TemplateParams->size(); I != C; ++I)
-  if (OccurringIndices[I])
+  if (I < OccurringIndices.size() && OccurringIndices[I])
 Atomic.ParameterMapping->push_back(
 S.getIdentityTemplateArgumentLoc(TemplateParams->begin()[I],
 // Here we assume we do not support things like
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 12038be - [Concepts] Fix crash in D41910

2019-12-18 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2019-12-18T21:31:33+02:00
New Revision: 12038be20ee6a903cdbd3fddce65535ef683e31d

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

LOG: [Concepts] Fix crash in D41910

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

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index cd41000fa023..f9d54a811469 100755
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -558,7 +558,7 @@ static bool substituteParameterMappings(Sema , 
NormalizedConstraint ,
 Atomic.ParameterMapping.emplace();
 Atomic.ParameterMapping->reserve(OccurringIndices.size());
 for (unsigned I = 0, C = TemplateParams->size(); I != C; ++I)
-  if (OccurringIndices[I])
+  if (I < OccurringIndices.size() && OccurringIndices[I])
 Atomic.ParameterMapping->push_back(
 S.getIdentityTemplateArgumentLoc(TemplateParams->begin()[I],
 // Here we assume we do not support things like



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > lildmh wrote:
> > > > > > ABataev wrote:
> > > > > > > lildmh wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > So, we're still going to use number of elements for mappers? 
> > > > > > > > > And pass it in the same parameter that in other cases is used 
> > > > > > > > > as size in bytes? If so, point to it explicitly in the review 
> > > > > > > > > for the runtime part so all are informed about it.
> > > > > > > > From interface, the mapper function uses size in bytes now. 
> > > > > > > > Inside, it needs number of elements to iterate through all 
> > > > > > > > elements. This has no impact on the runtime part, since it 
> > > > > > > > looks like normal mapping from the interface. All conversion 
> > > > > > > > happens inside the mapper function which is completely 
> > > > > > > > generated by the compiler.
> > > > > > > Ok. Then why do we need to convert size in bytes to number of 
> > > > > > > elements here?
> > > > > > This is used to 1) see if we are going to map an array of elements 
> > > > > > with mapper, and 2) iterate all to map them individually.
> > > > > Could you point where we have this kind of analysis here? Because I 
> > > > > don't see anything affected by this change in the patch.
> > > > Is this a bug fix in the previous implementation?
> > > The previous implementation assumes the size is the number of elements, 
> > > and it works correctly under that assumption. Since we change the meaning 
> > > of size here, I add this line of code so the previous implementation can 
> > > work correctly in the new assumption that the size is the size in bytes.
> > Ah, got it. Then, in general, looks good. Please, split the patches in to, 
> > possibly, 2 NFC (one with using of the new functions + another one for 
> > aggregating too many params into records) + another one with the new 
> > functionality.
> Okay, will do that. What do you think need to be done for the runtime patch 
> D68100?
Address comments and rebase, I think


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

https://reviews.llvm.org/D67833



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > lildmh wrote:
> > > > > > > ABataev wrote:
> > > > > > > > So, we're still going to use number of elements for mappers? 
> > > > > > > > And pass it in the same parameter that in other cases is used 
> > > > > > > > as size in bytes? If so, point to it explicitly in the review 
> > > > > > > > for the runtime part so all are informed about it.
> > > > > > > From interface, the mapper function uses size in bytes now. 
> > > > > > > Inside, it needs number of elements to iterate through all 
> > > > > > > elements. This has no impact on the runtime part, since it looks 
> > > > > > > like normal mapping from the interface. All conversion happens 
> > > > > > > inside the mapper function which is completely generated by the 
> > > > > > > compiler.
> > > > > > Ok. Then why do we need to convert size in bytes to number of 
> > > > > > elements here?
> > > > > This is used to 1) see if we are going to map an array of elements 
> > > > > with mapper, and 2) iterate all to map them individually.
> > > > Could you point where we have this kind of analysis here? Because I 
> > > > don't see anything affected by this change in the patch.
> > > Is this a bug fix in the previous implementation?
> > The previous implementation assumes the size is the number of elements, and 
> > it works correctly under that assumption. Since we change the meaning of 
> > size here, I add this line of code so the previous implementation can work 
> > correctly in the new assumption that the size is the size in bytes.
> Ah, got it. Then, in general, looks good. Please, split the patches in to, 
> possibly, 2 NFC (one with using of the new functions + another one for 
> aggregating too many params into records) + another one with the new 
> functionality.
Okay, will do that. What do you think need to be done for the runtime patch 
D68100?


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

https://reviews.llvm.org/D67833



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


[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I agree, in this case I think the comment will just be extra noise. The comment 
is likely to outlive the use of these buggy GCC versions. If someone runs into 
this bug again, it will probably happen somewhere else far away from this code, 
and the comment isn't going to help them avoid it.

I feel similarly about some MSVC workaround comments. The one that comes to 
mind is the fact that MSVC always gives unfixed enums the underlying type of 
`int`. We shouldn't sprinkle comments about this everywhere, we should document 
it once well in CodingStandards or something. In this case, I'm not sure we 
even need that. It seems like something better caught by a static assert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


[PATCH] D41910: [Concepts] Constrained partial specializations and function overloads.

2019-12-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This makes clang crash when running tests: 
http://45.33.8.238/linux/5976/step_7.txt

Please use "Differential Revision: https://reviews.llvm.org/D41910; instead of 
"Phabricator: D41910 " so that phab 
auto-closes the review and other auto-linking tools work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D41910



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


[PATCH] D71669: [Clang FE, SystemZ] Don't add "true" value for the "mnop-mcount" attribute.

2019-12-18 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa closed this revision.
jonpa added a comment.

ca52059 


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

https://reviews.llvm.org/D71669



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


[clang] ca52059 - [Clang FE, SystemZ] Don't add "true" value for the "mnop-mcount" attribute.

2019-12-18 Thread Jonas Paulsson via cfe-commits

Author: Jonas Paulsson
Date: 2019-12-18T11:04:13-08:00
New Revision: ca520592c081a76b45613ec794ebee4920933c1c

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

LOG: [Clang FE, SystemZ]  Don't add "true" value for the "mnop-mcount" 
attribute.

Let the "mnop-mcount" function attribute simply be present or non-present.
Update SystemZ backend as well to use hasFnAttribute() instead.

Review: Ulrich Weigand
https://reviews.llvm.org/D71669

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/mnop-mcount.c
llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 0db17431814f..89ce31e9b450 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -966,7 +966,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
 if (!CGM.getCodeGenOpts().CallFEntry)
   CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
 << "-mnop-mcount" << "-mfentry";
-Fn->addFnAttr("mnop-mcount", "true");
+Fn->addFnAttr("mnop-mcount");
   }
 }
   }

diff  --git a/clang/test/CodeGen/mnop-mcount.c 
b/clang/test/CodeGen/mnop-mcount.c
index 08d000dc4131..a6b10b625050 100644
--- a/clang/test/CodeGen/mnop-mcount.c
+++ b/clang/test/CodeGen/mnop-mcount.c
@@ -17,9 +17,9 @@ int __attribute__((no_instrument_function)) 
no_instrument(void) {
   return foo();
 }
 
-//CHECK: attributes #0 = { {{.*}}"mnop-mcount"="true"{{.*}} }
+//CHECK: attributes #0 = { {{.*}}"mnop-mcount"{{.*}} }
 //CHECK: attributes #1 = { {{.*}} }
-//CHECK-NOT: attributes #1 = { {{.*}}"mnop-mcount"="true"{{.*}} }
+//CHECK-NOT: attributes #1 = { {{.*}}"mnop-mcount"{{.*}} }
 //NOMFENTRY: error: option '-mnop-mcount' cannot be specified without 
'-mfentry'
 //NOPG-NOT: attributes #0 = { {{.*}}"mnop-mcount"{{.*}} }
 //NOPG-NOT: attributes #1 = { {{.*}}"mnop-mcount"{{.*}} }

diff  --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp 
b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
index 10023e9e169c..34f7bc99a0d7 100644
--- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -553,8 +553,7 @@ static unsigned EmitNop(MCContext , MCStreamer 
,
 void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr ,
  SystemZMCInstLower ) {
   MCContext  = MF->getContext();
-  if (MF->getFunction().getFnAttribute("mnop-mcount")
-   .getValueAsString() == "true") {
+  if (MF->getFunction().hasFnAttribute("mnop-mcount")) {
 EmitNop(Ctx, *OutStreamer, 6, getSubtargetInfo());
 return;
   }

diff  --git a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp 
b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
index 751034c2d41a..0bcbce68a5fe 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
@@ -347,7 +347,7 @@ class SystemZDAGToDAGISel : public SelectionDAGISel {
 
   bool runOnMachineFunction(MachineFunction ) override {
 const Function  = MF.getFunction();
-if (F.getFnAttribute("mnop-mcount").getValueAsString() == "true" &&
+if (F.hasFnAttribute("mnop-mcount") &&
 F.getFnAttribute("fentry-call").getValueAsString() != "true")
   report_fatal_error("mnop-mcount only supported with fentry-call");
 

diff  --git a/llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll 
b/llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
index 38f1db537b52..99aff5a223e6 100644
--- a/llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
+++ b/llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
@@ -22,5 +22,5 @@ entry:
 }
 
 attributes #0 = { "fentry-call"="true" }
-attributes #1 = { "fentry-call"="true" "mnop-mcount"="true" }
+attributes #1 = { "fentry-call"="true" "mnop-mcount" }
 

diff  --git a/llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll 
b/llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
index 19b1724d16ad..4a3629111318 100644
--- a/llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
+++ b/llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
@@ -7,5 +7,4 @@ entry:
   ret void
 }
 
-attributes #0 = { "instrument-function-entry-inlined"="mcount" 
"mnop-mcount"="true" }
-
+attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount" }



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

lildmh wrote:
> ABataev wrote:
> > ABataev wrote:
> > > lildmh wrote:
> > > > ABataev wrote:
> > > > > lildmh wrote:
> > > > > > ABataev wrote:
> > > > > > > So, we're still going to use number of elements for mappers? And 
> > > > > > > pass it in the same parameter that in other cases is used as size 
> > > > > > > in bytes? If so, point to it explicitly in the review for the 
> > > > > > > runtime part so all are informed about it.
> > > > > > From interface, the mapper function uses size in bytes now. Inside, 
> > > > > > it needs number of elements to iterate through all elements. This 
> > > > > > has no impact on the runtime part, since it looks like normal 
> > > > > > mapping from the interface. All conversion happens inside the 
> > > > > > mapper function which is completely generated by the compiler.
> > > > > Ok. Then why do we need to convert size in bytes to number of 
> > > > > elements here?
> > > > This is used to 1) see if we are going to map an array of elements with 
> > > > mapper, and 2) iterate all to map them individually.
> > > Could you point where we have this kind of analysis here? Because I don't 
> > > see anything affected by this change in the patch.
> > Is this a bug fix in the previous implementation?
> The previous implementation assumes the size is the number of elements, and 
> it works correctly under that assumption. Since we change the meaning of size 
> here, I add this line of code so the previous implementation can work 
> correctly in the new assumption that the size is the size in bytes.
Ah, got it. Then, in general, looks good. Please, split the patches in to, 
possibly, 2 NFC (one with using of the new functions + another one for 
aggregating too many params into records) + another one with the new 
functionality.


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

https://reviews.llvm.org/D67833



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


[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D71650#1790067 , @mstorsjo wrote:

> In D71650#1789897 , @rjmccall wrote:
>
> > Wow, that's novel.  Please add a comment explaining that this is a compiler 
> > workaround, but otherwise LGTM.
>
>
> The post-patch form doesn't look that odd to me (and we wouldn't want one 
> comment for every one of the existing enums that already are outside of the 
> structs where they are used for bitfield sizes), but do you think a comment 
> is warranted here on this one?


I think having a comment somewhere up there to say clearly that these things 
are hoisted up there as a workaround for a specific GCC port might help 
somebody from making this mistake again.  It also might not, but certainly not 
having a comment can't help.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D71650#1789897 , @rjmccall wrote:

> Wow, that's novel.  Please add a comment explaining that this is a compiler 
> workaround, but otherwise LGTM.


The post-patch form doesn't look that odd to me (and we wouldn't want one 
comment for every one of the existing enums that already are outside of the 
structs where they are used for bitfield sizes), but do you think a comment is 
warranted here on this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > So, we're still going to use number of elements for mappers? And 
> > > > > > pass it in the same parameter that in other cases is used as size 
> > > > > > in bytes? If so, point to it explicitly in the review for the 
> > > > > > runtime part so all are informed about it.
> > > > > From interface, the mapper function uses size in bytes now. Inside, 
> > > > > it needs number of elements to iterate through all elements. This has 
> > > > > no impact on the runtime part, since it looks like normal mapping 
> > > > > from the interface. All conversion happens inside the mapper function 
> > > > > which is completely generated by the compiler.
> > > > Ok. Then why do we need to convert size in bytes to number of elements 
> > > > here?
> > > This is used to 1) see if we are going to map an array of elements with 
> > > mapper, and 2) iterate all to map them individually.
> > Could you point where we have this kind of analysis here? Because I don't 
> > see anything affected by this change in the patch.
> Is this a bug fix in the previous implementation?
The previous implementation assumes the size is the number of elements, and it 
works correctly under that assumption. Since we change the meaning of size 
here, I add this line of code so the previous implementation can work correctly 
in the new assumption that the size is the size in bytes.


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

https://reviews.llvm.org/D67833



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


[PATCH] D71669: [Clang FE, SystemZ] Don't add "true" value for the "mnop-mcount" attribute.

2019-12-18 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D71669



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


[PATCH] D69990: Populate CUDA flags on FreeBSD too, as many other toolchains do.

2019-12-18 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> ... I'm curious if it's particularly useful. Last time I checked NVIDIA 
> didn't ship libcudart for FreeBSD and without it it's rather cumbersome to 
> use CUDA in practice.

FYI, I've just got our internal proof-of-concept runtime support library which 
may get CUDA apps run on FreeBSD:
https://github.com/google/gpu-runtime

It's somewhat old and misses few glue functions needed by CUDA-10, but it 
should work well enough for CUDA-9.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69990



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


[PATCH] D71039: Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr.

2019-12-18 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa85f5efd9597: Add support for the MS qualifiers __ptr32, 
__ptr64, __sptr, __uptr. (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71039

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/ms-mixed-ptr-sizes.c
  clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
  clang/test/Sema/MicrosoftExtensions.c
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388598)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388595)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x76>();
+  correct<0x73>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/Sema/MicrosoftExtensions.c
===
--- clang/test/Sema/MicrosoftExtensions.c
+++ clang/test/Sema/MicrosoftExtensions.c
@@ -150,6 +150,20 @@
 void ptr_func2(int * __sptr __ptr32 i) {}  // expected-note {{previous definition is here}}
 void ptr_func2(int * __uptr __ptr32 i) {} // expected-error {{redefinition of 'ptr_func2'}}
 
+// Check for warning when return types have the type attribute.
+void *__ptr32 ptr_func3() { return 0; } // expected-note {{previous definition is here}}
+void *__ptr64 ptr_func3() { return 0; } // expected-error {{redefinition of 'ptr_func3'}}
+
+// Test that __ptr32/__ptr64 can be passed as arguments with other address
+// spaces.
+void ptr_func4(int *i);
+void ptr_func5(int *__ptr32 i);
+void test_ptr_arguments() {
+  int *__ptr64 i64;
+  ptr_func4(i64);
+  ptr_func5(i64);
+}
+
 int * __sptr __ptr32 __sptr wrong4; // expected-warning {{attribute '__sptr' is already applied}}
 
 __ptr32 int *wrong5; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
Index: clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fms-extensions -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -fms-extensions -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN
+
+// CHECK-LABEL: define {{.*}}void @_Z2f0PU10ptr32_sptri
+// WIN-LABEL: define {{.*}}void @"?f0@@YAXPAH@Z"
+void f0(int * __ptr32 p) {}
+
+// CHECK-LABEL: define {{.*}}i8 addrspace(271)* @_Z2f1PU10ptr32_sptri
+// WIN-LABEL: define {{.*}}i8 addrspace(271)* @"?f1@@YAPAXPAH@Z"
+void * __ptr32 __uptr f1(int * __ptr32 p) { return 0; }
+
+// CHECK-LABEL: define {{.*}}void @_Z2f2Pi
+// WIN-LABEL: define {{.*}}void @"?f2@@YAXPEAH@Z"
+void f2(int * __ptr64 p) {}
+
+  // CHECK-LABEL: define {{.*}}i8* @_Z2f3Pi
+// WIN-LABEL: define {{.*}}i8* @"?f3@@YAPEAXPEAH@Z"
+void * __ptr64 f3(int * __ptr64 p) { return 0; }
Index: clang/test/CodeGen/ms-mixed-ptr-sizes.c
===
--- /dev/null
+++ clang/test/CodeGen/ms-mixed-ptr-sizes.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 \
+// RUN:   < %s | FileCheck %s --check-prefixes=X64,CHECK
+// RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 \
+// RUN:   < %s | FileCheck %s --check-prefixes=X86,CHECK
+
+struct Foo {
+  int * __ptr32 p32;
+  int * __ptr64 p64;
+};
+void use_foo(struct Foo *f);
+void test_sign_ext(struct Foo *f, int * __ptr32 __sptr i) {
+// 

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > lildmh wrote:
> > > > ABataev wrote:
> > > > > So, we're still going to use number of elements for mappers? And pass 
> > > > > it in the same parameter that in other cases is used as size in 
> > > > > bytes? If so, point to it explicitly in the review for the runtime 
> > > > > part so all are informed about it.
> > > > From interface, the mapper function uses size in bytes now. Inside, it 
> > > > needs number of elements to iterate through all elements. This has no 
> > > > impact on the runtime part, since it looks like normal mapping from the 
> > > > interface. All conversion happens inside the mapper function which is 
> > > > completely generated by the compiler.
> > > Ok. Then why do we need to convert size in bytes to number of elements 
> > > here?
> > This is used to 1) see if we are going to map an array of elements with 
> > mapper, and 2) iterate all to map them individually.
> Could you point where we have this kind of analysis here? Because I don't see 
> anything affected by this change in the patch.
Is this a bug fix in the previous implementation?


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

https://reviews.llvm.org/D67833



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


  1   2   >