[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

Thanks for fixing this. Could you use `.ll` IR file as test case and place it 
alongside with `test/Other/module-pass-printer.ll` or just reuse that one? We 
can also use `opt` to invoke new pass manager, so it doesn't need to be a clang 
test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74814



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


[clang-tools-extra] 4921e79 - Fix build after D74606

2020-02-19 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-02-19T09:19:15+01:00
New Revision: 4921e7919223a785081a13c8a08063e91bae0db8

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

LOG: Fix build after D74606

Added: 


Modified: 
clang-tools-extra/clangd/test/initialize-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index 8984f36db7d0..68e3ebc24a21 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -7,7 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
-# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"'|",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",



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


[PATCH] D73138: [libcxx] [test] Correct asserted type in subspan test; subspan with count should never produce dynamic_extent

2020-02-19 Thread Michael Schellenberger Costa via Phabricator via cfe-commits
miscco added a comment.

Ah sorry about that, I overlooked that we had special cased tests without count.

Thanks Billy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73138



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


[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-02-19 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/lib/Basic/FixedPoint.cpp:242
+  } else
+Overflowed = Result < Min || Result > Max;
+

rjmccall wrote:
> ebevhan wrote:
> > rjmccall wrote:
> > > leonardchan wrote:
> > > > ebevhan wrote:
> > > > > rjmccall wrote:
> > > > > > ebevhan wrote:
> > > > > > > ebevhan wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > fully-precise multiplication yields *k+e* for some epsilon 
> > > > > > > > > *e* that isn't representable in the result semantics, is that 
> > > > > > > > > considered an overflow?  If so, I think you need to do the 
> > > > > > > > > shift after these bound checks, since the shift destroys the 
> > > > > > > > > difference between *k* and *k+e*.  That is, unless there's a 
> > > > > > > > > compelling mathematical argument that it's not possible to 
> > > > > > > > > overflow only in the fully-precision multiplication — but 
> > > > > > > > > while I think that's possibly true of `_Fract` (since *k^2 < 
> > > > > > > > > k*), it seems unlikely to be true of `_Accum`, although I 
> > > > > > > > > haven't looked for a counter-example.  And if there is a 
> > > > > > > > > compelling argument, it should probably be at least alluded 
> > > > > > > > > to in a comment.
> > > > > > > > > 
> > > > > > > > > Would this algorithm be simpler if you took advantage of the 
> > > > > > > > > fact that `APFixedPointSemantics` doesn't have to correspond 
> > > > > > > > > to a real type?  You could probably just convert to a 
> > > > > > > > > double-width common semantics, right?
> > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > fully-precise multiplication yields *k+e* for some epsilon 
> > > > > > > > > *e* that isn't representable in the result semantics, is that 
> > > > > > > > > considered an overflow? If so, I think you need to do the 
> > > > > > > > > shift after these bound checks, since the shift destroys the 
> > > > > > > > > difference between *k* and *k+e*.
> > > > > > > > 
> > > > > > > > I don't think I would consider that to be overflow; that's 
> > > > > > > > precision loss. E-C considers these to be different:
> > > > > > > > 
> > > > > > > > > If the source value cannot be represented exactly by the 
> > > > > > > > > fixed-point type, the source value is rounded to either the 
> > > > > > > > > closest fixed-point value greater than the source value 
> > > > > > > > > (rounded up) or to the closest fixed-point value less than 
> > > > > > > > > the source value (rounded down).
> > > > > > > > >
> > > > > > > > > When the source value does not fit within the range of the 
> > > > > > > > > fixed-point type, the conversion overflows. [...]
> > > > > > > > >
> > > > > > > > > [...]
> > > > > > > > >
> > > > > > > > > If the result type of an arithmetic operation is a 
> > > > > > > > > fixed-point type, [...] the calculated result is the 
> > > > > > > > > mathematically exact result with overflow handling and 
> > > > > > > > > rounding performed to the full precision of the result type 
> > > > > > > > > as explained in 4.1.3. 
> > > > > > > > 
> > > > > > > > There is also no value of `e` that would affect saturation. Any 
> > > > > > > > full precision calculation that gives `k+e` must be `k` after 
> > > > > > > > downscaling, since the bits that represent `e` must come from 
> > > > > > > > the extra precision range. Even though `k+e` is technically 
> > > > > > > > larger than `k`, saturation would still just give us `k` after 
> > > > > > > > truncating out `e`, so the end result is the same.
> > > > > > > > 
> > > > > > > > > Would this algorithm be simpler if you took advantage of the 
> > > > > > > > > fact that APFixedPointSemantics doesn't have to correspond to 
> > > > > > > > > a real type? You could probably just convert to a 
> > > > > > > > > double-width common semantics, right?
> > > > > > > > 
> > > > > > > > It's likely possible to use APFixedPoint in the calculations 
> > > > > > > > here, but I used APInt to make the behavior explicit and not 
> > > > > > > > accidentally be dependent on the behavior of APFixedPoint's 
> > > > > > > > conversions or operations.
> > > > > > > Although.,. I guess I see your point in that an intermediate 
> > > > > > > result of k+e technically "does not fit within the range of the 
> > > > > > > fixed-point type"... but I wonder if treating such cases as 
> > > > > > > overflow is particularly meaningful. I don't find there to be 
> > > > > > > much of a distinction between such a case and the case where the 
> > > > > > > exact result lands inbetween two representable values. We just 
> > > > > > > end up with a less precise result.
> > > > > > Right, I was wondering if there was an accepted answer here.  For 
> > > > > > saturating arithmetic, it's equivalent to truncate this extra 
> > > > > > precision down to *k* or to saturate to the 

[clang-tools-extra] fa6aef4 - [clang-tidy] Added a case to UnconventionalAssignOperatorCheck.

2020-02-19 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-02-19T10:07:34+01:00
New Revision: fa6aef44277230adecb541c78a71978172accd5c

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

LOG: [clang-tidy] Added a case to UnconventionalAssignOperatorCheck.

Summary:
The check accepts now a `return (*this = something);` as return
statement too (beneath of `*this`).

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: aaron.ballman

Subscribers: xazax.hun, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
index 8c87dae90080..811b55bd12be 100644
--- a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -60,7 +60,12 @@ void UnconventionalAssignOperatorCheck::registerMatchers(
   anyOf(unaryOperator(hasOperatorName("*"), 
hasUnaryOperand(cxxThisExpr())),
 cxxOperatorCallExpr(argumentCountIs(1),
 callee(unresolvedLookupExpr()),
-hasArgument(0, cxxThisExpr(;
+hasArgument(0, cxxThisExpr())),
+cxxOperatorCallExpr(
+hasOverloadedOperatorName("="),
+hasArgument(
+0, unaryOperator(hasOperatorName("*"),
+ hasUnaryOperand(cxxThisExpr());
   const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType);
 
   Finder->addMatcher(returnStmt(IsBadReturnStatement, 
forFunction(IsGoodAssign))

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
index a0a37c0ff1c7..4f0713a01f6f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
@@ -109,3 +109,21 @@ struct Template {
 
 Template TemplateInt;
 }
+
+struct AssignmentCallAtReturn {
+  AssignmentCallAtReturn &returnThis() {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(int rhs) {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(char rhs) {
+// Allow call to assignment from other type.
+return (*this = static_cast(rhs));
+  }
+  AssignmentCallAtReturn &operator=(float rhs) {
+// Do not allow calls to other functions.
+return returnThis();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always 
return '*this'
+  }
+};



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


[PATCH] D74529: [clang-tidy] Added a case to UnconventionalAssignOperatorCheck.

2020-02-19 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa6aef442772: [clang-tidy] Added a case to 
UnconventionalAssignOperatorCheck. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74529

Files:
  clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
@@ -109,3 +109,21 @@
 
 Template TemplateInt;
 }
+
+struct AssignmentCallAtReturn {
+  AssignmentCallAtReturn &returnThis() {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(int rhs) {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(char rhs) {
+// Allow call to assignment from other type.
+return (*this = static_cast(rhs));
+  }
+  AssignmentCallAtReturn &operator=(float rhs) {
+// Do not allow calls to other functions.
+return returnThis();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always 
return '*this'
+  }
+};
Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -60,7 +60,12 @@
   anyOf(unaryOperator(hasOperatorName("*"), 
hasUnaryOperand(cxxThisExpr())),
 cxxOperatorCallExpr(argumentCountIs(1),
 callee(unresolvedLookupExpr()),
-hasArgument(0, cxxThisExpr(;
+hasArgument(0, cxxThisExpr())),
+cxxOperatorCallExpr(
+hasOverloadedOperatorName("="),
+hasArgument(
+0, unaryOperator(hasOperatorName("*"),
+ hasUnaryOperand(cxxThisExpr());
   const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType);
 
   Finder->addMatcher(returnStmt(IsBadReturnStatement, 
forFunction(IsGoodAssign))


Index: clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
@@ -109,3 +109,21 @@
 
 Template TemplateInt;
 }
+
+struct AssignmentCallAtReturn {
+  AssignmentCallAtReturn &returnThis() {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(int rhs) {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(char rhs) {
+// Allow call to assignment from other type.
+return (*this = static_cast(rhs));
+  }
+  AssignmentCallAtReturn &operator=(float rhs) {
+// Do not allow calls to other functions.
+return returnThis();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
+  }
+};
Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -60,7 +60,12 @@
   anyOf(unaryOperator(hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())),
 cxxOperatorCallExpr(argumentCountIs(1),
 callee(unresolvedLookupExpr()),
-hasArgument(0, cxxThisExpr(;
+hasArgument(0, cxxThisExpr())),
+cxxOperatorCallExpr(
+hasOverloadedOperatorName("="),
+hasArgument(
+0, unaryOperator(hasOperatorName("*"),
+ hasUnaryOperand(cxxThisExpr());
   const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType);
 
   Finder->addMatcher(returnStmt(IsBadReturnStatement, forFunction(IsGoodAssign))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.

lg


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

https://reviews.llvm.org/D74801



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


[clang] faff707 - Reland "[DebugInfo] Enable the debug entry values feature by default"

2020-02-19 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-02-19T11:12:26+01:00
New Revision: faff707db82d7db12fcd9f7826b8741261230e63

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

LOG: Reland "[DebugInfo] Enable the debug entry values feature by default"

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

Added: 
llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir
llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
llvm/test/CodeGen/ARM/smml.ll
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/CodeGen/X86/hoist-invariant-load.ll
llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
llvm/test/CodeGen/X86/statepoint-allocas.ll
llvm/test/CodeGen/X86/tail-dup-repeat.ll
llvm/test/CodeGen/X86/xray-custom-log.ll
llvm/test/CodeGen/X86/xray-typed-event-log.ll
llvm/test/DebugInfo/AArch64/call-site-info-output.ll
llvm/test/DebugInfo/ARM/call-site-info-output.ll
llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/DebugInfo/X86

[PATCH] D74769: [AArch64][SVE] Add SVE2 intrinsics for polynomial arithmetic

2020-02-19 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63236078d243: [AArch64][SVE] Add SVE2 intrinsics for 
polynomial arithmetic (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74769

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic-128.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic.ll
@@ -0,0 +1,149 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; EORBT
+;
+
+define  @eorbt_i8( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i8:
+; CHECK: eorbt z0.b, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv16i8( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eorbt_i16( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i16:
+; CHECK: eorbt z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv8i16( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eorbt_i32( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i32:
+; CHECK: eorbt z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv4i32( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eorbt_i64( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i64:
+; CHECK: eorbt z0.d, z1.d, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv2i64( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+;
+; EORTB
+;
+
+define  @eortb_i8( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i8:
+; CHECK: eortb z0.b, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv16i8( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eortb_i16( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i16:
+; CHECK: eortb z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv8i16( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eortb_i32( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i32:
+; CHECK: eortb z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv4i32( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eortb_i64( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i64:
+; CHECK: eortb z0.d, z1.d, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv2i64( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+;
+; PMULLB
+;
+
+define  @pmullb_i8( %a,  %b) {
+; CHECK-LABEL: pmullb_i8:
+; CHECK: pmullb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullb.pair.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @pmullb_i32( %a,  %b) {
+; CHECK-LABEL: pmullb_i32:
+; CHECK: pmullb z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullb.pair.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+;
+; PMULLT
+;
+
+define  @pmullt_i8( %a,  %b) {
+; CHECK-LABEL: pmullt_i8:
+; CHECK: pmullt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullt.pair.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @pmullt_i32( %a,  %b) {
+; CHECK-LABEL: pmullt_i32:
+; CHECK: pmullt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullt.pair.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.eorbt.nxv16i8(, , )
+declare  @llvm.aarch64.sve.eorbt.nxv8i16(, , )
+declare  @llvm.aarch64.sve.eorbt.nxv4i32(, , )
+declare  @llvm.aarch64.sve.eorbt.nxv2i64(, , )
+
+declare  @llvm.aarch64.sve.eortb.nxv16i8(, , )
+declare  @llvm.aarch64.sve.eortb.

[PATCH] D74806: [analyzer] NFCi: Refactor CStringChecker: use strongly typed internal API

2020-02-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

This is fantastic, i love it!

> all tests are preserved and passing; only *the message changed at some 
> places*. In my opinion, these messages are holding the same information.

You make it sound like an accident; i encourage you to have a closer look to 
make sure that there are no other effects than the ones observed on tests.




Comment at: clang/test/Analysis/string.c:454
   if (strlen(y) == 4)
-strcat(x, y); // expected-warning{{String copy function overflows 
destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows 
the destination buffer}}
 }

Nice catch indeed!~


Repository:
  rC Clang

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

https://reviews.llvm.org/D74806



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


[PATCH] D69782: Summary: Instead of dropping all the ranges associated with a Diagnostic when converting them to a ClangTidy error, instead attach them to the ClangTidyError, so they can be consumed b

2020-02-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: include/clang/Tooling/Core/Diagnostic.h:51
+/// Represents a single source ranges to be associated with a diagnostic.
+struct DiagnosticAssociatedRange {
+  DiagnosticAssociatedRange() = default;

This comment was lost by Phabricator (or I just wanted to leave it without 
actually doing it?).

The name assumes a specific usage. I'd try to make it more generic in case 
there's another use case for the struct, for example: `ByteRange` (as opposed 
to `TextRange`, which would be {start line, start column, end line, end 
column}) or `FileByteRange` (if we want to stress that it contains a file name).


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

https://reviews.llvm.org/D69782



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


[clang] 78654e8 - Revert "Reland D74436 "Change clang option -ffp-model=precise to select ffp-contract=on"""

2020-02-19 Thread Oliver Stannard via cfe-commits

Author: Oliver Stannard
Date: 2020-02-19T12:03:27Z
New Revision: 78654e8511cf16d49f6680d782f3771a767ba942

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

LOG: Revert "Reland D74436 "Change clang option -ffp-model=precise to select 
ffp-contract=on"""

Reverting because this patch is causing ~20 llvm-test-suite failures on
a number of different bots:
* http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/3366
* http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/8222
* http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/13275
* http://lab.llvm.org:8011/builders/clang-s390x-linux-lnt/builds/17213

This reverts commit cd2c5af6dfd6e32ee7043894bcb42981ce99e8ac.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 6c8c9f802082..856d5e34bbcc 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,50 +1190,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1427,7 +1385,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1d9e741f4cf8..1091db691858 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2525,9 +2525,10 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
+
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-ml

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-19 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 245373.
bader marked 12 inline comments as done.
bader added a comment.

Rebase to ToT and address comments from Ronan.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/sycl.c
  clang/test/Frontend/sycl-aux-triple.cpp
  clang/test/Preprocessor/sycl-macro.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp

Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- clang/test/SemaSYCL/kernel-attribute.cpp
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s
 
 // Only function templates
 [[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
Index: clang/test/Preprocessor/sycl-macro.cpp
===
--- clang/test/Preprocessor/sycl-macro.cpp
+++ clang/test/Preprocessor/sycl-macro.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 %s -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -fsycl -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s
 
 // CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
+// CHECK-NOT:#define CL_SYCL_LANGUAGE_VERSION 121
+// CHECK-SYCL-STD:#define CL_SYCL_LANGUAGE_VERSION 121
 // CHECK-SYCL:#define __SYCL_DEVICE_ONLY__ 1
Index: clang/test/Frontend/sycl-aux-triple.cpp
===
--- clang/test/Frontend/sycl-aux-triple.cpp
+++ clang/test/Frontend/sycl-aux-triple.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
 
 // CHECK-NOT:#define __x86_64__ 1
 // CHECK-SYCL:#define __x86_64__ 1
Index: clang/test/Driver/sycl.c
===
--- clang/test/Driver/sycl.c
+++ clang/test/Driver/sycl.c
@@ -1,10 +1,20 @@
 // RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=1.2.1 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=121 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=2017 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=sycl-1.2.1 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clang -### -fno-sycl -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -sycl-std=2017 %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clangxx -### -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### -fsycl -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
+// RUN: %clang_cl -### -fsycl -sycl-std=2017 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang_cl -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang_cl -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 
 // ENABLED: "-cc1"{{.*}} "-fsycl-is-device"
+// ENABLED-SAME: "-sycl-std={{[-.sycl0-9]+}}"
 // DISABLED-NOT: "-fsycl-is-device"
+// DISABLED-NOT: "-sycl-std="
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -460,6 +460,13 @@
 if (LangOpts.FastRelaxedMath)
   Builder.defineMacro("__FAST_RELAXED_MATH__");
   }
+
+  if (LangOpts.SYCL) {
+// SYCL Version is set to a value when building SYCL applications
+if (LangOpts.SYCLVersion == 2017)
+  Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
+  }
+
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");
Index: clang/lib/Frontend/CompilerInvoc

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-19 Thread Alexey Bader via Phabricator via cfe-commits
bader marked an inline comment as done.
bader added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3419
+def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
+  HelpText<"SYCL language standard to compile for.">, Values<"2015, 121, 
1.2.1, sycl-1.2.1">;
 

keryell wrote:
> I suggest replacing all the 2015 by 2017.
> While this is true SYCL 1.2 was published in 2015, SYCL 1.2.1 was published 
> in 2017. Only 1.2.1 matters here since 1.2 was never fully implemented by any 
> conformant implementation. https://en.wikipedia.org/wiki/SYCL
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[clang] 49b307e - [AArch64][SVE] CodeGen of ACLE Builtin Types

2020-02-19 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-02-19T12:10:47Z
New Revision: 49b307e96d47a74e4aa8f60f3d493eac10849d4b

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

LOG: [AArch64][SVE] CodeGen of ACLE Builtin Types

Summary:
This patch adds codegen support for the ACLE builtin types added in:

  https://reviews.llvm.org/D62960

so that the ACLE builtin types are emitted as corresponding scalable
vector types in LLVM.

Reviewers: rsandifo-arm, rovka, rjmccall, efriedma

Reviewed By: efriedma

Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, llvm-commits, 
cfe-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/test/CodeGen/aarch64-sve.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 1767e744bac7..34269b282b80 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1517,9 +1517,12 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
 // is rare.
 if (!Bypasses.IsBypassed(&D) &&
 !(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) {
-  uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy);
+  llvm::TypeSize size =
+  CGM.getDataLayout().getTypeAllocSize(allocaTy);
   emission.SizeForLifetimeMarkers =
-  EmitLifetimeStart(size, AllocaAddr.getPointer());
+  size.isScalable() ? EmitLifetimeStart(-1, 
AllocaAddr.getPointer())
+: EmitLifetimeStart(size.getFixedSize(),
+AllocaAddr.getPointer());
 }
   } else {
 assert(!emission.useLifetimeMarkers());

diff  --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index a458811d7a30..31eca16bbbe5 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -511,23 +511,44 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
 case BuiltinType::OCLReserveID:
   ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
   break;
-
-// TODO: real CodeGen support for SVE types requires more infrastructure
-// to be added first.  Report an error until then.
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
-{
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "cannot yet generate code for SVE type '%0'");
-  auto *BT = cast(Ty);
-  auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
-  CGM.getDiags().Report(DiagID) << Name;
-  // Return something safe.
-  ResultType = llvm::IntegerType::get(getLLVMContext(), 32);
+case BuiltinType::SveInt8:
+case BuiltinType::SveUint8:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 8),
+   {16, true});
+case BuiltinType::SveInt16:
+case BuiltinType::SveUint16:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 
16),
+   {8, true});
+case BuiltinType::SveInt32:
+case BuiltinType::SveUint32:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 
32),
+   {4, true});
+case BuiltinType::SveInt64:
+case BuiltinType::SveUint64:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 
64),
+   {2, true});
+case BuiltinType::SveFloat16:
+  return llvm::VectorType::get(
+  getTypeForFormat(getLLVMContext(),
+   Context.getFloatTypeSemantics(Context.HalfTy),
+   /* UseNativeHalf = */ true),
+  {8, true});
+case BuiltinType::SveFloat32:
+  return llvm::VectorType::get(
+  getTypeForFormat(getLLVMContext(),
+   Context.getFloatTypeSemantics(Context.FloatTy),
+   /* UseNativeHalf = */ false),
+  {4, true});
+case BuiltinType::SveFloat64:
+  return llvm::VectorType::get(
+  getTypeForFormat(getLLVMContext(),
+   Context.getFloatTypeSemantics(Context.DoubleTy),
+   /* UseNativeHalf = */ false),
+  {2, true});
+case BuiltinType::SveBool:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 1),
+   {16, true});
   break;
-}
-
 case BuiltinType::Dependent:
 #define BUILTIN_TYPE(Id, SingletonId)
 #define PLACEHOLDER_TYPE(Id, Singleton

[PATCH] D74724: [AArch64][SVE] CodeGen of ACLE Builtin Types

2020-02-19 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49b307e96d47: [AArch64][SVE] CodeGen of ACLE Builtin Types 
(authored by sdesmalen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74724

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGen/aarch64-sve.c

Index: clang/test/CodeGen/aarch64-sve.c
===
--- clang/test/CodeGen/aarch64-sve.c
+++ clang/test/CodeGen/aarch64-sve.c
@@ -1,9 +1,51 @@
 // RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
-// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s
+// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s -check-prefix=CHECK-DEBUG
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN:  -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
-// Placeholder test for SVE types
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt8_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint8_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVBool_t'
 
-// CHECK: cannot yet generate code for SVE type '__SVInt8_t'
-// CHECK: cannot yet generate debug info for SVE type '__SVInt8_t'
+// CHECK: @ptr = common global * null, align 8
+// CHECK: %s8 = alloca , align 16
+// CHECK: %s16 = alloca , align 16
+// CHECK: %s32 = alloca , align 16
+// CHECK: %s64 = alloca , align 16
+// CHECK: %u8 = alloca , align 16
+// CHECK: %u16 = alloca , align 16
+// CHECK: %u32 = alloca , align 16
+// CHECK: %u64 = alloca , align 16
+// CHECK: %f16 = alloca , align 16
+// CHECK: %f32 = alloca , align 16
+// CHECK: %f64 = alloca , align 16
+// CHECK: %b8 = alloca , align 2
 
 __SVInt8_t *ptr;
+
+void test_locals(void) {
+  __SVInt8_t s8;
+  __SVInt16_t s16;
+  __SVInt32_t s32;
+  __SVInt64_t s64;
+
+  __SVUint8_t u8;
+  __SVUint16_t u16;
+  __SVUint32_t u32;
+  __SVUint64_t u64;
+
+  __SVFloat16_t f16;
+  __SVFloat32_t f32;
+  __SVFloat64_t f64;
+
+  __SVBool_t b8;
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -511,23 +511,44 @@
 case BuiltinType::OCLReserveID:
   ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
   break;
-
-// TODO: real CodeGen support for SVE types requires more infrastructure
-// to be added first.  Report an error until then.
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
-{
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "cannot yet generate code for SVE type '%0'");
-  auto *BT = cast(Ty);
-  auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
-  CGM.getDiags().Report(DiagID) << Name;
-  // Return something safe.
-  ResultType = llvm::IntegerType::get(getLLVMContext(), 32);
+case BuiltinType::SveInt8:
+case BuiltinType::SveUint8:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 8),
+   {16, true});
+case BuiltinType::SveInt16:
+case BuiltinType::SveUint16:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 16),
+   {8, true});
+case BuiltinType::SveInt32:
+case BuiltinType::SveUint32:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 32),
+   {4, true});
+case BuiltinType::SveInt64:
+case BuiltinType::SveUint64:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 64),
+   {2, true});
+case BuiltinType::SveFloat16:
+  return llvm::VectorType::get(
+  getTypeForFormat(getLLVMContext(),
+   Context.getFloatTypeSemantics(Context.HalfTy),
+   /* UseNativeHalf = */ true),
+  {8, true});
+case BuiltinType::SveFloat32:
+  return llvm::VectorType::get(
+

[PATCH] D74787: [IRBuilder] Always respect inserter/folder

2020-02-19 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle accepted this revision.
nhaehnle added a comment.
This revision is now accepted and ready to land.

LGTM. I think it's a pretty reasonable idea to add this threshold check to 
track down things that should be minor, but can add up in terms of compile-time 
performance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74787



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


[PATCH] D74757: Fix compiler extension in standalone mode

2020-02-19 Thread Marc-Antoine Perennou via Phabricator via cfe-commits
Keruspe accepted this revision.
Keruspe added a comment.
This revision is now accepted and ready to land.

Works fine with 10.0.0rc2 and related patches applied, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74757



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


[PATCH] D74806: [analyzer] NFCi: Refactor CStringChecker: use strongly typed internal API

2020-02-19 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added a comment.

In D74806#1882300 , @NoQ wrote:

> This is fantastic, i love it!
>
> > all tests are preserved and passing; only *the message changed at some 
> > places*. In my opinion, these messages are holding the same information.
>
> You make it sound like an accident; i encourage you to have a closer look to 
> make sure that there are no other effects than the ones observed on tests.


How should I look for differences/regressions without extending and validating 
systematically the test cases we have for this checker? That seems to be a huge 
work since `bstring.c` has 500+ and the `string.c` has 1600+ lines.




Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:36
+  const Expr *Expression;
+  unsigned ArgumentIndex;
+};

I'm not marking it `const` in this patch since the 496th line swaps two 
instances of this class, so it cannot be done without refactoring that function.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:492-496
   // Switch the values so that firstVal is before secondVal.
   std::swap(firstLoc, secondLoc);
 
   // Switch the Exprs as well, so that they still correspond.
   std::swap(First, Second);

It is really interesting that it swaps the arguments in some sense.

I'm pretty sure that now if a diagnostic is emitted after this swap, the 
argument indexes used to construct the diagnostic message would mismatch. I 
will dig into this later, probably refactor the whole function to make the 
intentions clear. What do you think? @NoQ 



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1578-1584
+  // FIXME(benics): Why do we choose the srcExpr if the access has no size?
+  //  Note that the 3rd argument of the call would be the size parameter.
+  SizeArgExpr SrcExprAsSizeDummy = {srcExpr.Expression, srcExpr.ArgumentIndex};
+  state = CheckOverlap(
+  C, state,
+  (IsBounded ? SizeArgExpr{CE->getArg(2), 2} : SrcExprAsSizeDummy), Dst,
+  srcExpr);

This part is really interesting.

Using strong types highlighted this particular code. Since `SizeArgExpr` is 
conceptually different than a `SourceArgExpr` this code did not compile without 
additional effort.

Previously it passed the `size` argument if it were given, but if the function 
were //unbounded// than it passed the `source` expression where `size` was 
expected, which does not make any sense.

Since I plan to refactor the whole cstring related functions, not just the 
`memset`, `memcpy` etc. I tried to leave it as it were, to preserve the current 
//(broken)// semantics of the function.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74806



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


[PATCH] D74564: libclang: Add static build support for Windows

2020-02-19 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

@mstorsjo can you help me with pushing this commit? Thank you in advance!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74564



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-19 Thread Stefanos Baziotis via Phabricator via cfe-commits
baziotis added a comment.

In D74801#1882155 , @lebedev.ri wrote:

> lg


Great! Just a note: I don't have commit access.


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

https://reviews.llvm.org/D74801



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


[PATCH] D74709: [clangd] Allow renaming class templates in cross-file rename.

2020-02-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

I think we might still give a warning of some sort that this is known to 
produce results that are not always correct. Otherwise it might feel like a 
bug/unknown behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74709



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


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

2020-02-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.
Herald added subscribers: martong, steakhal.

A few nits.




Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:93
+
+  bool IncludePath = false, ShouldEmitAsError = false, FixitsAsRemarks = false,
+   ApplyFixIts = false;

One variable per definition would result in a more readable code, IMO.



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:112
   void enableFixitsAsRemarks() { FixitsAsRemarks = true; }
+  void enableFixItApplication() { ApplyFixIts = true; }
 

nit: I'd suggest naming the method closer to the name of the corresponding 
field, e.g. `enableApplyFixIts`. Why isn't this `setApplyFixIts(bool)` btw?



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:154-155
+  if (llvm::Error Err = Repls.add(Repl)) {
+llvm::errs() << "An error occured during fix-it replacement:\n'"
+ << Repl.toString() << "'\nThe error message: '" << Err
+ << "'\n";

Cosmetics: I'd suggest to make the message less verbose. Specifically, to change

  An error occured during fix-it replacement:
 
  The error message: 

to

  Error applying replacement : 



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:198
+if (!applyAllReplacements(Repls, Rewrite)) {
+  llvm::errs() << "An error occured during applying fix-it 
replacements.\n";
+}

s/fix-it replacements/fix-it/


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

https://reviews.llvm.org/D69746



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


[PATCH] D72730: [clang-tidy] run-clang-tidy -export-fixes exports only fixes, not all warnings

2020-02-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D72730#1866043 , @AlexanderLanin 
wrote:

> On second thought maybe this should be fixed in clang-tidy and not here?
>  Maybe besides `-export-fixes` there should be an `-export-warnings` or just 
> `-yaml-export`?


I like the idea of introducing `-export-warnings` (to export warnings 
completely - with messages, notes, ranges and fixes) and changing 
`-export-fixes` to only export fixes.


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

https://reviews.llvm.org/D72730



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


[PATCH] D74562: [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

2020-02-19 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

I am done updating this patch.
I still don't have commit access, I'd appreciate it if you'd commit this for me 
when you get a chance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74562



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 245345.
djtodoro added a comment.

- Address the issue with ARM `describeLoadedValue()` (thanks to @vsk, I've 
reduced the test 
`llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir`)


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

https://reviews.llvm.org/D73534

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  lldb/packages/Python/lldbsuite/test/decorators.py
  
lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/TargetOptionsImpl.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
  llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
  llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
  llvm/test/CodeGen/ARM/smml.ll
  llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
  llvm/test/CodeGen/X86/call-site-info-output.ll
  llvm/test/CodeGen/X86/hoist-invariant-load.ll
  llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
  llvm/test/CodeGen/X86/statepoint-allocas.ll
  llvm/test/CodeGen/X86/tail-dup-repeat.ll
  llvm/test/CodeGen/X86/xray-custom-log.ll
  llvm/test/CodeGen/X86/xray-typed-event-log.ll
  llvm/test/DebugInfo/AArch64/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir
  llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
  llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
  llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
  llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
  llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
  llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
  llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
  llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
  llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
  llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
  llvm/test/DebugInfo/X86/dbg-value-range.ll
  llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
  llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
  llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
  llvm/test/DebugInfo/X86/loclists-dwp.ll
  llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll
  llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
  llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
  llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
  llvm/test/tools/llvm-locstats/locstats.ll

Index: llvm/test/tools/llvm-locs

[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread David Stenberg via Phabricator via cfe-commits
dstenb added a comment.

In D73534#1881353 , @nickdesaulniers 
wrote:

> As a heads up, Linaro's ToolChain Working Group's Linux kernel CI lit up on 
> this change. I see it's been reverted (thank you). Please cc me on the 
> updated patch and I can help test it against the Linux kernel.
>
> Edit: Link: 
> https://ci.linaro.org/job/tcwg_kernel-bisect-llvm-master-arm-mainline-allyesconfig/25/artifact/artifacts/build-a82d3e8a6e67473c94a5ce6345372748e9b61718/03-build_linux/console.log


Its hard to tell from the backtrace, but looking at the code, I think this 
might be a bug that sneaked in when I did D70431 
. Sorry if that is the case!

`ARMBaseInstrInfo::isAddImmediate()` does a `getReg()` without any `isReg()` 
guard:

  Optional ARMBaseInstrInfo::isAddImmediate(const MachineInstr &MI, 



 
Register Reg) const {   



 
  [...]
// TODO: Handle cases where Reg is a super- or sub-register of the  



 
// destination register.
if (Reg != MI.getOperand(0).getReg())
  return None;


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D73534#1882118 , @dstenb wrote:

> In D73534#1881353 , @nickdesaulniers 
> wrote:
>
> > As a heads up, Linaro's ToolChain Working Group's Linux kernel CI lit up on 
> > this change. I see it's been reverted (thank you). Please cc me on the 
> > updated patch and I can help test it against the Linux kernel.
> >
> > Edit: Link: 
> > https://ci.linaro.org/job/tcwg_kernel-bisect-llvm-master-arm-mainline-allyesconfig/25/artifact/artifacts/build-a82d3e8a6e67473c94a5ce6345372748e9b61718/03-build_linux/console.log
>
>
> Its hard to tell from the backtrace, but looking at the code, I think this 
> might be a bug that sneaked in when I did D70431 
> . Sorry if that is the case!
>
> `ARMBaseInstrInfo::isAddImmediate()` does a `getReg()` without any `isReg()` 
> guard:
>
>   Optional ARMBaseInstrInfo::isAddImmediate(const MachineInstr 
> &MI,  
>   
>   
> 
> Register Reg) const { 
>   
>   
>   
>  
>   [...]
> // TODO: Handle cases where Reg is a super- or sub-register of the
>   
>   
>   
>  
> // destination register.
> if (Reg != MI.getOperand(0).getReg())
>   return None;
>


@dstenb No problem, we have already addressed the issue. Thanks to @vsk and 
@nickdesaulniers! I'll update the patch.


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

https://reviews.llvm.org/D73534



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


[PATCH] D74829: [clang-rename] Add the USR of incomplete decl to the USRSet.

2020-02-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kbobyrev.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, ilya-biryukov.
Herald added a project: clang.

This fixes a clangd rename issue, which is missing the reference of
an incomplete specialization.

Unfortunately, I didn't reproduce this issue in clang-rename, I guess
the input `FoundDecl` of AdditionalUSRFinder is different in clangd vs
clang-rename, clang-rename uses the underlying CXXRecordDecl of the
ClassTemplateDecl, which is fixed in 
https://github.com/llvm/llvm-project/commit/5d862c042b52ae2aad37471d0b83b6c678a520e3;
while clangd-rename uses the ClassTemplateDecl.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74829

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp


Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -126,12 +126,14 @@
 addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
   }
 
-  void addUSRsOfCtorDtors(const CXXRecordDecl *RecordDecl) {
-RecordDecl = RecordDecl->getDefinition();
+  void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
+const auto* RecordDecl = RD->getDefinition();
 
 // Skip if the CXXRecordDecl doesn't have definition.
-if (!RecordDecl)
+if (!RecordDecl) {
+  USRSet.insert(getUSRForDecl(RD));
   return;
+}
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -202,6 +202,13 @@
 }
   )cpp",
 
+  // Incomplete class specializations
+  R"cpp(
+template 
+class [[Fo^o]] {};
+void func([[Foo]]);
+  )cpp",
+
   // Template class instantiations.
   R"cpp(
 template 


Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -126,12 +126,14 @@
 addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
   }
 
-  void addUSRsOfCtorDtors(const CXXRecordDecl *RecordDecl) {
-RecordDecl = RecordDecl->getDefinition();
+  void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
+const auto* RecordDecl = RD->getDefinition();
 
 // Skip if the CXXRecordDecl doesn't have definition.
-if (!RecordDecl)
+if (!RecordDecl) {
+  USRSet.insert(getUSRForDecl(RD));
   return;
+}
 
 for (const auto *CtorDecl : RecordDecl->ctors())
   USRSet.insert(getUSRForDecl(CtorDecl));
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -202,6 +202,13 @@
 }
   )cpp",
 
+  // Incomplete class specializations
+  R"cpp(
+template 
+class [[Fo^o]] {};
+void func([[Foo]]);
+  )cpp",
+
   // Template class instantiations.
   R"cpp(
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread David Stenberg via Phabricator via cfe-commits
dstenb added a comment.

In D73534#1882127 , @djtodoro wrote:

> @dstenb No problem, we have already addressed the issue. Thanks to @vsk and 
> @nickdesaulniers! I'll update the patch.


Great, thanks!


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

https://reviews.llvm.org/D73534



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


[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

2020-02-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, ilya-biryukov.
Herald added a project: clang.

libindex will canonicalize references to template instantiations:

- 1) reference to an explicit template specialization, report the 
specializatiion
- 2) otherwise, report the primary template

but 2) is not true for incomplete instantiations, this patch fixes this.

Fixes https://github.com/clangd/clangd/issues/287


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74830

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/test/Index/Core/index-instantiated-source.cpp
  clang/test/Index/Core/index-source.cpp

Index: clang/test/Index/Core/index-source.cpp
===
--- clang/test/Index/Core/index-source.cpp
+++ clang/test/Index/Core/index-source.cpp
@@ -321,7 +321,7 @@
 void functionSp, Record::C>() {
 // CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | __Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | rel: 1
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-5]]:50 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-6]]:42 | struct/C++ | Record | c:@S@Record |  | Ref,RelCont | rel: 1
@@ -332,7 +332,7 @@
 
 template<>
 class ClassWithCorrectSpecialization, Record::C> { };
-// CHECK: [[@LINE-1]]:38 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:38 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
 // CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 // CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,Read | rel: 0
 // CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record |  | Ref | rel: 0
@@ -505,7 +505,7 @@
 // CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t |  | Def,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
 Guided(double) -> Guided;
-// CHECK: [[@LINE-1]]:19 | struct(Gen,TS)/C++ | Guided | c:@S@Guided>#f |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 auto guided = Guided{1.0};
 // CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0
Index: clang/test/Index/Core/index-instantiated-source.cpp
===
--- clang/test/Index/Core/index-instantiated-source.cpp
+++ clang/test/Index/Core/index-instantiated-source.cpp
@@ -86,3 +86,25 @@
   (void)TT::NestedType::Enum::EnumCase;
 // CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
 }
+
+namespace index_specialization {
+template
+class Foo {};
+
+// if there are no explicit template specializations provided, report the
+// primary templates.
+Foo* t1; // incomplete instantiation.
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+Foo t2;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+
+template
+class Bar {};
+template<>
+class Bar {};
+// report the explicit template specialization if it exists.
+Bar* t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#I |  | Ref,RelCont | rel: 1
+}
Index: clang/lib/Index/IndexingContext.cpp
===
--- clang/lib/Index/IndexingContext.cpp
+++ clang/lib/Index/IndexingContext.cpp
@@ -167,6 +167,13 @@
 if (const auto *Parent = dyn_cast(D->getDeclContext()))
   return isTemplateImplicitInstantiation(Parent);
   }
+
+  // Incomplete template specialization is not instantiated, we still treat it
+  // as an instantiation as we'd like to keep the canonicalized result
+  // consistent.
+  if (TKind == TSK_Undeclared)
+return dyn_cast(D);
+
   switch (TKind) {
 case TSK_Undeclared:
 case TSK_ExplicitSpecialization:
@@ -206,6 +213,9 @@
 static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) {
   if (const ClassTemplateSpecializationDecl *
   SD = dyn_cast(D)) {
+// Fallback to primary template if this is an incomplete specialization.
+if (SD->getTemplateSpecializatio

[clang] 81e8b60 - [OpenCL] Only declare _sat conversions for integer types

2020-02-19 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-02-19T13:52:58Z
New Revision: 81e8b60b722e5494cb92b6b4ec03d4631028eece

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

LOG: [OpenCL] Only declare _sat conversions for integer types

The `-fdeclare-opencl-builtins` option was accepting saturated
conversions for non-integer types, which contradicts both the OpenCL
specification (v2.0 s6.2.3) and Clang's opencl-c.h file.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index f0790dd32527..f79bb54a8143 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -378,7 +378,11 @@ foreach RType = [Float, Double, Half, Char, UChar, Short,
  UShort, Int, UInt, Long, ULong] in {
   foreach IType = [Float, Double, Half, Char, UChar, Short,
UShort, Int, UInt, Long, ULong] in {
-foreach sat = ["", "_sat"] in {
+// Conversions to integer type have a sat and non-sat variant.
+foreach sat = !cond(!eq(RType.Name, "float") : [""],
+!eq(RType.Name, "double") : [""],
+!eq(RType.Name, "half") : [""],
+1 : ["", "_sat"]) in {
   foreach rnd = ["", "_rte", "_rtn", "_rtp", "_rtz"] in {
 def : Builtin<"convert_" # RType.Name # sat # rnd, [RType, IType],
   Attr.Const>;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index dd89f40761c0..e593b21ec459 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -71,11 +71,25 @@ kernel void basic_conversion() {
   int4 i4;
 
   f = convert_float(d);
-  d = convert_double_sat_rtp(f);
+  d = convert_double_rtp(f);
   l2 = convert_long2_rtz(c2);
   i4 = convert_int4_sat(f4);
 }
 
+kernel void basic_conversion_neg() {
+  int i;
+  float f;
+
+  f = convert_float_sat(i);
+#if !defined(__OPENCL_CPP_VERSION__)
+  // expected-error@-2{{implicit declaration of function 'convert_float_sat' 
is invalid in OpenCL}}
+  // expected-error@-3{{implicit conversion from 'int' to 'float' may lose 
precision}}
+#else
+  // expected-error@-5{{use of undeclared identifier 'convert_float_sat'; did 
you mean 'convert_float'?}}
+  // expected-note@-6{{'convert_float' declared here}}
+#endif
+}
+
 char4 test_int(char c, char4 c4) {
   char m = max(c, c);
   char4 m4 = max(c4, c4);



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


[PATCH] D74833: [AArch64][SVE] Add intrinsics for SVE2 cryptographic instructions

2020-02-19 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, c-rhodes, dancgr, cameron.mcinally, 
efriedma.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Implements the following SVE2 intrinsics:

- @llvm.aarch64.sve.aesd
- @llvm.aarch64.sve.aesimc
- @llvm.aarch64.sve.aese
- @llvm.aarch64.sve.aesmc
- @llvm.aarch64.sve.rax1
- @llvm.aarch64.sve.sm4e
- @llvm.aarch64.sve.sm4ekey


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74833

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-crypto.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-crypto.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-crypto.ll
@@ -0,0 +1,99 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2-aes,+sve2-sha3,+sve2-sm4 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; AESD
+;
+
+define  @aesd_i8( %a,  %b) {
+; CHECK-LABEL: aesd_i8:
+; CHECK: aesd z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aesd( %a,
+ %b)
+  ret  %out
+}
+
+;
+; AESIMC
+;
+
+define  @aesimc_i8( %a) {
+; CHECK-LABEL: aesimc_i8:
+; CHECK: aesimc z0.b, z0.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aesimc( %a)
+  ret  %out
+}
+
+;
+; AESE
+;
+
+define  @aese_i8( %a,  %b) {
+; CHECK-LABEL: aese_i8:
+; CHECK: aese z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aese( %a,
+ %b)
+  ret  %out
+}
+
+;
+; AESMC
+;
+
+define  @aesmc_i8( %a) {
+; CHECK-LABEL: aesmc_i8:
+; CHECK: aesmc z0.b, z0.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aesmc( %a)
+  ret  %out
+}
+
+;
+; RAX1
+;
+
+define  @rax1_i64( %a,  %b) {
+; CHECK-LABEL: rax1_i64:
+; CHECK: rax1 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.rax1( %a,
+ %b)
+  ret  %out
+}
+
+;
+; SM4E
+;
+
+define  @sm4e_i32( %a,  %b) {
+; CHECK-LABEL: sm4e_i32:
+; CHECK: sm4e z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sm4e( %a,
+ %b)
+  ret  %out
+}
+
+;
+; SM4EKEY
+;
+
+define  @sm4ekey_i32( %a,  %b) {
+; CHECK-LABEL: sm4ekey_i32:
+; CHECK: sm4ekey z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sm4ekey( %a,
+%b)
+  ret  %out
+}
+
+
+declare  @llvm.aarch64.sve.aesd(, )
+declare  @llvm.aarch64.sve.aesimc()
+declare  @llvm.aarch64.sve.aese(, )
+declare  @llvm.aarch64.sve.aesmc()
+declare  @llvm.aarch64.sve.rax1(, )
+declare  @llvm.aarch64.sve.sm4e(, )
+declare  @llvm.aarch64.sve.sm4ekey(, )
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -7024,6 +7024,12 @@
   let Inst{4-0}   = Zd;
 }
 
+multiclass sve2_crypto_cons_bin_op {
+  def NAME : sve2_crypto_cons_bin_op;
+  def : SVE_2_Op_Pat(NAME)>;
+}
+
 class sve2_crypto_des_bin_op opc, string asm, ZPRRegOp zprty>
 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm),
   asm, "\t$Zdn, $_Zdn, $Zm",
@@ -7041,8 +7047,14 @@
   let Constraints = "$Zdn = $_Zdn";
 }
 
-class sve2_crypto_unary_op
-: I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn),
+multiclass sve2_crypto_des_bin_op opc, string asm, ZPRRegOp zprty,
+  SDPatternOperator op, ValueType vt> {
+  def NAME : sve2_crypto_des_bin_op;
+  def : SVE_2_Op_Pat(NAME)>;
+}
+
+class sve2_crypto_unary_op
+: I<(outs zprty:$Zdn), (ins zprty:$_Zdn),
   asm, "\t$Zdn, $_Zdn",
   "",
   []>, Sched<[]> {
@@ -7054,3 +7066,8 @@
 
   let Constraints = "$Zdn = $_Zdn";
 }
+
+multiclass sve2_crypto_unary_op {
+  def NAME : sve2_crypto_unary_op;
+  def : SVE_1_Op_Pat(NAME)>;
+}
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1801,12 +1801,12 @@
 
 let Predicates = [HasSVE2AES] in {
   // SVE2 crypto destructive binary operations
-  def AESE_ZZZ_B : sve2_crypto_des_bin_op<0b00, "aese", ZPR8>;
-  def AESD_ZZZ_B : sve2_crypto_des_bin_op<0b01, "aesd", ZPR8>;
+  defm AESE_ZZZ_B : sve2_crypto_des_bin_op<0b00, "aese", ZPR8, int_aarch64_sve_aese, nxv16i8>;
+  defm AESD_ZZZ_B : sve2_crypto_des_bin_op<0b01, "aesd", ZPR8, int_aarch64_sve_aesd, nxv16i8>;
 
   // SVE2 crypto unary operations
-  def AESMC_ZZ_B  : sve2_crypto_unary_op<0b0, "aesmc">;
-  def AESIMC_ZZ_B : sve2_crypto_unary_op<0b1, "aesimc">;
+  defm AESMC_ZZ_B  : sve2_crypto_unary_op<0b0, "aesmc", 

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-02-19 Thread Thibault North via Phabricator via cfe-commits
tnorth added a comment.

Ping. I guess we need more approval to go forward?


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[PATCH] D74834: [clangd] Expose the rename LimitFiles option to the C++ API, NFC.

2020-02-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74834

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -714,8 +714,13 @@
   TestTU TU = TestTU::withCode(MainCode.code());
   auto AST = TU.build();
   llvm::StringRef NewName = "newName";
-  auto Results = rename({MainCode.point(), NewName, AST, MainFilePath,
- Index.get(), /*CrossFile=*/true, GetDirtyBuffer});
+  auto Results = rename({MainCode.point(),
+ NewName,
+ AST,
+ MainFilePath,
+ Index.get(),
+ {/*CrossFile=*/true},
+ GetDirtyBuffer});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(*Results)),
@@ -730,8 +735,13 @@
   // Set a file "bar.cc" on disk.
   TU.AdditionalFiles["bar.cc"] = std::string(BarCode.code());
   AST = TU.build();
-  Results = rename({MainCode.point(), NewName, AST, MainFilePath, Index.get(),
-/*CrossFile=*/true, GetDirtyBuffer});
+  Results = rename({MainCode.point(),
+NewName,
+AST,
+MainFilePath,
+Index.get(),
+{/*CrossFile=*/true},
+GetDirtyBuffer});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(*Results)),
@@ -761,8 +771,13 @@
Callback) const override {}
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
-  Results = rename({MainCode.point(), NewName, AST, MainFilePath, &PIndex,
-/*CrossFile=*/true, GetDirtyBuffer});
+  Results = rename({MainCode.point(),
+NewName,
+AST,
+MainFilePath,
+&PIndex,
+{/*CrossFile=*/true},
+GetDirtyBuffer});
   EXPECT_FALSE(Results);
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("too many occurrences"));
@@ -803,9 +818,12 @@
 
 RefsRequest *Out;
   } RIndex(&Req);
-  auto Results =
-  rename({MainCode.point(), "NewName", AST, testPath("main.cc"), &RIndex,
-  /*CrossFile=*/true});
+  auto Results = rename({MainCode.point(),
+ "NewName",
+ AST,
+ testPath("main.cc"),
+ &RIndex,
+ {/*CrossFile=*/true}});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   const auto HeaderSymbols = TU.headerSymbols();
   EXPECT_THAT(Req.IDs,
@@ -850,8 +868,9 @@
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
   llvm::StringRef NewName = "newName";
-  auto Results = rename({MainCode.point(), NewName, AST, MainFilePath, &DIndex,
- /*CrossFile=*/true});
+  RenameOptions RenameOpts{true, 50};
+  auto Results = rename(
+  {MainCode.point(), NewName, AST, MainFilePath, &DIndex, RenameOpts});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(*Results)),
@@ -1021,7 +1040,7 @@
 FS.Files[FooCCPath] = std::string(FooCC.code());
 
 auto ServerOpts = ClangdServer::optsForTest();
-ServerOpts.CrossFileRename = true;
+ServerOpts.RenameOpts.AllowCrossFile = true;
 ServerOpts.BuildDynamicSymbolIndex = true;
 ClangdServer Server(CDB, FS, ServerOpts);
 
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -628,7 +628,7 @@
   }
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;
-  Opts.CrossFileRename = CrossFileRename;
+  Opts.RenameOpts.AllowCrossFile = CrossFileRename;
 
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -26,6 +26,14 @@
 using DirtyBufferGetter =
 llvm::function_ref(PathRef AbsPath)>;
 
+struct RenameOptions {
+  boo

[PATCH] D68578: [HIP] Fix device stub name

2020-02-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/GlobalDecl.h:40
+  Stub = 1,
+};
+

tra wrote:
> rjmccall wrote:
> > tra wrote:
> > > rjmccall wrote:
> > > > The attribute here is `CUDAGlobalAttr`; should this be named in terms 
> > > > of CUDA, or is the CUDA model sufficiently different  from HIP that the 
> > > > same implementation concept doesn't apply?
> > > I believe the attribute serves the same purpose in both CUDA and HIP and 
> > > could be renamed appropriately in a separate patch.
> > > 
> > > While the changes in this patch are not required for CUDA, CUDA would 
> > > benefit from them. We could use a generic GPU prefix and migrate CUDA to 
> > > the same model later. A TODO comment about that would be nice. 
> > I'd just like consistency.  If they're serving the same purpose, then as 
> > someone with no dog in this fight, I would give precedence to CUDA over HIP 
> > in names since it's both the older language and was implemented first in 
> > Clang (even if only partially, IIUC).  I don't think a generic name works 
> > unless we can meaningfully generalize it to all languages with a similar 
> > feature, e.g. OpenCL and so on.
> Naming, the hardest problem in computer science. :-)
> I personally would prefer generalization-with-exclusions over specific name 
> which is inconsistently commingles things that's really specific to that name 
> and things that are more widely used. Alas, right now CUDA is the example of 
> the latter case -- some parts are CUDA-specific and a lot are shared with HIP.
> 
> For the new features we've been sort of sticking with using CUDA/HIP for 
> specific parts and GPU for shared functionality, but as things are a lot of 
> shared bits are still 'CUDA' and it's hard to tell them apart. As you point 
> it out, renaming the incumbent names would be a pain, so here we are.
> 
> I think using `GPUKernelKind` with a comment that it reflects HIP & CUDA 
> kernels would be somewhat better choice than `CUDAKernelKind` which would be 
> somewhat confusing at this point given that CUDA actually does not use it 
> yet. I'm also fine with keeping it `HIPKernelKind` and postpone the naming 
> decision until CUDA-related parts are actually implemented.
Maybe `KernelReferenceKind`?  It's probably a common concept across all 
heterogenous-computing models.


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

https://reviews.llvm.org/D68578



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  Can we raise this with the kernel folks instead of just assuming they'll 
be opposed?  An obvious patch to fix a few dozen places where they're hit by a 
warning they intentionally enabled really doesn't seem like a burden.  If they 
push back, fine, we can enable the warning without covering enums.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74116: [Sema][C++] Propagate conversion type in order to specialize the diagnostics

2020-02-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:14829
+if (getLangOpts().CPlusPlus)
+  isInvalid = true;
 break;

Could you hoist this up to the place where we pick the diagnostic and then make 
it unconditional in the path that always selects an error?

That's a general comment: we should be setting `isInvalid` for all the places 
below where we select an error diagnostic.


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

https://reviews.llvm.org/D74116



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-02-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.
Herald added a subscriber: martong.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D74838: [ARM,MVE] Fix predicate types of some intrinsics

2020-02-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

Some predicated MVE intrinsics return a vector with element size
different from the input vector element size. In this case the
predicate must type correspond to the output vector type.

The following intrinsics use the incorrect predicate type:

- llvm.arm.mve.mull.int.predicated
- llvm.arm.mve.mull.poly.predicated
- llvm.arm.mve.vshll.imm.predicated

This patch fixes the issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74838

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vector-shift-imm.c
  clang/test/CodeGen/arm-mve-intrinsics/vmullbq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmulltq.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vector-shift-imm.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmullbq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll
@@ -59,14 +59,14 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
-  %2 = tail call <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, i32 0, i32 1, <16 x i1> %1, <8 x i16> %inactive)
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v8i1(<16 x i8> %a, <16 x i8> %b, i32 0, i32 1, <8 x i1> %1, <8 x i16> %inactive)
   ret <8 x i16> %2
 }
 
-declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #1
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #1
 
-declare <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, i32, <16 x i1>, <8 x i16>) #1
+declare <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v8i1(<16 x i8>, <16 x i8>, i32, i32, <8 x i1>, <8 x i16>) #1
 
 define arm_aapcs_vfpcc <4 x i32> @test_vmulltq_int_m_u16(<4 x i32> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #0 {
 ; CHECK-LABEL: test_vmulltq_int_m_u16:
@@ -77,14 +77,14 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
-  %2 = tail call <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, i32 1, i32 1, <8 x i1> %1, <4 x i32> %inactive)
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v4i1(<8 x i16> %a, <8 x i16> %b, i32 1, i32 1, <4 x i1> %1, <4 x i32> %inactive)
   ret <4 x i32> %2
 }
 
-declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #1
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #1
 
-declare <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v8i1(<8 x i16>, <8 x i16>, i32, i32, <8 x i1>, <4 x i32>) #1
+declare <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v4i1(<8 x i16>, <8 x i16>, i32, i32, <4 x i1>, <4 x i32>) #1
 
 define arm_aapcs_vfpcc <2 x i64> @test_vmulltq_int_m_s32(<2 x i64> %inactive, <4 x i32> %a, <4 x i32> %b, i16 zeroext %p) local_unnamed_addr #0 {
 ; CHECK-LABEL: test_vmulltq_int_m_s32:
@@ -100,8 +100,6 @@
   ret <2 x i64> %2
 }
 
-declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #1
-
 declare <2 x i64> @llvm.arm.mve.mull.int.predicated.v2i64.v4i32.v4i1(<4 x i32>, <4 x i32>, i32, i32, <4 x i1>, <2 x i64>) #1
 
 define arm_aapcs_vfpcc <8 x i16> @test_vmulltq_poly_m_p8(<8 x i16> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #0 {
@@ -113,12 +111,12 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
-  %2 = tail call <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, i32 1, <16 x i1> %1, <8 x i16> %inactive)
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v8i1(<16 x i8> %a, <16 x i8> %b, i32 1, <8 x i1> %1, <8 x i16> %inactive)
   ret <8 x i16> %2
 }
 
-declare <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, <16 x i1>, <8 x i16>) #1
+declare <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v8i1(<16 x i8>, <16 x i8>, i32, <8 x i1>, <8 x i16>) #1
 
 define arm_aapcs_vfpcc <8 x i16> @test_vmulltq_int_x_u8(<16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #0 {
 ; CHECK-LABEL: test_vmulltq_int_x_u8:
@@ -129,8 +127,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <16 x i1> @llvm.arm.mve

[PATCH] D74838: [ARM,MVE] Fix predicate types of some intrinsics

2020-02-19 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM added a comment.

Nice catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74838



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


[PATCH] D74840: [AST matchers] Add basic matchers for googletest EXPECT/ASSERT calls.

2020-02-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr2.
Herald added a subscriber: mgorny.
Herald added a project: clang.

This revision adds matchers that match calls to the gtest EXPECT and ASSERT
macros almost like function calls. The matchers are placed in separate files
(GtestMatchers...), because they are specific to the gtest library.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74840

Files:
  clang/include/clang/ASTMatchers/GtestMatchers.h
  clang/lib/ASTMatchers/CMakeLists.txt
  clang/lib/ASTMatchers/GtestMatchers.cpp
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/GtestMatchersTest.cpp

Index: clang/unittests/ASTMatchers/GtestMatchersTest.cpp
===
--- /dev/null
+++ clang/unittests/ASTMatchers/GtestMatchersTest.cpp
@@ -0,0 +1,191 @@
+//===- unittests/ASTMatchers/GTestMatchersTest.cpp - GTest matcher unit tests //
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ASTMatchersTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/GtestMatchers.h"
+
+namespace clang {
+namespace ast_matchers {
+
+constexpr llvm::StringLiteral GtestMockDecls = R"cc(
+  static int testerr;
+
+#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+switch (0)  \
+case 0: \
+default:  // NOLINT
+
+#define GTEST_NONFATAL_FAILURE_(code) testerr = code
+
+#define GTEST_FATAL_FAILURE_(code) testerr = code
+
+#define GTEST_ASSERT_(expression, on_failure) \
+GTEST_AMBIGUOUS_ELSE_BLOCKER_   \
+if (const int gtest_ar = (expression))  \
+  ; \
+else\
+  on_failure(gtest_ar)
+
+  // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
+  // Don't use this in your code.
+#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure) \
+GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
+
+#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
+GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
+#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
+GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
+
+#define EXPECT_EQ(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
+#define EXPECT_NE(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
+#define EXPECT_GE(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
+#define EXPECT_GT(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
+#define EXPECT_LE(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
+#define EXPECT_LT(val1, val2) \
+EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
+
+#define ASSERT_EQ(val1, val2) \
+ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
+#define ASSERT_NE(val1, val2) \
+ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
+
+  namespace testing {
+  namespace internal {
+  class EqHelper {
+   public:
+// This templatized version is for the general case.
+template 
+static int Compare(const char* lhs_expression, const char* rhs_expression,
+   const T1& lhs, const T2& rhs) {
+  return 0;
+}
+  };
+  template 
+  int CmpHelperNE(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperGE(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperGT(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperLE(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  template 
+  int CmpHelperLT(const char* expr1, const char* expr2, const T1& val1,
+  const T2& val2) {
+return 0;
+  }
+  }  // namespace internal
+  }  // namespace testing
+)cc";
+
+static std::string wrapGtest(llvm::StringRef Input) {
+  return (GtestMockDecls + Input).str();
+}
+
+TEST(GtestAssertTest, ShouldMatchAssert) {
+  std::string Input = R"cc(
+void Test() { ASSERT_EQ(1010, 4321); }
+  )cc";
+  EXPECT_TRUE(matches(wrapGtest(Input),
+  gtestAssert(GtestCmp::Eq, integerLiteral(equals(1010)),
+  integerLiteral(equals(4321);
+}
+
+TEST(GtestAssertTest, ShouldNotMatchExpect) {
+  std::string Input = R"cc(
+void Test() { EXPECT_EQ(2,

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-02-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: include/clang/Format/Format.h:2341
 /// directory if ``FileName`` is empty.
+/// * "file=" to explicitly specify the configuration file to use.
 ///

So is it `:` or `=`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-02-19 Thread Vedant Kumar via Phabricator via cfe-commits
vsk edited reviewers, added: ahatanak, erik.pilkington, dexonsmith; removed: 
vsk.
vsk added a comment.

At a high level the idea sounds good to me. For out OSes, symbol name 
instability results in serious performance regressions as this invalidates 
text/data orderfiles. Why shouldn’t this be on by default?

Also, could you add tests to cover this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74813



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


[PATCH] D71092: [VFS] More consistent support for Windows

2020-02-19 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth closed this revision.
amccarth added a comment.

This landed in da45bd232165eab5d6ec4f1f4f18db8644289142 


It wasn't automatically closed because I misspelled "Differential Revision."


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

https://reviews.llvm.org/D71092



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


[PATCH] D74838: [ARM,MVE] Fix predicate types of some intrinsics

2020-02-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

The test failure is unrelated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74838



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


[clang] 461fd94 - [ARM,MVE] Fix predicate types of some intrinsics

2020-02-19 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-02-19T16:24:54Z
New Revision: 461fd94f004c78374fc7b0338d018f9610f2e5f5

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

LOG: [ARM,MVE] Fix predicate types of some intrinsics

Summary:
Some predicated MVE intrinsics return a vector with element size
different from the input vector element size. In this case the
predicate must type correspond to the output vector type.

The following intrinsics use the incorrect predicate type:
* llvm.arm.mve.mull.int.predicated
* llvm.arm.mve.mull.poly.predicated
* llvm.arm.mve.vshll.imm.predicated

This patch fixes the issue.

Reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM

Reviewed By: MarkMurrayARM

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
clang/test/CodeGen/arm-mve-intrinsics/vector-shift-imm.c
clang/test/CodeGen/arm-mve-intrinsics/vmullbq.c
clang/test/CodeGen/arm-mve-intrinsics/vmulltq.c
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/test/CodeGen/Thumb2/mve-intrinsics/vector-shift-imm.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmullbq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 45cd1fb28605..bfb49864922f 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -332,8 +332,8 @@ let params = T.Usual in {
 
 multiclass DblVectorVectorArithmetic {
   defm "" : IntrinsicMX<
-  DblVector, (args Vector:$a, Vector:$b, Predicate:$pred),
-  !con((IRInt $a, $b),
+  DblVector, (args Vector:$a, Vector:$b, DblPredicate:$pred),
+  !con((IRInt $a, $b),
extraArgs, (? $pred, $inactive))>;
 }
 
@@ -881,8 +881,8 @@ multiclass vshll_imm {
 (IRInt<"vshll_imm", [DblVector, Vector]>
 $v, $sh, (unsignedflag Scalar), top)>;
 defm "": IntrinsicMX
+  DblPredicate:$pred),
+(IRInt<"vshll_imm_predicated", [DblVector, Vector, DblPredicate]>
 $v, $sh, (unsignedflag Scalar), top, $pred, $inactive), 1, "_n">;
   }
 }

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index 7f8f717e8163..776dc9c73da4 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -318,9 +318,11 @@ def SScalar: Signed;
 def SVector: VecOf;
 
 // DblVector expands to a vector of scalars of size twice the size of Scalar.
+// DblPredicate expands to a predicate corresponding to DblVector
 // HalfVector, similarly, expands to a vector of half-sized scalars. And
 // UHalfVector is a vector of half-sized _unsigned integers_.
 def DblVector: VecOf>;
+def DblPredicate: PredOf>;
 def HalfVector: VecOf>;
 def UHalfVector: VecOf>>;
 

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vector-shift-imm.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vector-shift-imm.c
index 2128d0801c6a..e86f78b659c0 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/vector-shift-imm.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vector-shift-imm.c
@@ -1382,8 +1382,8 @@ uint32x4_t test_vshlltq_n_u16(uint16x8_t a)
 // CHECK-LABEL: @test_vshllbq_m_n_s8(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
-// CHECK-NEXT:[[TMP1:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
-// CHECK-NEXT:[[TMP2:%.*]] = call <8 x i16> 
@llvm.arm.mve.vshll.imm.predicated.v8i16.v16i8.v16i1(<16 x i8> [[A:%.*]], i32 
6, i32 0, i32 0, <16 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <8 x i16> 
@llvm.arm.mve.vshll.imm.predicated.v8i16.v16i8.v8i1(<16 x i8> [[A:%.*]], i32 6, 
i32 0, i32 0, <8 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
 // CHECK-NEXT:ret <8 x i16> [[TMP2]]
 //
 int16x8_t test_vshllbq_m_n_s8(int16x8_t inactive, int8x16_t a, mve_pred16_t p)
@@ -1398,8 +1398,8 @@ int16x8_t test_vshllbq_m_n_s8(int16x8_t inactive, 
int8x16_t a, mve_pred16_t p)
 // CHECK-LABEL: @test_vshllbq_m_n_s16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
-// CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
-// CHECK-NEXT:[[TMP2:%.*]] = call <4 x i32> 
@llvm.arm.mve.vshll.imm.predicated.v4i32.v8i16.v8i1(<8 x i16> [[A:%.*]], i32 
10, i32 0, i32 0, <8 x i1> [[TMP1]], <4 x i32> [[INACTIVE:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 
[[

[PATCH] D74838: [ARM,MVE] Fix predicate types of some intrinsics

2020-02-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG461fd94f004c: [ARM,MVE] Fix predicate types of some 
intrinsics (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74838

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vector-shift-imm.c
  clang/test/CodeGen/arm-mve-intrinsics/vmullbq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmulltq.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vector-shift-imm.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmullbq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulltq.ll
@@ -59,14 +59,14 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
-  %2 = tail call <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, i32 0, i32 1, <16 x i1> %1, <8 x i16> %inactive)
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v8i1(<16 x i8> %a, <16 x i8> %b, i32 0, i32 1, <8 x i1> %1, <8 x i16> %inactive)
   ret <8 x i16> %2
 }
 
-declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #1
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #1
 
-declare <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, i32, <16 x i1>, <8 x i16>) #1
+declare <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v8i1(<16 x i8>, <16 x i8>, i32, i32, <8 x i1>, <8 x i16>) #1
 
 define arm_aapcs_vfpcc <4 x i32> @test_vmulltq_int_m_u16(<4 x i32> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #0 {
 ; CHECK-LABEL: test_vmulltq_int_m_u16:
@@ -77,14 +77,14 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
-  %2 = tail call <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, i32 1, i32 1, <8 x i1> %1, <4 x i32> %inactive)
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v4i1(<8 x i16> %a, <8 x i16> %b, i32 1, i32 1, <4 x i1> %1, <4 x i32> %inactive)
   ret <4 x i32> %2
 }
 
-declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #1
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #1
 
-declare <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v8i1(<8 x i16>, <8 x i16>, i32, i32, <8 x i1>, <4 x i32>) #1
+declare <4 x i32> @llvm.arm.mve.mull.int.predicated.v4i32.v8i16.v4i1(<8 x i16>, <8 x i16>, i32, i32, <4 x i1>, <4 x i32>) #1
 
 define arm_aapcs_vfpcc <2 x i64> @test_vmulltq_int_m_s32(<2 x i64> %inactive, <4 x i32> %a, <4 x i32> %b, i16 zeroext %p) local_unnamed_addr #0 {
 ; CHECK-LABEL: test_vmulltq_int_m_s32:
@@ -100,8 +100,6 @@
   ret <2 x i64> %2
 }
 
-declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #1
-
 declare <2 x i64> @llvm.arm.mve.mull.int.predicated.v2i64.v4i32.v4i1(<4 x i32>, <4 x i32>, i32, i32, <4 x i1>, <2 x i64>) #1
 
 define arm_aapcs_vfpcc <8 x i16> @test_vmulltq_poly_m_p8(<8 x i16> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #0 {
@@ -113,12 +111,12 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
-  %2 = tail call <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, i32 1, <16 x i1> %1, <8 x i16> %inactive)
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v8i1(<16 x i8> %a, <16 x i8> %b, i32 1, <8 x i1> %1, <8 x i16> %inactive)
   ret <8 x i16> %2
 }
 
-declare <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, <16 x i1>, <8 x i16>) #1
+declare <8 x i16> @llvm.arm.mve.mull.poly.predicated.v8i16.v16i8.v8i1(<16 x i8>, <16 x i8>, i32, <8 x i1>, <8 x i16>) #1
 
 define arm_aapcs_vfpcc <8 x i16> @test_vmulltq_int_x_u8(<16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #0 {
 ; CHECK-LABEL: test_vmulltq_int_x_u8:
@@ -129,8 +127,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %0 = zext i16 %p to i32
-  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
-  %2 = tail call <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, i32 1, i32 1, <16 x i1> %1, <8 x i16> undef)
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.mull.int.predicated.v8i16.v16i8.v8i1(<16 x i8> %a, <16 x i8> %b, i32 1, i32 

[PATCH] D74790: [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 245415.
dgoldman added a comment.

- Fixes for Sam's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74790

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/included-symlinks.cpp


Index: clang/test/CodeCompletion/included-symlinks.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/included-symlinks.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t && mkdir -p %t/real/myproj && mkdir -p %t/links
+// RUN: touch %t/real/foo.h && ln -s %t/real/foo.h %t/links/foo.h
+// RUN: touch %t/real/foobar.h && ln -s %t/real/foobar.h %t/links/foobar.h
+// RUN: touch %t/real/myproj/test.h && ln -s %t/real/myproj %t/links/myproj
+
+// Suggest symlinked header files.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:7:13 %s 
| FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo.h"
+// CHECK-1: foobar.h"
+
+// Suggest symlinked folder.
+#include "mypr"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:13:13 
%s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: myproj/
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,16 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // To know whether a symlink should be treated as file or a directory, we
+  // have to stat it. This should be cheap enough as there shouldn't be 
many
+  // symlinks.
+  llvm::sys::fs::file_type Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+if (auto FileStatus = FS.status(It->path()))
+  Type = FileStatus->getType();
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" 
suffix,
 // but the suffix does not appear in the source code's include/import.


Index: clang/test/CodeCompletion/included-symlinks.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/included-symlinks.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t && mkdir -p %t/real/myproj && mkdir -p %t/links
+// RUN: touch %t/real/foo.h && ln -s %t/real/foo.h %t/links/foo.h
+// RUN: touch %t/real/foobar.h && ln -s %t/real/foobar.h %t/links/foobar.h
+// RUN: touch %t/real/myproj/test.h && ln -s %t/real/myproj %t/links/myproj
+
+// Suggest symlinked header files.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:7:13 %s | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo.h"
+// CHECK-1: foobar.h"
+
+// Suggest symlinked folder.
+#include "mypr"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:13:13 %s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: myproj/
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,16 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // To know whether a symlink should be treated as file or a directory, we
+  // have to stat it. This should be cheap enough as there shouldn't be many
+  // symlinks.
+  llvm::sys::fs::file_type Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+if (auto FileStatus = FS.status(It->path()))
+  Type = FileStatus->getType();
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" suffix,
 // but the suffix does not appear in the source code's include/import.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D73916#1881396 , @nridge wrote:

> Which client(s) use or plan to use this extension?


SourceKit-LSP https://github.com/apple/sourcekit-lsp/pull/242


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916



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


[PATCH] D74790: [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked 3 inline comments as done.
dgoldman added a comment.

In D74790#1881827 , @sammccall wrote:

> Thanks! I can't see this being a performance problem (famous last words...)


Technically it is capped at 2500 symlinks =) fingers crossed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74790



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


[PATCH] D74811: [Driver] Escape the program path for -frecord-command-line

2020-02-19 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

This LGTM, but could you add a simple test with a command-line that needs the 
escaping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74811



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


[PATCH] D74842: [clangd] Make use of syntax tokens in ReplayPreamble

2020-02-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Replace usage of RawLexer with syntax tokens inside ReplayPreamble.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74842

Files:
  clang-tools-extra/clangd/ParsedAST.cpp


Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -134,8 +134,9 @@
   ReplayPreamble(const IncludeStructure &Includes, PPCallbacks *Delegate,
  const SourceManager &SM, Preprocessor &PP,
  const LangOptions &LangOpts)
-  : Includes(Includes), Delegate(Delegate), SM(SM), PP(PP),
-LangOpts(LangOpts) {}
+  : Includes(Includes), Delegate(Delegate), SM(SM), PP(PP) {
+MainFileTokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  }
 
   // In a normal compile, the preamble traverses the following structure:
   //
@@ -167,29 +168,50 @@
 if (auto FE = SM.getFileManager().getFile(Inc.Resolved))
   File = *FE;
 
+  // Re-lex the #include directive to find its interesting parts.
+  auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset)
+ .getRawEncoding();
+  auto HashTok =
+  llvm::find_if(MainFileTokens, [&HashLoc](const syntax::Token &T) {
+return T.location().getRawEncoding() == HashLoc;
+  });
+  assert(HashTok != MainFileTokens.end() && HashTok->kind() == tok::hash);
+
+  auto IncTok = std::next(HashTok);
+  assert(IncTok != MainFileTokens.end());
+
+  auto FileTok = std::next(IncTok);
+  assert(FileTok != MainFileTokens.end());
+
+  // We imitate the PP logic here, except clang::Token::Flags, none of the
+  // callers seem to care about it (yet).
+  Token IncludeTok;
+  IncludeTok.startToken();
+  IncludeTok.setLocation(IncTok->location());
+  IncludeTok.setLength(IncTok->length());
+  IncludeTok.setKind(tok::raw_identifier);
+  IncludeTok.setRawIdentifierData(IncTok->text(SM).data());
+  PP.LookUpIdentifierInfo(IncludeTok);
+
+  // Again we imitate PP logic here, except clang::Token::Flags.
+  Token FilenameTok;
+  FilenameTok.startToken();
+  FilenameTok.setLocation(FileTok->location());
+  // Note that we can't make use of FileTok->length/text in here as in the
+  // case of angled includes this will contain tok::less instead of
+  // filename. Whereas Inc.Written contains the full header name including
+  // quotes/angles.
+  FilenameTok.setLength(Inc.Written.length());
+  FilenameTok.setKind(tok::header_name);
+  FilenameTok.setLiteralData(Inc.Written.data());
+
   llvm::StringRef WrittenFilename =
   llvm::StringRef(Inc.Written).drop_front().drop_back();
-  bool Angled = llvm::StringRef(Inc.Written).startswith("<");
-
-  // Re-lex the #include directive to find its interesting parts.
-  llvm::StringRef Src = SM.getBufferData(SM.getMainFileID());
-  Lexer RawLexer(SM.getLocForStartOfFile(SM.getMainFileID()), LangOpts,
- Src.begin(), Src.begin() + Inc.HashOffset, Src.end());
-  Token HashTok, IncludeTok, FilenameTok;
-  RawLexer.LexFromRawLexer(HashTok);
-  assert(HashTok.getKind() == tok::hash);
-  RawLexer.setParsingPreprocessorDirective(true);
-  RawLexer.LexFromRawLexer(IncludeTok);
-  IdentifierInfo *II = PP.getIdentifierInfo(IncludeTok.getRawIdentifier());
-  IncludeTok.setIdentifierInfo(II);
-  IncludeTok.setKind(II->getTokenID());
-  RawLexer.LexIncludeFilename(FilenameTok);
-
-  Delegate->InclusionDirective(
-  HashTok.getLocation(), IncludeTok, WrittenFilename, Angled,
-  CharSourceRange::getCharRange(FilenameTok.getLocation(),
-FilenameTok.getEndLoc()),
-  File, "SearchPath", "RelPath", /*Imported=*/nullptr, Inc.FileKind);
+  Delegate->InclusionDirective(HashTok->location(), IncludeTok,
+   WrittenFilename, Inc.Written.front() == '<',
+   FileTok->range(SM).toCharRange(SM), File,
+   "SearchPath", "RelPath",
+   /*Imported=*/nullptr, Inc.FileKind);
   if (File)
 // FIXME: Use correctly named FileEntryRef.
 Delegate->FileSkipped(FileEntryRef(File->getName(), *File), 
FilenameTok,
@@ -205,7 +227,7 @@
   PPCallbacks *Delegate;
   const SourceManager &SM;
   Preprocessor &PP;
-  const LangOptions &LangOpts;
+  std::vector MainFileTokens;
 };
 
 } // namespace


Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ c

[clang] f12fb2d - [IRBuilder] Always respect inserter/folder

2020-02-19 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2020-02-19T17:44:43+01:00
New Revision: f12fb2d99b8dd0dbef1c79f1d401200150f2d0bd

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

LOG: [IRBuilder] Always respect inserter/folder

Some IRBuilder methods that were originally defined on
IRBuilderBase do not respect custom IRBuilder inserters/folders,
because those were not accessible prior to D73835. Fix this by
making use of existing (and now accessible) IRBuilder methods,
which will handle inserters/folders correctly.

There are some changes in OpenMP tests, where bitcasts now get
constant folded. I've also highlighted one InstCombine test which
now finishes in two rather than three iterations, thanks to new
instructions being inserted into the worklist.

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

Added: 


Modified: 
clang/test/OpenMP/parallel_codegen.cpp
clang/test/OpenMP/target_firstprivate_codegen.cpp
llvm/lib/IR/IRBuilder.cpp
llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Removed: 




diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index f96ad406c25f..586187f09521 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -60,8 +60,7 @@ int main (int argc, char **argv) {
 // ALL-DEBUG-LABEL: define i32 @main(i32 %argc, i8** %argv)
 // CHECK-DEBUG:   [[LOC_2_ADDR:%.+]] = alloca %struct.ident_t
 // CHECK-DEBUG:   [[KMPC_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* 
[[LOC_2_ADDR]] to i8*
-// CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_VOIDPTR:%.+]] = bitcast 
%struct.ident_t* [[DEF_LOC_2]] to i8*
-// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 [[KMPC_DEFAULT_LOC_VOIDPTR]], i64 24, i1 
false)
+// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 bitcast (%struct.ident_t* [[DEF_LOC_2]] to 
i8*), i64 24, i1 false)
 // ALL-DEBUG:   store i32 %argc, i32* [[ARGC_ADDR:%.+]],
 // ALL-DEBUG:   [[VLA:%.+]] = alloca i32, i64 [[VLA_SIZE:%[^,]+]],
 // CHECK-DEBUG:   [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds 
%struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
@@ -118,8 +117,7 @@ int main (int argc, char **argv) {
 // ALL-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
 // CHECK-DEBUG-DAG:   [[LOC_2_ADDR:%.+]] = alloca %struct.ident_t
 // CHECK-DEBUG:   [[KMPC_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* 
[[LOC_2_ADDR]] to i8*
-// CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_VOIDPTR:%.+]] = bitcast 
%struct.ident_t* [[DEF_LOC_2]] to i8*
-// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 [[KMPC_DEFAULT_LOC_VOIDPTR]], i64 24, i1 
false)
+// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 bitcast (%struct.ident_t* [[DEF_LOC_2]] to 
i8*), i64 24, i1 false)
 // CHECK-DEBUG-NEXT:  store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK-DEBUG:  [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds 
%struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
 // CHECK-DEBUG-NEXT:  store i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} 
x i8]* [[LOC2]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]]

diff  --git a/clang/test/OpenMP/target_firstprivate_codegen.cpp 
b/clang/test/OpenMP/target_firstprivate_codegen.cpp
index 0b5f5f9b2b17..b90ab42f5ae2 100644
--- a/clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ b/clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -336,9 +336,8 @@ int foo(int n, double *ptr) {
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[FP_E_BC:%.+]] = bitcast [[TTII]]* [[FP_E]] to i8*
   // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} 
[[FP_E_BC]], i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
+  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast 
([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],

diff  --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index 457255b157cc..71cf2c04d1d0 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -65,38 +65,19 @@ Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
 return Ptr;
 
   // Otherwise, we need to insert a bitcast.
-  PT = getInt8PtrTy(PT->getAddressSpace());
-  B

[PATCH] D74787: [IRBuilder] Always respect inserter/folder

2020-02-19 Thread Nikita Popov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf12fb2d99b8d: [IRBuilder] Always respect inserter/folder 
(authored by nikic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74787

Files:
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Index: llvm/test/Transforms/InstCombine/saturating-add-sub.ll
===
--- llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
+; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s
 
 ;
 ; Saturating addition.
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -65,38 +65,19 @@
 return Ptr;
 
   // Otherwise, we need to insert a bitcast.
-  PT = getInt8PtrTy(PT->getAddressSpace());
-  BitCastInst *BCI = new BitCastInst(Ptr, PT, "");
-  BB->getInstList().insert(InsertPt, BCI);
-  SetInstDebugLocation(BCI);
-  return BCI;
+  return CreateBitCast(Ptr, getInt8PtrTy(PT->getAddressSpace()));
 }
 
 static CallInst *createCallHelper(Function *Callee, ArrayRef Ops,
   IRBuilderBase *Builder,
   const Twine &Name = "",
   Instruction *FMFSource = nullptr) {
-  CallInst *CI = CallInst::Create(Callee, Ops, Name);
+  CallInst *CI = Builder->CreateCall(Callee, Ops, Name);
   if (FMFSource)
 CI->copyFastMathFlags(FMFSource);
-  Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),CI);
-  Builder->SetInstDebugLocation(CI);
   return CI;
 }
 
-static InvokeInst *createInvokeHelper(Function *Invokee, BasicBlock *NormalDest,
-  BasicBlock *UnwindDest,
-  ArrayRef Ops,
-  IRBuilderBase *Builder,
-  const Twine &Name = "") {
-  InvokeInst *II =
-  InvokeInst::Create(Invokee, NormalDest, UnwindDest, Ops, Name);
-  Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),
-  II);
-  Builder->SetInstDebugLocation(II);
-  return II;
-}
-
 CallInst *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
   MaybeAlign Align, bool isVolatile,
   MDNode *TBAATag, MDNode *ScopeTag,
@@ -696,8 +677,8 @@
   std::vector Args =
   getStatepointArgs(*Builder, ID, NumPatchBytes, ActualInvokee, Flags,
 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
-  return createInvokeHelper(FnStatepoint, NormalDest, UnwindDest, Args, Builder,
-Name);
+  return Builder->CreateInvoke(FnStatepoint, NormalDest, UnwindDest, Args,
+   Name);
 }
 
 InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -336,9 +336,8 @@
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[FP_E_BC:%.+]] = bitcast [[TTII]]* [[FP_E]] to i8*
   // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} [[FP_E_BC]], i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
+  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
Index: clang/test/OpenMP/parallel_codegen.cpp
===
--- clang/test/OpenMP/parallel_codegen.cpp
+++ clang/test/OpenMP/parallel_codegen.cpp
@@ -60,8 +60,7 @@
 // ALL-DEBUG-LABEL: define i32 @main(i32 %argc, i8** %argv)
 // CHECK-DEBUG:   [[LOC_2_ADDR:%.+]] = alloca %struct.ident_t
 // CHECK-DEBUG:   [[KMPC_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* [[LOC_2_ADDR]] to i8*
-// CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* [[DEF_LOC_2]] to i8*
-// CHECK-DEBUG-NEXT:   call void @llvm.

[clang] f50fe5e - [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-19 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2020-02-19T11:45:58-05:00
New Revision: f50fe5eb6d2ec0adb5b2fd91a4023fc1573e061f

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

LOG: [Sema][CodeComplete] Handle symlinks for include code completion

Summary:
Previously any symlinks would be ignored since the directory
traversal doesn't follow them.

With this change we now follow symlinks (via a `stat` call
in order to figure out the target type of the symlink if it
is valid).

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeCompletion/included-symlinks.cpp

Modified: 
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 487ba46c20b6..6ba404034a86 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,16 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, 
bool Angled) {
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // To know whether a symlink should be treated as file or a directory, we
+  // have to stat it. This should be cheap enough as there shouldn't be 
many
+  // symlinks.
+  llvm::sys::fs::file_type Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+if (auto FileStatus = FS.status(It->path()))
+  Type = FileStatus->getType();
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" 
suffix,
 // but the suffix does not appear in the source code's include/import.

diff  --git a/clang/test/CodeCompletion/included-symlinks.cpp 
b/clang/test/CodeCompletion/included-symlinks.cpp
new file mode 100644
index ..a57a96b78474
--- /dev/null
+++ b/clang/test/CodeCompletion/included-symlinks.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t && mkdir -p %t/real/myproj && mkdir -p %t/links
+// RUN: touch %t/real/foo.h && ln -s %t/real/foo.h %t/links/foo.h
+// RUN: touch %t/real/foobar.h && ln -s %t/real/foobar.h %t/links/foobar.h
+// RUN: touch %t/real/myproj/test.h && ln -s %t/real/myproj %t/links/myproj
+
+// Suggest symlinked header files.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:7:13 %s 
| FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo.h"
+// CHECK-1: foobar.h"
+
+// Suggest symlinked folder.
+#include "mypr"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:13:13 
%s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: myproj/



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1514
+  void visitUsedDecl(SourceLocation Loc, Decl *D) {
+if (auto *TD = dyn_cast(D)) {
+  for (auto *DD : TD->decls()) {

Note that when recommitting this (if you choose to), this needs to also handle 
NamespaceDecl.  We're a downstream and discovered that this doesn't properly 
handle functions or records handled in a namespace.

It can be implemented identically to TranslationUnitDecl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74790: [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-19 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf50fe5eb6d2e: [Sema][CodeComplete] Handle symlinks for 
include code completion (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74790

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/included-symlinks.cpp


Index: clang/test/CodeCompletion/included-symlinks.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/included-symlinks.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t && mkdir -p %t/real/myproj && mkdir -p %t/links
+// RUN: touch %t/real/foo.h && ln -s %t/real/foo.h %t/links/foo.h
+// RUN: touch %t/real/foobar.h && ln -s %t/real/foobar.h %t/links/foobar.h
+// RUN: touch %t/real/myproj/test.h && ln -s %t/real/myproj %t/links/myproj
+
+// Suggest symlinked header files.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:7:13 %s 
| FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo.h"
+// CHECK-1: foobar.h"
+
+// Suggest symlinked folder.
+#include "mypr"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:13:13 
%s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: myproj/
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,16 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // To know whether a symlink should be treated as file or a directory, we
+  // have to stat it. This should be cheap enough as there shouldn't be 
many
+  // symlinks.
+  llvm::sys::fs::file_type Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+if (auto FileStatus = FS.status(It->path()))
+  Type = FileStatus->getType();
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" 
suffix,
 // but the suffix does not appear in the source code's include/import.


Index: clang/test/CodeCompletion/included-symlinks.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/included-symlinks.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t && mkdir -p %t/real/myproj && mkdir -p %t/links
+// RUN: touch %t/real/foo.h && ln -s %t/real/foo.h %t/links/foo.h
+// RUN: touch %t/real/foobar.h && ln -s %t/real/foobar.h %t/links/foobar.h
+// RUN: touch %t/real/myproj/test.h && ln -s %t/real/myproj %t/links/myproj
+
+// Suggest symlinked header files.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:7:13 %s | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo.h"
+// CHECK-1: foobar.h"
+
+// Suggest symlinked folder.
+#include "mypr"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:13:13 %s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: myproj/
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,16 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // To know whether a symlink should be treated as file or a directory, we
+  // have to stat it. This should be cheap enough as there shouldn't be many
+  // symlinks.
+  llvm::sys::fs::file_type Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+if (auto FileStatus = FS.status(It->path()))
+  Type = FileStatus->getType();
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" suffix,
 // but the suffix does not appear in the source code's include/import.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-19 Thread Hongtao Yu via Phabricator via cfe-commits
hoyFB added a comment.

In D74814#1882064 , @wenlei wrote:

> Thanks for fixing this. Could you use `.ll` IR file as test case and place it 
> alongside with `test/Other/module-pass-printer.ll` or just reuse that one? We 
> can also use `opt` to invoke new pass manager, so it doesn't need to be a 
> clang test.


Sounds good. I was trying to figure out how to invoke the new pass manager with 
OPT. Is there a command line switch to do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74814



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


[clang] b92b170 - Revert "[IRBuilder] Always respect inserter/folder"

2020-02-19 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2020-02-19T17:51:55+01:00
New Revision: b92b1701cd30d356fa3ac4da3d0dba20fa614e0b

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

LOG: Revert "[IRBuilder] Always respect inserter/folder"

This reverts commit f12fb2d99b8dd0dbef1c79f1d401200150f2d0bd.

I missed some changes in instrumentation test cases.

Added: 


Modified: 
clang/test/OpenMP/parallel_codegen.cpp
clang/test/OpenMP/target_firstprivate_codegen.cpp
llvm/lib/IR/IRBuilder.cpp
llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Removed: 




diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index 586187f09521..f96ad406c25f 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -60,7 +60,8 @@ int main (int argc, char **argv) {
 // ALL-DEBUG-LABEL: define i32 @main(i32 %argc, i8** %argv)
 // CHECK-DEBUG:   [[LOC_2_ADDR:%.+]] = alloca %struct.ident_t
 // CHECK-DEBUG:   [[KMPC_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* 
[[LOC_2_ADDR]] to i8*
-// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 bitcast (%struct.ident_t* [[DEF_LOC_2]] to 
i8*), i64 24, i1 false)
+// CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_VOIDPTR:%.+]] = bitcast 
%struct.ident_t* [[DEF_LOC_2]] to i8*
+// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 [[KMPC_DEFAULT_LOC_VOIDPTR]], i64 24, i1 
false)
 // ALL-DEBUG:   store i32 %argc, i32* [[ARGC_ADDR:%.+]],
 // ALL-DEBUG:   [[VLA:%.+]] = alloca i32, i64 [[VLA_SIZE:%[^,]+]],
 // CHECK-DEBUG:   [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds 
%struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
@@ -117,7 +118,8 @@ int main (int argc, char **argv) {
 // ALL-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
 // CHECK-DEBUG-DAG:   [[LOC_2_ADDR:%.+]] = alloca %struct.ident_t
 // CHECK-DEBUG:   [[KMPC_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* 
[[LOC_2_ADDR]] to i8*
-// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 bitcast (%struct.ident_t* [[DEF_LOC_2]] to 
i8*), i64 24, i1 false)
+// CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_VOIDPTR:%.+]] = bitcast 
%struct.ident_t* [[DEF_LOC_2]] to i8*
+// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 [[KMPC_DEFAULT_LOC_VOIDPTR]], i64 24, i1 
false)
 // CHECK-DEBUG-NEXT:  store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK-DEBUG:  [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds 
%struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
 // CHECK-DEBUG-NEXT:  store i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} 
x i8]* [[LOC2]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]]

diff  --git a/clang/test/OpenMP/target_firstprivate_codegen.cpp 
b/clang/test/OpenMP/target_firstprivate_codegen.cpp
index b90ab42f5ae2..0b5f5f9b2b17 100644
--- a/clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ b/clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -336,8 +336,9 @@ int foo(int n, double *ptr) {
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
+  // CHECK:  [[FP_E_BC:%.+]] = bitcast [[TTII]]* [[FP_E]] to i8*
   // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast 
([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
+  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} 
[[FP_E_BC]], i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],

diff  --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index 71cf2c04d1d0..457255b157cc 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -65,19 +65,38 @@ Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
 return Ptr;
 
   // Otherwise, we need to insert a bitcast.
-  return CreateBitCast(Ptr, getInt8PtrTy(PT->getAddressSpace()));
+  PT = getInt8PtrTy(PT->getAddressSpace());
+  BitCastInst *BCI = new BitCastInst(Ptr, PT, "");
+  BB->getInstList().insert(InsertPt, BCI);
+  SetInstDebugLocation(BCI);
+  return BCI;
 }
 
 static CallInst *createCallHelper(Function *Callee, ArrayRef Ops,
   IRBuilderBase *Builder,
   const Twine &Name = "",
   Instruction *FMFSource = nullptr) {

[PATCH] D74844: [clangd] Get rid of Lexer usage in CodeComplete

2020-02-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74844

Files:
  clang-tools-extra/clangd/CodeComplete.cpp


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -52,6 +52,7 @@
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Sema.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -588,9 +589,10 @@
 
   // Case 4: There was a qualifier, and Sema didn't resolve it.
   Scopes.AccessibleScopes.push_back(""); // Make sure global scope is included.
-  llvm::StringRef SpelledSpecifier = Lexer::getSourceText(
-  CharSourceRange::getCharRange(SemaSpecifier->getRange()),
-  CCSema.SourceMgr, clang::LangOptions());
+  llvm::StringRef SpelledSpecifier =
+  syntax::FileRange(CCSema.SourceMgr, SemaSpecifier->getBeginLoc(),
+SemaSpecifier->getEndLoc())
+  .text(CCSema.SourceMgr);
   if (SpelledSpecifier.consume_front("::"))
 Scopes.AccessibleScopes = {""};
   Scopes.UnresolvedQualifier = std::string(SpelledSpecifier);


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -52,6 +52,7 @@
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Sema.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -588,9 +589,10 @@
 
   // Case 4: There was a qualifier, and Sema didn't resolve it.
   Scopes.AccessibleScopes.push_back(""); // Make sure global scope is included.
-  llvm::StringRef SpelledSpecifier = Lexer::getSourceText(
-  CharSourceRange::getCharRange(SemaSpecifier->getRange()),
-  CCSema.SourceMgr, clang::LangOptions());
+  llvm::StringRef SpelledSpecifier =
+  syntax::FileRange(CCSema.SourceMgr, SemaSpecifier->getBeginLoc(),
+SemaSpecifier->getEndLoc())
+  .text(CCSema.SourceMgr);
   if (SpelledSpecifier.consume_front("::"))
 Scopes.AccessibleScopes = {""};
   Scopes.UnresolvedQualifier = std::string(SpelledSpecifier);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74807: Add cl_khr_mipmap_image_writes as supported to AMDGPU

2020-02-19 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner accepted this revision.
b-sumner added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D74807



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


RE: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-19 Thread Liu, Yaxun (Sam) via cfe-commits
[AMD Official Use Only - Internal Distribution Only]

Will do. Thanks.

Sam

-Original Message-
From: Erich Keane via Phabricator  
Sent: Wednesday, February 19, 2020 8:52 AM
To: Liu, Yaxun (Sam) ; t...@google.com; rjmcc...@gmail.com; 
rich...@metafoo.co.uk; jdoerf...@anl.gov; a.bat...@hotmail.com
Cc: erich.ke...@intel.com; echri...@gmail.com; jpien...@google.com; 
mask...@google.com; michael.hl...@gmail.com; mariya.podchishcha...@intel.com; 
alexey.ba...@intel.com; zhang.guans...@gmail.com; her...@google.com; 
r...@google.com; cfe-commits@lists.llvm.org; mlek...@skidmore.edu; 
blitzrak...@gmail.com; shen...@google.com
Subject: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a 
post-parsing AST travese

[CAUTION: External Email]

erichkeane added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1514
+  void visitUsedDecl(SourceLocation Loc, Decl *D) {
+if (auto *TD = dyn_cast(D)) {
+  for (auto *DD : TD->decls()) {

Note that when recommitting this (if you choose to), this needs to also handle 
NamespaceDecl.  We're a downstream and discovered that this doesn't properly 
handle functions or records handled in a namespace.

It can be implemented identically to TranslationUnitDecl.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172%2Fnew%2F&data=02%7C01%7Cyaxun.liu%40amd.com%7C9e1ec947ff5e4e65a52408d7b55bfd7b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637177279020210466&sdata=KdCHlCMkdeIhQ8%2B11lXTxz8srsvmYKtk2UiIR5aYheo%3D&reserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172&data=02%7C01%7Cyaxun.liu%40amd.com%7C9e1ec947ff5e4e65a52408d7b55bfd7b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637177279020210466&sdata=iZhUpTdtwu8kR%2FIRvhMVwMbig28F960X9LWzPTGO9WI%3D&reserved=0


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


[PATCH] D74842: [clangd] Make use of syntax tokens in ReplayPreamble

2020-02-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:138
+  : Includes(Includes), Delegate(Delegate), SM(SM), PP(PP) {
+MainFileTokens = syntax::tokenize(SM.getMainFileID(), SM, LangOpts);
+  }

tokenizing the whole file an extra time on every AST build seems a bit sad - 
this is considerably more lexing than we were doing before. Probably doesn't 
matter?

We could trim this to the preamble bounds I guess. Or even compute it once when 
the preamble is built, since we assume all the bytes are the same? I guess 
SourceLocations are the problem... we could just translate offsets into the new 
SM, but that gets messy.
On the other hand, assuming the preamble isn't going to change at all seems 
like an assumption not long for this world.
On the first hand again, maybe we'll have to revisit looots of stuff (go to 
definition and everything) once that assumption breaks anyway.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:173
+  auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset)
+ .getRawEncoding();
+  auto HashTok =

why raw encoding?



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:175
+  auto HashTok =
+  llvm::find_if(MainFileTokens, [&HashLoc](const syntax::Token &T) {
+return T.location().getRawEncoding() == HashLoc;

this looks like a linear search for each #include



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:186
+
+  // We imitate the PP logic here, except clang::Token::Flags, none of the
+  // callers seem to care about it (yet).

Not clear what "imitate the PP logic" means.
We construct a fake 'import'/'include' token... nobody cares about 
clang::Token::Flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74842



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


[PATCH] D74845: [ARM,MVE] Add vqdmull[b,t]q intrinsic families

2020-02-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: simon_tatham, MarkMurrayARM, dmgreen, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

This patch adds two families of ACLE intrinsics: vqdmullbq and
vqdmulltq (including vector-vector and vector-scalar variants) and the
corresponding LLVM IR intrinsics llvm.arm.mve.vqdmull and
llvm.arm.mve.vqdmull.predicated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74845

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

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vqdmull.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vqdmull.ll
@@ -0,0 +1,221 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32)
+
+declare <4 x i32> @llvm.arm.mve.vqdmull.v4i32.v8i16(<8 x i16>, <8 x i16>, i32)
+declare <2 x i64> @llvm.arm.mve.vqdmull.v2i64.v4i32(<4 x i32>, <4 x i32>, i32)
+declare <4 x i32> @llvm.arm.mve.vqdmull.predicated.v4i32.v8i16.v4i1(<8 x i16>, <8 x i16>, i32, <4 x i1>, <4 x i32>)
+declare <2 x i64> @llvm.arm.mve.vqdmull.predicated.v2i64.v4i32.v4i1(<4 x i32>, <4 x i32>, i32, <4 x i1>, <2 x i64>)
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_s16(<8 x i16> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vqdmullbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s16 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <4 x i32> @llvm.arm.mve.vqdmull.v4i32.v8i16(<8 x i16> %a, <8 x i16> %b, i32 0)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <2 x i64> @test_vqdmullbq_s32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vqdmullbq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s32 q2, q0, q1
+; CHECK-NEXT:vmov q0, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <2 x i64> @llvm.arm.mve.vqdmull.v2i64.v4i32(<4 x i32> %a, <4 x i32> %b, i32 0)
+  ret <2 x i64> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_m_s16(<4 x i32> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmullbq_m_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmullbt.s16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <4 x i32> @llvm.arm.mve.vqdmull.predicated.v4i32.v8i16.v4i1(<8 x i16> %a, <8 x i16> %b, i32 0, <4 x i1> %1, <4 x i32> %inactive)
+  ret <4 x i32> %2
+}
+
+define arm_aapcs_vfpcc <2 x i64> @test_vqdmullbq_m_s32(<2 x i64> %inactive, <4 x i32> %a, <4 x i32> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmullbq_m_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmullbt.s32 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <2 x i64> @llvm.arm.mve.vqdmull.predicated.v2i64.v4i32.v4i1(<4 x i32> %a, <4 x i32> %b, i32 0, <4 x i1> %1, <2 x i64> %inactive)
+  ret <2 x i64> %2
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_n_s16(<8 x i16> %a, i16 signext %b) {
+; CHECK-LABEL: test_vqdmullbq_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <8 x i16> undef, i16 %b, i32 0
+  %.splat = shufflevector <8 x i16> %.splatinsert, <8 x i16> undef, <8 x i32> zeroinitializer
+  %0 = call <4 x i32> @llvm.arm.mve.vqdmull.v4i32.v8i16(<8 x i16> %a, <8 x i16> %.splat, i32 0)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <2 x i64> @test_vqdmullbq_n_s32(<4 x i32> %a, i32 %b) #0 {
+; CHECK-LABEL: test_vqdmullbq_n_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s32 q1, q0, r0
+; CHECK-NEXT:vmov q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <4 x i32> undef, i32 %b, i32 0
+  %.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer
+  %0 = call <2 x i64> @llvm.arm.mve.vqdmull.v2i64.v4i32(<4 x i32> %a, <4 x i32> %.splat, i32 0)
+  ret <2 x i64> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_m_n_s16(<4 x i32> %inactive, <8 x i16> %a, i16 signext %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmullbq_m_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmullbt.s16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <8 x i16> undef, i16 %b, i32 0
+  %.splat = shufflevector <8 x i16> %.splati

[clang] a54d81f - [analyzer] CERT: POS34-C

2020-02-19 Thread Zurab Tsinadze via cfe-commits

Author: Zurab Tsinadze
Date: 2020-02-19T18:12:19+01:00
New Revision: a54d81f597963b8768ce2b94a8ef570f9eaaac25

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

LOG: [analyzer] CERT: POS34-C

Summary:
This patch introduces a new checker:
`alpha.security.cert.pos.34c`

This checker is implemented based on the following rule:
https://wiki.sei.cmu.edu/confluence/x/6NYxBQ
The check warns if  `putenv` function is
called with automatic storage variable as an argument.

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

Added: 
clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
clang/test/Analysis/cert/pos34-c-fp-suppression.cpp
clang/test/Analysis/cert/pos34-c.cpp

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index f39bf1f7b2b8..b130cc34f685 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1929,6 +1929,38 @@ Warns against using one vs. many plural pattern in code 
when generating localize
 
 alpha.security
 ^^
+
+
+alpha.security.cert
+^^^
+
+SEI CERT checkers which tries to find errors based on their `C coding 
rules`_.
+
+.. _alpha-security-cert-pos-checkers:
+
+alpha.security.cert.pos
+^^^
+
+SEI CERT checkers of POSIX `C coding 
rules`_.
+
+.. _alpha-security-cert-pos-34c:
+
+alpha.security.cert.pos.34c
+"""
+Finds calls to the ``putenv`` function which pass a pointer to an automatic 
variable as the argument.
+
+.. code-block:: c
+
+  int func(const char *var) {
+char env[1024];
+int retval = snprintf(env, sizeof(env),"TEST=%s", var);
+if (retval < 0 || (size_t)retval >= sizeof(env)) {
+/* Handle error */
+}
+ 
+return putenv(env); // putenv function should not be called with auto 
variables
+  }
+  
 .. _alpha-security-ArrayBound:
 
 alpha.security.ArrayBound (C)

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 76cf92af9113..91c0fc88f6e7 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -71,6 +71,9 @@ def InsecureAPI : Package<"insecureAPI">, 
ParentPackage;
 def SecurityAlpha : Package<"security">, ParentPackage;
 def Taint : Package<"taint">, ParentPackage;
 
+def CERT : Package<"cert">, ParentPackage;
+def POS : Package<"pos">, ParentPackage;
+
 def Unix : Package<"unix">;
 def UnixAlpha : Package<"unix">, ParentPackage;
 def CString : Package<"cstring">, ParentPackage;
@@ -829,6 +832,15 @@ def FloatLoopCounter : Checker<"FloatLoopCounter">,
 
 } // end "security"
 
+let ParentPackage = POS in {
+
+  def PutenvWithAuto : Checker<"34c">,
+  HelpText<"Finds calls to the 'putenv' function which pass a pointer to "
+   "an automatic variable as the argument.">,
+  Documentation;
+
+} // end "alpha.cert.pos"
+
 let ParentPackage = SecurityAlpha in {
 
 def ArrayBoundChecker : Checker<"ArrayBound">,

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
index 22c1a7dd98cc..637b89fd9036 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
@@ -11,16 +11,16 @@
 
 // Common strings used for the "category" of many static analyzer issues.
 namespace clang {
-  namespace ento {
-namespace categories {
-  extern const char * const CoreFoundationObjectiveC;
-  extern const char * const LogicError;
-  extern const char * const MemoryRefCount;
-  extern const char * const MemoryError;
-  extern const char * const UnixAPI;
-  extern const char * const CXXObjectLifecycle;
-}
-  }
-}
+namespace ento {
+namespace categories {
+extern const char *const CoreFoundationObjectiveC;
+extern const char *const LogicError;
+extern const char *const MemoryRefCount;
+extern const char *const MemoryError;
+extern const char *const UnixAPI;
+extern const char *const CXXObjectLifecycle;
+extern const char *const SecurityError;
+} // namespace categories
+} // namespace ento
+} // namespace clang
 #endif
-

diff  --git a/clang/lib/StaticAnalyzer/Checke

[PATCH] D71433: [analyzer] CERT: POS34-C

2020-02-19 Thread Zurab Tsinadze via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa54d81f59796: [analyzer] CERT: POS34-C (authored by 
zukatsinadze).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71433

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
  clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
  clang/test/Analysis/cert/pos34-c-fp-suppression.cpp
  clang/test/Analysis/cert/pos34-c.cpp

Index: clang/test/Analysis/cert/pos34-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/pos34-c.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=alpha.security.cert.pos.34c\
+// RUN:  -verify %s
+
+// Examples from the CERT rule's page.
+// https://wiki.sei.cmu.edu/confluence/x/6NYxBQ
+
+#include "../Inputs/system-header-simulator.h"
+void free(void *memblock);
+void *malloc(size_t size);
+int putenv(char *);
+int snprintf(char *str, size_t size, const char *format, ...);
+
+namespace test_auto_var_used_bad {
+
+int volatile_memory1(const char *var) {
+  char env[1024];
+  int retval = snprintf(env, sizeof(env), "TEST=%s", var);
+  if (retval < 0 || (size_t)retval >= sizeof(env)) {
+/* Handle error */
+  }
+
+  return putenv(env);
+  // expected-warning@-1 {{The 'putenv' function should not be called with arguments that have automatic storage}}
+}
+
+} // namespace test_auto_var_used_bad
+
+namespace test_auto_var_used_good {
+
+int test_static(const char *var) {
+  static char env[1024];
+
+  int retval = snprintf(env, sizeof(env), "TEST=%s", var);
+  if (retval < 0 || (size_t)retval >= sizeof(env)) {
+/* Handle error */
+  }
+
+  return putenv(env);
+}
+
+int test_heap_memory(const char *var) {
+  static char *oldenv;
+  const char *env_format = "TEST=%s";
+  const size_t len = strlen(var) + strlen(env_format);
+  char *env = (char *)malloc(len);
+  if (env == NULL) {
+return -1;
+  }
+  if (putenv(env) != 0) { // no-warning: env was dynamically allocated.
+free(env);
+return -1;
+  }
+  if (oldenv != NULL) {
+free(oldenv); /* avoid memory leak */
+  }
+  oldenv = env;
+  return 0;
+}
+
+} // namespace test_auto_var_used_good
Index: clang/test/Analysis/cert/pos34-c-fp-suppression.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/pos34-c-fp-suppression.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=alpha.security.cert.pos.34c\
+// RUN:  -verify %s
+
+#include "../Inputs/system-header-simulator.h"
+void free(void *memblock);
+void *malloc(size_t size);
+int putenv(char *);
+int rand();
+
+namespace test_auto_var_used_good {
+
+extern char *ex;
+int test_extern() {
+  return putenv(ex); // no-warning: extern storage class.
+}
+
+void foo(void) {
+  char *buffer = (char *)"huttah!";
+  if (rand() % 2 == 0) {
+buffer = (char *)malloc(5);
+strcpy(buffer, "woot");
+  }
+  putenv(buffer);
+}
+
+void bar(void) {
+  char *buffer = (char *)malloc(5);
+  strcpy(buffer, "woot");
+
+  if (rand() % 2 == 0) {
+free(buffer);
+buffer = (char *)"blah blah blah";
+  }
+  putenv(buffer);
+}
+
+void baz() {
+  char env[] = "NAME=value";
+  // TODO: False Positive
+  putenv(env);
+  // expected-warning@-1 {{The 'putenv' function should not be called with arguments that have automatic storage}}
+
+  /*
+DO SOMETHING
+  */
+
+  putenv((char *)"NAME=anothervalue");
+}
+
+} // namespace test_auto_var_used_good
Index: clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
===
--- clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
+++ clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
@@ -9,13 +9,18 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
 
 // Common strings used for the "category" of many static analyzer issues.
-namespace clang { namespace ento { namespace categories {
+namespace clang {
+namespace ento {
+namespace categories {
 
-const char * const CoreFoundationObjectiveC = "Core Foundation/Objective-C";
-const char * const LogicError = "Logic error";
-const char * const MemoryRefCount =
-  "Memory (Core Foundation/Objective-C/OSObject)";
-const char * const MemoryError = "Memory error";
-const char * const UnixAPI = "Unix API";
-const char * const CXXObjectLifecycle = "C++ object lifecycle";
-}}}
+const char *const CoreFoundationObjectiveC = "Core Foundation/Objective-C";
+const char *const LogicError = "Logic error";
+const char *const MemoryRefCount =
+"Memory (Core Foundation/Objective-C/OSObject)";
+const char *const MemoryError = "Memory error";
+const

[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44958)

2020-02-19 Thread Luboš Luňák via Phabricator via cfe-commits
llunak created this revision.
llunak added reviewers: hans, dblaikie.
llunak added a project: clang.
Herald added a subscriber: cfe-commits.

In D69778  I incorrectly handled two cases 
(checking for -building-pch-with-obj without also checking -fmodules-codegen).


Repository:
  rC Clang

https://reviews.llvm.org/D74846

Files:
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/PCH/Inputs/declspec-selectany-pch.cpp
  clang/test/PCH/Inputs/declspec-selectany-pch.h
  clang/test/PCH/declspec-selectany.cpp


Index: clang/test/PCH/declspec-selectany.cpp
===
--- /dev/null
+++ clang/test/PCH/declspec-selectany.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cl /Yc%S/Inputs/declspec-selectany-pch.h 
%S/Inputs/declspec-selectany-pch.cpp /c /Fo%t.obj /Fp%t.pch
+// RUN: %clang_cl /Yu%S/Inputs/declspec-selectany-pch.h %s /I%S/Inputs /c 
/Fo%t.obj /Fp%t.pch
+
+#include "declspec-selectany-pch.h"
+
+int main() {
+  CD3DX12_CPU_DESCRIPTOR_HANDLE desc = 
CD3DX12_CPU_DESCRIPTOR_HANDLE(D3D12_DEFAULT);
+  return desc.ptr;
+}
Index: clang/test/PCH/Inputs/declspec-selectany-pch.h
===
--- /dev/null
+++ clang/test/PCH/Inputs/declspec-selectany-pch.h
@@ -0,0 +1,7 @@
+struct CD3DX12_DEFAULT {};
+extern const __declspec(selectany) CD3DX12_DEFAULT D3D12_DEFAULT;
+
+struct CD3DX12_CPU_DESCRIPTOR_HANDLE {
+  CD3DX12_CPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) { ptr = 0; }
+  size_t ptr;
+};
Index: clang/test/PCH/Inputs/declspec-selectany-pch.cpp
===
--- /dev/null
+++ clang/test/PCH/Inputs/declspec-selectany-pch.cpp
@@ -0,0 +1 @@
+#include "declspec-selectany-pch.h"
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1017,10 +1017,12 @@
   // definition in the module interface is provided by the compilation of
   // that module interface unit, not by its users. (Inline variables are
   // still emitted in module users.)
+  // Similarly if a PCH is built with codegen and its own object file.
   ModulesCodegen =
   (((Writer.WritingModule &&
  Writer.WritingModule->Kind == Module::ModuleInterfaceUnit) ||
-Writer.Context->getLangOpts().BuildingPCHWithObjectFile) &&
+(Writer.Context->getLangOpts().BuildingPCHWithObjectFile &&
+ Writer.Context->getLangOpts().ModulesCodegen)) &&
Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal);
 }
 Record.push_back(ModulesCodegen);
@@ -2451,9 +2453,8 @@
   bool ModulesCodegen = false;
   if (!FD->isDependentContext()) {
 Optional Linkage;
-if ((Writer->WritingModule &&
- Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) ||
-Writer->Context->getLangOpts().BuildingPCHWithObjectFile) {
+if (Writer->WritingModule &&
+Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
   // When building a C++ Modules TS module interface unit, a strong
   // definition in the module interface is provided by the compilation of
   // that module interface unit, not by its users. (Inline functions are


Index: clang/test/PCH/declspec-selectany.cpp
===
--- /dev/null
+++ clang/test/PCH/declspec-selectany.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cl /Yc%S/Inputs/declspec-selectany-pch.h %S/Inputs/declspec-selectany-pch.cpp /c /Fo%t.obj /Fp%t.pch
+// RUN: %clang_cl /Yu%S/Inputs/declspec-selectany-pch.h %s /I%S/Inputs /c /Fo%t.obj /Fp%t.pch
+
+#include "declspec-selectany-pch.h"
+
+int main() {
+  CD3DX12_CPU_DESCRIPTOR_HANDLE desc = CD3DX12_CPU_DESCRIPTOR_HANDLE(D3D12_DEFAULT);
+  return desc.ptr;
+}
Index: clang/test/PCH/Inputs/declspec-selectany-pch.h
===
--- /dev/null
+++ clang/test/PCH/Inputs/declspec-selectany-pch.h
@@ -0,0 +1,7 @@
+struct CD3DX12_DEFAULT {};
+extern const __declspec(selectany) CD3DX12_DEFAULT D3D12_DEFAULT;
+
+struct CD3DX12_CPU_DESCRIPTOR_HANDLE {
+  CD3DX12_CPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) { ptr = 0; }
+  size_t ptr;
+};
Index: clang/test/PCH/Inputs/declspec-selectany-pch.cpp
===
--- /dev/null
+++ clang/test/PCH/Inputs/declspec-selectany-pch.cpp
@@ -0,0 +1 @@
+#include "declspec-selectany-pch.h"
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1017,10 +1017,12 @@
   // definition in the module interface is provided by the compilation of
   // that module interface unit, not by its users. (Inline variables a

[PATCH] D68578: [HIP] Fix device stub name

2020-02-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/AST/GlobalDecl.h:40
+  Stub = 1,
+};
+

rjmccall wrote:
> tra wrote:
> > rjmccall wrote:
> > > tra wrote:
> > > > rjmccall wrote:
> > > > > The attribute here is `CUDAGlobalAttr`; should this be named in terms 
> > > > > of CUDA, or is the CUDA model sufficiently different  from HIP that 
> > > > > the same implementation concept doesn't apply?
> > > > I believe the attribute serves the same purpose in both CUDA and HIP 
> > > > and could be renamed appropriately in a separate patch.
> > > > 
> > > > While the changes in this patch are not required for CUDA, CUDA would 
> > > > benefit from them. We could use a generic GPU prefix and migrate CUDA 
> > > > to the same model later. A TODO comment about that would be nice. 
> > > I'd just like consistency.  If they're serving the same purpose, then as 
> > > someone with no dog in this fight, I would give precedence to CUDA over 
> > > HIP in names since it's both the older language and was implemented first 
> > > in Clang (even if only partially, IIUC).  I don't think a generic name 
> > > works unless we can meaningfully generalize it to all languages with a 
> > > similar feature, e.g. OpenCL and so on.
> > Naming, the hardest problem in computer science. :-)
> > I personally would prefer generalization-with-exclusions over specific name 
> > which is inconsistently commingles things that's really specific to that 
> > name and things that are more widely used. Alas, right now CUDA is the 
> > example of the latter case -- some parts are CUDA-specific and a lot are 
> > shared with HIP.
> > 
> > For the new features we've been sort of sticking with using CUDA/HIP for 
> > specific parts and GPU for shared functionality, but as things are a lot of 
> > shared bits are still 'CUDA' and it's hard to tell them apart. As you point 
> > it out, renaming the incumbent names would be a pain, so here we are.
> > 
> > I think using `GPUKernelKind` with a comment that it reflects HIP & CUDA 
> > kernels would be somewhat better choice than `CUDAKernelKind` which would 
> > be somewhat confusing at this point given that CUDA actually does not use 
> > it yet. I'm also fine with keeping it `HIPKernelKind` and postpone the 
> > naming decision until CUDA-related parts are actually implemented.
> Maybe `KernelReferenceKind`?  It's probably a common concept across all 
> heterogenous-computing models.
SGTM.


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

https://reviews.llvm.org/D68578



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


[PATCH] D74844: [clangd] Get rid of Lexer usage in CodeComplete

2020-02-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:593
+  llvm::StringRef SpelledSpecifier =
+  syntax::FileRange(CCSema.SourceMgr, SemaSpecifier->getBeginLoc(),
+SemaSpecifier->getEndLoc())

what if beginLoc and endLoc are in different files?
(this is most of what Lexer deals with, I think)

I think you want TokenBuffer::expandedTokens(SourceRange), then 
spelledForExpanded, and then FileRange(...).text().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74844



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


[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-19 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

Patch LGTM as far a formatting/naming/testing etc. C++ specifics is outside my 
wheelhouse though, so I can't confirm things like the tail padding rules are 
correct for AIX. Because of that I'm not comfortable being the one to accept 
the patch.


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

https://reviews.llvm.org/D74015



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


[PATCH] D74845: [ARM,MVE] Add vqdmull[b,t]q intrinsic families

2020-02-19 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM accepted this revision.
MarkMurrayARM added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74845



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


[PATCH] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-19 Thread Luís Marques via Phabricator via cfe-commits
luismarques created this revision.
luismarques added reviewers: jyknight, eli.friedman, lenary.
Herald added subscribers: cfe-commits, evandro, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, PkmX, jfb, rkruppe, rogfer01, shiva0217, kito-cheng, simoncook.
Herald added a project: clang.

By default the RISC-V target doesn't have the atomics standard extension 
enabled. The first RUN line in `clang/test/CodeGen/atomic_ops.c` doesn't 
specify a target triple, which means that on RISC-V Linux hosts it will target 
RISC-V, but because we use clang cc1 we don't get the toolchain driver 
functionality to automatically turn on the extensions implied by the target 
triple (riscv64-linux includes atomics). This causes the test to fail on RISC-V 
hosts.

I waffled a bit regarding the best way to fix this. In the end I decided to 1) 
use XFAIL to blacklist RISC-V hosts and 2) add explicitly run lines for 
riscv32/64, with the atomics extension enabled. With that choice we 
//effectively// don't do the test on RISC-V hosts, but still get to test those 
two RISC-V targets on other hosts.

An alternative approach would be to eliminate the first RUN line and explicitly 
list all of the target triples we want to test. But looking at the other clang 
tests, there doesn't seem to be any test that comprehensively lists all of the 
targets, and it wasn't quite clear which should be listed on this test. Running 
clang with the non-cc1 interface would also be an option, but in principle that 
could still fail in some hypothetical scenarios, and the tests seem to prefer 
to use cc1.

(It's a shame that XFAIL necessarily means blacklisting host triples, and not 
target triples. That doesn't interact very well with cross-compilers.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74847

Files:
  clang/test/CodeGen/atomic_ops.c


Index: clang/test/CodeGen/atomic_ops.c
===
--- clang/test/CodeGen/atomic_ops.c
+++ clang/test/CodeGen/atomic_ops.c
@@ -1,7 +1,13 @@
 // XFAIL: hexagon,sparc
 //(due to not having native load atomic support)
+// XFAIL: riscv
+//(due to requiring an explicit -target-feature +a)
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +a -emit-llvm %s \
+// RUN:   -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +a -emit-llvm %s \
+// RUN:   -o - | FileCheck %s
 
 void foo(int x)
 {


Index: clang/test/CodeGen/atomic_ops.c
===
--- clang/test/CodeGen/atomic_ops.c
+++ clang/test/CodeGen/atomic_ops.c
@@ -1,7 +1,13 @@
 // XFAIL: hexagon,sparc
 //(due to not having native load atomic support)
+// XFAIL: riscv
+//(due to requiring an explicit -target-feature +a)
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +a -emit-llvm %s \
+// RUN:   -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +a -emit-llvm %s \
+// RUN:   -o - | FileCheck %s
 
 void foo(int x)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-19 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

I forgot if there is reason to use the option by default at all time (I did ask 
that in the previous review but Alex might have given more context offline).

You should definitely add test for this change. The fact that you change all 
`-mlinker-version=400` to `-mlinker-version=0` but not change any CHECK lines 
means the change is definitely not tested :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74784



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


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-19 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

In D74784#1882974 , @steven_wu wrote:

> I forgot if there is reason to use the option by default at all time (I did 
> ask that in the previous review but Alex might have given more context 
> offline).


I would really like to hear from @arphaman, but they haven't responded to 
anything since I filed PR44813 nearly two weeks ago. Do you have any means to 
contact them?

> You should definitely add test for this change. The fact that you change all 
> `-mlinker-version=400` to `-mlinker-version=0` but not change any CHECK lines 
> means the change is definitely not tested :)

Can you elaborate on what you would like to see tested? I thought I _was_ 
updating the tests to match the code. The `-mlinker-version=0` lines check that 
we now use the old behavior by default, and the existing `-mlinker-version=520` 
lines in e.g. `darwin-ld-platform-version-macos.c` test that we still use the 
new behavior when requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74784



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


[PATCH] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm not really a big fan of running tests with the host target triple, anyway; 
it seems to create work with almost no benefit.  I'd be happy to just run the 
test with one target that has native atomics, and one target that doesn't.  
(The relevant code is all target-independent, aside from the atomic widths, so 
we aren't really gaining anything by testing more targets.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74847



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


[PATCH] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

On a side-note, we could enhance the test runner to support "XFAIL: 
riscv32-default-target" if we thought it would be useful.  But again, I'm not a 
fan of tests that depend on the default target in the first place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74847



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D73534#1882136 , @djtodoro wrote:

> - Address the issue with ARM `describeLoadedValue()` (thanks to @vsk, I've 
> reduced the test 
> `llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir`)


I'd like to help test this, but `arc patch D73534` is now failing with merge 
conflicts. Can you please rebase this on master?


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

https://reviews.llvm.org/D73534



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


[PATCH] D74850: [clangd] Migrate Lexer usages in TypeHierarchy to TokenBuffers

2020-02-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Also fixes a bug, resulting from directly using ND.getEndLoc() for end
location of the range. As ND.getEndLoc() points to the begining of the last
token, whereas it should point one past the end, since LSP ranges are half open
(exclusive on the end).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74850

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/test/type-hierarchy.test

Index: clang-tools-extra/clangd/test/type-hierarchy.test
===
--- clang-tools-extra/clangd/test/type-hierarchy.test
+++ clang-tools-extra/clangd/test/type-hierarchy.test
@@ -48,7 +48,7 @@
 # CHECK-NEXT:"parents": [],
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
-# CHECK-NEXT:"character": 15,
+# CHECK-NEXT:"character": 16,
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "start": {
@@ -71,7 +71,7 @@
 # CHECK-NEXT:],
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
-# CHECK-NEXT:"character": 24,
+# CHECK-NEXT:"character": 25,
 # CHECK-NEXT:"line": 1
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "start": {
@@ -94,7 +94,7 @@
 # CHECK-NEXT:],
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
-# CHECK-NEXT:"character": 24,
+# CHECK-NEXT:"character": 25,
 # CHECK-NEXT:"line": 2
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "start": {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -36,6 +36,7 @@
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/IndexingOptions.h"
 #include "clang/Index/USRGeneration.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -592,22 +593,25 @@
 
 // FIXME(nridge): Reduce duplication between this function and declToSym().
 static llvm::Optional
-declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND) {
+declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND,
+const syntax::TokenBuffer &TB) {
   auto &SM = Ctx.getSourceManager();
-
   SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
-  // getFileLoc is a good choice for us, but we also need to make sure
-  // sourceLocToPosition won't switch files, so we call getSpellingLoc on top of
-  // that to make sure it does not switch files.
-  // FIXME: sourceLocToPosition should not switch files!
-  SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
-  SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
-  if (NameLoc.isInvalid() || BeginLoc.isInvalid() || EndLoc.isInvalid())
-return llvm::None;
+  auto FilePath =
+  getCanonicalPath(SM.getFileEntryForID(SM.getFileID(NameLoc)), SM);
+  auto TUPath = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
+  if (!FilePath || !TUPath)
+return llvm::None; // Not useful without a uri.
 
-  Position NameBegin = sourceLocToPosition(SM, NameLoc);
-  Position NameEnd = sourceLocToPosition(
-  SM, Lexer::getLocForEndOfToken(NameLoc, 0, SM, Ctx.getLangOpts()));
+  auto Tokens = TB.spelledForExpanded(TB.expandedTokens(ND.getSourceRange()));
+  if (!Tokens || Tokens->empty())
+return llvm::None;
+  const auto *NameTok =
+  llvm::partition_point(*Tokens, [&SM, &NameLoc](const syntax::Token &T) {
+return SM.isBeforeInTranslationUnit(T.location(), NameLoc);
+  });
+  if (!NameTok)
+return llvm::None;
 
   index::SymbolInfo SymInfo = index::getSymbolInfo(&ND);
   // FIXME: this is not classifying constructors, destructors and operators
@@ -618,20 +622,16 @@
   THI.name = printName(Ctx, ND);
   THI.kind = SK;
   THI.deprecated = ND.isDeprecated();
-  THI.range =
-  Range{sourceLocToPosition(SM, BeginLoc), sourceLocToPosition(SM, EndLoc)};
-  THI.selectionRange = Range{NameBegin, NameEnd};
+  THI.range = halfOpenToRange(
+  SM, syntax::Token::range(SM, Tokens->front(), Tokens->back())
+  .toCharRange(SM));
+  THI.selectionRange = halfOpenToRange(SM, NameTok->range(SM).toCharRange(SM));
   if (!THI.range.contains(THI.selectionRange)) {
 // 'selectionRange' must be contained in 'range', so in cases where clang
 // reports unrelated ranges we need to reconcile somehow.
 THI.range = THI.selectionRange;
   }
 
-  auto FilePath =
-  getCanonicalPath(SM.getFileEntryForID(SM.getFileID(BeginLoc)), SM);
-  auto TUPath = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
-  if (!FilePath || !TUPath)
- 

[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.



> Sounds good. I was trying to figure out how to invoke the new pass manager 
> with OPT. Is there a command line switch to do that?

If you just do `opt -passes=`, it will invoke new pass manager for 
`opt`. See https://reviews.llvm.org/D66560 for example - that was for legacy 
PM, the equivalent for new PM would be something like `opt < %s 2>&1 
-passes=forceattrs ...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74814



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1514
+  void visitUsedDecl(SourceLocation Loc, Decl *D) {
+if (auto *TD = dyn_cast(D)) {
+  for (auto *DD : TD->decls()) {

erichkeane wrote:
> Note that when recommitting this (if you choose to), this needs to also 
> handle NamespaceDecl.  We're a downstream and discovered that this doesn't 
> properly handle functions or records handled in a namespace.
> 
> It can be implemented identically to TranslationUnitDecl.
Wait, what?  We shouldn't be doing this for TranslationUnitDecl either.   I 
don't even know how we're "using" a TranslationUnitDecl, but neither this case 
not the case for `NamespaceDecl` should be recursively using every declaration 
declared inside it.  If there's a declaration in a namespace that's being used, 
it should be getting visited as part of the actual use of it.

The logic for `RecordDecl` has the same problem.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74811: [Driver] Escape the program path for -frecord-command-line

2020-02-19 Thread Ravi Ramaseshan via Phabricator via cfe-commits
ravi-ramaseshan updated this revision to Diff 245456.
ravi-ramaseshan added a comment.

Add a simple test with a command-line that needs the escaping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74811

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -581,6 +581,11 @@
 // CHECK-RECORD-GCC-SWITCHES: "-record-command-line"
 // CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line"
 // CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option 
'-frecord-command-line' for target
+// Test when clang is in a path containing a space.
+// RUN: mkdir -p "%t.r/with spaces"
+// RUN: cp %clang "%t.r/with spaces/clang"
+// RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux 
-frecord-gcc-switches %s 2>&1 | FileCheck 
-check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s
+// CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}/with\\ 
spaces/clang {{.+}}"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | 
FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck 
-check-prefix=CHECK-TRIVIAL-PATTERN %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5880,7 +5880,7 @@
   Arg->render(Args, OriginalArgs);
 
 SmallString<256> Flags;
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
@@ -6788,7 +6788,7 @@
 
 SmallString<256> Flags;
 const char *Exec = getToolChain().getDriver().getClangProgramPath();
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -581,6 +581,11 @@
 // CHECK-RECORD-GCC-SWITCHES: "-record-command-line"
 // CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line"
 // CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option '-frecord-command-line' for target
+// Test when clang is in a path containing a space.
+// RUN: mkdir -p "%t.r/with spaces"
+// RUN: cp %clang "%t.r/with spaces/clang"
+// RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s
+// CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}/with\\ spaces/clang {{.+}}"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5880,7 +5880,7 @@
   Arg->render(Args, OriginalArgs);
 
 SmallString<256> Flags;
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
@@ -6788,7 +6788,7 @@
 
 SmallString<256> Flags;
 const char *Exec = getToolChain().getDriver().getClangProgramPath();
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74811: [Driver] Escape the program path for -frecord-command-line

2020-02-19 Thread Ravi Ramaseshan via Phabricator via cfe-commits
ravi-ramaseshan added a comment.

In D74811#1882783 , @scott.linder 
wrote:

> This LGTM, but could you add a simple test with a command-line that needs the 
> escaping?


Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74811



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


[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-19 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 245461.
hliao added a comment.

Rebase to the latest trunk code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/global-initializers-host.cu
  clang/test/SemaCUDA/hip-pinned-shadow.cu

Index: clang/test/SemaCUDA/hip-pinned-shadow.cu
===
--- clang/test/SemaCUDA/hip-pinned-shadow.cu
+++ clang/test/SemaCUDA/hip-pinned-shadow.cu
@@ -13,13 +13,19 @@
 
 template 
 struct texture : public textureReference {
+// expected-note@-1{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-3{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-4{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
 texture() { a = 1; }
+// expected-note@-1{{candidate constructor not viable: call to __host__ function from __device__ function}}
+// expected-note@-2{{candidate constructor not viable: call to __host__ function from __device__ function}}
 };
 
 __hip_pinned_shadow__ texture tex;
 __device__ __hip_pinned_shadow__ texture tex2; // expected-error{{'hip_pinned_shadow' and 'device' attributes are not compatible}}
-// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-// expected-note@-2{{conflicting attribute is here}}
+// expected-note@-1{{conflicting attribute is here}}
+// expected-error@-2{{no matching constructor for initialization of 'texture'}}
 __constant__ __hip_pinned_shadow__ texture tex3; // expected-error{{'hip_pinned_shadow' and 'constant' attributes are not compatible}}
-  // expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-  // expected-note@-2{{conflicting attribute is here}}
+  // expected-note@-1{{conflicting attribute is here}}
+  // expected-error@-2{{no matching constructor for initialization of 'texture'}}
Index: clang/test/SemaCUDA/global-initializers-host.cu
===
--- clang/test/SemaCUDA/global-initializers-host.cu
+++ clang/test/SemaCUDA/global-initializers-host.cu
@@ -6,12 +6,14 @@
 // module initializer.
 
 struct S {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
   __device__ S() {}
-  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 
 S s;
-// expected-error@-1 {{reference to __device__ function 'S' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'S'}}
 
 struct T {
   __host__ __device__ T() {}
@@ -19,14 +21,17 @@
 T t;  // No error, this is OK.
 
 struct U {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const U' for 1st argument}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'U' for 1st argument}}
   __host__ U() {}
+  // expected-note@-1 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
   __device__ U(int) {}
-  // expected-note@-1 {{'U' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 U u(42);
-// expected-error@-1 {{reference to __device__ function 'U' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'U'}}
 
 __device__ int device_fn() { return 42; }
-// expected-note@-1 {{'device_fn' declared here}}
+// expected-note@-1 {{candidate function not viable: call to __devi

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1514
+  void visitUsedDecl(SourceLocation Loc, Decl *D) {
+if (auto *TD = dyn_cast(D)) {
+  for (auto *DD : TD->decls()) {

rjmccall wrote:
> erichkeane wrote:
> > Note that when recommitting this (if you choose to), this needs to also 
> > handle NamespaceDecl.  We're a downstream and discovered that this doesn't 
> > properly handle functions or records handled in a namespace.
> > 
> > It can be implemented identically to TranslationUnitDecl.
> Wait, what?  We shouldn't be doing this for TranslationUnitDecl either.   I 
> don't even know how we're "using" a TranslationUnitDecl, but neither this 
> case not the case for `NamespaceDecl` should be recursively using every 
> declaration declared inside it.  If there's a declaration in a namespace 
> that's being used, it should be getting visited as part of the actual use of 
> it.
> 
> The logic for `RecordDecl` has the same problem.  
Despite the name, this seems to be more of a home-written ast walking class.  
The entry point is the 'translation unit' which seems to walk through 
everything in an attempt to find all the functions (including those that are 
'marked' as used by an attribute).

You'll see the FunctionDecl section makes this assumption as well (not 
necessarily that we got to a function via a call). IMO, this approach is 
strange, and we should register entry points in some manner (functions marked 
as emitted to the device in some fashion), then just follow its call-graph (via 
the clang::CallGraph?) to emit all of these functions.

It seemed really odd to see this approach here, but it seemed well reviewed by 
the time I noticed it (via a downstream bug) so I figured I'd lost my chance to 
disagree with the approach.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-02-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

This code has now been tested on a running Linux kernel making use of the 
feature.

I still would like @jyknight to clarify his comments, consider explicitly 
requesting changes to this CL, or consider resigning as reviewer.




Comment at: llvm/include/llvm/CodeGen/MachineBasicBlock.h:137
+  /// List of indirect targets of the callbr of a basic block.
+  SmallPtrSet InlineAsmBrIndirectTargets;
+

It's likely the count here is 0, or maybe 1.  We don't see too often a large 
list of labels here.



Comment at: llvm/lib/CodeGen/MachineVerifier.cpp:701
+  } else if (MBB->succ_size() == LandingPadSuccs.size() ||
+ MBB->succ_size() == IndirectPadSuccs.size()) {
 // It's possible that the block legitimately ends with a noreturn

void wrote:
> void wrote:
> > jyknight wrote:
> > > void wrote:
> > > > jyknight wrote:
> > > > > This isn't correct.
> > > > > 
> > > > > This line here, is looking at a block which doesn't end in a jump to 
> > > > > a successor. So, it's trying to verify that the successor list makes 
> > > > > sense in that context.
> > > > > 
> > > > > The unstated assumption in the code is that the only successors will 
> > > > > be landing pads. Instead of actually checking each one, instead it 
> > > > > just checks that the count is the number of landing pads, with the 
> > > > > assumption that all the successors should be landing pads, and that 
> > > > > all the landing pads should be successors.
> > > > > 
> > > > > The next clause is then checking for the case where there's a 
> > > > > fallthrough to the next block. In that case, the successors should've 
> > > > > been all the landing pads, and the single fallthrough block.
> > > > > 
> > > > > Adding similar code to check for the number of callbr targets doesn't 
> > > > > really make sense. It's certainly not the case that all callbr 
> > > > > targets are targets of all 
> > > > > callbr instructions. And even if it was, this still wouldn't be 
> > > > > counting things correctly.
> > > > > 
> > > > > 
> > > > > However -- I think i'd expect analyzeBranch to error out (returning 
> > > > > true) when confronted by a callbr instruction, because it cannot 
> > > > > actually tell what's going on there. If that were the case, nothing 
> > > > > in this block should even be invoked. But I guess that's probably not 
> > > > > happening, due to the terminator being followed by non-terminators.
> > > > > 
> > > > > That seems likely to be a problem that needs to be fixed. (And if 
> > > > > that is fixed, I think the changes here aren't needed anymore)
> > > > > 
> > > > > 
> > > > Your comment is very confusing. Could you please give an example of 
> > > > where this fails?
> > > Sorry about that, I should've delimited the parts of that message 
> > > better...
> > > Basically:
> > > - Paragraphs 2-4 are describing why the code before this patch appears to 
> > > be correct for landing pad, even though it's taking some shortcuts and 
> > > making some non-obvious assumptions.
> > > - Paragraph 5 ("Adding similar code"...) is why it's not correct for 
> > > callbr.
> > > - Paragraph 6-7 are how I'd suggest to resolve it.
> > > 
> > > 
> > > I believe the code as of your patch will fail validation if you have a 
> > > callbr instruction which has a normal-successor block which is an 
> > > indirect target of a *different* callbr in the function.
> > > 
> > > I believe it'll also fail if you have any landing-pad successors, since 
> > > those aren't being added to the count of expected successors, but rather 
> > > checked separately.
> > > 
> > > But more seriously than these potential verifier failures, I expect that 
> > > analyzeBranch returning wrong answers (in that it may report that a block 
> > > unconditionally-jumps to a successor, while it really has both a callbr 
> > > and jump, separated by the non-terminator copies) will cause 
> > > miscompilation. I'm not sure exactly how that will exhibit, but I'm 
> > > pretty sure it's not going to be good.
> > > 
> > > And, if analyzeBranch properly said "no idea" when confronted by callbr 
> > > control flow, then this code in the verifier wouldn't be reached.
> > I didn't need a delineation of the parts of the comment. I needed a clearer 
> > description of what your concern is, and to give an example of code that 
> > fails here.
> > 
> > This bit of code is simply saying that if the block containing the 
> > `INLINEASM_BR` doesn't end with a `BR` instruction, then the number of its 
> > successors should be equal to the number of indirect successors. This is 
> > correct, as it's not valid to have a duplicate label used in a `callbr` 
> > instruction:
> > 
> > ```
> > $ llc -o /dev/null x.ll
> > Duplicate callbr destination!
> >   %3 = callbr i32 asm sideeffect "testl $0, $

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1514
+  void visitUsedDecl(SourceLocation Loc, Decl *D) {
+if (auto *TD = dyn_cast(D)) {
+  for (auto *DD : TD->decls()) {

erichkeane wrote:
> rjmccall wrote:
> > erichkeane wrote:
> > > Note that when recommitting this (if you choose to), this needs to also 
> > > handle NamespaceDecl.  We're a downstream and discovered that this 
> > > doesn't properly handle functions or records handled in a namespace.
> > > 
> > > It can be implemented identically to TranslationUnitDecl.
> > Wait, what?  We shouldn't be doing this for TranslationUnitDecl either.   I 
> > don't even know how we're "using" a TranslationUnitDecl, but neither this 
> > case not the case for `NamespaceDecl` should be recursively using every 
> > declaration declared inside it.  If there's a declaration in a namespace 
> > that's being used, it should be getting visited as part of the actual use 
> > of it.
> > 
> > The logic for `RecordDecl` has the same problem.  
> Despite the name, this seems to be more of a home-written ast walking class.  
> The entry point is the 'translation unit' which seems to walk through 
> everything in an attempt to find all the functions (including those that are 
> 'marked' as used by an attribute).
> 
> You'll see the FunctionDecl section makes this assumption as well (not 
> necessarily that we got to a function via a call). IMO, this approach is 
> strange, and we should register entry points in some manner (functions marked 
> as emitted to the device in some fashion), then just follow its call-graph 
> (via the clang::CallGraph?) to emit all of these functions.
> 
> It seemed really odd to see this approach here, but it seemed well reviewed 
> by the time I noticed it (via a downstream bug) so I figured I'd lost my 
> chance to disagree with the approach.
> 
> 
Sure, but `visitUsedDecl` isn't the right place to be entering the walk.  
`visitUsedDecl` is supposed to be the *callback* from the walk.  If they need 
to walk all the global declarations to find kernels instead of tracking the 
kernels as they're encountered (which would be a *much* better approach), it 
should be done as a separate function.

I just missed this in the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-19 Thread Hongtao Yu via Phabricator via cfe-commits
hoyFB updated this revision to Diff 245474.
hoyFB added a comment.

Updating D74814 : IR printing for single 
function with the new pass manager.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74814

Files:
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/module-pass-printer.ll


Index: llvm/test/Other/module-pass-printer.ll
===
--- llvm/test/Other/module-pass-printer.ll
+++ llvm/test/Other/module-pass-printer.ll
@@ -1,14 +1,28 @@
 ; Check pass name is only printed once.
 ; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all | FileCheck 
%s
 ; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo,bar | FileCheck %s
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo | FileCheck %s  -check-prefix=FOO
 
 ; Check pass name is not printed if a module doesn't include any function 
specified in -filter-print-funcs.
 ; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all 
-filter-print-funcs=baz | FileCheck %s -allow-empty -check-prefix=EMPTY
 
+; Check whole module is printed with user-specified wildcast switch 
-filter-print-funcs=* or -print-module-scope
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all | 
FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=* | FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo -print-module-scope | FileCheck %s -check-prefix=ALL
+
 ; CHECK: *** IR Dump After Force set function attributes ***
 ; CHECK-NOT: *** IR Dump After Force set function attributes ***
 ; EMPTY-NOT: *** IR Dump After Force set function attributes ***
 
+; FOO:  IR Dump After ForceFunctionAttrsPass
+; FOO:  define void @foo
+; FOO-NOT:  define void @bar
+
+; ALL:  IR Dump After ForceFunctionAttrsPass
+; ALL:  define void @foo
+; ALL:  define void @bar
+
 define void @foo() {
   ret void
 }
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -70,16 +70,24 @@
   llvm_unreachable("Unknown IR unit");
 }
 
-void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
-  dbgs() << Banner << Extra << "\n";
-  M->print(dbgs(), nullptr, false);
-}
 void printIR(const Function *F, StringRef Banner,
  StringRef Extra = StringRef()) {
   if (!llvm::isFunctionInPrintList(F->getName()))
 return;
   dbgs() << Banner << Extra << "\n" << static_cast(*F);
 }
+
+void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
+  if (llvm::isFunctionInPrintList("*") || llvm::forcePrintModuleIR()) {
+dbgs() << Banner << Extra << "\n";
+M->print(dbgs(), nullptr, false);
+  } else {
+for (const auto &F : M->functions()) {
+  printIR(&F, Banner, Extra);
+}
+  }
+}
+
 void printIR(const LazyCallGraph::SCC *C, StringRef Banner,
  StringRef Extra = StringRef()) {
   bool BannerPrinted = false;


Index: llvm/test/Other/module-pass-printer.ll
===
--- llvm/test/Other/module-pass-printer.ll
+++ llvm/test/Other/module-pass-printer.ll
@@ -1,14 +1,28 @@
 ; Check pass name is only printed once.
 ; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all | FileCheck %s
 ; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all -filter-print-funcs=foo,bar | FileCheck %s
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all -filter-print-funcs=foo | FileCheck %s  -check-prefix=FOO
 
 ; Check pass name is not printed if a module doesn't include any function specified in -filter-print-funcs.
 ; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all -filter-print-funcs=baz | FileCheck %s -allow-empty -check-prefix=EMPTY
 
+; Check whole module is printed with user-specified wildcast switch -filter-print-funcs=* or -print-module-scope
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all | FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all -filter-print-funcs=* | FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all -filter-print-funcs=foo -print-module-scope | FileCheck %s -check-prefix=ALL
+
 ; CHECK: *** IR Dump After Force set function attributes ***
 ; CHECK-NOT: *** IR Dump After Force set function attributes ***
 ; EMPTY-NOT: *** IR Dump After Force set function attributes ***
 
+; FOO:  IR Dump After ForceFunctionAttrsPass
+; FOO:  define void @foo
+; FOO-NOT:  define void 

[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei accepted this revision.
wenlei added a comment.
This revision is now accepted and ready to land.

Thanks for the making the changes, it would be nice to have some consistency 
(the same structure) between test cases for legacy PM and new PM, e.g. `EMPTY` 
is only tested for legacy PM, but not new; multi-function filter also only 
tested for legacy PM, would be nice to do them for both, and unify the 
check-prefix, otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74814



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


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-02-19 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv added a subscriber: vsk.
alexbdv added a comment.

@vsk  - sure will add tests when removing from RFC.
As for making it default - would rather have this under a flag as hashing the 
block contents does have some overhead and I imagine this feature wouldn't be 
beneficial in most scenarios. Also, unexpectedly (by default) changing the name 
of the function blocks might have a negative impact on some existing workflows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74813



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D73534#1883048 , @djtodoro wrote:

> I’ve already pushed this. Please rebase on the latest commits.


Ah faff707db82d7db12fcd9f7826b8741261230e63 
. Cool, I 
can no longer reproduce the previous issue. Thanks for the quick fix.


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D73534#1883022 , @nickdesaulniers 
wrote:

> In D73534#1882136 , @djtodoro wrote:
>
> > - Address the issue with ARM `describeLoadedValue()` (thanks to @vsk, I've 
> > reduced the test 
> > `llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir`)
>
>
> I'd like to help test this, but `arc patch D73534` is now failing with merge 
> conflicts. Can you please rebase this on master?


I’ve already pushed this. Please rebase on the latest commits.


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

https://reviews.llvm.org/D73534



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


[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-19 Thread Hongtao Yu via Phabricator via cfe-commits
hoyFB updated this revision to Diff 245484.
hoyFB added a comment.

Updating D74814 : IR printing for single 
function with the new pass manager.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74814

Files:
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/module-pass-printer.ll


Index: llvm/test/Other/module-pass-printer.ll
===
--- llvm/test/Other/module-pass-printer.ll
+++ llvm/test/Other/module-pass-printer.ll
@@ -1,13 +1,43 @@
 ; Check pass name is only printed once.
-; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all | FileCheck 
%s
-; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo,bar | FileCheck %s
+; Check only one function is printed
+; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo | FileCheck %s  -check-prefix=FOO
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo | FileCheck %s  -check-prefix=FOO
+
+; Check pass name is only printed once.
+; Check both functions are printed
+; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo,bar | FileCheck %s -check-prefix=BOTH
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo,bar | FileCheck %s -check-prefix=BOTH
 
 ; Check pass name is not printed if a module doesn't include any function 
specified in -filter-print-funcs.
 ; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all 
-filter-print-funcs=baz | FileCheck %s -allow-empty -check-prefix=EMPTY
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=baz | FileCheck %s -allow-empty -check-prefix=EMPTY
+
+; Check whole module is printed with user-specified wildcast switch 
-filter-print-funcs=* or -print-module-scope
+; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all | FileCheck 
%s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -forceattrs -disable-output  -print-after-all 
-filter-print-funcs=* | FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo -print-module-scope | FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all | 
FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=* | FileCheck %s -check-prefix=ALL
+; RUN: opt < %s 2>&1 -passes=forceattrs -disable-output -print-after-all 
-filter-print-funcs=foo -print-module-scope | FileCheck %s -check-prefix=ALL
+
+; FOO:  IR Dump After {{Force set function 
attributes|ForceFunctionAttrsPass}}
+; FOO:  define void @foo
+; FOO-NOT:  define void @bar
+; FOO-NOT:  IR Dump After {{Force set function 
attributes|ForceFunctionAttrsPass}}
+
+; BOTH: IR Dump After {{Force set function 
attributes|ForceFunctionAttrsPass}}
+; BOTH: define void @foo
+; BOTH: define void @bar
+; BOTH-NOT: IR Dump After {{Force set function 
attributes|ForceFunctionAttrsPass}}
+; BOTH-NOT: ModuleID =
+
+; EMPTY-NOT: IR Dump After {{Force set function 
attributes|ForceFunctionAttrsPass}}
 
-; CHECK: *** IR Dump After Force set function attributes ***
-; CHECK-NOT: *** IR Dump After Force set function attributes ***
-; EMPTY-NOT: *** IR Dump After Force set function attributes ***
+; ALL:  IR Dump After {{Force set function attributes|ForceFunctionAttrsPass}}
+; ALL:  ModuleID =
+; ALL:  define void @foo
+; ALL:  define void @bar
+; ALL-NOT: IR Dump After {{Force set function 
attributes|ForceFunctionAttrsPass}}
 
 define void @foo() {
   ret void
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -70,16 +70,24 @@
   llvm_unreachable("Unknown IR unit");
 }
 
-void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
-  dbgs() << Banner << Extra << "\n";
-  M->print(dbgs(), nullptr, false);
-}
 void printIR(const Function *F, StringRef Banner,
  StringRef Extra = StringRef()) {
   if (!llvm::isFunctionInPrintList(F->getName()))
 return;
   dbgs() << Banner << Extra << "\n" << static_cast(*F);
 }
+
+void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
+  if (llvm::isFunctionInPrintList("*") || llvm::forcePrintModuleIR()) {
+dbgs() << Banner << Extra << "\n";
+M->print(dbgs(), nullptr, false);
+  } else {
+for (const auto &F : M->functions()) {
+  printIR(&F, Banner, Extra);
+}
+  }
+}
+
 void printIR(const LazyCallGraph::SCC *C, StringRef Banner,
  StringRef Extra = StringRef()) {
   bool BannerPrinted = false;


Index: llvm/tes

[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-19 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D72231#1882658 , @rjmccall wrote:

> Okay.  Can we raise this with the kernel folks instead of just assuming 
> they'll be opposed?  An obvious patch to fix a few dozen places where they're 
> hit by a warning they intentionally enabled really doesn't seem like a 
> burden.  If they push back, fine, we can enable the warning without covering 
> enums.


In the original diff the warning was opt in, in the final version it's enabled 
by default. So they didn't enable the warning intentionally. I agree; if the 
kernel folks rather not change their code I can create an option to disable the 
warning for enums, just like it can already be disabled for `void*`s.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-02-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/Basic/FixedPoint.cpp:242
+  } else
+Overflowed = Result < Min || Result > Max;
+

ebevhan wrote:
> rjmccall wrote:
> > ebevhan wrote:
> > > rjmccall wrote:
> > > > leonardchan wrote:
> > > > > ebevhan wrote:
> > > > > > rjmccall wrote:
> > > > > > > ebevhan wrote:
> > > > > > > > ebevhan wrote:
> > > > > > > > > rjmccall wrote:
> > > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > > fully-precise multiplication yields *k+e* for some epsilon 
> > > > > > > > > > *e* that isn't representable in the result semantics, is 
> > > > > > > > > > that considered an overflow?  If so, I think you need to do 
> > > > > > > > > > the shift after these bound checks, since the shift 
> > > > > > > > > > destroys the difference between *k* and *k+e*.  That is, 
> > > > > > > > > > unless there's a compelling mathematical argument that it's 
> > > > > > > > > > not possible to overflow only in the fully-precision 
> > > > > > > > > > multiplication — but while I think that's possibly true of 
> > > > > > > > > > `_Fract` (since *k^2 < k*), it seems unlikely to be true of 
> > > > > > > > > > `_Accum`, although I haven't looked for a counter-example.  
> > > > > > > > > > And if there is a compelling argument, it should probably 
> > > > > > > > > > be at least alluded to in a comment.
> > > > > > > > > > 
> > > > > > > > > > Would this algorithm be simpler if you took advantage of 
> > > > > > > > > > the fact that `APFixedPointSemantics` doesn't have to 
> > > > > > > > > > correspond to a real type?  You could probably just convert 
> > > > > > > > > > to a double-width common semantics, right?
> > > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > > fully-precise multiplication yields *k+e* for some epsilon 
> > > > > > > > > > *e* that isn't representable in the result semantics, is 
> > > > > > > > > > that considered an overflow? If so, I think you need to do 
> > > > > > > > > > the shift after these bound checks, since the shift 
> > > > > > > > > > destroys the difference between *k* and *k+e*.
> > > > > > > > > 
> > > > > > > > > I don't think I would consider that to be overflow; that's 
> > > > > > > > > precision loss. E-C considers these to be different:
> > > > > > > > > 
> > > > > > > > > > If the source value cannot be represented exactly by the 
> > > > > > > > > > fixed-point type, the source value is rounded to either the 
> > > > > > > > > > closest fixed-point value greater than the source value 
> > > > > > > > > > (rounded up) or to the closest fixed-point value less than 
> > > > > > > > > > the source value (rounded down).
> > > > > > > > > >
> > > > > > > > > > When the source value does not fit within the range of the 
> > > > > > > > > > fixed-point type, the conversion overflows. [...]
> > > > > > > > > >
> > > > > > > > > > [...]
> > > > > > > > > >
> > > > > > > > > > If the result type of an arithmetic operation is a 
> > > > > > > > > > fixed-point type, [...] the calculated result is the 
> > > > > > > > > > mathematically exact result with overflow handling and 
> > > > > > > > > > rounding performed to the full precision of the result type 
> > > > > > > > > > as explained in 4.1.3. 
> > > > > > > > > 
> > > > > > > > > There is also no value of `e` that would affect saturation. 
> > > > > > > > > Any full precision calculation that gives `k+e` must be `k` 
> > > > > > > > > after downscaling, since the bits that represent `e` must 
> > > > > > > > > come from the extra precision range. Even though `k+e` is 
> > > > > > > > > technically larger than `k`, saturation would still just give 
> > > > > > > > > us `k` after truncating out `e`, so the end result is the 
> > > > > > > > > same.
> > > > > > > > > 
> > > > > > > > > > Would this algorithm be simpler if you took advantage of 
> > > > > > > > > > the fact that APFixedPointSemantics doesn't have to 
> > > > > > > > > > correspond to a real type? You could probably just convert 
> > > > > > > > > > to a double-width common semantics, right?
> > > > > > > > > 
> > > > > > > > > It's likely possible to use APFixedPoint in the calculations 
> > > > > > > > > here, but I used APInt to make the behavior explicit and not 
> > > > > > > > > accidentally be dependent on the behavior of APFixedPoint's 
> > > > > > > > > conversions or operations.
> > > > > > > > Although.,. I guess I see your point in that an intermediate 
> > > > > > > > result of k+e technically "does not fit within the range of the 
> > > > > > > > fixed-point type"... but I wonder if treating such cases as 
> > > > > > > > overflow is particularly meaningful. I don't find there to be 
> > > > > > > > much of a distinction between such a case and the case where 
> > > > > > > > the exact result lands inbetween two representable values. We 
> > > > > > > > just end up with a less precise result.
> > > > > > > Righ

[clang] f6875c4 - Reapply [IRBuilder] Always respect inserter/folder

2020-02-19 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2020-02-19T20:51:38+01:00
New Revision: f6875c434ec20eb4f24495317592f64334347784

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

LOG: Reapply [IRBuilder] Always respect inserter/folder

Some IRBuilder methods that were originally defined on
IRBuilderBase do not respect custom IRBuilder inserters/folders,
because those were not accessible prior to D73835. Fix this by
making use of existing (and now accessible) IRBuilder methods,
which will handle inserters/folders correctly.

There are some changes in OpenMP and Instrumentation tests, where
bitcasts now get constant folded. I've also highlighted one
InstCombine test which now finishes in two rather than three
iterations, thanks to new instructions being inserted into the
worklist.

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

Added: 


Modified: 
clang/test/OpenMP/parallel_codegen.cpp
clang/test/OpenMP/target_firstprivate_codegen.cpp
llvm/lib/IR/IRBuilder.cpp
llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll
llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll
llvm/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64.ll
llvm/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64le.ll
llvm/test/Instrumentation/MemorySanitizer/X86/vararg_call.ll
llvm/test/Instrumentation/MemorySanitizer/byval-alignment.ll
llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Removed: 




diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index f96ad406c25f..586187f09521 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -60,8 +60,7 @@ int main (int argc, char **argv) {
 // ALL-DEBUG-LABEL: define i32 @main(i32 %argc, i8** %argv)
 // CHECK-DEBUG:   [[LOC_2_ADDR:%.+]] = alloca %struct.ident_t
 // CHECK-DEBUG:   [[KMPC_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* 
[[LOC_2_ADDR]] to i8*
-// CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_VOIDPTR:%.+]] = bitcast 
%struct.ident_t* [[DEF_LOC_2]] to i8*
-// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 [[KMPC_DEFAULT_LOC_VOIDPTR]], i64 24, i1 
false)
+// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 bitcast (%struct.ident_t* [[DEF_LOC_2]] to 
i8*), i64 24, i1 false)
 // ALL-DEBUG:   store i32 %argc, i32* [[ARGC_ADDR:%.+]],
 // ALL-DEBUG:   [[VLA:%.+]] = alloca i32, i64 [[VLA_SIZE:%[^,]+]],
 // CHECK-DEBUG:   [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds 
%struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
@@ -118,8 +117,7 @@ int main (int argc, char **argv) {
 // ALL-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
 // CHECK-DEBUG-DAG:   [[LOC_2_ADDR:%.+]] = alloca %struct.ident_t
 // CHECK-DEBUG:   [[KMPC_LOC_VOIDPTR:%.+]] = bitcast %struct.ident_t* 
[[LOC_2_ADDR]] to i8*
-// CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_VOIDPTR:%.+]] = bitcast 
%struct.ident_t* [[DEF_LOC_2]] to i8*
-// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 [[KMPC_DEFAULT_LOC_VOIDPTR]], i64 24, i1 
false)
+// CHECK-DEBUG-NEXT:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 
[[KMPC_LOC_VOIDPTR]], i8* align 8 bitcast (%struct.ident_t* [[DEF_LOC_2]] to 
i8*), i64 24, i1 false)
 // CHECK-DEBUG-NEXT:  store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK-DEBUG:  [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds 
%struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
 // CHECK-DEBUG-NEXT:  store i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} 
x i8]* [[LOC2]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]]

diff  --git a/clang/test/OpenMP/target_firstprivate_codegen.cpp 
b/clang/test/OpenMP/target_firstprivate_codegen.cpp
index 0b5f5f9b2b17..b90ab42f5ae2 100644
--- a/clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ b/clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -336,9 +336,8 @@ int foo(int n, double *ptr) {
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[FP_E_BC:%.+]] = bitcast [[TTII]]* [[FP_E]] to i8*
   // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} 
[[FP_E_BC]], i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
+  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast 
([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAS

[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-02-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Basic/FixedPoint.cpp:242
+  } else
+Overflowed = Result < Min || Result > Max;
+

leonardchan wrote:
> ebevhan wrote:
> > rjmccall wrote:
> > > ebevhan wrote:
> > > > rjmccall wrote:
> > > > > leonardchan wrote:
> > > > > > ebevhan wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > ebevhan wrote:
> > > > > > > > > ebevhan wrote:
> > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > > > fully-precise multiplication yields *k+e* for some 
> > > > > > > > > > > epsilon *e* that isn't representable in the result 
> > > > > > > > > > > semantics, is that considered an overflow?  If so, I 
> > > > > > > > > > > think you need to do the shift after these bound checks, 
> > > > > > > > > > > since the shift destroys the difference between *k* and 
> > > > > > > > > > > *k+e*.  That is, unless there's a compelling mathematical 
> > > > > > > > > > > argument that it's not possible to overflow only in the 
> > > > > > > > > > > fully-precision multiplication — but while I think that's 
> > > > > > > > > > > possibly true of `_Fract` (since *k^2 < k*), it seems 
> > > > > > > > > > > unlikely to be true of `_Accum`, although I haven't 
> > > > > > > > > > > looked for a counter-example.  And if there is a 
> > > > > > > > > > > compelling argument, it should probably be at least 
> > > > > > > > > > > alluded to in a comment.
> > > > > > > > > > > 
> > > > > > > > > > > Would this algorithm be simpler if you took advantage of 
> > > > > > > > > > > the fact that `APFixedPointSemantics` doesn't have to 
> > > > > > > > > > > correspond to a real type?  You could probably just 
> > > > > > > > > > > convert to a double-width common semantics, right?
> > > > > > > > > > > If the maximum expressible value is *k*, and the 
> > > > > > > > > > > fully-precise multiplication yields *k+e* for some 
> > > > > > > > > > > epsilon *e* that isn't representable in the result 
> > > > > > > > > > > semantics, is that considered an overflow? If so, I think 
> > > > > > > > > > > you need to do the shift after these bound checks, since 
> > > > > > > > > > > the shift destroys the difference between *k* and *k+e*.
> > > > > > > > > > 
> > > > > > > > > > I don't think I would consider that to be overflow; that's 
> > > > > > > > > > precision loss. E-C considers these to be different:
> > > > > > > > > > 
> > > > > > > > > > > If the source value cannot be represented exactly by the 
> > > > > > > > > > > fixed-point type, the source value is rounded to either 
> > > > > > > > > > > the closest fixed-point value greater than the source 
> > > > > > > > > > > value (rounded up) or to the closest fixed-point value 
> > > > > > > > > > > less than the source value (rounded down).
> > > > > > > > > > >
> > > > > > > > > > > When the source value does not fit within the range of 
> > > > > > > > > > > the fixed-point type, the conversion overflows. [...]
> > > > > > > > > > >
> > > > > > > > > > > [...]
> > > > > > > > > > >
> > > > > > > > > > > If the result type of an arithmetic operation is a 
> > > > > > > > > > > fixed-point type, [...] the calculated result is the 
> > > > > > > > > > > mathematically exact result with overflow handling and 
> > > > > > > > > > > rounding performed to the full precision of the result 
> > > > > > > > > > > type as explained in 4.1.3. 
> > > > > > > > > > 
> > > > > > > > > > There is also no value of `e` that would affect saturation. 
> > > > > > > > > > Any full precision calculation that gives `k+e` must be `k` 
> > > > > > > > > > after downscaling, since the bits that represent `e` must 
> > > > > > > > > > come from the extra precision range. Even though `k+e` is 
> > > > > > > > > > technically larger than `k`, saturation would still just 
> > > > > > > > > > give us `k` after truncating out `e`, so the end result is 
> > > > > > > > > > the same.
> > > > > > > > > > 
> > > > > > > > > > > Would this algorithm be simpler if you took advantage of 
> > > > > > > > > > > the fact that APFixedPointSemantics doesn't have to 
> > > > > > > > > > > correspond to a real type? You could probably just 
> > > > > > > > > > > convert to a double-width common semantics, right?
> > > > > > > > > > 
> > > > > > > > > > It's likely possible to use APFixedPoint in the 
> > > > > > > > > > calculations here, but I used APInt to make the behavior 
> > > > > > > > > > explicit and not accidentally be dependent on the behavior 
> > > > > > > > > > of APFixedPoint's conversions or operations.
> > > > > > > > > Although.,. I guess I see your point in that an intermediate 
> > > > > > > > > result of k+e technically "does not fit within the range of 
> > > > > > > > > the fixed-point type"... but I wonder if treating such cases 
> > > > > > > > > as overflow is particularly meaningful. I don't find there to 
> > > > > > > > > be much of a distinction 

[clang] ba3f863 - [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

2020-02-19 Thread Johannes Doerfert via cfe-commits

Author: Fady Ghanim
Date: 2020-02-19T14:11:17-06:00
New Revision: ba3f863dfb9c5f9bf5e6fdca2198b609df3b7761

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

LOG: [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

This patch introduces a new helper class `OMPBuilderCBHelpers`,
which will contain all reusable C/C++ language specific function-
alities required by the `OMPIRBuilder`.

Initially, this helper class contains the body and finalization
codegen functionalities implemented using callbacks which were
moved here for reusability among the different directives
implemented in the `OMPIRBuilder`, along with RAIIs for preserving
state prior to emitting outlined and/or inlined OpenMP regions.

In the future this helper class will also contain all the different
call backs required by OpenMP clauses/variable privatization.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/OpenMP/cancel_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index d7115e00836c..bcd2d0635caf 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1450,15 +1450,7 @@ void CodeGenFunction::EmitOMPParallelDirective(const 
OMPParallelDirective &S) {
 // The cleanup callback that finalizes all variabels at the given location,
 // thus calls destructors etc.
 auto FiniCB = [this](InsertPointTy IP) {
-  CGBuilderTy::InsertPointGuard IPG(Builder);
-  assert(IP.getBlock()->end() != IP.getPoint() &&
- "OpenMP IR Builder should cause terminated block!");
-  llvm::BasicBlock *IPBB = IP.getBlock();
-  llvm::BasicBlock *DestBB = IPBB->splitBasicBlock(IP.getPoint());
-  IPBB->getTerminator()->eraseFromParent();
-  Builder.SetInsertPoint(IPBB);
-  CodeGenFunction::JumpDest Dest = getJumpDestInCurrentScope(DestBB);
-  EmitBranchThroughCleanup(Dest);
+  OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
 };
 
 // Privatization callback that performs appropriate action for
@@ -1480,25 +1472,10 @@ void CodeGenFunction::EmitOMPParallelDirective(const 
OMPParallelDirective &S) {
 auto BodyGenCB = [ParallelRegionBodyStmt,
   this](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
 llvm::BasicBlock &ContinuationBB) {
-  auto OldAllocaIP = AllocaInsertPt;
-  AllocaInsertPt = &*AllocaIP.getPoint();
-
-  auto OldReturnBlock = ReturnBlock;
-  ReturnBlock = getJumpDestInCurrentScope(&ContinuationBB);
-
-  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
-  CodeGenIPBB->splitBasicBlock(CodeGenIP.getPoint());
-  llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator();
-  CodeGenIPBBTI->removeFromParent();
-
-  Builder.SetInsertPoint(CodeGenIPBB);
-
-  EmitStmt(ParallelRegionBodyStmt);
-
-  Builder.Insert(CodeGenIPBBTI);
-
-  AllocaInsertPt = OldAllocaIP;
-  ReturnBlock = OldReturnBlock;
+  OMPBuilderCBHelpers::OutlinedRegionBodyRAII ORB(*this, AllocaIP,
+  ContinuationBB);
+  OMPBuilderCBHelpers::EmitOMPRegionBody(*this, ParallelRegionBodyStmt,
+ CodeGenIP, ContinuationBB);
 };
 
 CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
@@ -3152,55 +3129,18 @@ void CodeGenFunction::EmitOMPMasterDirective(const 
OMPMasterDirective &S) {
 const CapturedStmt *CS = S.getInnermostCapturedStmt();
 const Stmt *MasterRegionBodyStmt = CS->getCapturedStmt();
 
-// TODO: Replace with a generic helper function for finalization
 auto FiniCB = [this](InsertPointTy IP) {
-  CGBuilderTy::InsertPointGuard IPG(Builder);
-  assert(IP.getBlock()->end() != IP.getPoint() &&
- "OpenMP IR Builder should cause terminated block!");
-
-  llvm::BasicBlock *IPBB = IP.getBlock();
-  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
-  assert(DestBB && "Finalization block should have one successor!");
-
-  // erase and replace with cleanup branch.
-  IPBB->getTerminator()->eraseFromParent();
-  Builder.SetInsertPoint(IPBB);
-  CodeGenFunction::JumpDest Dest = getJumpDestInCurrentScope(DestBB);
-  EmitBranchThroughCleanup(Dest);
+  OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
 };
 
-// TODO: Replace with a generic helper function for emitting body
 auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
   InsertPointTy CodeGenIP,

[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11442
+  ContextDecl = getCUDACurrentNonLocalVariable();
+return ContextDecl;
+  }

This is tricky because we could be in a nested context, not just the 
initializer, and that context just might not be a function.   For example, 
there could be a local class in a lambda or something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227



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


[PATCH] D74116: [Sema][C++] Propagate conversion type in order to specialize the diagnostics

2020-02-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:14829
+if (getLangOpts().CPlusPlus)
+  isInvalid = true;
 break;

rjmccall wrote:
> Could you hoist this up to the place where we pick the diagnostic and then 
> make it unconditional in the path that always selects an error?
> 
> That's a general comment: we should be setting `isInvalid` for all the places 
> below where we select an error diagnostic.
> That's a general comment: we should be setting isInvalid for all the places 
> below where we select an error diagnostic.

If I change to set `isInvalid` for all error cases I get less diagnostics. I 
guess it's because we now stop earlier and don't continue to diagnosing in some 
cases.


```
FAIL: Clang :: Sema/block-call.c (9327 of 16808)
 TEST 'Clang :: Sema/block-call.c' FAILED 

Script:
--
: 'RUN: at line 1';   /data/llvm/llvm-forcommits/build/bin/clang -cc1 
-internal-isystem /data/llvm/llvm-forcommits/build/lib/clang/11.0.0/include 
-nostdsysteminc -fsyntax-only -verify 
/data/llvm/llvm-forcommits/clang/test/Sema/block-call.c -fblocks
--
Exit Code: 1

Command Output (stderr):
--
error: 'error' diagnostics expected but not seen: 
  File /data/llvm/llvm-forcommits/clang/test/Sema/block-call.c Line 36: invalid 
block pointer conversion assigning to 'int *(^)()' from 'int'
1 error generated.

--


FAIL: Clang :: SemaObjC/arc.m (10804 of 16808)
 TEST 'Clang :: SemaObjC/arc.m' FAILED 
Script:
--
: 'RUN: at line 1';   /data/llvm/llvm-forcommits/build/bin/clang -cc1 
-internal-isystem /data/llvm/llvm-forcommits/build/lib/clang/11.0.0/include 
-nostdsysteminc -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class 
/data/llvm/llvm-forcommits/clang/test/SemaObjC/arc.m
: 'RUN: at line 2';   not /data/llvm/llvm-forcommits/build/bin/clang -cc1 
-internal-isystem /data/llvm/llvm-forcommits/build/lib/clang/11.0.0/include 
-nostdsysteminc -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -Wno-objc-root-class 
-fdiagnostics-parseable-fixits 
/data/llvm/llvm-forcommits/clang/test/SemaObjC/arc.m 2>&1
--
Exit Code: 1

Command Output (stderr):
--
error: 'error' diagnostics expected but not seen: 
  File /data/llvm/llvm-forcommits/clang/test/SemaObjC/arc.m Line 117: assigning 
'__strong id *' to '__autoreleasing id *' changes retain/release properties of 
pointer
1 error generated.

```


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

https://reviews.llvm.org/D74116



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


  1   2   >