LLVM buildmaster will be updated and restarted soon

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

LLVM buildmaster will be updated and restarted in the nearest hour.

Thanks

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


[PATCH] D68854: [X86] add mayRaiseFPException flag and FPCW registers for X87 instructions

2019-11-01 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf3a7de20c3f: [X86] add mayRaiseFPException flag and FPCW 
registers for X87  instructions (authored by pengfei).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68854

Files:
  clang/test/CodeGen/ms-inline-asm.c
  llvm/lib/Target/X86/X86InstrFPStack.td
  llvm/lib/Target/X86/X86InstrFormats.td
  llvm/test/CodeGen/X86/x87-reg-usage.mir

Index: llvm/test/CodeGen/X86/x87-reg-usage.mir
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x87-reg-usage.mir
@@ -0,0 +1,248 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=x86-64 -mattr=+x87 -mattr=-sse -run-pass none -o - %s | FileCheck %s
+# This test ensures that the MIR parser parses the x87 fpsw and fpcw regs
+
+--- |
+  declare float @llvm.sqrt.f32(float)
+
+  define void @f1(float* %a, float* %b) {
+%1 = load float, float* %a, align 4
+%2 = load float, float* %b, align 4
+%sub = fsub float %1, %2
+store float %sub, float* %a, align 4
+ret void
+  }
+
+  define void @f2(double* %a, double* %b) {
+%1 = load double, double* %a, align 8
+%2 = load double, double* %b, align 8
+%add = fadd double %1, %2
+store double %add, double* %a, align 8
+ret void
+  }
+
+  define void @f3(x86_fp80* %a, x86_fp80* %b) {
+%1 = load x86_fp80, x86_fp80* %a, align 16
+%2 = load x86_fp80, x86_fp80* %b, align 16
+%mul = fmul x86_fp80 %1, %2
+store x86_fp80 %mul, x86_fp80* %a, align 16
+ret void
+  }
+
+  define void @f4(float* %a, float* %b) {
+%1 = load float, float* %a, align 4
+%2 = load float, float* %b, align 4
+%div = fdiv float %1, %2
+store float %div, float* %a, align 4
+ret void
+  }
+
+  define void @f5(float* %val, double* %ret) {
+%1 = load float, float* %val, align 4
+%res = fpext float %1 to double
+store double %res, double* %ret, align 8
+ret void
+  }
+
+  define void @f6(double* %val, float* %ret) {
+%1 = load double, double* %val, align 8
+%res = fptrunc double %1 to float
+store float %res, float* %ret, align 4
+ret void
+  }
+
+  define void @f7(float* %a) {
+%1 = load float, float* %a, align 4
+%res = call float @llvm.sqrt.f32(float %1)
+store float %res, float* %a, align 4
+ret void
+  }
+
+
+
+...
+---
+name:f1
+alignment:   16
+tracksRegLiveness: true
+liveins:
+  - { reg: '$rdi' }
+  - { reg: '$rsi' }
+frameInfo:
+  maxAlignment:1
+machineFunctionInfo: {}
+body: |
+  bb.0 (%ir-block.0):
+liveins: $rdi, $rsi
+
+; CHECK-LABEL: name: f1
+; CHECK: liveins: $rdi, $rsi
+; CHECK: renamable $fp0 = LD_Fp32m renamable $rdi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 4 from %ir.a)
+; CHECK: renamable $fp0 = SUB_Fp32m killed renamable $fp0, killed renamable $rsi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 4 from %ir.b)
+; CHECK: ST_Fp32m killed renamable $rdi, 1, $noreg, 0, $noreg, killed renamable $fp0, implicit-def dead $fpsw, implicit $fpcw :: (store 4 into %ir.a)
+; CHECK: RET 0
+renamable $fp0 = LD_Fp32m renamable $rdi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 4 from %ir.a)
+renamable $fp0 = SUB_Fp32m killed renamable $fp0, killed renamable $rsi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 4 from %ir.b)
+ST_Fp32m killed renamable $rdi, 1, $noreg, 0, $noreg, killed renamable $fp0, implicit-def dead $fpsw, implicit $fpcw :: (store 4 into %ir.a)
+RET 0
+
+...
+---
+name:f2
+alignment:   16
+tracksRegLiveness: true
+liveins:
+  - { reg: '$rdi' }
+  - { reg: '$rsi' }
+frameInfo:
+  maxAlignment:1
+machineFunctionInfo: {}
+body: |
+  bb.0 (%ir-block.0):
+liveins: $rdi, $rsi
+
+; CHECK-LABEL: name: f2
+; CHECK: liveins: $rdi, $rsi
+; CHECK: renamable $fp0 = LD_Fp64m renamable $rdi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 8 from %ir.a)
+; CHECK: renamable $fp0 = ADD_Fp64m killed renamable $fp0, killed renamable $rsi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 8 from %ir.b)
+; CHECK: ST_Fp64m killed renamable $rdi, 1, $noreg, 0, $noreg, killed renamable $fp0, implicit-def dead $fpsw, implicit $fpcw :: (store 8 into %ir.a)
+; CHECK: RET 0
+renamable $fp0 = LD_Fp64m renamable $rdi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 8 from %ir.a)
+renamable $fp0 = ADD_Fp64m killed renamable $fp0, killed renamable $rsi, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load 8 from %ir.b)
+ST_Fp64m killed renamable $rdi, 1, $noreg, 0, $noreg, killed 

[clang] af3a7de - [X86] add mayRaiseFPException flag and FPCW registers for X87 instructions

2019-11-01 Thread Pengfei Wang via cfe-commits

Author: Pengfei Wang
Date: 2019-11-01T21:12:43-07:00
New Revision: af3a7de20c3f92f5aee828d03049032200b21f08

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

LOG: [X86] add mayRaiseFPException flag and FPCW registers for X87  instructions

Summary:
This patch adds flag "mayRaiseFPException"  , FPCW and FPSW for X87 
instructions which could raise
float exception.

Reviewers: pengfei, RKSimon, andrew.w.kaylor, uweigand, kpn, spatel, 
cameron.mcinally, craig.topper

Reviewed By: craig.topper

Subscribers: thakis, hiraditya, llvm-commits

Patch by LiuChen.

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

Added: 
llvm/test/CodeGen/X86/x87-reg-usage.mir

Modified: 
clang/test/CodeGen/ms-inline-asm.c
llvm/lib/Target/X86/X86InstrFPStack.td
llvm/lib/Target/X86/X86InstrFormats.td

Removed: 




diff  --git a/clang/test/CodeGen/ms-inline-asm.c 
b/clang/test/CodeGen/ms-inline-asm.c
index edcbaa8aa455..ca9b937a7cde 100644
--- a/clang/test/CodeGen/ms-inline-asm.c
+++ b/clang/test/CodeGen/ms-inline-asm.c
@@ -752,7 +752,7 @@ void mxcsr() {
   __asm fxrstor buf
 }
 // CHECK-LABEL: define void @mxcsr
-// CHECK: call void asm sideeffect inteldialect "fxrstor $0", 
"=*m,~{dirflag},~{fpsr},~{flags}"
+// CHECK: call void asm sideeffect inteldialect "fxrstor $0", 
"=*m,~{fpcr},~{dirflag},~{fpsr},~{flags}"
 
 // Make sure we can find the register for the dirflag for popfd
 void dirflag() {

diff  --git a/llvm/lib/Target/X86/X86InstrFPStack.td 
b/llvm/lib/Target/X86/X86InstrFPStack.td
index 73cffc9aee4f..1b7a2ccde51f 100644
--- a/llvm/lib/Target/X86/X86InstrFPStack.td
+++ b/llvm/lib/Target/X86/X86InstrFPStack.td
@@ -282,7 +282,7 @@ def _FI32m  : FPI<0xDA, fp, (outs), (ins i32mem:$src),
   !strconcat("fi", asmstring, "{l}\t$src")>;
 }
 
-let Defs = [FPSW], Uses = [FPCW] in {
+let Uses = [FPCW], mayRaiseFPException = 1 in {
 // FPBinary_rr just defines pseudo-instructions, no need to set a scheduling
 // resources.
 let hasNoSchedulingInfo = 1 in {
@@ -307,7 +307,7 @@ let SchedRW = [WriteFDivLd] in {
 defm DIV : FPBinary;
 defm DIVR: FPBinary;
 }
-} // Defs = [FPSW]
+} // Uses = [FPCW], mayRaiseFPException = 1
 
 class FPST0rInst
   : FPI<0xD8, fp, (outs), (ins RSTi:$op), asm>;
@@ -319,7 +319,7 @@ class FPrST0PInst
 // NOTE: GAS and apparently all other AT style assemblers have a broken 
notion
 // of some of the 'reverse' forms of the fsub and fdiv instructions.  As such,
 // we have to put some 'r's in and take them out of weird places.
-let SchedRW = [WriteFAdd], Defs = [FPSW], Uses = [FPCW] in {
+let SchedRW = [WriteFAdd], Uses = [FPCW], mayRaiseFPException = 1 in {
 def ADD_FST0r   : FPST0rInst ;
 def ADD_FrST0   : FPrST0Inst ;
 def ADD_FPrST0  : FPrST0PInst;
@@ -330,16 +330,16 @@ def SUB_FST0r   : FPST0rInst ;
 def SUBR_FrST0  : FPrST0Inst ;
 def SUBR_FPrST0 : FPrST0PInst;
 } // SchedRW
-let SchedRW = [WriteFCom], Defs = [FPSW], Uses = [FPCW] in {
+let SchedRW = [WriteFCom], Uses = [FPCW], mayRaiseFPException = 1 in {
 def COM_FST0r   : FPST0rInst ;
 def COMP_FST0r  : FPST0rInst ;
 } // SchedRW
-let SchedRW = [WriteFMul], Defs = [FPSW], Uses = [FPCW] in {
+let SchedRW = [WriteFMul], Uses = [FPCW], mayRaiseFPException = 1 in {
 def MUL_FST0r   : FPST0rInst ;
 def MUL_FrST0   : FPrST0Inst ;
 def MUL_FPrST0  : FPrST0PInst;
 } // SchedRW
-let SchedRW = [WriteFDiv], Defs = [FPSW], Uses = [FPCW] in {
+let SchedRW = [WriteFDiv], Uses = [FPCW], mayRaiseFPException = 1 in {
 def DIVR_FST0r  : FPST0rInst ;
 def DIV_FrST0   : FPrST0Inst ;
 def DIV_FPrST0  : FPrST0PInst;
@@ -359,13 +359,12 @@ def _Fp80  : FpI_<(outs RFP80:$dst), (ins RFP80:$src), 
OneArgFPRW,
 def _F : FPI<0xD9, fp, (outs), (ins), asmstring>;
 }
 
-let Defs = [FPSW], Uses = [FPCW] in {
-
 let SchedRW = [WriteFSign] in {
 defm CHS : FPUnary;
 defm ABS : FPUnary;
 }
 
+let Uses = [FPCW], mayRaiseFPException = 1 in {
 let SchedRW = [WriteFSqrt80] in
 defm SQRT: FPUnary;
 
@@ -378,11 +377,11 @@ def TST_Fp80  : FpI_<(outs), (ins RFP80:$src), OneArgFP, 
[]>;
 
 def TST_F  : FPI<0xD9, MRM_E4, (outs), (ins), "ftst">;
 } // SchedRW
-} // Defs = [FPSW]
+} // Uses = [FPCW], mayRaiseFPException = 1
 
 // Versions of FP instructions that take a single memory operand.  Added for 
the
 //   disassembler; remove as they are included with patterns elsewhere.
-let SchedRW = [WriteFComLd], Defs = [FPSW], Uses = [FPCW] in {
+let SchedRW = [WriteFComLd], Uses = [FPCW], mayRaiseFPException = 1 in {
 def FCOM32m  : FPI<0xD8, MRM2m, (outs), (ins f32mem:$src), "fcom{s}\t$src">;
 def FCOMP32m : FPI<0xD8, MRM3m, (outs), (ins f32mem:$src), "fcomp{s}\t$src">;
 
@@ -397,14 +396,21 @@ def FICOMP32m: FPI<0xDA, MRM3m, (outs), (ins 
i32mem:$src), "ficomp{l}\t$src">;
 } // SchedRW
 
 let SchedRW = [WriteMicrocoded] in {
+let Defs = [FPSW, 

[PATCH] D68074: [clang-tidy] Add readability-make-member-function-const

2019-11-01 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:321
+
+} // namespace Keep

Could you add tests for calls to members of `this` through member function 
pointers? I don't care about possible false negatives in that case, but the 
code shouldn't crash or produce false positives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68074



___
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

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Hey! I would like to reuse your script without any reinvention. It serves every 
needs, but at some point we start to heavily diverge. When I started with the 
Tidy I really enjoyed that script, and most of the people I know both develop 
Tidy and the Analyzer, so I would keep the design of the script to make it 
consistent to use.

Could you please let me use it as it is?


Repository:
  rC Clang

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] D69746: [analyzer] FixItHint: apply and test hints with the Clang Tidy's script

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added reviewers: NoQ, alexfh, zinovy.nis, JonasToth, hokein, 
gribozavr, lebedev.ri.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, mgorny, 
dylanmckay.

This patch introduces a way to apply the fix-its by the Analyzer:
`-analyzer-config apply-fixits=true`.

The fix-its should be testable, therefore I have copied the well-tested
`check_clang_tidy.py` script. The idea is that the Analyzer's workflow
is different so it would be very difficult to use only one script for
both Tidy and the Analyzer, the script would diverge a lot.

When the copy-paste happened the original authors were:
@alexfh, @zinovy.nis, @JonasToth, @hokein, @gribozavr, @lebedev.ri


Repository:
  rC Clang

https://reviews.llvm.org/D69746

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/check_analyzer_fixit.py
  clang/test/Analysis/virtualcall-fixit-remark.cpp
  clang/test/Analysis/virtualcall-fixit.cpp
  clang/test/Analysis/virtualcall-fixits.cpp
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -77,6 +77,11 @@
 if config.clang_staticanalyzer_z3 == '1':
 config.available_features.add('z3')
 
+check_analyzer_fixit_path = os.path.join(
+config.test_source_root, "Analysis", "check_analyzer_fixit.py")
+config.substitutions.append(
+('%check_analyzer_fixit',
+ '%s %s' % (config.python_executable, check_analyzer_fixit_path)))
 
 llvm_config.add_tool_substitutions(tools, tool_dirs)
 
Index: clang/test/Analysis/virtualcall-fixit.cpp
===
--- /dev/null
+++ clang/test/Analysis/virtualcall-fixit.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_analyzer_fixit %s %t \
+// RUN:   -analyzer-checker=core,optin.cplusplus.VirtualCall \
+// RUN:   -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true
+
+struct S {
+  virtual void foo();
+  S() {
+foo();
+// expected-warning@-1 {{Call to virtual method 'S::foo' during construction bypasses virtual dispatch}}
+// CHECK-FIXES: S::foo();
+  }
+  ~S();
+};
Index: clang/test/Analysis/check_analyzer_fixit.py
===
--- /dev/null
+++ clang/test/Analysis/check_analyzer_fixit.py
@@ -0,0 +1,137 @@
+#!/usr/bin/env python
+#
+#===- check_analyzer_fixit.py - Static Analyzer test helper ---*- python -*-===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#======#
+#
+#  This file mostly copy-pasted from the Clang Tidy's 'check_clang_tidy.py'
+#  and some parts from the LLVM Lit's 'config.py'.
+#
+#======#
+
+r"""
+Clang Static Analyzer test helper
+=
+
+This script runs the Analyzer in fix-it mode and verify fixes, warnings, notes.
+
+Usage:
+  check_analyzer_fixit.py   [analyzer arguments]
+
+Example:
+  // RUN: %check_analyzer_fixit %s %t -analyzer-checker=core
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+
+
+def get_process_output(command):
+  try:
+cmd = subprocess.Popen(
+  command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+stdout, stderr = cmd.communicate()
+return (stdout, stderr)
+  except OSError:
+print('Could not run process %s' % command)
+
+
+def get_clang_builtin_include_dir():
+  clang_dir, _ = get_process_output(['clang', '-print-file-name=include'])
+
+  clang_dir = clang_dir.strip()
+  if sys.platform in ['win32']:
+clang_dir = clang_dir.replace('\\', '/')
+
+  return clang_dir
+
+
+def write_file(file_name, text):
+  with open(file_name, 'w') as f:
+f.write(text)
+f.truncate()
+
+
+def run_test_once(args, extra_args):
+  input_file_name = args.input_file_name
+  temp_file_name = args.temp_file_name
+  clang_analyzer_extra_args = extra_args
+
+  file_name_with_extension = input_file_name
+  _, extension = os.path.splitext(file_name_with_extension)
+  if extension not in ['.c', '.hpp', '.m', '.mm']:
+  extension = '.cpp'
+  temp_file_name = temp_file_name + extension
+
+  with open(input_file_name, 'r') as input_file:
+input_text = input_file.read()
+
+  # Remove the contents of the CHECK lines to avoid CHECKs matching on
+  # themselves.  We need to keep the comments to preserve line numbers while
+  # avoiding empty lines which could potentially 

[PATCH] D69088: [Lex] #pragma clang transform

2019-11-01 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 227561.
Meinersbur added a comment.

- Implement -f(no-)experimental-transform-pragma


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69088

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/test/Parser/pragma-no-transform.cpp

Index: clang/test/Parser/pragma-no-transform.cpp
===
--- /dev/null
+++ clang/test/Parser/pragma-no-transform.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -fno-experimental-transform-pragma -Wall -verify %s
+
+void pragma_transform(int *List, int Length) {
+/* expected-warning@+1 {{unknown pragma ignored}} */
+#pragma clang transform unroll partial(4)
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+}
+
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -247,6 +247,12 @@
   void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override;
 
+struct PragmaTransformHandler : public PragmaHandler {
+  PragmaTransformHandler() : PragmaHandler("transform") {}
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
+Token ) override;
+};
+
 private:
   Sema 
 };
@@ -382,6 +388,11 @@
   AttributePragmaHandler =
   std::make_unique(AttrFactory);
   PP.AddPragmaHandler("clang", AttributePragmaHandler.get());
+
+  if (getLangOpts().ExperimentalTransformPragma) {
+TransformHandler = std::make_unique();
+PP.AddPragmaHandler("clang", TransformHandler.get());
+  }
 }
 
 void Parser::resetPragmaHandlers() {
@@ -487,6 +498,11 @@
 
   PP.RemovePragmaHandler("clang", AttributePragmaHandler.get());
   AttributePragmaHandler.reset();
+
+  if (getLangOpts().ExperimentalTransformPragma) {
+PP.RemovePragmaHandler("clang", TransformHandler.get());
+TransformHandler.reset();
+  }
 }
 
 /// Handle the annotation token produced for #pragma unused(...)
@@ -3008,6 +3024,71 @@
   /*DisableMacroExpansion=*/false, /*IsReinject=*/false);
 }
 
+/// Handle
+///   #pragma clang transform ...
+void PragmaTransformHandler::HandlePragma(Preprocessor ,
+  PragmaIntroducer Introducer,
+  Token ) {
+  // "clang" token is not passed
+  // "transform" is FirstTok
+  // Everything up until tok::eod (or tok::eof) is wrapped between
+  // tok::annot_pragma_transform and tok::annot_pragma_transform_end, and
+  // pushed-back into the token stream. The tok::eod/eof is consumed as well:
+  //
+  // Token stream before:
+  //   FirstTok:"transform" |  [clauses..] eod   ...
+  //
+  // Token stream after :
+  //"transform"[clauses..] eod | ...
+  // After pushing the annotation tokens:
+  //
+  // | annot_pragma_transform  [clauses..] annot_pragma_transform_end ...
+  //
+  // The symbol | is before the next token returned by PP.Lex()
+  SmallVector PragmaToks;
+
+  Token StartTok;
+  StartTok.startToken();
+  StartTok.setKind(tok::annot_pragma_transform);
+  StartTok.setLocation(FirstTok.getLocation());
+  PragmaToks.push_back(StartTok);
+
+  SourceLocation EodLoc = FirstTok.getLocation();
+  while (true) {
+Token Tok;
+PP.Lex(Tok);
+
+// TODO: Handle nested pragmas as in r325369.
+assert(!Tok.isAnnotation());
+assert(Tok.isNot(tok::annot_pragma_transform));
+assert(Tok.isNot(tok::annot_pragma_transform_end));
+assert(Tok.isNot(tok::annot_pragma_openmp));
+assert(Tok.isNot(tok::annot_pragma_openmp_end));
+assert(Tok.isNot(tok::annot_pragma_loop_hint));
+
+if (Tok.is(tok::eod) || Tok.is(tok::eof)) {
+  EodLoc = Tok.getLocation();
+  break;
+}
+
+PragmaToks.push_back(Tok);
+  }
+
+  Token EndTok;
+  EndTok.startToken();
+  EndTok.setKind(tok::annot_pragma_transform_end);
+  EndTok.setLocation(EodLoc);
+  PragmaToks.push_back(EndTok);
+
+  // Copy tokens for the preprocessor to own and free.
+  auto Toks = std::make_unique(PragmaToks.size());
+  std::copy(PragmaToks.begin(), PragmaToks.end(), Toks.get());
+
+  // Handle in parser
+  PP.EnterTokenStream(std::move(Toks), PragmaToks.size(),
+  /*DisableMacroExpansion=*/false, /*IsReinject=*/false);
+}
+
 /// Handle the Microsoft \#pragma intrinsic extension.
 ///
 /// The syntax is:
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3227,6 +3227,11 @@
 
   Opts.CompleteMemberPointers = 

[PATCH] D69745: [analyzer] Checker: check::BeginAnalysis

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added a comment.

I felt that it will be easier, eh.




Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:118
+SubEng.processBeginWorklist(BuilderCtx, Node, DstBegin, StartLoc);
 SubEng.processBeginOfFunction(BuilderCtx, Node, DstBegin, StartLoc);
 

I think we need to merge the `BeginFunction` into the `BeginWorklist`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69745



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69731#1730956 , @Charusso wrote:

> I am thinking of a callback which is something like:
>
>   void checkBeginAnalysis(const Decl *D, BugReporter ) const;
>
>
> so it would be easy and meaningful to have a place for the `Preprocessor` 
> logic. Do you think it would worth it?


Well, it made me mad to create setters / public fields and to rely on only the 
`AnalysisManager`. I am going to publish my first real checker, and it turns 
out being cool: D69745 


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

https://reviews.llvm.org/D69731



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


[PATCH] D69745: [analyzer] Checker: check::BeginAnalysis

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Charusso added a parent revision: D69731: [analyzer] CheckerContext: Make the 
Preprocessor available.

This callback is called when the analysis starts. It could be used to
construct the fields of the checker. Here is an example:

  void CoolFuncChecker::checkBeginAnalysis(CheckerContext ) const {
CheckerManager  = C.getCheckerManager();
  
CheckCoolFunctions = Mgr.getAnalyzerOptions().getCheckerBooleanOption(
this, "WantToCheckCoolFunctions");
  
BT = std::make_unique(Mgr.getCurrentCheckerName(),
   "Cool function call", categories::TooCool);
  
Preprocessor  = C.getPreprocessor();
UseMyCoolLib = PP.isMacroDefined("__MY_COOL_LIB__");
  }


Repository:
  rC Clang

https://reviews.llvm.org/D69745

Files:
  clang/include/clang/StaticAnalyzer/Core/Checker.h
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/traversal-begin-end-function.c

Index: clang/test/Analysis/traversal-begin-end-function.c
===
--- clang/test/Analysis/traversal-begin-end-function.c
+++ clang/test/Analysis/traversal-begin-end-function.c
@@ -2,17 +2,9 @@
 
 void inline_callee(int i);
 
-// CHECK: --BEGIN FUNCTION--
 void inline_caller() {
-  // CHECK: --BEGIN FUNCTION--
-  // CHECK: --BEGIN FUNCTION--
-  // CHECK: --BEGIN FUNCTION--
   inline_callee(3);
-  // CHECK: --END FUNCTION--
-  // CHECK: --END FUNCTION--
-  // CHECK: --END FUNCTION--
 }
-// CHECK: --END FUNCTION--
 
 void inline_callee(int i) {
   if (i <= 1)
@@ -20,3 +12,17 @@
 
   inline_callee(i - 1);
 }
+
+// CHECK:  --BEGIN ANALYSIS--
+// CHECK-NEXT: --BEGIN FUNCTION--
+// CHECK-NEXT: --BEGIN FUNCTION--
+// CHECK-NEXT: IfStmt
+// CHECK-NEXT: --BEGIN FUNCTION--
+// CHECK-NEXT: IfStmt
+// CHECK-NEXT: --BEGIN FUNCTION--
+// CHECK-NEXT: IfStmt
+// CHECK-NEXT: --END FUNCTION--
+// CHECK-NEXT: --END FUNCTION--
+// CHECK-NEXT: --END FUNCTION--
+// CHECK-NEXT: --END FUNCTION--
+// CHECK-NEXT: --END ANALYSIS--
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -620,6 +620,13 @@
IsDot);
 }
 
+void ExprEngine::processBeginWorklist(NodeBuilderContext ,
+  ExplodedNode *Pred, ExplodedNodeSet ,
+  const BlockEdge ) {
+  SaveAndRestore NodeContextRAII(currBldrCtx, );
+  getCheckerManager().runCheckersForBeginAnalysis(Dst, L, Pred, *this);
+}
+
 void ExprEngine::processEndWorklist() {
   getCheckerManager().runCheckersForEndAnalysis(G, BR, *this);
 }
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -113,6 +113,8 @@
 
 NodeBuilderContext BuilderCtx(*this, StartLoc.getDst(), Node);
 ExplodedNodeSet DstBegin;
+
+SubEng.processBeginWorklist(BuilderCtx, Node, DstBegin, StartLoc);
 SubEng.processBeginOfFunction(BuilderCtx, Node, DstBegin, StartLoc);
 
 enqueue(DstBegin);
Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -399,6 +399,41 @@
   expandGraphWithCheckers(C, Dst, Src);
 }
 
+namespace {
+struct CheckBeginAnalysisContext {
+  using CheckersTy = std::vector;
+
+  const CheckersTy 
+  ExprEngine 
+  const ProgramPoint 
+
+  CheckBeginAnalysisContext(const CheckersTy , ExprEngine ,
+const ProgramPoint )
+  : Checkers(Checkers), Eng(Eng), PP(PP) {}
+
+  CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
+  CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
+
+  void runChecker(CheckerManager::CheckBeginAnalysisFunc checkFn,
+  NodeBuilder , ExplodedNode *Pred) {
+const ProgramPoint  = PP.withTag(checkFn.Checker);
+CheckerContext C(Bldr, Eng, Pred, L);
+
+checkFn(C);
+  }
+};
+} // 

[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227557.
Charusso added a comment.

- Use less `const`, it prevented the usage of non-const methods.


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

https://reviews.llvm.org/D69731

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -58,7 +58,7 @@
   ExprEngineConsumer(CompilerInstance )
   : C(C), ChkMgr(C.getASTContext(), *C.getAnalyzerOpts()), CTU(C),
 Consumers(),
-AMgr(C.getASTContext(), Consumers,
+AMgr(C.getASTContext(), C.getPreprocessor(), Consumers,
  CreateRegionStoreManager, CreateRangeConstraintManager, ,
  *C.getAnalyzerOpts()),
 VisitedCallees(), FS(),
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -192,7 +192,7 @@
 
 public:
   ASTContext *Ctx;
-  const Preprocessor 
+  Preprocessor 
   const std::string OutDir;
   AnalyzerOptionsRef Opts;
   ArrayRef Plugins;
@@ -335,8 +335,8 @@
 checkerMgr = createCheckerManager(
 *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics());
 
-Mgr = std::make_unique(*Ctx, PathConsumers, CreateStoreMgr,
-CreateConstraintMgr,
+Mgr = std::make_unique(*Ctx, PP, PathConsumers,
+CreateStoreMgr, CreateConstraintMgr,
 checkerMgr.get(), *Opts, Injector);
   }
 
Index: clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -13,7 +13,7 @@
 
 void AnalysisManager::anchor() { }
 
-AnalysisManager::AnalysisManager(ASTContext ,
+AnalysisManager::AnalysisManager(ASTContext , Preprocessor ,
  const PathDiagnosticConsumers ,
  StoreManagerCreator storemgr,
  ConstraintManagerCreator constraintmgr,
@@ -38,7 +38,7 @@
   Options.ShouldElideConstructors,
   /*addVirtualBaseBranches=*/true,
   injector),
-  Ctx(ASTCtx), LangOpts(ASTCtx.getLangOpts()),
+  Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()),
   PathConsumers(PDC), CreateStoreMgr(storemgr),
   CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
   options(Options) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -107,6 +107,8 @@
 return getBugReporter().getSourceManager();
   }
 
+  Preprocessor () { return getBugReporter().getPreprocessor(); }
+
   SValBuilder () {
 return Eng.getSValBuilder();
   }
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -16,6 +16,7 @@
 
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
@@ -32,6 +33,7 @@
   AnalysisDeclContextManager AnaCtxMgr;
 
   ASTContext 
+  Preprocessor 
   const LangOptions 
   PathDiagnosticConsumers PathConsumers;
 
@@ -44,7 +46,7 @@
 public:
   AnalyzerOptions 
 
-  AnalysisManager(ASTContext ,
+  AnalysisManager(ASTContext , Preprocessor ,
   const PathDiagnosticConsumers ,
   StoreManagerCreator storemgr,
   ConstraintManagerCreator constraintmgr,
@@ -61,6 +63,8 @@
 return AnaCtxMgr;
   }
 
+  Preprocessor () override { return PP; }
+
   StoreManagerCreator getStoreManagerCreator() {
 return CreateStoreMgr;
   }
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

[PATCH] D69743: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood

2019-11-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
vsk added reviewers: aprantl, djtodoro, dblaikie.

Currently, clang emits subprograms for declared functions when the
target debugger or DWARF standard is known to support entry values
(DW_OP_entry_value & the GNU equivalent).

Expand this behavior to include debuggers that support DW_AT_tail_call.
This allows debuggers to follow cross-TU tail calls.

Pre-patch debug session with a cross-TU tail call:

  * frame #0: 0x00010fa4 main`target at b.c:4:3 [opt]
frame #1: 0x00010f99 main`main at a.c:8:10 [opt]

Post-patch (note that the tail-calling frame, "helper", is visible):

  * frame #0: 0x00010fa4 main`target at b.c:4:3 [opt]
frame #1: 0x00010f80 main`helper [opt] [artificial]
frame #2: 0x00010f99 main`main at a.c:8:10 [opt]

rdar://46577651


https://reviews.llvm.org/D69743

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -56,6 +56,7 @@
 
 // NO-ATTR-NOT: FlagAllCallsDescribed
 
+// HAS-ATTR-DAG: DISubprogram(name: "declaration1", {{.*}}, flags: 
DIFlagPrototyped
 // HAS-ATTR-DAG: DISubprogram(name: "declaration2", {{.*}}, flags: 
DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition
 // HAS-ATTR-DAG: DISubprogram(name: "struct1", {{.*}}, flags: 
DIFlagPrototyped, spFlags: DISPFlagOptimized)
 // HAS-ATTR-DAG: DISubprogram(name: "struct1", {{.*}}, flags: DIFlagPrototyped 
| DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition
Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,8 +1,21 @@
-// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -target 
x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix=CHECK-EXT
-// CHECK-EXT: !DISubprogram(name: "fn1"
+// When entry values are emitted, expect a subprogram for extern decls so that
+// the dwarf generator can describe call site parameters at extern call sites.
+//
+// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -target 
x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix=ENTRY-VAL
+// ENTRY-VAL: !DISubprogram(name: "fn1"
 
-// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | 
FileCheck %s
-// CHECK-NOT: !DISubprogram(name: "fn1"
+// Similarly, when the debugger tuning is gdb, expect a subprogram for extern
+// decls so that the dwarf generator can describe information needed for tail
+// call frame reconstrution.
+//
+// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -ggdb -S -emit-llvm %s -o 
- | FileCheck %s -check-prefix=GDB
+// GDB: !DISubprogram(name: "fn1"
+//
+// Do not emit a subprogram for extern decls when entry values are disabled and
+// the tuning is not set to gdb.
+//
+// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o 
- | FileCheck %s -check-prefix=SCE
+// SCE-NOT: !DISubprogram(name: "fn1"
 
 extern int fn1(int a, int b);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3731,9 +3731,7 @@
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
   QualType CalleeType,
   const FunctionDecl *CalleeDecl) {
-  auto  = CGM.getCodeGenOpts();
-  if (!CGOpts.EnableDebugEntryValues || !CGM.getLangOpts().Optimize ||
-  !CallOrInvoke)
+  if (!CallOrInvoke || getCallSiteRelatedAttrs() == llvm::DINode::FlagZero)
 return;
 
   auto *Func = CallOrInvoke->getCalledFunction();
@@ -4791,10 +4789,10 @@
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
   (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
-   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
-   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB);
 
-  if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
+  if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5 &&
+  !CGM.getCodeGenOpts().EnableDebugEntryValues)
 return llvm::DINode::FlagZero;
 
   return llvm::DINode::FlagAllCallsDescribed;


Index: clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -56,6 +56,7 @@
 
 

[PATCH] D57829: [CUDA][HIP] Disable emitting llvm.linker.options in device compilation

2019-11-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:389-392
+  // The linker_option directives are intended for host compilation.
+  if (JA.isDeviceOffloading(Action::OFK_Cuda) ||
+  JA.isDeviceOffloading(Action::OFK_HIP))
+Default = false;

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > Shouldn't it be `true`, considering that we do want to **disable** 
> > > autolinking by default for device-side CUDA/HIP?
> > > 
> > > If we don't support autolinking at all for CUDA/HIP, perhaps we should 
> > > just return `true` here.
> > This variable Default is to be used as the default value of OPT_fautolink. 
> > For device compilation we want the default value to be false. However if 
> > users want to force it to be true, we may still want to respect it.
> You are correct. I've missed the `!` in the return below.  Don't never use 
> double negation. :-/
> 
> Nit: Perhaps we can rename `Default` -> `AutolinkEnabledByDefault` because 
> right now it's easy to misinterpret it as the default return value of the 
> function. Maybe, even change the function itself to `ShouldEnableAutolink()`. 
> 
will change it to ShouldEnableAutolink


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

https://reviews.llvm.org/D57829



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-11-01 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 227550.
Meinersbur added a comment.

- Use PRAGMA_ANNOTATION
- Monorepo layout


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69088

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParsePragma.cpp

Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -225,6 +225,12 @@
 Token ) override;
 };
 
+struct PragmaTransformHandler : public PragmaHandler {
+  PragmaTransformHandler() : PragmaHandler("transform") {}
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
+Token ) override;
+};
+
 struct PragmaMSRuntimeChecksHandler : public EmptyPragmaHandler {
   PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {}
 };
@@ -376,6 +382,9 @@
   std::make_unique("nounroll_and_jam");
   PP.AddPragmaHandler(NoUnrollAndJamHintHandler.get());
 
+  TransformHandler = std::make_unique();
+  PP.AddPragmaHandler("clang", TransformHandler.get());
+
   FPHandler = std::make_unique();
   PP.AddPragmaHandler("clang", FPHandler.get());
 
@@ -482,6 +491,9 @@
   PP.RemovePragmaHandler(NoUnrollAndJamHintHandler.get());
   NoUnrollAndJamHintHandler.reset();
 
+  PP.RemovePragmaHandler("clang", TransformHandler.get());
+  TransformHandler.reset();
+
   PP.RemovePragmaHandler("clang", FPHandler.get());
   FPHandler.reset();
 
@@ -3008,6 +3020,71 @@
   /*DisableMacroExpansion=*/false, /*IsReinject=*/false);
 }
 
+/// Handle
+///   #pragma clang transform ...
+void PragmaTransformHandler::HandlePragma(Preprocessor ,
+  PragmaIntroducer Introducer,
+  Token ) {
+  // "clang" token is not passed
+  // "transform" is FirstTok
+  // Everything up until tok::eod (or tok::eof) is wrapped between
+  // tok::annot_pragma_transform and tok::annot_pragma_transform_end, and
+  // pushed-back into the token stream. The tok::eod/eof is consumed as well:
+  //
+  // Token stream before:
+  //   FirstTok:"transform" |  [clauses..] eod   ...
+  //
+  // Token stream after :
+  //"transform"[clauses..] eod | ...
+  // After pushing the annotation tokens:
+  //
+  // | annot_pragma_transform  [clauses..] annot_pragma_transform_end ...
+  //
+  // The symbol | is before the next token returned by PP.Lex()
+  SmallVector PragmaToks;
+
+  Token StartTok;
+  StartTok.startToken();
+  StartTok.setKind(tok::annot_pragma_transform);
+  StartTok.setLocation(FirstTok.getLocation());
+  PragmaToks.push_back(StartTok);
+
+  SourceLocation EodLoc = FirstTok.getLocation();
+  while (true) {
+Token Tok;
+PP.Lex(Tok);
+
+// TODO: Handle nested pragmas as in r325369.
+assert(!Tok.isAnnotation());
+assert(Tok.isNot(tok::annot_pragma_transform));
+assert(Tok.isNot(tok::annot_pragma_transform_end));
+assert(Tok.isNot(tok::annot_pragma_openmp));
+assert(Tok.isNot(tok::annot_pragma_openmp_end));
+assert(Tok.isNot(tok::annot_pragma_loop_hint));
+
+if (Tok.is(tok::eod) || Tok.is(tok::eof)) {
+  EodLoc = Tok.getLocation();
+  break;
+}
+
+PragmaToks.push_back(Tok);
+  }
+
+  Token EndTok;
+  EndTok.startToken();
+  EndTok.setKind(tok::annot_pragma_transform_end);
+  EndTok.setLocation(EodLoc);
+  PragmaToks.push_back(EndTok);
+
+  // Copy tokens for the preprocessor to own and free.
+  auto Toks = std::make_unique(PragmaToks.size());
+  std::copy(PragmaToks.begin(), PragmaToks.end(), Toks.get());
+
+  // Handle in parser
+  PP.EnterTokenStream(std::move(Toks), PragmaToks.size(),
+  /*DisableMacroExpansion=*/false, /*IsReinject=*/false);
+}
+
 /// Handle the Microsoft \#pragma intrinsic extension.
 ///
 /// The syntax is:
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -195,6 +195,7 @@
   std::unique_ptr NoUnrollHintHandler;
   std::unique_ptr UnrollAndJamHintHandler;
   std::unique_ptr NoUnrollAndJamHintHandler;
+  std::unique_ptr TransformHandler;
   std::unique_ptr FPHandler;
   std::unique_ptr STDCFENVHandler;
   std::unique_ptr STDCCXLIMITHandler;
Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -830,6 +830,11 @@
 PRAGMA_ANNOTATION(pragma_openmp)
 PRAGMA_ANNOTATION(pragma_openmp_end)
 
+// Annotations for code transformation pragmas
+// #pragma clang transform ...
+PRAGMA_ANNOTATION(pragma_transform)
+PRAGMA_ANNOTATION(pragma_transform_end)
+
 // Annotations for loop pragma directives #pragma clang loop ...
 // 

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

2019-11-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

(Didn't finish the review, but I have to run now.)




Comment at: include/clang/AST/DeclTemplate.h:742
   findSpecializationImpl(llvm::FoldingSetVector ,
- ArrayRef Args, void *);
+ void *, ProfileArguments... ProfileArgs);
 

`ProfileArguments &&...ProfileArgs`?



Comment at: include/clang/AST/DeclTemplate.h:1989-2004
+  void Profile(llvm::FoldingSetNodeID ) const {
+llvm::SmallVector AC;
+getAssociatedConstraints(AC);
+Profile(ID, getTemplateArgs().asArray(), AC, getASTContext());
+  }
+
+  static void

Hmm, is this the right set of things to be profiling? The relevant rule should 
be that the //template-head//s are equivalent and the //simple-template-id//s 
are equivalent, and checking the associated constraints isn't sufficient to 
check the former. Should we be profiling the template parameter list and 
template arguments instead?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2469-2470
+def note_could_not_normalize_argument_substitution_failed : Note<
+  "when substituting into %0 %1. Make sure concept arguments are "
+  "valid for any substitution">;
 

Please don't join sentences with periods like this; it looks strange given that 
we generally render diagnostics in lowercase, and not as full sentences). I'm 
also not sure what the second sentence here is telling the user. (What do you 
mean by "any"? "some", or "all", or substitutions the program requires, or 
something else?)

We generally use "while" not "when" for these "here's what I was doing" notes.



Comment at: lib/Sema/SemaConcept.cpp:484-486
+  static llvm::Optional fromConstraintExpr(
+  Sema , const Expr *E, TemplateDecl *TD = nullptr,
+  const ASTTemplateArgumentListInfo *ParameterMapping = nullptr) {

The specification says we substitute into the parameter mapping bottom-up 
(starting with atomic constraints and then substituting as they get used in 
enclosing constraints), but you're substituting top-down. That's not 
equivalent: specifically, the rules say that we should not perform substitution 
for parameters that are not used in the expansion of a concept 
([temp.constr.atomic]p1: "[...] a mapping from the template parameters **that 
appear within E** to template arguments involving the [...]"). Example:

```
template concept True = true;
template concept Foo = True;
template concept Bar = Foo;
template void f() requires Bar;
```

Here, the `true` atomic constraint has no parameter mappings, so we should 
never perform the substitution that would form `T&*`, and so shouldn't reject 
this for forming a pointer to a reference.

I think it's sufficient to first determine which parameters are used in a 
concept (perhaps when the concept is defined), and then form a parameter 
mapping top-down skipping the unused arguments, but you need to be careful to 
do that recursively (`Bar` doesn't use its `T` because `Foo` doesn't use its 
`T`).



Comment at: lib/Sema/SemaConcept.cpp:777-778
+
+static bool subsumes(Sema , ArrayRef P,
+ ArrayRef Q) {
+  // C++ [temp.constr.order] p2

There are a bunch of ways we can optimize this, but let's get the 
straightforward approach landed first :)



Comment at: lib/Sema/SemaTemplate.cpp:3772
+&& (!Context.getLangOpts().ConceptsTS
+|| !TemplateParams->hasAssociatedConstraints())) {
   // C++ [temp.class.spec]p9b3:

`&&` and `||` on prior line, please.


Repository:
  rC Clang

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

https://reviews.llvm.org/D41910



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


[PATCH] D69732: [WIP][LTO] Apply SamplePGO pipeline tunes for ThinLTO pre-link to full LTO

2019-11-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D69732#1730884 , @wenlei wrote:

> > The comments indicate that this is in part due to issues with
> >  the new PM loop pass manager
>
> Wondering how different it is for these loop passes to be enabled for MonoLTO 
> vs ThinLTO? If it's due to problems with the newPM, I guess ThinLTO would 
> have the same problems?


The ThinLTO backends don't use this code but rather 
PassBuilder::buildModuleOptimizationPipeline, which includes all of these loop 
optimizations (and other optimizations, since the ThinLTO backends can absorb 
the extra compile time cost). That's what makes me think this comment is stale 
and someone just forgot to add the loop optimization passes to the full LTO 
post-link pipeline. I haven't looked at the history of all these changes. My 
guess is that since the full LTO pre-link pipeline does all these loop 
optimizations (also through buildModuleOptimizationPipeline), no one noticed 
that they weren't also being done in the post-link full LTO pipeline.

> Asking because we have almost the same change as internal patch trying to get 
> better LTO time profile precision for MonoLTO, and with that there's small 
> win for oldPM+MonoLTO.

That's good to know, it's what I would expect but good to have the confirmation.

> But we'd love to converge on new PM for both MonoLTO and ThinLTO.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69732



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

I am thinking of a callback which is something like:

  void checkBeginAnalysis(const Decl *D, BugReporter ) const;

so it would be easy and meaningful to have a place for the `Preprocessor` 
logic. Do you think it would worth it?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69540: [analyzer] DynamicSize: Remove 'getExtent()' from regions

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks!


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

https://reviews.llvm.org/D69540



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks for the review!




Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

NoQ wrote:
> Charusso wrote:
> > NoQ wrote:
> > > Charusso wrote:
> > > > NoQ wrote:
> > > > > And then remove the manual division.
> > > > Hmpf.
> > > > 
> > > > ```
> > > > Failing Tests (7):
> > > > Clang :: Analysis/misc-ps-region-store.m
> > > > Clang :: Analysis/mpichecker.cpp
> > > > Clang :: Analysis/outofbound.c
> > > > Clang :: Analysis/rdar-6541136-region.c
> > > > Clang :: Analysis/return-ptr-range.cpp
> > > > Clang :: Analysis/track-control-dependency-conditions.cpp
> > > > Clang :: Analysis/uninit-vals.c
> > > > ```
> > > > 
> > > > I would pick that solution because it may be a tiny-bit faster, and 
> > > > then later on investigate this issue when we model more about dynamic 
> > > > sizes.
> > > Soo what does it tell us about the correctness of the new 
> > > `evalBinOp`-based solution?
> > So, when I tried to inject an `APSInt` it converted to `0` so division by 
> > zero made that. I felt that the implicit conversion is wonky, but dividing 
> > by 0, ugh.
> Yay, great job figuring this out!
> 
> Also the conversion wasn't implicit; you explicitly specified 
> `llvm::APSInt(...)`. I agree that this constructor is evil, though.
`getQuantity()` retuns a `QuantityType`, but now I see: `typedef int64_t 
QuantityType`, so I was fooled.


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

https://reviews.llvm.org/D69599



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227546.
Charusso marked 3 inline comments as done.
Charusso added a comment.

- Done.


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

https://reviews.llvm.org/D69599

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -622,15 +622,6 @@
   StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx,
   SymbolReaper& SymReaper) override;
 
-  //===--===//
-  // Region "extents".
-  //===--===//
-
-  // FIXME: This method will soon be eliminated; see the note in Store.h.
-  DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion* R,
- QualType EleTy) override;
-
   //===--===//
   // Utility methods.
   //===--===//
@@ -1387,37 +1378,6 @@
   return StoreRef(B.asStore(), *this);
 }
 
-//===--===//
-// Extents for regions.
-//===--===//
-
-DefinedOrUnknownSVal
-RegionStoreManager::getSizeInElements(ProgramStateRef state,
-  const MemRegion *R,
-  QualType EleTy) {
-  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
-  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
-  if (!SizeInt)
-return UnknownVal();
-
-  CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
-
-  if (Ctx.getAsVariableArrayType(EleTy)) {
-// FIXME: We need to track extra state to properly record the size
-// of VLAs.  Returning UnknownVal here, however, is a stop-gap so that
-// we don't have a divide-by-zero below.
-return UnknownVal();
-  }
-
-  CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
-
-  // If a variable is reinterpreted as a type that doesn't fit into a larger
-  // type evenly, round it down.
-  // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize,
-svalBuilder.getArrayIndexType());
-}
-
 //===--===//
 // Location and region casting.
 //===--===//
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
+++ clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -26,5 +27,22 @@
   return MR->getMemRegionManager().getStaticSize(MR, SVB);
 }
 
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder ,
+QualType ElementTy) {
+  MemRegionManager  = MR->getMemRegionManager();
+  ASTContext  = MemMgr.getContext();
+
+  DefinedOrUnknownSVal Size = getDynamicSize(State, MR, SVB);
+  SVal ElementSizeV = SVB.makeIntVal(
+  Ctx.getTypeSizeInChars(ElementTy).getQuantity(), SVB.getArrayIndexType());
+
+  SVal DivisionV =
+  SVB.evalBinOp(State, BO_Div, Size, ElementSizeV, SVB.getArrayIndexType());
+
+  return DivisionV.castAs();
+}
+
 } // namespace ento
 } // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -16,6 +16,7 @@
 #include 

[clang] 1de2a05 - DebugInfo: Accept -gdwarf even in clang-cl

2019-11-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-01T15:36:15-07:00
New Revision: 1de2a05701e73f8ef5914c2f6ea2dcbe617ce18b

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

LOG: DebugInfo: Accept -gdwarf even in clang-cl

Fixes regression introduced by llvmorg-10-init-8908-g098d901bd1b

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 44259a2a53e8..722427bc35a6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1974,7 +1974,7 @@ def glldb : Flag<["-"], "glldb">, Group;
 def gsce : Flag<["-"], "gsce">, Group;
 // Equivalent to our default dwarf version. Forces usual dwarf emission when
 // CodeView is enabled.
-def gdwarf : Flag<["-"], "gdwarf">, Group,
+def gdwarf : Flag<["-"], "gdwarf">, Group, Flags<[CoreOption]>,
   HelpText<"Generate source-level debug information with the default dwarf 
version">;
 def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group,
   HelpText<"Generate source-level debug information with dwarf version 2">;



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69731#1730899 , @NoQ wrote:

> Clang-Tidy's `PPCallbacks` subsystem looks much more realistic.


I wanted to make it available from the `AnalysisManager` so that I can obtain 
the macro definitions once before the analysis starts. Nor the Clang Tidy's 
`PPCallback`, nor the `AnalysisManager` could retrieve the necessary 
information at that point in the analysis. However, at that point when we 
analyze something all the necessary information is available. Most of the Tidy 
checkers grab their own `PP` reference to use it later on. The Tidy devs agree 
to retrieve such information even in the main `check()` call which going to 
rerun in every `TranslationUnit`. So even it is so primitive, there is no 
better solution as I know. I hope we could find something better / cache it. At 
the moment this code-snippet I have just showed you runs in every `evalCall()`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[clang] 098d901 - DebugInfo: Let -gdwarf use the toolchain default DWARF version, instead of hardcoded/aliased to -gdwarf-4

2019-11-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-01T15:17:51-07:00
New Revision: 098d901bd1be07f60c41450fa4af775b130117b9

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

LOG: DebugInfo: Let -gdwarf use the toolchain default DWARF version, instead of 
hardcoded/aliased to -gdwarf-4

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/dwarf-version.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 07c27ebcefee..44259a2a53e8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1972,6 +1972,10 @@ def ggdb2 : Flag<["-"], "ggdb2">, Group;
 def ggdb3 : Flag<["-"], "ggdb3">, Group;
 def glldb : Flag<["-"], "glldb">, Group;
 def gsce : Flag<["-"], "gsce">, Group;
+// Equivalent to our default dwarf version. Forces usual dwarf emission when
+// CodeView is enabled.
+def gdwarf : Flag<["-"], "gdwarf">, Group,
+  HelpText<"Generate source-level debug information with the default dwarf 
version">;
 def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group,
   HelpText<"Generate source-level debug information with dwarf version 2">;
 def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group,
@@ -1989,10 +1993,6 @@ def gcodeview_ghash : Flag<["-"], "gcodeview-ghash">,
   Flags<[CC1Option, CoreOption]>;
 def gno_codeview_ghash : Flag<["-"], "gno-codeview-ghash">, 
Flags<[CoreOption]>;
 
-// Equivalent to our default dwarf version. Forces usual dwarf emission when
-// CodeView is enabled.
-def gdwarf : Flag<["-"], "gdwarf">, Alias, Flags<[CoreOption]>;
-
 def gfull : Flag<["-"], "gfull">, Group;
 def gused : Flag<["-"], "gused">, Group;
 def gstabs : Joined<["-"], "gstabs">, Group, Flags<[Unsupported]>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9cfa39840566..529c33a16748 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,9 +3198,9 @@ static void RenderDebugOptions(const ToolChain , const 
Driver ,
   }
 
   // If a -gdwarf argument appeared, remember it.
-  const Arg *GDwarfN =
-  Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
-  options::OPT_gdwarf_4, options::OPT_gdwarf_5);
+  const Arg *GDwarfN = Args.getLastArg(
+  options::OPT_gdwarf_2, options::OPT_gdwarf_3, options::OPT_gdwarf_4,
+  options::OPT_gdwarf_5, options::OPT_gdwarf);
   bool EmitDwarf = false;
   if (GDwarfN) {
 if (checkDebugInfoOption(GDwarfN, Args, D, TC))
@@ -3231,6 +3231,7 @@ static void RenderDebugOptions(const ToolChain , const 
Driver ,
   if (EmitDwarf) {
 // Start with the platform default DWARF version
 DWARFVersion = TC.GetDefaultDwarfVersion();
+assert(DWARFVersion && "toolchain default DWARF version must be nonzero");
 
 // Override with a user-specified DWARF version
 if (GDwarfN)

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index 39bcbc209037..10add21d88dd 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -14,6 +14,7 @@
 // RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VER2
+// RUN: %clang -target i386-pc-solaris -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 
 // Check which debug info formats we use on Windows. By default, in an MSVC
 // environment, we should use codeview. You can enable dwarf, which implicitly



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

Charusso wrote:
> NoQ wrote:
> > Charusso wrote:
> > > NoQ wrote:
> > > > And then remove the manual division.
> > > Hmpf.
> > > 
> > > ```
> > > Failing Tests (7):
> > > Clang :: Analysis/misc-ps-region-store.m
> > > Clang :: Analysis/mpichecker.cpp
> > > Clang :: Analysis/outofbound.c
> > > Clang :: Analysis/rdar-6541136-region.c
> > > Clang :: Analysis/return-ptr-range.cpp
> > > Clang :: Analysis/track-control-dependency-conditions.cpp
> > > Clang :: Analysis/uninit-vals.c
> > > ```
> > > 
> > > I would pick that solution because it may be a tiny-bit faster, and then 
> > > later on investigate this issue when we model more about dynamic sizes.
> > Soo what does it tell us about the correctness of the new 
> > `evalBinOp`-based solution?
> So, when I tried to inject an `APSInt` it converted to `0` so division by 
> zero made that. I felt that the implicit conversion is wonky, but dividing by 
> 0, ugh.
Yay, great job figuring this out!

Also the conversion wasn't implicit; you explicitly specified 
`llvm::APSInt(...)`. I agree that this constructor is evil, though.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:44-47
+  if (auto DV = DivisionV.getAs())
+return *DV;
+
+  return UnknownVal();

I'd rather do a `castAs` here. Allocating a region of garbage size should be an 
immediate warning; supplying a zero-size `ElementTy` should be an immediate 
crash; in all other cases the result of division must be defined.


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

https://reviews.llvm.org/D69599



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


[PATCH] D69540: [analyzer] DynamicSize: Remove 'getExtent()' from regions

2019-11-01 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.

Fantastic, let's land this!


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

https://reviews.llvm.org/D69540



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


[PATCH] D69638: [NFC] Add SUPPORT_PLUGINS to add_llvm_executable()

2019-11-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz 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/D69638/new/

https://reviews.llvm.org/D69638



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks, now it is cool!




Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

NoQ wrote:
> Charusso wrote:
> > NoQ wrote:
> > > And then remove the manual division.
> > Hmpf.
> > 
> > ```
> > Failing Tests (7):
> > Clang :: Analysis/misc-ps-region-store.m
> > Clang :: Analysis/mpichecker.cpp
> > Clang :: Analysis/outofbound.c
> > Clang :: Analysis/rdar-6541136-region.c
> > Clang :: Analysis/return-ptr-range.cpp
> > Clang :: Analysis/track-control-dependency-conditions.cpp
> > Clang :: Analysis/uninit-vals.c
> > ```
> > 
> > I would pick that solution because it may be a tiny-bit faster, and then 
> > later on investigate this issue when we model more about dynamic sizes.
> Soo what does it tell us about the correctness of the new 
> `evalBinOp`-based solution?
So, when I tried to inject an `APSInt` it converted to `0` so division by zero 
made that. I felt that the implicit conversion is wonky, but dividing by 0, ugh.


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

https://reviews.llvm.org/D69599



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227543.
Charusso marked 4 inline comments as done.
Charusso added a comment.

- Old division swapped by `evalBinOp`.


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

https://reviews.llvm.org/D69599

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -622,15 +622,6 @@
   StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx,
   SymbolReaper& SymReaper) override;
 
-  //===--===//
-  // Region "extents".
-  //===--===//
-
-  // FIXME: This method will soon be eliminated; see the note in Store.h.
-  DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion* R,
- QualType EleTy) override;
-
   //===--===//
   // Utility methods.
   //===--===//
@@ -1387,37 +1378,6 @@
   return StoreRef(B.asStore(), *this);
 }
 
-//===--===//
-// Extents for regions.
-//===--===//
-
-DefinedOrUnknownSVal
-RegionStoreManager::getSizeInElements(ProgramStateRef state,
-  const MemRegion *R,
-  QualType EleTy) {
-  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
-  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
-  if (!SizeInt)
-return UnknownVal();
-
-  CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
-
-  if (Ctx.getAsVariableArrayType(EleTy)) {
-// FIXME: We need to track extra state to properly record the size
-// of VLAs.  Returning UnknownVal here, however, is a stop-gap so that
-// we don't have a divide-by-zero below.
-return UnknownVal();
-  }
-
-  CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
-
-  // If a variable is reinterpreted as a type that doesn't fit into a larger
-  // type evenly, round it down.
-  // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize,
-svalBuilder.getArrayIndexType());
-}
-
 //===--===//
 // Location and region casting.
 //===--===//
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
+++ clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -26,5 +27,25 @@
   return MR->getMemRegionManager().getStaticSize(MR, SVB);
 }
 
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder ,
+QualType ElementTy) {
+  MemRegionManager  = MR->getMemRegionManager();
+  ASTContext  = MemMgr.getContext();
+
+  DefinedOrUnknownSVal Size = getDynamicSize(State, MR, SVB);
+  SVal ElementSizeV = SVB.makeIntVal(
+  Ctx.getTypeSizeInChars(ElementTy).getQuantity(), SVB.getArrayIndexType());
+
+  SVal DivisionV =
+  SVB.evalBinOp(State, BO_Div, Size, ElementSizeV, SVB.getArrayIndexType());
+
+  if (auto DV = DivisionV.getAs())
+return *DV;
+
+  return UnknownVal();
+}
+
 } // namespace ento
 } // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ 

[clang] 42465f4 - DebugInfo: (NFC) Refactor DWARF version calculation to make a future change (-fdebug-default-version) easier

2019-11-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-01T14:56:43-07:00
New Revision: 42465f406bcea5ea06001ccc52ab779120b68e87

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

LOG: DebugInfo: (NFC) Refactor DWARF version calculation to make a future 
change (-fdebug-default-version) easier

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 81e01aee1da9..9cfa39840566 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,11 +3198,16 @@ static void RenderDebugOptions(const ToolChain , 
const Driver ,
   }
 
   // If a -gdwarf argument appeared, remember it.
-  if (const Arg *A =
+  const Arg *GDwarfN =
   Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
-  options::OPT_gdwarf_4, options::OPT_gdwarf_5))
-if (checkDebugInfoOption(A, Args, D, TC))
-  DWARFVersion = DwarfVersionNum(A->getSpelling());
+  options::OPT_gdwarf_4, options::OPT_gdwarf_5);
+  bool EmitDwarf = false;
+  if (GDwarfN) {
+if (checkDebugInfoOption(GDwarfN, Args, D, TC))
+  EmitDwarf = true;
+else
+  GDwarfN = nullptr;
+  }
 
   if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) {
 if (checkDebugInfoOption(A, Args, D, TC))
@@ -3211,18 +3216,28 @@ static void RenderDebugOptions(const ToolChain , 
const Driver ,
 
   // If the user asked for debug info but did not explicitly specify -gcodeview
   // or -gdwarf, ask the toolchain for the default format.
-  if (!EmitCodeView && DWARFVersion == 0 &&
+  if (!EmitCodeView && !EmitDwarf &&
   DebugInfoKind != codegenoptions::NoDebugInfo) {
 switch (TC.getDefaultDebugFormat()) {
 case codegenoptions::DIF_CodeView:
   EmitCodeView = true;
   break;
 case codegenoptions::DIF_DWARF:
-  DWARFVersion = TC.GetDefaultDwarfVersion();
+  EmitDwarf = true;
   break;
 }
   }
 
+  if (EmitDwarf) {
+// Start with the platform default DWARF version
+DWARFVersion = TC.GetDefaultDwarfVersion();
+
+// Override with a user-specified DWARF version
+if (GDwarfN)
+  if (auto ExplicitVersion = DwarfVersionNum(GDwarfN->getSpelling()))
+DWARFVersion = ExplicitVersion;
+  }
+
   // -gline-directives-only supported only for the DWARF debug info.
   if (DWARFVersion == 0 && DebugInfoKind == 
codegenoptions::DebugDirectivesOnly)
 DebugInfoKind = codegenoptions::NoDebugInfo;



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

It sounds like the code is querying the temporary internal state of the 
preprocessor which is supposed to be queried during preprocessing, not after 
it. Say, `PP.isMacroDefined("__STDC_LIB_EXT1__")` clearly depends on the 
location, as a macro can be un-defined and re-defined as many times as 
possible. But it doesn't receive the location as an argument, so it's probably 
implied to be "the location that the preprocessor is currently 
preprocessing"(?) Like, i've no idea how does the `Preprocessor` class work, 
but the code clearly looks too primitive to solve the problem. Clang-Tidy's 
`PPCallbacks` subsystem looks much more realistic.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

Charusso wrote:
> NoQ wrote:
> > And then remove the manual division.
> Hmpf.
> 
> ```
> Failing Tests (7):
> Clang :: Analysis/misc-ps-region-store.m
> Clang :: Analysis/mpichecker.cpp
> Clang :: Analysis/outofbound.c
> Clang :: Analysis/rdar-6541136-region.c
> Clang :: Analysis/return-ptr-range.cpp
> Clang :: Analysis/track-control-dependency-conditions.cpp
> Clang :: Analysis/uninit-vals.c
> ```
> 
> I would pick that solution because it may be a tiny-bit faster, and then 
> later on investigate this issue when we model more about dynamic sizes.
Soo what does it tell us about the correctness of the new `evalBinOp`-based 
solution?


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

https://reviews.llvm.org/D69599



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69731#1730784 , @NoQ wrote:

> I'm not sure though - because we somehow survived without this for like 10 
> years. Eg. `BugReporterVisitors.cpp`: [...]
>  I'd love to see some actual use before committing.


"Teaser":

  const Preprocessor  = C.getPreprocessor();
  Optional WantSafeFunctions;

  if (PP.isMacroDefined("__STDC_LIB_EXT1__")) {
MacroDefinition MD = PP.getMacroDefinition("__STDC_WANT_LIB_EXT1__");
if (const MacroInfo *MI = MD.getMacroInfo()) {
  const Token  = MI->tokens().back();
  StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
  llvm::APInt IntValue;
  ValueStr.getAsInteger(10, IntValue);
  WantSafeFunctions = IntValue.getZExtValue();
}
  }


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69732: [WIP][LTO] Apply SamplePGO pipeline tunes for ThinLTO pre-link to full LTO

2019-11-01 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

> The comments indicate that this is in part due to issues with
>  the new PM loop pass manager

Wondering how different it is for these loop passes to be enabled for MonoLTO 
vs ThinLTO? If it's due to problems with the newPM, I guess ThinLTO would have 
the same problems? Asking because we have almost the same change as internal 
patch trying to get better LTO time profile precision for MonoLTO, and with 
that there's small win for oldPM+MonoLTO. But we'd love to converge on new PM 
for both MonoLTO and ThinLTO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69732



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227534.
Charusso marked 6 inline comments as done.
Charusso added a comment.

- Fix.


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

https://reviews.llvm.org/D69726

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSizeInfo.h
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -10,7 +10,6 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
@@ -18,6 +17,8 @@
 #include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -653,16 +654,21 @@
 
 // See if we need to conjure a heap pointer instead of
 // a regular unknown pointer.
-bool IsHeapPointer = false;
-if (const auto *CNE = dyn_cast(E))
-  if (CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
-// FIXME: Delegate this to evalCall in MallocChecker?
-IsHeapPointer = true;
+const auto *CNE = dyn_cast(E);
+if (CNE && CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  // FIXME: Delegate this to evalCall in MallocChecker?
+  DefinedOrUnknownSVal Size = UnknownVal();
+  const Expr *SizeExpr = nullptr;
+
+  if ((SizeExpr = CNE->getArraySize().getValueOr(nullptr))) {
+Size = State->getSVal(SizeExpr, LCtx).castAs();
   }
 
-R = IsHeapPointer ? svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count)
-  : svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy,
- Count);
+  R = svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count);
+  State = setDynamicSize(State, R.getAsRegion(), Size, SizeExpr);
+} else {
+  R = svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy, Count);
+}
   }
   return State->BindExpr(E, LCtx, R);
 }
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -10,15 +10,16 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
-#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
-#include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
+#include "clang/AST/StmtCXX.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 
 using namespace clang;
 using namespace ento;
@@ -761,11 +762,20 @@
   // heap. We realize this is an approximation that might not correctly model
   // a custom global allocator.
   if (symVal.isUnknown()) {
-if (IsStandardGlobalOpNewFunction)
+if (IsStandardGlobalOpNewFunction) {
+  DefinedOrUnknownSVal Size = UnknownVal();
+  const Expr *SizeExpr = nullptr;
+
+  if ((SizeExpr = CNE->getArraySize().getValueOr(nullptr))) {
+Size = State->getSVal(SizeExpr, LCtx).castAs();
+  }
+
   symVal = svalBuilder.getConjuredHeapSymbolVal(CNE, LCtx, blockCount);
-else
+  State = setDynamicSize(State, symVal.getAsRegion(), Size, SizeExpr);
+} else {
   symVal = svalBuilder.conjureSymbolVal(nullptr, CNE, LCtx, CNE->getType(),
 blockCount);
+}
   }
 
   CallEventManager  = getStateManager().getCallEventManager();
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- 

[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h:29-31
+/// \returns The stored dynamic size expression for the region \p MR.
+const Expr *getDynamicSizeExpr(ProgramStateRef State, const MemRegion *MR);
+

NoQ wrote:
> Why do we need this?
I think as the checkers are growing and we push more-and-more allocation 
modeling so that at some point the Git's 8-parameter allocator's size 
expression could be retrieved so easily. This is the full arsenal of my 
buffer-overflow checker's needs, so I have pushed it here. Also it made a 
meaning to have a helper-class with two fields (one would be lame).



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1416
+   SizeInBytes.castAs(),
+   NE->getArraySize().getValueOr(nullptr));
   }

My problem was only that. It partially repeats the 
`ExprEngine::bindReturnValue()`, which is a wonky design. I will look into that 
later.



Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:180
-  // Assume should not fail at this point.
-  assert(state);
 

NoQ wrote:
> This gets rid of the assertion failure in 
> https://bugs.llvm.org/show_bug.cgi?id=28450 by implementing my suggestion 
> (2). Yay.
Cool!


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

https://reviews.llvm.org/D69726



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


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

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:133
+
+llvm::ConstrainedFPIntrinsic::ExceptionBehavior
+CodeGenFunction::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) {

rjmccall wrote:
> mibintc wrote:
> > I added these 2 functions, is this what you have in mind or do you want me 
> > to write them differently?
> Slightly differently, yes, please.
> 
> ```
> static llvm::ConstrainedFPIntrinsic::ExceptionBehavior 
> getConstrainedExceptionBehavior(LangOptions;:FPExceptionModeKind kind) {
>   switch (kind) {
>   case LangOptions::FPE_Ignore:
> return llvm::ConstrainedFPIntrinsic::ebIgnore;
>   // ...rest of cases here...
>   // no default: should be exhaustive over the enum
>   }
>   llvm_unreachable("bad kind");
> }
> ```
sorry i missed that detail (static) the first time around


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

NoQ wrote:
> And then remove the manual division.
Hmpf.

```
Failing Tests (7):
Clang :: Analysis/misc-ps-region-store.m
Clang :: Analysis/mpichecker.cpp
Clang :: Analysis/outofbound.c
Clang :: Analysis/rdar-6541136-region.c
Clang :: Analysis/return-ptr-range.cpp
Clang :: Analysis/track-control-dependency-conditions.cpp
Clang :: Analysis/uninit-vals.c
```

I would pick that solution because it may be a tiny-bit faster, and then later 
on investigate this issue when we model more about dynamic sizes.


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

https://reviews.llvm.org/D69599



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


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

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 227532.
mibintc added a comment.

Made a couple functions static per @rjmccall request


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fast-math.c
  clang/test/Driver/fp-model.c
  llvm/include/llvm/Target/TargetOptions.h

Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -107,7 +107,7 @@
   public:
 TargetOptions()
 : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
-  NoNaNsFPMath(false), NoTrappingFPMath(false),
+  NoNaNsFPMath(false), NoTrappingFPMath(true),
   NoSignedZerosFPMath(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
Index: clang/test/Driver/fp-model.c
===
--- /dev/null
+++ clang/test/Driver/fp-model.c
@@ -0,0 +1,130 @@
+// Test that incompatible combinations of -ffp-model= options
+// and other floating point options get a warning diagnostic.
+//
+// REQUIRES: clang-driver
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN %s
+// WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN1 %s
+// WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN2 %s
+// WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN3 %s
+// WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN4 %s
+// WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN5 %s
+// WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN7 %s
+// WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN8 %s
+// WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN9 %s
+// WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNa %s
+// WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNb %s
+// WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNc %s
+// WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNd %s
+// WARNd: warning: overriding '-ffp-model=strict' option with '-freciprocal-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -funsafe-math-optimizations -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNe %s
+// 

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

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



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:137
+  llvm_unreachable("Unsupported FP Exception Behavior");
+}
+

Sorry for dragging this out, but is there a reason these need to be member 
functions on `CodeGenFunction` rather than just `static` functions in this file?


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

https://reviews.llvm.org/D62731



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

And then remove the manual division.


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

https://reviews.llvm.org/D69599



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


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

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 227527.
mibintc added a comment.

Recoded ToConstrainedRoundingMD and ToConstrainedExceptionMD as requested by 
@rjmccall


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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fast-math.c
  clang/test/Driver/fp-model.c
  llvm/include/llvm/Target/TargetOptions.h

Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -107,7 +107,7 @@
   public:
 TargetOptions()
 : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
-  NoNaNsFPMath(false), NoTrappingFPMath(false),
+  NoNaNsFPMath(false), NoTrappingFPMath(true),
   NoSignedZerosFPMath(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
Index: clang/test/Driver/fp-model.c
===
--- /dev/null
+++ clang/test/Driver/fp-model.c
@@ -0,0 +1,130 @@
+// Test that incompatible combinations of -ffp-model= options
+// and other floating point options get a warning diagnostic.
+//
+// REQUIRES: clang-driver
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN %s
+// WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN1 %s
+// WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN2 %s
+// WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN3 %s
+// WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN4 %s
+// WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN5 %s
+// WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN7 %s
+// WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN8 %s
+// WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN9 %s
+// WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNa %s
+// WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNb %s
+// WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNc %s
+// WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNd %s
+// WARNd: warning: overriding '-ffp-model=strict' option with '-freciprocal-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -funsafe-math-optimizations -c %s 2>&1 \
+// RUN:   | FileCheck 

[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69599#1730707 , @NoQ wrote:

> > This is the first step to mitigate that issue.
>
> What's the issue?


Well, after I mentioned an issue I have realized the somewhat path-insensitive 
`getSizeInElements()` does not touch the (void *) return value. Basically the 
expression `int *foo = malloc()` could not compile, and I had felt that the 
assumptions about the overflow are wrong. Now I see that none of the overflow 
tests would compile, so I think we just bypass a cast here-and-there. Therefore 
there is no issue, just I was surprised.




Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:37-39
+  const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size);
+  if (!SizeInt)
+return UnknownVal();

NoQ wrote:
> Even if the size is not concrete, you can ask `SValBuilder` to perform the 
> division. It's going to be a symbolic expression which we won't be able to 
> work with anyway, but these days we believe that it's still worth it, in hope 
> that our constraint solver eventually gets better.
Good idea, thanks!


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

https://reviews.llvm.org/D69599



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227524.
Charusso marked 2 inline comments as done.
Charusso added a comment.

- Fix.


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

https://reviews.llvm.org/D69599

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -622,15 +622,6 @@
   StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx,
   SymbolReaper& SymReaper) override;
 
-  //===--===//
-  // Region "extents".
-  //===--===//
-
-  // FIXME: This method will soon be eliminated; see the note in Store.h.
-  DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion* R,
- QualType EleTy) override;
-
   //===--===//
   // Utility methods.
   //===--===//
@@ -1387,37 +1378,6 @@
   return StoreRef(B.asStore(), *this);
 }
 
-//===--===//
-// Extents for regions.
-//===--===//
-
-DefinedOrUnknownSVal
-RegionStoreManager::getSizeInElements(ProgramStateRef state,
-  const MemRegion *R,
-  QualType EleTy) {
-  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
-  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
-  if (!SizeInt)
-return UnknownVal();
-
-  CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
-
-  if (Ctx.getAsVariableArrayType(EleTy)) {
-// FIXME: We need to track extra state to properly record the size
-// of VLAs.  Returning UnknownVal here, however, is a stop-gap so that
-// we don't have a divide-by-zero below.
-return UnknownVal();
-  }
-
-  CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
-
-  // If a variable is reinterpreted as a type that doesn't fit into a larger
-  // type evenly, round it down.
-  // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize,
-svalBuilder.getArrayIndexType());
-}
-
 //===--===//
 // Location and region casting.
 //===--===//
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
+++ clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -26,5 +27,37 @@
   return MR->getMemRegionManager().getStaticSize(MR, SVB);
 }
 
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder ,
+QualType ElementTy) {
+  MemRegionManager  = MR->getMemRegionManager();
+  ASTContext  = MemMgr.getContext();
+
+  CharUnits ElementSize = Ctx.getTypeSizeInChars(ElementTy);
+  DefinedOrUnknownSVal Size = getDynamicSize(State, MR, SVB);
+
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.
+return SVB.makeIntVal(RegionSize / ElementSize, SVB.getArrayIndexType());
+  }
+
+  // Try to rely on the 'SValBuilder'.
+  SVal ElementSizeV = SVB.makeIntVal(
+  

[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2019-11-01 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 227512.
lewis-revill added a comment.
Herald added a subscriber: sameer.abuasal.

Rebased and merged D68644  into this patch - 
this patch already assumes shrink wrapping support anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-features.c
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.h
  llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.h
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/saverestore.ll
  llvm/test/CodeGen/RISCV/shrinkwrap.ll

Index: llvm/test/CodeGen/RISCV/shrinkwrap.ll
===
--- llvm/test/CodeGen/RISCV/shrinkwrap.ll
+++ llvm/test/CodeGen/RISCV/shrinkwrap.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple riscv32 < %s | FileCheck %s -check-prefix=RV32I-NOSW
 ; RUN: llc -mtriple riscv32 -enable-shrink-wrap < %s | FileCheck %s -check-prefix=RV32I-SW
+; RUN: llc -mtriple riscv32 -enable-shrink-wrap -mattr=+save-restore < %s \
+; RUN: | FileCheck %s -check-prefix=RV32I-SW-SR
 
 
 declare void @abort()
@@ -29,6 +31,16 @@
 ; RV32I-SW-NEXT:addi sp, sp, -16
 ; RV32I-SW-NEXT:sw ra, 12(sp)
 ; RV32I-SW-NEXT:call abort
+;
+; RV32I-SW-SR-LABEL: eliminate_restore:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bgeu a1, a0, .LBB0_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.end
+; RV32I-SW-SR-NEXT:ret
+; RV32I-SW-SR-NEXT:  .LBB0_2: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_0
+; RV32I-SW-SR-NEXT:call abort
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
@@ -84,6 +96,23 @@
 ; RV32I-SW-NEXT:addi sp, sp, 16
 ; RV32I-SW-NEXT:  .LBB1_2: # %if.end
 ; RV32I-SW-NEXT:ret
+;
+; RV32I-SW-SR-LABEL: conditional_alloca:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bltu a1, a0, .LBB1_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_1
+; RV32I-SW-SR-NEXT:addi s0, sp, 16
+; RV32I-SW-SR-NEXT:addi a0, a0, 15
+; RV32I-SW-SR-NEXT:andi a0, a0, -16
+; RV32I-SW-SR-NEXT:sub a0, sp, a0
+; RV32I-SW-SR-NEXT:mv sp, a0
+; RV32I-SW-SR-NEXT:call notdead
+; RV32I-SW-SR-NEXT:addi sp, s0, -16
+; RV32I-SW-SR-NEXT:tail __riscv_restore_1
+; RV32I-SW-SR-NEXT:  .LBB1_2: # %if.end
+; RV32I-SW-SR-NEXT:ret
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
Index: llvm/test/CodeGen/RISCV/saverestore.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/saverestore.ll
@@ -0,0 +1,299 @@
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s -check-prefix=RV32I
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s -check-prefix=RV64I
+; RUN: llc -mtriple=riscv32 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV32I-SR
+; RUN: llc -mtriple=riscv64 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV64I-SR
+; RUN: llc -mtriple=riscv32 -mattr=+f,+save-restore -target-abi=ilp32f < %s | FileCheck %s -check-prefix=RV32I-FP-SR
+; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+save-restore -target-abi=lp64d < %s | FileCheck %s -check-prefix=RV64I-FP-SR
+
+; Check that the correct save/restore libcalls are generated.
+
+@var0 = global [18 x i32] zeroinitializer
+@var1 = global [24 x i32] zeroinitializer
+@var2 = global [30 x i32] zeroinitializer
+
+define void @callee_saved0() nounwind {
+; RV32I-LABEL: callee_saved0:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved0:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail __riscv_restore
+;
+; RV32I-SR-LABEL: callee_saved0:
+; RV32I-SR: call t0, __riscv_save_5
+; RV32I-SR: tail __riscv_restore_5
+;
+; RV64I-SR-LABEL: callee_saved0:
+; RV64I-SR: call t0, __riscv_save_5
+; RV64I-SR: tail __riscv_restore_5
+;
+; RV32I-FP-SR-LABEL: callee_saved0:
+; RV32I-FP-SR: call t0, __riscv_save_5
+; RV32I-FP-SR: tail __riscv_restore_5
+;
+; RV64I-FP-SR-LABEL: callee_saved0:
+; RV64I-FP-SR: call t0, __riscv_save_5
+; RV64I-FP-SR: tail __riscv_restore_5
+  %val = load [18 x i32], [18 x i32]* @var0
+  store volatile [18 x i32] %val, [18 x i32]* @var0
+  ret void
+}
+
+define void @callee_saved1() nounwind {
+; RV32I-LABEL: callee_saved1:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved1:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail 

[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 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.

We probably need this because every time we try to deal with macros we struggle 
quite a bit.

I'm not sure though - because we somehow survived without this for like 10 
years. Eg. `BugReporterVisitors.cpp`:

  250 static bool isFunctionMacroExpansion(SourceLocation Loc,
  251 const SourceManager ) {
  252   if (!Loc.isMacroID())
  253 return false;
  254   while (SM.isMacroArgExpansion(Loc))
  255 Loc = SM.getImmediateExpansionRange(Loc).getBegin();
  256   std::pair TLInfo = SM.getDecomposedLoc(Loc);
  257   SrcMgr::SLocEntry SE = SM.getSLocEntry(TLInfo.first);
  258   const SrcMgr::ExpansionInfo  = SE.getExpansion();
  259   return EInfo.isFunctionMacroExpansion();
  260 }

I'd love to see some actual use before committing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Also path-insensitive checkers will probably benefit a lot more from this info.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[clang] 52ea308 - [NFC]: Removed an implicit capture argument from lambda.

2019-11-01 Thread Sourabh Singh Tomar via cfe-commits

Author: Sourabh Singh Tomar
Date: 2019-11-02T01:37:46+05:30
New Revision: 52ea308f705af0a8f5d55e036a64fd2b5e4c2ee6

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

LOG: [NFC]: Removed an implicit capture argument from lambda.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d2d9e8e59119..38750d7d3369 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1608,7 +1608,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
 
   // We're checking for deleted C++ special member functions
   // [Ctors,Dtors, Copy/Move]
-  auto checkAttrDeleted = [](const auto *Method) {
+  auto checkAttrDeleted = [&](const auto *Method) {
 if (Method->getCanonicalDecl()->isDeleted())
   SPFlags |= llvm::DISubprogram::SPFlagDeleted;
   };



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


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

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



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:133
+
+llvm::ConstrainedFPIntrinsic::ExceptionBehavior
+CodeGenFunction::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) {

mibintc wrote:
> I added these 2 functions, is this what you have in mind or do you want me to 
> write them differently?
Slightly differently, yes, please.

```
static llvm::ConstrainedFPIntrinsic::ExceptionBehavior 
getConstrainedExceptionBehavior(LangOptions;:FPExceptionModeKind kind) {
  switch (kind) {
  case LangOptions::FPE_Ignore:
return llvm::ConstrainedFPIntrinsic::ebIgnore;
  // ...rest of cases here...
  // no default: should be exhaustive over the enum
  }
  llvm_unreachable("bad kind");
}
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h:29-31
+/// \returns The stored dynamic size expression for the region \p MR.
+const Expr *getDynamicSizeExpr(ProgramStateRef State, const MemRegion *MR);
+

Why do we need this?



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1073
+
+setDynamicSize(State, BR, *SizeNL, Size);
 

Charusso wrote:
> That dual assumption made changes in the test files, and there is no other 
> dual assumption.
Wait, this code should not have been changed. It's not an allocation site, we 
don't receive any new information about the size of the region here.



Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:180
-  // Assume should not fail at this point.
-  assert(state);
 

This gets rid of the assertion failure in 
https://bugs.llvm.org/show_bug.cgi?id=28450 by implementing my suggestion (2). 
Yay.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69726



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


[PATCH] D69732: [WIP][LTO] Apply SamplePGO pipeline tunes for ThinLTO pre-link to full LTO

2019-11-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

This probably needs to be taken over by someone who cares about full LTO 
performance (@wristow or @ormris ?). This patch was some cleanup of the full 
LTO sample PGO pipeline, but has a number of issues I enumerate in the summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69732



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


[PATCH] D69715: NeonEmitter: change Type representation. NFC.

2019-11-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

I guess the extra checks are due to existing code "accidentally" doing the 
right thing?

Have you verified this is NFC in terms of the generated arm_neon.h etc?

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69715



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


[PATCH] D69732: [WIP][LTO] Apply SamplePGO pipeline tunes for ThinLTO pre-link to full LTO

2019-11-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: wristow, ormris.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya, inglorion, mehdi_amini.
Herald added projects: clang, LLVM.

There are several modifications to the optimizations performed by the
ThinLTO pre link compile when building with Sample PGO, in order to get
better matching of the SamplePGO when it is re-applied in the backend.
These same tunes should be done for full LTO pre-links as well, as
presumably the same matching issues could occur there.

There are a few issues with this patch as it stands, relating to the
fact that not all of these optimizations are attempted again in the full
LTO backend, owing to the larger compile time with the monolithic LTO.
Specifically, this includes some loop optimizations:

- In the old PM, LoopUnrollAndJam is not done in the full LTO backend.
- In the new PM, none of the loop unrolling is done in the full LTO

backend. The comments indicate that this is in part due to issues with
the new PM loop pass manager (presumably sorted out by now, but I
haven't followed this). Here is the comment:

  // FIXME: at this point, we run a bunch of loop passes:
  // indVarSimplify, loopDeletion, loopInterchange, loopUnroll,
  // loopVectorize. Enable them once the remaining issue with LPM
  // are sorted out.

So what needs to happen still is to either:

1. Continue to diverge the ThinLTO and full LTO pre-link pipelines for

these optimizations (which means this patch needs to be adjusted).
OR

2. Fix the full LTO post-link pipelines to ensure these optimizations

all occur there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/pgo-sample-thinlto-summary.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -498,12 +498,12 @@
 MPM.add(createPGOIndirectCallPromotionLegacyPass(/*InLTO = */ true,
  !PGOSampleUse.empty()));
 
-  // For SamplePGO in ThinLTO compile phase, we do not want to unroll loops
+  // For SamplePGO in the *LTO compile phase, we do not want to unroll loops
   // as it will change the CFG too much to make the 2nd profile annotation
   // in backend more difficult.
-  bool PrepareForThinLTOUsingPGOSampleProfile =
-  PrepareForThinLTO && !PGOSampleUse.empty();
-  if (PrepareForThinLTOUsingPGOSampleProfile)
+  bool PrepareForLTOUsingPGOSampleProfile =
+  (PrepareForThinLTO || PrepareForLTO) && !PGOSampleUse.empty();
+  if (PrepareForLTOUsingPGOSampleProfile)
 DisableUnrollLoops = true;
 
   // Infer attributes about declarations if possible.
@@ -530,12 +530,12 @@
   addExtensionsToPM(EP_Peephole, MPM);
   MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
 
-  // For SamplePGO in ThinLTO compile phase, we do not want to do indirect
+  // For SamplePGO in the *LTO compile phase, we do not want to do indirect
   // call promotion as it will change the CFG too much to make the 2nd
   // profile annotation in backend more difficult.
-  // PGO instrumentation is added during the compile phase for ThinLTO, do
+  // PGO instrumentation is added during the compile phase for *LTO, do
   // not run it a second time
-  if (DefaultOrPreLinkPipeline && !PrepareForThinLTOUsingPGOSampleProfile)
+  if (DefaultOrPreLinkPipeline && !PrepareForLTOUsingPGOSampleProfile)
 addPGOInstrPasses(MPM);
 
   // Create profile COMDAT variables. Lld linker wants to see all variables
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -383,10 +383,8 @@
 C(LAM);
 }
 
-FunctionPassManager
-PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
- ThinLTOPhase Phase,
- bool DebugLogging) {
+FunctionPassManager PassBuilder::buildFunctionSimplificationPipeline(
+OptimizationLevel Level, LTOPhase Phase, bool DebugLogging) {
   assert(Level != O0 && "Must request optimizations!");
   FunctionPassManager FPM(DebugLogging);
 
@@ -465,10 +463,10 @@
 C(LPM2, Level);
 
   LPM2.addPass(LoopDeletionPass());
-  // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
+  // Do not enable unrolling in PreLink LTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  if ((Phase != LTOPhase::PreLink || !PGOOpt ||
PGOOpt->Action != PGOOptions::SampleUse) &&
 

[PATCH] D69662: [Checkers] Avoid using evalCall in StreamChecker.

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

But why?




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:161
   .castAs();
   state = state->BindExpr(CE, C.getLocationContext(), RetVal);
 

You're not allowed to do this in `checkPostCall` because other post-call 
checkers may have already read the return value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69662



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> This is the first step to mitigate that issue.

What's the issue?




Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:37-39
+  const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size);
+  if (!SizeInt)
+return UnknownVal();

Even if the size is not concrete, you can ask `SValBuilder` to perform the 
division. It's going to be a symbolic expression which we won't be able to work 
with anyway, but these days we believe that it's still worth it, in hope that 
our constraint solver eventually gets better.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69599



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added a comment.

It is needed for my work, and also I have seen other checkers in need of that.




Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:195
   ASTContext *Ctx;
-  const Preprocessor 
   const std::string OutDir;

I have dropped the `const` because the methods of `Preprocessor` are non-const 
because of the `BumpPtrAllocator`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69716: NeonEmitter: remove special 'a' modifier.

2019-11-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D69716/new/

https://reviews.llvm.org/D69716



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


[PATCH] D69651: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Vlad Vereschaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa264e85dd9f9: [CMake] Add cross Windows to ARM Linux 
toolchain CMake cache file. (authored by vvereschaka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake

Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- /dev/null
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -0,0 +1,109 @@
+# CrossWinToARMLinux.cmake
+#
+# Set up a CMakeCache for a cross Windows to ARM Linux toolchain build.
+#
+# This cache file can be used to build a cross toolchain to ARM Linux
+# on Windows platform.
+#
+# NOTE: the build requires a development ARM Linux root filesystem to use
+# proper target platform depended library and header files.
+#
+# Configure:
+#  cmake -G Ninja ^
+#   -DCMAKE_INSTALL_PREFIX=../install ^
+#   -DDEFAULT_SYSROOT= ^
+#   -DLLVM_AR=/bin/llvm-ar[.exe] ^
+#   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -C/llvm-project/clang/caches/CrossWinToARMLinux.cmake ^
+#   /llvm-project/llvm
+# Build:
+#  cmake --build . --target install
+# Test:
+#  cmake --build . --target check-llvm
+#  cmake --build . --target check-clang
+#  cmake --build . --target check-lld
+
+if (NOT DEFINED DEFAULT_SYSROOT)
+  message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
+endif()
+
+if (DEFINED LLVM_AR)
+  set(CMAKE_AR "${LLVM_AR}" CACHE STRING "")
+endif()
+
+if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
+  set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_C_COMPILER_TARGET)
+  # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
+  set(CMAKE_C_COMPILER_TARGET "armv7-linux-gnueabihf" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+endif()
+
+set(CMAKE_CROSSCOMPILINGON CACHE BOOL "")
+set(CMAKE_CL_SHOWINCLUDES_PREFIX"Note: including file: " CACHE STRING "")
+
+set(LLVM_ENABLE_ASSERTIONS  ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS"clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
+set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
+
+set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
+
+set(COMPILER_RT_BUILD_BUILTINS  ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERSOFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY  OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
+set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+
+set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBUNWIND_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDERON CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
+set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLY 			ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  LTO
+  clang-format
+  builtins
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Charusso added a parent revision: D69726: [analyzer] DynamicSize: Store the 
dynamic size.

This patch hooks the `Preprocessor` trough `BugReporter` to the
`CheckerContext` so the checkers could look for macro definitions.


Repository:
  rC Clang

https://reviews.llvm.org/D69731

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -58,7 +58,7 @@
   ExprEngineConsumer(CompilerInstance )
   : C(C), ChkMgr(C.getASTContext(), *C.getAnalyzerOpts()), CTU(C),
 Consumers(),
-AMgr(C.getASTContext(), Consumers,
+AMgr(C.getASTContext(), C.getPreprocessor(), Consumers,
  CreateRegionStoreManager, CreateRangeConstraintManager, ,
  *C.getAnalyzerOpts()),
 VisitedCallees(), FS(),
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -192,7 +192,7 @@
 
 public:
   ASTContext *Ctx;
-  const Preprocessor 
+  Preprocessor 
   const std::string OutDir;
   AnalyzerOptionsRef Opts;
   ArrayRef Plugins;
@@ -335,8 +335,8 @@
 checkerMgr = createCheckerManager(
 *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics());
 
-Mgr = std::make_unique(*Ctx, PathConsumers, CreateStoreMgr,
-CreateConstraintMgr,
+Mgr = std::make_unique(*Ctx, PP, PathConsumers,
+CreateStoreMgr, CreateConstraintMgr,
 checkerMgr.get(), *Opts, Injector);
   }
 
Index: clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -13,7 +13,7 @@
 
 void AnalysisManager::anchor() { }
 
-AnalysisManager::AnalysisManager(ASTContext ,
+AnalysisManager::AnalysisManager(ASTContext , Preprocessor ,
  const PathDiagnosticConsumers ,
  StoreManagerCreator storemgr,
  ConstraintManagerCreator constraintmgr,
@@ -38,7 +38,7 @@
   Options.ShouldElideConstructors,
   /*addVirtualBaseBranches=*/true,
   injector),
-  Ctx(ASTCtx), LangOpts(ASTCtx.getLangOpts()),
+  Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()),
   PathConsumers(PDC), CreateStoreMgr(storemgr),
   CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
   options(Options) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -107,6 +107,10 @@
 return getBugReporter().getSourceManager();
   }
 
+  const Preprocessor () {
+return getBugReporter().getPreprocessor();
+  }
+
   SValBuilder () {
 return Eng.getSValBuilder();
   }
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -16,6 +16,7 @@
 
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
@@ -32,6 +33,7 @@
   AnalysisDeclContextManager AnaCtxMgr;
 
   ASTContext 
+  Preprocessor 
   const LangOptions 
   PathDiagnosticConsumers PathConsumers;
 
@@ -44,7 +46,7 @@
 public:
   AnalyzerOptions 
 
-  AnalysisManager(ASTContext ,
+  AnalysisManager(ASTContext , Preprocessor ,
   const PathDiagnosticConsumers ,
   StoreManagerCreator storemgr,
   ConstraintManagerCreator 

[clang] a264e85 - [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Vladimir Vereschaka via cfe-commits

Author: Vladimir Vereschaka
Date: 2019-11-01T12:40:25-07:00
New Revision: a264e85dd9f99391bedc7f069926bdd8d2f44388

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

LOG: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

This cache file can be used to build a cross Windows to ARM Linux
toolchain.

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

Added: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Modified: 


Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
new file mode 100644
index ..246f6241f0e2
--- /dev/null
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -0,0 +1,109 @@
+# CrossWinToARMLinux.cmake
+#
+# Set up a CMakeCache for a cross Windows to ARM Linux toolchain build.
+#
+# This cache file can be used to build a cross toolchain to ARM Linux
+# on Windows platform.
+#
+# NOTE: the build requires a development ARM Linux root filesystem to use
+# proper target platform depended library and header files.
+#
+# Configure:
+#  cmake -G Ninja ^
+#   -DCMAKE_INSTALL_PREFIX=../install ^
+#   -DDEFAULT_SYSROOT= ^
+#   -DLLVM_AR=/bin/llvm-ar[.exe] ^
+#   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -C/llvm-project/clang/caches/CrossWinToARMLinux.cmake ^
+#   /llvm-project/llvm
+# Build:
+#  cmake --build . --target install
+# Test:
+#  cmake --build . --target check-llvm
+#  cmake --build . --target check-clang
+#  cmake --build . --target check-lld
+
+if (NOT DEFINED DEFAULT_SYSROOT)
+  message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain 
build.")
+endif()
+
+if (DEFINED LLVM_AR)
+  set(CMAKE_AR "${LLVM_AR}" CACHE STRING "")
+endif()
+
+if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
+  set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_C_COMPILER_TARGET)
+  # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
+  set(CMAKE_C_COMPILER_TARGET "armv7-linux-gnueabihf" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+endif()
+
+set(CMAKE_CROSSCOMPILINGON CACHE BOOL "")
+set(CMAKE_CL_SHOWINCLUDES_PREFIX"Note: including file: " CACHE 
STRING "")
+
+set(LLVM_ENABLE_ASSERTIONS  ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS"clang;clang-tools-extra;lld" 
CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES
"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
+set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE 
STRING "" FORCE)
+
+set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
+
+set(COMPILER_RT_BUILD_BUILTINS  ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERSOFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY  OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
+set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+
+set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LIBUNWIND_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING 
"")
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDERON CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING 
"")
+
+set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
+set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
+
+set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLYON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+

[PATCH] D69651: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Galina via Phabricator via cfe-commits
gkistanova accepted this revision.
gkistanova added a comment.

LGTM. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651



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


[PATCH] D69651: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Andrei Lebedev via Phabricator via cfe-commits
andreil99 accepted this revision.
andreil99 added a comment.
This revision is now accepted and ready to land.

Thanks, Vlad! Looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added a comment.

I do not want to reverse engineer the `MallocChecker` to obtain the size on 
call basis. The current model without D68725  
makes it enough difficult to obtain the size even with this generic map, but it 
is working fine.




Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1073
+
+setDynamicSize(State, BR, *SizeNL, Size);
 

That dual assumption made changes in the test files, and there is no other dual 
assumption.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69726



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


[PATCH] D69642: [analyzer] DynamicSize: Simplify the assumption creating of sizes

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso abandoned this revision.
Charusso added a comment.

I think we do not need to create assumptions. However, there is a tiny 
difference which continues in D69726 


Repository:
  rC Clang

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

https://reviews.llvm.org/D69642



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

This patch introduces a way to store the symbolic size and its expression.


Repository:
  rC Clang

https://reviews.llvm.org/D69726

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSizeInfo.h
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/test/Analysis/null-deref-ps-region.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -1274,7 +1274,7 @@
 void memset5_char_malloc_overflow_null() {
   char *str = (char *)malloc(10 * sizeof(char));
   memset(str, '\0', 12);
-  clang_analyzer_eval(str[1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(str[1] == 0); // expected-warning{{TRUE}}
   free(str);
 }
 #endif
@@ -1362,7 +1362,7 @@
   char *str = (char *)malloc(10 * sizeof(int));
   int *array = (int *)str;
   memset(array, 0, 5 * sizeof(int));
-  clang_analyzer_eval(str[10] == '\0');// expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(str[10] == '\0');// expected-warning{{TRUE}}
   clang_analyzer_eval(strlen((char *)array) == 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(strlen(str) == 0);   // expected-warning{{TRUE}}
   free(str);
@@ -1380,7 +1380,7 @@
 int memset21_scalar() {
   int *x = malloc(sizeof(int));
   memset(x, 0, 1);
-  int num = 1 / *x;
+  int num = 1 / *x; // expected-warning{{Division by zero}}
   free(x);
   return num;
 }
@@ -1476,7 +1476,7 @@
 #endif
   clang_analyzer_eval(privkey[0] == '\0');
 #ifdef SUPPRESS_OUT_OF_BOUND
-  // expected-warning@-2 {{UNKNOWN}}
+  // expected-warning@-2 {{TRUE}}
 #endif
   free(privkey);
 }
Index: clang/test/Analysis/null-deref-ps-region.c
===
--- clang/test/Analysis/null-deref-ps-region.c
+++ clang/test/Analysis/null-deref-ps-region.c
@@ -33,7 +33,7 @@
 void bar() {
   int *x = malloc(sizeof(int));
   memset(x, 0, 1);
-  int n = 1 / *x; // no-warning
+  int n = 1 / *x; // expected-warning {{Division by zero}}
   free(x);
 }
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -10,7 +10,6 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
@@ -18,6 +17,8 @@
 #include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -653,16 +654,21 @@
 
 // See if we need to conjure a heap pointer instead of
 // a regular unknown pointer.
-bool IsHeapPointer = false;
-if (const auto *CNE = dyn_cast(E))
-  if (CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
-// FIXME: Delegate this to evalCall in MallocChecker?
-IsHeapPointer = true;
+const auto *CNE = dyn_cast(E);
+if (CNE && CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  // FIXME: Delegate this to evalCall in MallocChecker?
+  DefinedOrUnknownSVal Size = UnknownVal();
+  const Expr *SizeExpr = nullptr;
+
+  if ((SizeExpr = CNE->getArraySize().getValueOr(nullptr))) {
+Size = State->getSVal(SizeExpr, LCtx).castAs();
   }
 
-R = IsHeapPointer ? svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count)
-  : svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy,
- Count);
+  R = svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count);
+  State = setDynamicSize(State, R.getAsRegion(), Size, SizeExpr);
+} else {
+  R = svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy, Count);
+}
   }
   return State->BindExpr(E, LCtx, R);
 }
Index: 

[PATCH] D69651: [CMake] Add cross ARM toolchain CMake cache file.

2019-11-01 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka updated this revision to Diff 227501.
vvereschaka edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake

Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- /dev/null
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -0,0 +1,109 @@
+# CrossWinToARMLinux.cmake
+#
+# Set up a CMakeCache for a cross Windows to ARM Linux toolchain build.
+#
+# This cache file can be used to build a cross toolchain to ARM Linux
+# on Windows platform.
+#
+# NOTE: the build requires a development ARM Linux root filesystem to use
+# proper target platform depended library and header files.
+#
+# Configure:
+#  cmake -G Ninja ^
+#   -DCMAKE_INSTALL_PREFIX=../install ^
+#   -DDEFAULT_SYSROOT= ^
+#   -DLLVM_AR=/bin/llvm-ar[.exe] ^
+#   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -C/llvm-project/clang/caches/CrossWinToARMLinux.cmake ^
+#   /llvm-project/llvm
+# Build:
+#  cmake --build . --target install
+# Test:
+#  cmake --build . --target check-llvm
+#  cmake --build . --target check-clang
+#  cmake --build . --target check-lld
+
+if (NOT DEFINED DEFAULT_SYSROOT)
+  message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
+endif()
+
+if (DEFINED LLVM_AR)
+  set(CMAKE_AR "${LLVM_AR}" CACHE STRING "")
+endif()
+
+if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
+  set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_C_COMPILER_TARGET)
+  # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
+  set(CMAKE_C_COMPILER_TARGET "armv7-linux-gnueabihf" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+endif()
+
+set(CMAKE_CROSSCOMPILINGON CACHE BOOL "")
+set(CMAKE_CL_SHOWINCLUDES_PREFIX"Note: including file: " CACHE STRING "")
+
+set(LLVM_ENABLE_ASSERTIONS  ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS"clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
+set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
+
+set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
+
+set(COMPILER_RT_BUILD_BUILTINS  ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERSOFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY  OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
+set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+
+set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBUNWIND_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDERON CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
+set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLY 			ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  LTO
+  clang-format
+  builtins
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69184: [libTooling] Introduce general combinator for fixed-value `MatchConsumer`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D69184#1730523 , @gribozavr2 wrote:

> > In fact, it might be a good idea to rename `change` to `changeTo` (WDYT?).
>
> I like it. It should combine well with all stencils, not just `text`.


Agreed. Will do.

> 
> 
>> An alternative, is not to introduce a new combinator at all, and just use 
>> Stencils:
> 
> I think we are converging on that in another review. Do you plan to pursue 
> this patch still?

Agreed. Let's drop this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69184



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


[PATCH] D69184: [libTooling] Introduce general combinator for fixed-value `MatchConsumer`s.

2019-11-01 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> In fact, it might be a good idea to rename `change` to `changeTo` (WDYT?).

I like it. It should combine well with all stencils, not just `text`.

> An alternative, is not to introduce a new combinator at all, and just use 
> Stencils:

I think we are converging on that in another review. Do you plan to pursue this 
patch still?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69184



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


[PATCH] D68074: [clang-tidy] Add readability-make-member-function-const

2019-11-01 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp:180
+//  use((const S*)this);
+//  (const S*)->f()
+// when 'f' is a public member function.

I think you meant `((const S*)this)->f()`.



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:21
+  Str S;
+  Str Sref;
+

Did you mean `Str `?



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:168
+
+  int M;
+  int keepConst() const { return M; }

Move up, close to other data members?



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:179
+
+  Str S;
+  void call_non_const_member_on_field() { S.non_const_method(); }

Move up, close to other data members?



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:247
+template 
+struct KeepWithTemplateBase : public Base {
+  int M;

"DependentBase"



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:255
+template 
+struct KeepTemplateClass {
+  int M;

"ClassTemplate"




Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:262
+
+struct KeepTemplateMethod {
+  int M;

"MemberFunctionTemplate"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68074



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


[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.def:426-436
+OPENMP_DEFAULTMAP_KIND(aggregate)
+OPENMP_DEFAULTMAP_KIND(pointer)
 
 // Modifiers for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_MODIFIER(alloc)
+OPENMP_DEFAULTMAP_MODIFIER(to)
+OPENMP_DEFAULTMAP_MODIFIER(from)

cchen wrote:
> ABataev wrote:
> > Add some guards in the code, these values must be enabled only for OpenMP 
> > 5.0, for 4.5 only scalar:tofrom is allowed. Add a test that the error 
> > messages are emitted for new cases in OpenMP 4.5
> Do you mean that I should add the guards in this file (OpenMPKinds.def) so 
> that Clang will not even parse those new keywords for OpenMP < 50 or I could 
> just check the use of those keywords in Sema?
> If I should put guards in the .def file, could you give me any hint or point 
> me to an example? Thanks!
No, not in this file, this is just general comment. You need to guard this 
during semantic analysis


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-01 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.def:426-436
+OPENMP_DEFAULTMAP_KIND(aggregate)
+OPENMP_DEFAULTMAP_KIND(pointer)
 
 // Modifiers for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_MODIFIER(alloc)
+OPENMP_DEFAULTMAP_MODIFIER(to)
+OPENMP_DEFAULTMAP_MODIFIER(from)

ABataev wrote:
> Add some guards in the code, these values must be enabled only for OpenMP 
> 5.0, for 4.5 only scalar:tofrom is allowed. Add a test that the error 
> messages are emitted for new cases in OpenMP 4.5
Do you mean that I should add the guards in this file (OpenMPKinds.def) so that 
Clang will not even parse those new keywords for OpenMP < 50 or I could just 
check the use of those keywords in Sema?
If I should put guards in the .def file, could you give me any hint or point me 
to an example? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D69697: [WebAssembly] Add experimental SIMD dot product instruction

2019-11-01 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG935c84c3c27d: [WebAssembly] Add experimental SIMD dot 
product instruction (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69697

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

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -571,4 +571,7 @@
 # CHECK: v128.andnot # encoding: [0xfd,0xd8,0x01]
 v128.andnot
 
+# CHECK: i32x4.dot_i16x8_s # encoding: [0xfd,0xd9,0x01]
+i32x4.dot_i16x8_s
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -387,6 +387,16 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: dot:
+; SIMD128-NEXT: .functype dot (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i32x4.dot_i16x8_s $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.wasm.dot(<8 x i16>, <8 x i16>)
+define <4 x i32> @dot(<8 x i16> %x, <8 x i16> %y) {
+  %a = call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y)
+  ret <4 x i32> %a
+}
+
 ; CHECK-LABEL: any_v4i32:
 ; SIMD128-NEXT: .functype any_v4i32 (v128) -> (i32){{$}}
 ; SIMD128-NEXT: i32x4.any_true $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -738,6 +738,13 @@
 defm MAX_U : SIMDBinaryIntNoI64x2;
 } // isCommutable = 1
 
+// Widening dot product: i32x4.dot_i16x8_s
+let isCommutable = 1 in
+defm DOT : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs), (outs), (ins),
+  [(set V128:$dst, (int_wasm_dot V128:$lhs, V128:$rhs))],
+  "i32x4.dot_i16x8_s\t$dst, $lhs, $rhs", "i32x4.dot_i16x8_s",
+  217>;
+
 //===--===//
 // Floating-point unary arithmetic
 //===--===//
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -152,6 +152,10 @@
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
+def int_wasm_dot :
+  Intrinsic<[llvm_v4i32_ty],
+[llvm_v8i16_ty, llvm_v8i16_ty],
+[IntrNoMem, IntrSpeculatable]>;
 def int_wasm_narrow_signed :
   Intrinsic<[llvm_anyvector_ty],
 [llvm_anyvector_ty, LLVMMatchType<1>],
Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -436,6 +436,12 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i32x4 dot_i16x8_s(i16x8 x, i16x8 y) {
+  return __builtin_wasm_dot_s_i32x4_i16x8(x, y);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) {
   return __builtin_wasm_bitselect(x, y, c);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.bitselect.v4i32(
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -14360,6 +14360,12 @@
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_dot_s_i32x4_i16x8: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_dot);
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_any_true_i8x16:
   case WebAssembly::BI__builtin_wasm_any_true_i16x8:
   case WebAssembly::BI__builtin_wasm_any_true_i32x4:
Index: clang/include/clang/Basic/BuiltinsWebAssembly.def
===
--- clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -132,6 +132,8 @@
 

[clang] 935c84c - [WebAssembly] Add experimental SIMD dot product instruction

2019-11-01 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2019-11-01T10:45:48-07:00
New Revision: 935c84c3c27de4544917216fc2b0557314802202

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

LOG: [WebAssembly] Add experimental SIMD dot product instruction

Summary:
This instruction is not merged to the spec proposal, but we need it to
be implemented in the toolchain to experiment with it. It is available
only on an opt-in basis through a clang builtin.

Defined in https://github.com/WebAssembly/simd/pull/127.

Depends on D69696.

Reviewers: aheejin

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

Tags: #clang, #llvm

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 2233c20c4d64..2c57c5b70ef6 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -132,6 +132,8 @@ TARGET_BUILTIN(__builtin_wasm_max_f32x4, "V4fV4fV4f", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_min_f64x2, "V2dV2dV2d", "nc", 
"unimplemented-simd128")
 TARGET_BUILTIN(__builtin_wasm_max_f64x2, "V2dV2dV2d", "nc", 
"unimplemented-simd128")
 
+TARGET_BUILTIN(__builtin_wasm_dot_s_i32x4_i16x8, "V4iV8sV8s", "nc", "simd128")
+
 TARGET_BUILTIN(__builtin_wasm_sqrt_f32x4, "V4fV4f", "nc", 
"unimplemented-simd128")
 TARGET_BUILTIN(__builtin_wasm_sqrt_f64x2, "V2dV2d", "nc", 
"unimplemented-simd128")
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fef5cab8c8d1..cc2cbb907076 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14360,6 +14360,12 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_dot_s_i32x4_i16x8: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_dot);
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_any_true_i8x16:
   case WebAssembly::BI__builtin_wasm_any_true_i16x8:
   case WebAssembly::BI__builtin_wasm_any_true_i32x4:

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index c07e73fa1af8..eea51eb71b69 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -436,6 +436,12 @@ i32x4 max_u_i32x4(i32x4 x, i32x4 y) {
   // WEBASSEMBLY-NEXT: ret
 }
 
+i32x4 dot_i16x8_s(i16x8 x, i16x8 y) {
+  return __builtin_wasm_dot_s_i32x4_i16x8(x, y);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) {
   return __builtin_wasm_bitselect(x, y, c);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.bitselect.v4i32(

diff  --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td 
b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
index b99abb43d116..422334a78bb4 100644
--- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -152,6 +152,10 @@ def int_wasm_qfms :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
+def int_wasm_dot :
+  Intrinsic<[llvm_v4i32_ty],
+[llvm_v8i16_ty, llvm_v8i16_ty],
+[IntrNoMem, IntrSpeculatable]>;
 def int_wasm_narrow_signed :
   Intrinsic<[llvm_anyvector_ty],
 [llvm_anyvector_ty, LLVMMatchType<1>],

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index 2a423acc3016..137234f89b30 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -738,6 +738,13 @@ defm MAX_S : SIMDBinaryIntNoI64x2;
 defm MAX_U : SIMDBinaryIntNoI64x2;
 } // isCommutable = 1
 
+// Widening dot product: i32x4.dot_i16x8_s
+let isCommutable = 1 in
+defm DOT : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs), (outs), (ins),
+  [(set V128:$dst, (int_wasm_dot V128:$lhs, V128:$rhs))],
+  "i32x4.dot_i16x8_s\t$dst, $lhs, $rhs", 

[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 227478.
ymandel marked an inline comment as done.
ymandel added a comment.

remove stray comments; clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -96,7 +96,7 @@
  .bind("expr")))
 .bind("stmt"));
 ASSERT_TRUE(StmtMatch);
-if (auto ResultOrErr = Stencil.eval(StmtMatch->Result)) {
+if (auto ResultOrErr = Stencil->eval(StmtMatch->Result)) {
   ADD_FAILURE() << "Expected failure but succeeded: " << *ResultOrErr;
 } else {
   auto Err = llvm::handleErrors(ResultOrErr.takeError(),
@@ -131,11 +131,12 @@
   // Invert the if-then-else.
   auto Stencil = cat("if (!", node(Condition), ") ", statement(Else), " else ",
  statement(Then));
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
-TEST_F(StencilTest, SingleStatementCallOperator) {
+// Tests `stencil`.
+TEST_F(StencilTest, StencilFactoryFunction) {
   StringRef Condition("C"), Then("T"), Else("E");
   const std::string Snippet = R"cc(
 if (true)
@@ -148,9 +149,9 @@
   hasThen(stmt().bind(Then)), hasElse(stmt().bind(Else;
   ASSERT_TRUE(StmtMatch);
   // Invert the if-then-else.
-  Stencil S = cat("if (!", node(Condition), ") ", statement(Else), " else ",
-  statement(Then));
-  EXPECT_THAT_EXPECTED(S(StmtMatch->Result),
+  auto Consumer = cat("if (!", node(Condition), ") ", statement(Else), " else ",
+  statement(Then));
+  EXPECT_THAT_EXPECTED(Consumer(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
@@ -165,7 +166,7 @@
  hasThen(stmt().bind("a2";
   ASSERT_TRUE(StmtMatch);
   auto Stencil = cat("if(!", node("a1"), ") ", node("UNBOUND"), ";");
-  auto ResultOrErr = Stencil.eval(StmtMatch->Result);
+  auto ResultOrErr = Stencil->eval(StmtMatch->Result);
   EXPECT_TRUE(llvm::errorToBool(ResultOrErr.takeError()))
   << "Expected unbound node, got " << *ResultOrErr;
 }
@@ -176,14 +177,14 @@
   StringRef Expected) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result), HasValue(Expected));
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result), HasValue(Expected));
 }
 
 void testFailure(StringRef Id, StringRef Snippet, const Stencil ,
  testing::Matcher MessageMatcher) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
Failed(testing::Property(
::getMessage, MessageMatcher)));
 }
@@ -195,28 +196,28 @@
 
 TEST_F(StencilTest, IfBoundOpBound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound(Id, text("5"), text("7"))), "5");
+  testExpr(Id, "3;", ifBound(Id, text("5"), text("7")), "5");
 }
 
 TEST_F(StencilTest, IfBoundOpUnbound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound("other", text("5"), text("7"))), "7");
+  testExpr(Id, "3;", ifBound("other", text("5"), text("7")), "7");
 }
 
 TEST_F(StencilTest, ExpressionOpNoParens) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(expression(Id)), "3");
+  testExpr(Id, "3;", expression(Id), "3");
 }
 
 // Don't parenthesize a parens expression.
 TEST_F(StencilTest, ExpressionOpNoParensParens) {
   StringRef Id = "id";
-  testExpr(Id, "(3);", cat(expression(Id)), "(3)");
+  testExpr(Id, "(3);", expression(Id), "(3)");
 }
 
 TEST_F(StencilTest, ExpressionOpBinaryOpParens) {
   StringRef Id = "id";
-  testExpr(Id, "3+4;", cat(expression(Id)), "(3+4)");
+  testExpr(Id, "3+4;", expression(Id), "(3+4)");
 }
 
 // `expression` shares code with other ops, so we get sufficient coverage of the
@@ -224,33 +225,33 @@
 // tests should be added.
 TEST_F(StencilTest, ExpressionOpUnbound) {
   StringRef Id = "id";
-  testFailure(Id, "3;", cat(expression("ACACA")),
+  testFailure(Id, "3;", expression("ACACA"),
   AllOf(HasSubstr("ACACA"), HasSubstr("not bound")));
 }
 
 TEST_F(StencilTest, DerefPointer) {
   StringRef Id = "id";
-  testExpr(Id, "int *x; x;", cat(deref(Id)), "*x");
+  testExpr(Id, "int *x; x;", deref(Id), "*x");
 }
 
 TEST_F(StencilTest, DerefBinOp) {
   StringRef Id = "id";
-  testExpr(Id, "int *x; x + 1;", 

[PATCH] D68781: [OpenCL] Fix address space for const method call from nonconst

2019-11-01 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 227476.
svenvh retitled this revision from "[OpenCL] Fix addr space conversion check in 
obj arg initialization" to "[OpenCL] Fix address space for const method call 
from nonconst".
svenvh set the repository for this revision to rC Clang.
svenvh added a comment.
Herald added subscribers: cfe-commits, ebevhan.
Herald added a project: clang.

Fix formatting, reduce use of auto, and add a test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68781

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -203,3 +203,14 @@
 // IMPL: [[C2GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C2GEN]] to 
i8 addrspace(4)*
 // IMPL: [[C1GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C1GEN]] to 
i8 addrspace(4)*
 // IMPL:  call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* 
{{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]]
+
+// Test that calling a const method from a non-const method does not crash 
Clang.
+class ConstAndNonConstMethod {
+public:
+  void DoConst() const {
+  }
+
+  void DoNonConst() {
+DoConst();
+  }
+};
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5370,7 +5370,10 @@
 
   if (!Context.hasSameType(From->getType(), DestType)) {
 CastKind CK;
-if (FromRecordType.getAddressSpace() != DestType.getAddressSpace())
+QualType PteeTy = DestType->getPointeeType();
+LangAS DestAS =
+PteeTy.isNull() ? DestType.getAddressSpace() : 
PteeTy.getAddressSpace();
+if (FromRecordType.getAddressSpace() != DestAS)
   CK = CK_AddressSpaceConversion;
 else
   CK = CK_NoOp;


Index: clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -203,3 +203,14 @@
 // IMPL: [[C2GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C2GEN]] to i8 addrspace(4)*
 // IMPL: [[C1GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C1GEN]] to i8 addrspace(4)*
 // IMPL:  call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* {{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]]
+
+// Test that calling a const method from a non-const method does not crash Clang.
+class ConstAndNonConstMethod {
+public:
+  void DoConst() const {
+  }
+
+  void DoNonConst() {
+DoConst();
+  }
+};
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5370,7 +5370,10 @@
 
   if (!Context.hasSameType(From->getType(), DestType)) {
 CastKind CK;
-if (FromRecordType.getAddressSpace() != DestType.getAddressSpace())
+QualType PteeTy = DestType->getPointeeType();
+LangAS DestAS =
+PteeTy.isNull() ? DestType.getAddressSpace() : PteeTy.getAddressSpace();
+if (FromRecordType.getAddressSpace() != DestAS)
   CK = CK_AddressSpaceConversion;
 else
   CK = CK_NoOp;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 12 inline comments as done.
ymandel added a comment.

In D69613#1730238 , @ymandel wrote:

> In D69613#1729703 , @gribozavr2 
> wrote:
>
> > I see. Some decoupling is desirable, I agree. Maybe move `StencilInterface` 
> > and `Stencil` into a separate header that `RewriteRule` can depend on, and 
> > then define the library of stencils in another header?
>
>
> This sounds good. I'll put together a (stacked) revision to do this. It seems 
> worth doing separately given that it will involve a substantial to the 
> RewriteRule library & tests.


In order to keep the client unaffected by the change, I reinstated a simple 
Stencil class to wrap the shared_ptr and provide the call operator.  This means 
that the code is now backwards compatible and forwards compatible (to the 
change we've discussed in RewriteRule to be stencil-aware).  This was simpler 
than adding temporary(?) overloads in `RewriteRule.h` for every function with a 
`TextGenerator` argument.

I included an overload of `operator->` so that we can collapse it back to just 
a type alias.




Comment at: clang/include/clang/Tooling/Transformer/Stencil.h:155
+template  MatchConsumer stencil(Ts &&... Parts) {
+  Stencil S = cat(std::forward(Parts)...);
+  return [S](const ast_matchers::MatchFinder::MatchResult ) {

gribozavr2 wrote:
> I'm not sure the convenience of being able to avoid to say "cat(...)" at the 
> callsite is worth the API complexity. In other words, my suggestion is to 
> make this function take a single stencil.
Based on discussion, removed this entirely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613



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


[PATCH] D57829: [CUDA][HIP] Disable emitting llvm.linker.options in device compilation

2019-11-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:389-392
+  // The linker_option directives are intended for host compilation.
+  if (JA.isDeviceOffloading(Action::OFK_Cuda) ||
+  JA.isDeviceOffloading(Action::OFK_HIP))
+Default = false;

yaxunl wrote:
> tra wrote:
> > Shouldn't it be `true`, considering that we do want to **disable** 
> > autolinking by default for device-side CUDA/HIP?
> > 
> > If we don't support autolinking at all for CUDA/HIP, perhaps we should just 
> > return `true` here.
> This variable Default is to be used as the default value of OPT_fautolink. 
> For device compilation we want the default value to be false. However if 
> users want to force it to be true, we may still want to respect it.
You are correct. I've missed the `!` in the return below.  Don't never use 
double negation. :-/

Nit: Perhaps we can rename `Default` -> `AutolinkEnabledByDefault` because 
right now it's easy to misinterpret it as the default return value of the 
function. Maybe, even change the function itself to `ShouldEnableAutolink()`. 



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

https://reviews.llvm.org/D57829



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


[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 227473.
ymandel added a comment.

addressed to comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -96,7 +96,7 @@
  .bind("expr")))
 .bind("stmt"));
 ASSERT_TRUE(StmtMatch);
-if (auto ResultOrErr = Stencil.eval(StmtMatch->Result)) {
+if (auto ResultOrErr = Stencil->eval(StmtMatch->Result)) {
   ADD_FAILURE() << "Expected failure but succeeded: " << *ResultOrErr;
 } else {
   auto Err = llvm::handleErrors(ResultOrErr.takeError(),
@@ -131,11 +131,12 @@
   // Invert the if-then-else.
   auto Stencil = cat("if (!", node(Condition), ") ", statement(Else), " else ",
  statement(Then));
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
-TEST_F(StencilTest, SingleStatementCallOperator) {
+// Tests `stencil`.
+TEST_F(StencilTest, StencilFactoryFunction) {
   StringRef Condition("C"), Then("T"), Else("E");
   const std::string Snippet = R"cc(
 if (true)
@@ -148,9 +149,9 @@
   hasThen(stmt().bind(Then)), hasElse(stmt().bind(Else;
   ASSERT_TRUE(StmtMatch);
   // Invert the if-then-else.
-  Stencil S = cat("if (!", node(Condition), ") ", statement(Else), " else ",
-  statement(Then));
-  EXPECT_THAT_EXPECTED(S(StmtMatch->Result),
+  auto Consumer = cat("if (!", node(Condition), ") ", statement(Else), " else ",
+  statement(Then));
+  EXPECT_THAT_EXPECTED(Consumer(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
@@ -165,7 +166,7 @@
  hasThen(stmt().bind("a2";
   ASSERT_TRUE(StmtMatch);
   auto Stencil = cat("if(!", node("a1"), ") ", node("UNBOUND"), ";");
-  auto ResultOrErr = Stencil.eval(StmtMatch->Result);
+  auto ResultOrErr = Stencil->eval(StmtMatch->Result);
   EXPECT_TRUE(llvm::errorToBool(ResultOrErr.takeError()))
   << "Expected unbound node, got " << *ResultOrErr;
 }
@@ -176,14 +177,14 @@
   StringRef Expected) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result), HasValue(Expected));
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result), HasValue(Expected));
 }
 
 void testFailure(StringRef Id, StringRef Snippet, const Stencil ,
  testing::Matcher MessageMatcher) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
Failed(testing::Property(
::getMessage, MessageMatcher)));
 }
@@ -195,28 +196,28 @@
 
 TEST_F(StencilTest, IfBoundOpBound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound(Id, text("5"), text("7"))), "5");
+  testExpr(Id, "3;", ifBound(Id, text("5"), text("7")), "5");
 }
 
 TEST_F(StencilTest, IfBoundOpUnbound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound("other", text("5"), text("7"))), "7");
+  testExpr(Id, "3;", ifBound("other", text("5"), text("7")), "7");
 }
 
 TEST_F(StencilTest, ExpressionOpNoParens) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(expression(Id)), "3");
+  testExpr(Id, "3;", expression(Id), "3");
 }
 
 // Don't parenthesize a parens expression.
 TEST_F(StencilTest, ExpressionOpNoParensParens) {
   StringRef Id = "id";
-  testExpr(Id, "(3);", cat(expression(Id)), "(3)");
+  testExpr(Id, "(3);", expression(Id), "(3)");
 }
 
 TEST_F(StencilTest, ExpressionOpBinaryOpParens) {
   StringRef Id = "id";
-  testExpr(Id, "3+4;", cat(expression(Id)), "(3+4)");
+  testExpr(Id, "3+4;", expression(Id), "(3+4)");
 }
 
 // `expression` shares code with other ops, so we get sufficient coverage of the
@@ -224,33 +225,33 @@
 // tests should be added.
 TEST_F(StencilTest, ExpressionOpUnbound) {
   StringRef Id = "id";
-  testFailure(Id, "3;", cat(expression("ACACA")),
+  testFailure(Id, "3;", expression("ACACA"),
   AllOf(HasSubstr("ACACA"), HasSubstr("not bound")));
 }
 
 TEST_F(StencilTest, DerefPointer) {
   StringRef Id = "id";
-  testExpr(Id, "int *x; x;", cat(deref(Id)), "*x");
+  testExpr(Id, "int *x; x;", deref(Id), "*x");
 }
 
 TEST_F(StencilTest, DerefBinOp) {
   StringRef Id = "id";
-  testExpr(Id, "int *x; x + 1;", cat(deref(Id)), "*(x + 1)");
+  testExpr(Id, "int *x; x 

[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2019-11-01 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

kindly PING for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322



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


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

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:133
+
+llvm::ConstrainedFPIntrinsic::ExceptionBehavior
+CodeGenFunction::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) {

I added these 2 functions, is this what you have in mind or do you want me to 
write them differently?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


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

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 227470.
mibintc added a comment.

Respond to recent code review from @rjmccall ; I modified the test cases and 
added functions for translating between the LangOptions enumeration and llvm 
enumeration for rounding-mode and exception-behavior.  I wasn't able to use 
BooleanFFlag because at the moment that is only usable for unsupported options.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fast-math.c
  clang/test/Driver/fp-model.c
  llvm/include/llvm/Target/TargetOptions.h

Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -107,7 +107,7 @@
   public:
 TargetOptions()
 : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
-  NoNaNsFPMath(false), NoTrappingFPMath(false),
+  NoNaNsFPMath(false), NoTrappingFPMath(true),
   NoSignedZerosFPMath(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
Index: clang/test/Driver/fp-model.c
===
--- /dev/null
+++ clang/test/Driver/fp-model.c
@@ -0,0 +1,130 @@
+// Test that incompatible combinations of -ffp-model= options
+// and other floating point options get a warning diagnostic.
+//
+// REQUIRES: clang-driver
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN %s
+// WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN1 %s
+// WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN2 %s
+// WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN3 %s
+// WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN4 %s
+// WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN5 %s
+// WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN7 %s
+// WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN8 %s
+// WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN9 %s
+// WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNa %s
+// WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNb %s
+// WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNc %s
+// WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN:   | FileCheck 

[PATCH] D69625: [libTooling] Support implicit coercions in Stencil's `access` combinator.

2019-11-01 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> Are you suggesting we remove text and selection entirely?

Yes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69625



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


[PATCH] D69393: [RFC][DebugInfo] emit user specified address_space in dwarf

2019-11-01 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a subscriber: rsmith.
probinson added a comment.

In D69393#1729772 , @yonghong-song 
wrote:

> During experimenting with linux kernel codes, I found that clang does not 
> allow address_space attribute for function pointers, specifically, in 
> `clang/lib/Sema/SemaType.cpp`,
>
>   // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "A function type shall not be
>   // qualified by an address-space qualifier."
>   if (Type->isFunctionType()) {
> S.Diag(Attr.getLoc(), diag::err_attribute_address_function_type);
> Attr.setInvalid();
> return;
>   }
>   
>
> But linux kernel tries to annotate signal handling function pointer with 
> address space to indicate it is accessing user space.
>
>   typedef __signalfn_t __user *__sighandler_t;
>   typedef __restorefn_t __user *__sigrestore_t;
>
>
> Such attribute makes sense for linux since indeed the signal handler code 
> resides in user space and the kernel pointer
>  merely points to user memory here.
>
> But such attributes are not allowed for function pointers.
>
> Maybe somebody can give some context about this particular ISO/IEC TR 18037 
> specification? cc @probinson


I have no insight into the standards committees.  @rsmith is your guru here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69393



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


[PATCH] D69699: [clang][driver] Add ProfileData to LLVM_LINK_COMPONENTS

2019-11-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69699



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


[PATCH] D69632: [libTooling] Add Stencil constructor.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e759daf2ea8: [libTooling] Add Stencil constructor. 
(authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69632

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e759da - [libTooling] Add Stencil constructor.

2019-11-01 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2019-11-01T11:53:14-04:00
New Revision: 6e759daf2ea891fdd624d68690cdafdadcca11c9

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

LOG: [libTooling] Add Stencil constructor.

Summary:
Adds a constructor that takes a vector with which to initialize the `Parts`
field and a corresponding free function that forwards to the constructor. These
definitions are needed to assist in transitioning away from `Stencil` as a class
to defining it as a type alias.

Reviewers: ilya-biryukov

Subscribers: cfe-commits, gribozavr

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/Stencil.h

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/Stencil.h 
b/clang/include/clang/Tooling/Transformer/Stencil.h
index 66d1388f9710..6ef44e5ce7ba 100644
--- a/clang/include/clang/Tooling/Transformer/Stencil.h
+++ b/clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@ class StencilPart {
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@ class Stencil {
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);



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


[PATCH] D69638: [NFC] Add SUPPORT_PLUGINS to add_llvm_executable()

2019-11-01 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 227463.
daltenty marked an inline comment as done.
daltenty added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69638

Files:
  clang/tools/driver/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/opt/CMakeLists.txt

Index: llvm/tools/opt/CMakeLists.txt
===
--- llvm/tools/opt/CMakeLists.txt
+++ llvm/tools/opt/CMakeLists.txt
@@ -24,9 +24,6 @@
   Passes
   )
 
-# Support plugins.
-set(LLVM_NO_DEAD_STRIP 1)
-
 add_llvm_tool(opt
   AnalysisWrappers.cpp
   BreakpointPrinter.cpp
@@ -39,6 +36,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(opt)
 
Index: llvm/tools/llc/CMakeLists.txt
===
--- llvm/tools/llc/CMakeLists.txt
+++ llvm/tools/llc/CMakeLists.txt
@@ -19,13 +19,11 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_NO_DEAD_STRIP 1)
-
 add_llvm_tool(llc
   llc.cpp
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(llc)
Index: llvm/tools/bugpoint/CMakeLists.txt
===
--- llvm/tools/bugpoint/CMakeLists.txt
+++ llvm/tools/bugpoint/CMakeLists.txt
@@ -21,9 +21,6 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_NO_DEAD_STRIP 1)
-
 add_llvm_tool(bugpoint
   BugDriver.cpp
   CrashDebugger.cpp
@@ -37,6 +34,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(bugpoint)
 
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -732,7 +732,7 @@
 
 macro(add_llvm_executable name)
   cmake_parse_arguments(ARG
-"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
 "ENTITLEMENTS;BUNDLE_PATH"
 "DEPENDS"
 ${ARGN})
@@ -782,6 +782,11 @@
   if(NOT LLVM_ENABLE_OBJLIB)
 llvm_update_compile_flags(${name})
   endif()
+
+  if (ARG_SUPPORT_PLUGINS)
+set(LLVM_NO_DEAD_STRIP On)
+  endif()
+
   add_link_opts( ${name} )
 
   # Do not add -Dname_EXPORTS to the command-line when building files in this
Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -19,10 +19,9 @@
 
 option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
 
-# Support plugins. This must be before add_clang_executable as it reads
-# LLVM_NO_DEAD_STRIP.
+# Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
-  set(LLVM_NO_DEAD_STRIP 1)
+  set(support_plugins SUPPORT_PLUGINS)
 endif()
 
 if(NOT CLANG_BUILT_STANDALONE)
@@ -37,6 +36,7 @@
 
   DEPENDS
   ${tablegen_deps}
+  ${support_plugins}
   )
 
 clang_target_link_libraries(clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69638: [NFC] Add SUPPORT_PLUGINS to add_llvm_executable()

2019-11-01 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 227461.
daltenty added a comment.

- Address review comments round 1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69638

Files:
  clang/tools/driver/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/opt/CMakeLists.txt

Index: llvm/tools/opt/CMakeLists.txt
===
--- llvm/tools/opt/CMakeLists.txt
+++ llvm/tools/opt/CMakeLists.txt
@@ -24,9 +24,6 @@
   Passes
   )
 
-# Support plugins.
-set(LLVM_SUPPORT_PLUGINS 1)
-
 add_llvm_tool(opt
   AnalysisWrappers.cpp
   BreakpointPrinter.cpp
@@ -39,6 +36,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(opt)
 
Index: llvm/tools/llc/CMakeLists.txt
===
--- llvm/tools/llc/CMakeLists.txt
+++ llvm/tools/llc/CMakeLists.txt
@@ -19,13 +19,11 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_SUPPORT_PLUGINS 1)
-
 add_llvm_tool(llc
   llc.cpp
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(llc)
Index: llvm/tools/bugpoint/CMakeLists.txt
===
--- llvm/tools/bugpoint/CMakeLists.txt
+++ llvm/tools/bugpoint/CMakeLists.txt
@@ -21,9 +21,6 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_SUPPORT_PLUGINS 1)
-
 add_llvm_tool(bugpoint
   BugDriver.cpp
   CrashDebugger.cpp
@@ -37,6 +34,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(bugpoint)
 
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -744,7 +744,7 @@
 # Add flags for add_dead_strip().
 # FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
 # But MinSizeRel seems to add that automatically, so maybe disable these
-# flags instead if LLVM_SUPPORT_PLUGINS is set.
+# flags instead if LLVM_NO_DEAD_STRIP is set.
 if(NOT CYGWIN AND NOT WIN32)
   if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND
  NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -228,7 +228,7 @@
   # to enable. See https://sourceware.org/bugzilla/show_bug.cgi?id=17704.
 endif()
 
-if(NOT LLVM_SUPPORT_PLUGINS)
+if(NOT LLVM_NO_DEAD_STRIP)
   if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 # ld64's implementation of -dead_strip breaks tools that use plugins.
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
@@ -245,7 +245,7 @@
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
  LINK_FLAGS " -Wl,--gc-sections")
   endif()
-else() #LLVM_SUPPORT_PLUGINS
+else() #LLVM_NO_DEAD_STRIP
   if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
  LINK_FLAGS " -Wl,-bnogc")
@@ -732,7 +732,7 @@
 
 macro(add_llvm_executable name)
   cmake_parse_arguments(ARG
-"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
 "ENTITLEMENTS;BUNDLE_PATH"
 "DEPENDS"
 ${ARGN})
@@ -782,6 +782,11 @@
   if(NOT LLVM_ENABLE_OBJLIB)
 llvm_update_compile_flags(${name})
   endif()
+
+  if (ARG_SUPPORT_PLUGINS)
+set(LLVM_NO_DEAD_STRIP On)
+  endif()
+
   add_link_opts( ${name} )
 
   # Do not add -Dname_EXPORTS to the command-line when building files in this
Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -19,10 +19,9 @@
 
 option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
 
-# Support plugins. This must be before add_clang_executable as it reads
-# LLVM_SUPPORT_PLUGINS.
+# Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
-  set(LLVM_SUPPORT_PLUGINS 1)
+  set(support_plugins SUPPORT_PLUGINS)
 endif()
 
 if(NOT CLANG_BUILT_STANDALONE)
@@ -37,6 +36,7 @@
 
   DEPENDS
   ${tablegen_deps}
+  ${support_plugins}
   )
 
 clang_target_link_libraries(clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69360: [NFC] Refactor representation of materialized temporaries

2019-11-01 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 227454.
Tyker marked 8 inline comments as done.
Tyker added a comment.

fixed comments.

i will do the other changes later.

i also renamed MaterializeTemporaryExpr::GetTemporaryExpr to 
MaterializeTemporaryExpr::getSubExpr and change all uses of 
MaterializeTemporaryExpr::getTemporary to use it.
the renaming is for consistancy with other implicit nodes.


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

https://reviews.llvm.org/D69360

Files:
  clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
  clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Sema/Template.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/Consumed.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6308,6 +6308,7 @@
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
   case Decl::Concept:
+  case Decl::LifetimeExtendedTemporary:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -27,7 +27,7 @@
   ExplodedNode *Pred,
   ExplodedNodeSet ) {
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
-  const Expr *tempExpr = ME->GetTemporaryExpr()->IgnoreParens();
+  const Expr *tempExpr = ME->getSubExpr()->IgnoreParens();
   ProgramStateRef state = Pred->getState();
   const LocationContext *LCtx = Pred->getLocationContext();
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1427,7 +1427,7 @@
 
   bool IsTemporary = false;
   if (const auto *MTE = dyn_cast(ArgE)) {
-ArgE = MTE->GetTemporaryExpr();
+ArgE = MTE->getSubExpr();
 IsTemporary = true;
   }
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -766,8 +766,7 @@
 CheckerContext ) const {
   /* Transfer iterator state to temporary objects */
   auto State = C.getState();
-  const auto *Pos =
-  getIteratorPosition(State, C.getSVal(MTE->GetTemporaryExpr()));
+  const auto *Pos = getIteratorPosition(State, C.getSVal(MTE->getSubExpr()));
   if (!Pos)
 return;
   State = setIteratorPosition(State, C.getSVal(MTE), *Pos);
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1835,9 +1835,11 @@
 
 void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
   VisitExpr(E);
-  Record.AddStmt(E->getTemporary());
-  Record.AddDeclRef(E->getExtendingDecl());
-  Record.push_back(E->getManglingNumber());
+  

[PATCH] D69625: [libTooling] Support implicit coercions in Stencil's `access` combinator.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D69625#1729702 , @gribozavr2 wrote:

> > Which idiom do you think we should encourage, then, for text and 
> > range-selectors -- the named combinator or the single-argument cat? That is
>
> You are making a very interesting point!
>
> It sounds very appealing to me to remove the special `text` and `selection` 
> functions in favor of `cat`. Users of the library (both readers and writers) 
> will have to know about `cat`. So the advantage of having special functions 
> `text` and `selection` is really limited I think.


Are you suggesting we remove `text` and `selection` entirely?  I really like 
this idea, just want to be sure I hadn't read more into your comment than you 
intended.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69625



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


[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added a comment.

In D69613#1729703 , @gribozavr2 wrote:

> I see. Some decoupling is desirable, I agree. Maybe move `StencilInterface` 
> and `Stencil` into a separate header that `RewriteRule` can depend on, and 
> then define the library of stencils in another header?


This sounds good. I'll put together a (stacked) revision to do this. It seems 
worth doing separately given that it will involve a substantial to the 
RewriteRule library & tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613



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


[PATCH] D69574: Remove lazy thread-initialisation

2019-11-01 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc 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/D69574/new/

https://reviews.llvm.org/D69574



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


[PATCH] D69632: [libTooling] Add Stencil constructor.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 227457.
ymandel added a comment.

renamed free function to avoid overloading a templated function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69632

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69574: Remove lazy thread-initialisation

2019-11-01 Thread Matthew Malcomson via Phabricator via cfe-commits
mmalcomson added a comment.

Ping @pcc -- does this change to remove lazy thread initialisation look OK?

(I'm looking to start upstreaming hwasan instrumentation to GCC soon, and need 
to know whether GCC must insert the thread initialisation code in function 
prologues)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69574



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


[clang-tools-extra] d36a033 - [clang-tidy] New checker performance-trivially-destructible-check

2019-11-01 Thread Anton Bikineev via cfe-commits

Author: Anton Bikineev
Date: 2019-11-01T16:16:49+01:00
New Revision: d36a0333102698a1398971d0717465322b1c5c2c

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

LOG: [clang-tidy] New checker performance-trivially-destructible-check

Checks for types which can be made trivially-destructible by removing
out-of-line defaulted destructor declarations.

The check is motivated by the work on C++ garbage collector in Blink
(rendering engine for Chrome), which strives to minimize destructors and
improve runtime of sweeping phase.

In the entire chromium codebase the check hits over 2000 times.

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

Added: 
clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.h

clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst

clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp

Modified: 
clang-tools-extra/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
clang-tools-extra/clang-tidy/utils/Matchers.h
clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
clang-tools-extra/clang-tidy/utils/TypeTraits.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
index b6302a5ff815..cde2e246bf9e 100644
--- a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
@@ -11,6 +11,7 @@ add_clang_library(clangTidyPerformanceModule
   MoveConstructorInitCheck.cpp
   NoexceptMoveConstructorCheck.cpp
   PerformanceTidyModule.cpp
+  TriviallyDestructibleCheck.cpp
   TypePromotionInMathFnCheck.cpp
   UnnecessaryCopyInitialization.cpp
   UnnecessaryValueParamCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp 
b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
index f4b620a14f85..269d09b98a68 100644
--- a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
@@ -18,6 +18,7 @@
 #include "MoveConstArgCheck.h"
 #include "MoveConstructorInitCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
+#include "TriviallyDestructibleCheck.h"
 #include "TypePromotionInMathFnCheck.h"
 #include "UnnecessaryCopyInitialization.h"
 #include "UnnecessaryValueParamCheck.h"
@@ -47,6 +48,8 @@ class PerformanceModule : public ClangTidyModule {
 "performance-move-constructor-init");
 CheckFactories.registerCheck(
 "performance-noexcept-move-constructor");
+CheckFactories.registerCheck(
+"performance-trivially-destructible");
 CheckFactories.registerCheck(
 "performance-type-promotion-in-math-fn");
 CheckFactories.registerCheck(

diff  --git 
a/clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
new file mode 100644
index ..5ed705b0cd79
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
@@ -0,0 +1,82 @@
+//===--- TriviallyDestructibleCheck.cpp - clang-tidy 
--===//
+//
+// 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 "TriviallyDestructibleCheck.h"
+#include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+using namespace clang::ast_matchers::internal;
+using namespace clang::tidy::matchers;
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+namespace {
+
+AST_MATCHER(Decl, isFirstDecl) { return Node.isFirstDecl(); }
+
+AST_MATCHER_P(CXXRecordDecl, hasBase, Matcher, InnerMatcher) {
+  for (const CXXBaseSpecifier  : Node.bases()) {
+QualType BaseType = BaseSpec.getType();
+if (InnerMatcher.matches(BaseType, Finder, Builder))
+  return true;
+  }
+  return false;
+}
+
+} // namespace
+
+void TriviallyDestructibleCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  Finder->addMatcher(
+  cxxDestructorDecl(
+  isDefaulted(),
+  unless(anyOf(isFirstDecl(), isVirtual(),
+   

[PATCH] D69435: [clang-tidy] New checker performance-trivially-destructible-check

2019-11-01 Thread Anton Bikineev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd36a03331026: [clang-tidy] New checker 
performance-trivially-destructible-check (authored by AntonBikineev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69435

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
  clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.h
  clang-tools-extra/clang-tidy/utils/Matchers.h
  clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
  clang-tools-extra/clang-tidy/utils/TypeTraits.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s performance-trivially-destructible %t
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,performance-trivially-destructible' -fix
+// RUN: clang-tidy %t.cpp -checks='-*,performance-trivially-destructible' -warnings-as-errors='-*,performance-trivially-destructible'
+
+struct TriviallyDestructible1 {
+  int a;
+};
+
+struct TriviallyDestructible2 : TriviallyDestructible1 {
+  ~TriviallyDestructible2() = default;
+  TriviallyDestructible1 b;
+};
+
+struct NotTriviallyDestructible1 : TriviallyDestructible2 {
+  ~NotTriviallyDestructible1();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'NotTriviallyDestructible1' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
+  // CHECK-FIXES: ~NotTriviallyDestructible1() = default;
+  TriviallyDestructible2 b;
+};
+
+NotTriviallyDestructible1::~NotTriviallyDestructible1() = default; // to-be-removed
+// CHECK-MESSAGES: :[[@LINE-1]]:28: note: destructor definition is here
+// CHECK-FIXES: {{^}}// to-be-removed
+
+// Don't emit for class template with type-dependent fields.
+template 
+struct MaybeTriviallyDestructible1 {
+  ~MaybeTriviallyDestructible1() noexcept;
+  T t;
+};
+
+template 
+MaybeTriviallyDestructible1::~MaybeTriviallyDestructible1() noexcept = default;
+
+// Don't emit for specializations.
+template struct MaybeTriviallyDestructible1;
+
+// Don't emit for class template with type-dependent bases.
+template 
+struct MaybeTriviallyDestructible2 : T {
+  ~MaybeTriviallyDestructible2() noexcept;
+};
+
+template 
+MaybeTriviallyDestructible2::~MaybeTriviallyDestructible2() noexcept = default;
+
+// Emit for templates without dependent bases and fields.
+template 
+struct MaybeTriviallyDestructible1 {
+  ~MaybeTriviallyDestructible1() noexcept;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'MaybeTriviallyDestructible1' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
+  // CHECK-FIXES: ~MaybeTriviallyDestructible1() noexcept = default;
+  TriviallyDestructible1 t;
+};
+
+template 
+MaybeTriviallyDestructible1::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
+// CHECK-MESSAGES: :[[@LINE-1]]:35: note: destructor definition is here
+// CHECK-FIXES: {{^}}// to-be-removed
+
+// Emit for explicit specializations.
+template <>
+struct MaybeTriviallyDestructible1: TriviallyDestructible1 {
+  ~MaybeTriviallyDestructible1() noexcept;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'MaybeTriviallyDestructible1' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
+  // CHECK-FIXES: ~MaybeTriviallyDestructible1() noexcept = default;
+};
+
+MaybeTriviallyDestructible1::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
+// CHECK-MESSAGES: :[[@LINE-1]]:38: note: destructor definition is here
+// CHECK-FIXES: {{^}}// to-be-removed
+
+struct NotTriviallyDestructible2 {
+  virtual ~NotTriviallyDestructible2();
+};
+
+NotTriviallyDestructible2::~NotTriviallyDestructible2() = default;
+
+struct NotTriviallyDestructible3: NotTriviallyDestructible2 {
+  ~NotTriviallyDestructible3();
+};
+
+NotTriviallyDestructible3::~NotTriviallyDestructible3() = default;
Index: clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst
@@ -0,0 +1,15 @@
+.. title:: clang-tidy - 

[PATCH] D69716: NeonEmitter: remove special 'a' modifier.

2019-11-01 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: efriedma.
Herald added a subscriber: mcrosier.
Herald added a project: clang.

This has been separated off from D69618  to 
reduce diff clutter, as it really stands on its own. The 'a' modifier is rarely 
used, but emits splatting code from NeonEmitter.cpp when it is. This 
functionality can be implemented directly in .td files though, at a net 
reduction in lines of code.

There are a few test changes, but they're just moving bitcasts around due to 
the slightly different input Clang sees. Nothing really changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69716

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/test/CodeGen/aarch64-neon-2velem.c
  clang/test/CodeGen/arm_neon_intrinsics.c
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -412,17 +412,6 @@
 return Idx - 1;
   }
 
-  /// Return true if the intrinsic takes an splat operand.
-  bool hasSplat() const { return Proto.find('a') != std::string::npos; }
-
-  /// Return the parameter index of the splat operand.
-  unsigned getSplatIdx() const {
-assert(hasSplat());
-unsigned Idx = Proto.find('a');
-assert(Idx > 0 && "Can't return a splat!");
-return Idx - 1;
-  }
-
   unsigned getNumParams() const { return Proto.size() - 1; }
   Type getReturnType() const { return Types[0]; }
   Type getParamType(unsigned I) const { return Types[I + 1]; }
@@ -431,7 +420,6 @@
   std::string getProto() const { return Proto; }
 
   /// Return true if the prototype has a scalar argument.
-  /// This does not return true for the "splat" code ('a').
   bool protoHasScalar() const;
 
   /// Return the index that parameter PIndex will sit at
@@ -950,7 +938,6 @@
 NumVectors = 0;
 break;
   case 's':
-  case 'a':
 Bitwidth = ElementBitwidth;
 NumVectors = 0;
 break;
@@ -1354,8 +1341,6 @@
   }
 }
 
-// We don't check 'a' in this function, because for builtin function the
-// argument matching to 'a' uses a vector type splatted from a scalar type.
 bool Intrinsic::protoHasScalar() const {
   return (Proto.find('s') != std::string::npos ||
   Proto.find('z') != std::string::npos ||
@@ -1374,12 +1359,6 @@
   bool SRet = getReturnType().getNumVectors() >= 2;
 
   StringRef N = Name;
-  if (hasSplat()) {
-// Call the non-splat builtin: chop off the "_n" suffix from the name.
-assert(N.endswith("_n"));
-N = N.drop_back(2);
-  }
-
   ClassKind LocalCK = CK;
   if (!protoHasScalar())
 LocalCK = ClassB;
@@ -1413,21 +1392,8 @@
   continue;
 }
 
-std::string Arg;
+std::string Arg = V.getName();
 Type CastToType = T;
-if (hasSplat() && I == getSplatIdx()) {
-  Arg = "(" + BaseType.str() + ") {";
-  for (unsigned J = 0; J < BaseType.getNumElements(); ++J) {
-if (J != 0)
-  Arg += ", ";
-Arg += V.getName();
-  }
-  Arg += "}";
-
-  CastToType = BaseType;
-} else {
-  Arg = V.getName();
-}
 
 // Check if an explicit cast is needed.
 if (CastToType.isVector()) {
@@ -2091,10 +2057,6 @@
   for (auto *Def : Defs) {
 if (Def->hasBody())
   continue;
-// Functions with 'a' (the splat code) in the type prototype should not get
-// their own builtin as they use the non-splat variant.
-if (Def->hasSplat())
-  continue;
 
 std::string S = "BUILTIN(__builtin_neon_" + Def->getMangledName() + ", \"";
 
@@ -2131,10 +2093,6 @@
 // __builtin_neon_* so we don't need to generate a definition for it.
 if (Def->hasBody())
   continue;
-// Functions with 'a' (the splat code) in the type prototype should not get
-// their own builtin as they use the non-splat variant.
-if (Def->hasSplat())
-  continue;
 // Functions which have a scalar argument cannot be overloaded, no need to
 // check them if we are emitting the type checking code.
 if (Def->protoHasScalar())
@@ -2215,10 +2173,6 @@
   for (auto *Def : Defs) {
 if (Def->hasBody())
   continue;
-// Functions with 'a' (the splat code) in the type prototype should not get
-// their own builtin as they use the non-splat variant.
-if (Def->hasSplat())
-  continue;
 // Functions which do not have an immediate do not need to have range
 // checking code emitted.
 if (!Def->hasImmediate())
Index: clang/test/CodeGen/arm_neon_intrinsics.c
===
--- clang/test/CodeGen/arm_neon_intrinsics.c
+++ clang/test/CodeGen/arm_neon_intrinsics.c
@@ -8472,11 +8472,11 @@
 }
 
 // CHECK-LABEL: @test_vmull_n_s16(
-// CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
 // CHECK:   [[VECINIT_I:%.*]] = insertelement 

[PATCH] D69715: NeonEmitter: change Type representation. NFC.

2019-11-01 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: efriedma.
Herald added a subscriber: mcrosier.
Herald added a project: clang.

This has been separated off from D69618  to 
reduce clutter. Instead of using a sequence of bools to describe whether a type 
is floating, signed, ..., which can fairly easily end up in an inconsistent or 
otherwise meaningless state this switches to a single enum Kind. There should 
be no functional changes from this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69715

Files:
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -140,7 +140,15 @@
 private:
   TypeSpec TS;
 
-  bool Float, Signed, Immediate, Void, Poly, Constant, Pointer;
+  enum TypeKind {
+Void,
+Float,
+SInt,
+UInt,
+Poly,
+  };
+  TypeKind Kind;
+  bool Immediate, Constant, Pointer;
   // ScalarForMangling and NoManglingQ are really not suited to live here as
   // they are not related to the type. But they live in the TypeSpec (not the
   // prototype), so this is really the only place to store them.
@@ -149,15 +157,14 @@
 
 public:
   Type()
-  : Float(false), Signed(false), Immediate(false), Void(true), Poly(false),
-Constant(false), Pointer(false), ScalarForMangling(false),
-NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
+  : Kind(Void), Immediate(false), Constant(false),
+Pointer(false), ScalarForMangling(false), NoManglingQ(false),
+Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
 
   Type(TypeSpec TS, char CharMod)
-  : TS(std::move(TS)), Float(false), Signed(false), Immediate(false),
-Void(false), Poly(false), Constant(false), Pointer(false),
-ScalarForMangling(false), NoManglingQ(false), Bitwidth(0),
-ElementBitwidth(0), NumVectors(0) {
+  : TS(std::move(TS)), Kind(Void), Immediate(false),
+Constant(false), Pointer(false), ScalarForMangling(false),
+NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {
 applyModifier(CharMod);
   }
 
@@ -174,21 +181,21 @@
   bool noManglingQ() const { return NoManglingQ; }
 
   bool isPointer() const { return Pointer; }
-  bool isFloating() const { return Float; }
-  bool isInteger() const { return !Float && !Poly; }
-  bool isSigned() const { return Signed; }
+  bool isFloating() const { return Kind == Float; }
+  bool isInteger() const { return Kind == SInt || Kind == UInt; }
+  bool isPoly() const { return Kind == Poly; }
+  bool isSigned() const { return Kind == SInt; }
   bool isImmediate() const { return Immediate; }
   bool isScalar() const { return NumVectors == 0; }
   bool isVector() const { return NumVectors > 0; }
-  bool isFloat() const { return Float && ElementBitwidth == 32; }
-  bool isDouble() const { return Float && ElementBitwidth == 64; }
-  bool isHalf() const { return Float && ElementBitwidth == 16; }
-  bool isPoly() const { return Poly; }
+  bool isFloat() const { return isFloating() && ElementBitwidth == 32; }
+  bool isDouble() const { return isFloating() && ElementBitwidth == 64; }
+  bool isHalf() const { return isFloating() && ElementBitwidth == 16; }
   bool isChar() const { return ElementBitwidth == 8; }
-  bool isShort() const { return !Float && ElementBitwidth == 16; }
-  bool isInt() const { return !Float && ElementBitwidth == 32; }
-  bool isLong() const { return !Float && ElementBitwidth == 64; }
-  bool isVoid() const { return Void; }
+  bool isShort() const { return isInteger() && ElementBitwidth == 16; }
+  bool isInt() const { return isInteger() && ElementBitwidth == 32; }
+  bool isLong() const { return isInteger() && ElementBitwidth == 64; }
+  bool isVoid() const { return Kind == Void; }
   unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
   unsigned getSizeInBits() const { return Bitwidth; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -197,21 +204,24 @@
   //
   // Mutator functions
   //
-  void makeUnsigned() { Signed = false; }
-  void makeSigned() { Signed = true; }
+  void makeUnsigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = UInt;
+  }
+  void makeSigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = SInt;
+  }
 
   void makeInteger(unsigned ElemWidth, bool Sign) {
-Float = false;
-Poly = false;
-Signed = Sign;
+assert(!isVoid() && "converting void to int probably not useful");
+Kind = Sign ? SInt : UInt;
 Immediate = false;
 ElementBitwidth = ElemWidth;
   }
 
   void makeImmediate(unsigned ElemWidth) {
-Float = false;
-Poly = false;
-Signed = true;
+Kind = SInt;
 Immediate = true;
 ElementBitwidth = ElemWidth;
   }
@@ -257,7 +267,7 @@
   /// seen. 

[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.def:426-436
+OPENMP_DEFAULTMAP_KIND(aggregate)
+OPENMP_DEFAULTMAP_KIND(pointer)
 
 // Modifiers for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_MODIFIER(alloc)
+OPENMP_DEFAULTMAP_MODIFIER(to)
+OPENMP_DEFAULTMAP_MODIFIER(from)

Add some guards in the code, these values must be enabled only for OpenMP 5.0, 
for 4.5 only scalar:tofrom is allowed. Add a test that the error messages are 
emitted for new cases in OpenMP 4.5



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7274
+  case OMPC_DEFAULTMAP_MODIFIER_none:
+Bits = OMP_MAP_NONE;
+break;

I think you just need to keep the original value of the `Bits` variable set in 
line 7242



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7276
+break;
+  default:
+llvm_unreachable("Unexpected implicit behavior!");

It is not recommended to use `default:` case in switches over enumerics, just 
add a case for each enum value and remove `default:`



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7368-7370
+  bool IsImplicit, OpenMPDefaultmapClauseModifier ImplicitBehavior =
+  OMPC_DEFAULTMAP_MODIFIER_default,
+  OpenMPDefaultmapClauseKind VariableCategory = OMPC_DEFAULTMAP_unknown,

Do you really need the default params values here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:134
+DefaultMapVariableCategory VariableCategory = DMVC_unspecified;
+SourceLocation SLoc = SourceLocation();
+DefaultmapInfo() = default;

No need to call the constructor for classes as a default value, just 
`SourceLocation SLoc;` is enough



Comment at: clang/lib/Sema/SemaOpenMP.cpp:149
 SourceLocation DefaultAttrLoc;
-DefaultMapAttributes DefaultMapAttr = DMA_unspecified;
-SourceLocation DefaultMapAttrLoc;
+DefaultmapInfo DefaultmapMap[3];
+

Maybe, it would be better to make `DMVC_unspecified` the last one in the 
`DefaultMapVariableCategory` and use it as an array dimension here rather than 
rely on the magical number?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:623
+auto  = getTopOfStack().
+   DefaultmapMap[static_cast(DMVC-1)];
+DefaultmapInfo.ImplicitBehavior = DMIB;

Do you really need the static_cast here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:625
+DefaultmapInfo.ImplicitBehavior = DMIB;
+DefaultmapInfo.VariableCategory = DMVC;
+DefaultmapInfo.SLoc = Loc;

Do you really need this field if your DefaultmapMap already variable category 
based array?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:630
+  bool hasSetDefaultmapCategory(OpenMPDefaultmapClauseKind VariableCategory) {
+int VC = static_cast(VariableCategory);
+return getTopOfStack().DefaultmapMap[VC].ImplicitBehavior != 
DMIB_unspecified &&

Do you really need a cast here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:656
+ DefaultMapVariableCategory DMVC) const {
+if (DMVC == DMVC_scalar) {
+  return (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==

Better to use switch here.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:657-673
+  return (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==
+DMIB_alloc) ||
+ (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==
+DMIB_to) ||
+ (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==
+DMIB_from) ||
+ (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==

Seems to me, these 2 checks are very similar, you cam merge them



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2928
+bool IsDMIBNone = false;
+if (VD->getType()->isPointerType() || 
VD->getType()->isMemberPointerType()) {
+  IsDMIBNone =

Just `isAnyPointerType()`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2932-2933
+} else if (VD->getType()->isScalarType() &&
+   !VD->getType()->isBlockPointerType() &&
+   !VD->getType()->isObjCObjectPointerType()) {
+  IsDMIBNone =

Just `!VD->getType()->isAnyPointerType()`. Plus, I think you won't need it here 
in case of fixed condition in the main `if`.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2936
+Stack->getDefaultDMIB(OMPC_DEFAULTMAP_scalar) == DMIB_none;
+} else if (VD->getType()->isArrayType() || 
VD->getType()->isRecordType()) {
+  IsDMIBNone =

Just `isAggregateType()`? 



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2996-3003
+

[PATCH] D69233: [OpenCL] Support -fdeclare-opencl-builtins in C++ mode

2019-11-01 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0aed36d261d3: [OpenCL] Support -fdeclare-opencl-builtins in 
C++ mode (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69233

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -4,8 +4,10 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 // expected-no-diagnostics
 #endif
 
@@ -97,7 +99,7 @@
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is 
invalid in OpenCL}}
 // expected-error@-3{{implicit conversion changes signedness: 'int' to 'uint' 
(aka 'unsigned int')}}
 #endif
@@ -130,7 +132,7 @@
   uint ui;
 
   get_enqueued_local_size(ui);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 
'get_enqueued_local_size' is invalid in OpenCL}}
 #endif
 }
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -765,10 +765,13 @@
 ASTContext  = S.Context;
 
 // Ignore this BIF if its version does not match the language options.
-if (Context.getLangOpts().OpenCLVersion < OpenCLBuiltin.MinVersion)
+unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
+if (Context.getLangOpts().OpenCLCPlusPlus)
+  OpenCLVersion = 200;
+if (OpenCLVersion < OpenCLBuiltin.MinVersion)
   continue;
 if ((OpenCLBuiltin.MaxVersion != 0) &&
-(Context.getLangOpts().OpenCLVersion >= OpenCLBuiltin.MaxVersion))
+(OpenCLVersion >= OpenCLBuiltin.MaxVersion))
   continue;
 
 SmallVector RetTypes;


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -4,8 +4,10 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 // expected-no-diagnostics
 #endif
 
@@ -97,7 +99,7 @@
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is invalid in OpenCL}}
 // expected-error@-3{{implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int')}}
 #endif
@@ -130,7 +132,7 @@
   uint ui;
 
   get_enqueued_local_size(ui);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_enqueued_local_size' is 

[clang] 0aed36d - [OpenCL] Support -fdeclare-opencl-builtins in C++ mode

2019-11-01 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-11-01T13:56:43Z
New Revision: 0aed36d261d38c8dbc98bc52be26189e0ce57e30

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

LOG: [OpenCL] Support -fdeclare-opencl-builtins in C++ mode

Support for C++ mode was accidentally lacking due to not checking the
OpenCLCPlusPlus LangOpts version.

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

Added: 


Modified: 
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d56c5980237c..3aedcdc66bcf 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -765,10 +765,13 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema 
, LookupResult ,
 ASTContext  = S.Context;
 
 // Ignore this BIF if its version does not match the language options.
-if (Context.getLangOpts().OpenCLVersion < OpenCLBuiltin.MinVersion)
+unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
+if (Context.getLangOpts().OpenCLCPlusPlus)
+  OpenCLVersion = 200;
+if (OpenCLVersion < OpenCLBuiltin.MinVersion)
   continue;
 if ((OpenCLBuiltin.MaxVersion != 0) &&
-(Context.getLangOpts().OpenCLVersion >= OpenCLBuiltin.MaxVersion))
+(OpenCLVersion >= OpenCLBuiltin.MaxVersion))
   continue;
 
 SmallVector RetTypes;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 250a3f008c94..84cbb7aeec9b 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -4,8 +4,10 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 // expected-no-diagnostics
 #endif
 
@@ -97,7 +99,7 @@ kernel void basic_image_writeonly(write_only image1d_buffer_t 
image_write_only_i
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is 
invalid in OpenCL}}
 // expected-error@-3{{implicit conversion changes signedness: 'int' to 'uint' 
(aka 'unsigned int')}}
 #endif
@@ -130,7 +132,7 @@ kernel void basic_work_item() {
   uint ui;
 
   get_enqueued_local_size(ui);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 
'get_enqueued_local_size' is invalid in OpenCL}}
 #endif
 }



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


  1   2   >