[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6416
+  if (D->hasAttr())
+return true;
+

I don't think we can just unconditionally check for the attribute.  The rule 
for `trivial_abi` is that it overrides direct sources of non-triviality, but if 
there's a subobject which can't be safely passed in registers, we'll still pass 
aggregates indirectly.  This means we can safely add the attribute whenever a 
class's own special members don't rely on non-triviality without having to 
recursively check the component types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D88394: [Driver][M68k] (Patch 8/8) Add driver support for M68k

2020-11-30 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3125
+foreach i = {0-4} in
+  def m680#i#0 : Flag<["-"], "m680"#i#"0">, Group;
 

bruno wrote:
> rengolin wrote:
> > Same question as @RKSimon had below: Shouldn't this cover all models the 
> > back-end recognises?
> Unless you are planning to add 100 or more target variations I'd prefer to 
> see these explicitly defined instead of a `foreach`. If I'm grepping for a 
> specific CPU variation in the code base it's nice to get that information 
> easily. 
@rengolin  I think the backend currently doesn't support M68060 either


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

https://reviews.llvm.org/D88394

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


[PATCH] D88394: [Driver][M68k] (Patch 8/8) Add driver support for M68k

2020-11-30 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 308551.
myhsu marked 11 inline comments as done.
myhsu added a comment.

- Rebased to latest changes
- Addressed some of the feedbacks


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

https://reviews.llvm.org/D88394

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/Arch/M68k.cpp
  clang/lib/Driver/ToolChains/Arch/M68k.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/m68k-features.cpp
  clang/test/Driver/m68k-sub-archs.cpp

Index: clang/test/Driver/m68k-sub-archs.cpp
===
--- /dev/null
+++ clang/test/Driver/m68k-sub-archs.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68000 %s 2>&1 | FileCheck --check-prefix=CHECK-MX00 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68000 %s 2>&1 | FileCheck --check-prefix=CHECK-MX00 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68000 %s 2>&1 | FileCheck --check-prefix=CHECK-MX00 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68000 %s 2>&1 | FileCheck --check-prefix=CHECK-MX00 %s
+// CHECK-MX00: "-target-cpu" "M68000"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68010 %s 2>&1 | FileCheck --check-prefix=CHECK-MX10 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68010 %s 2>&1 | FileCheck --check-prefix=CHECK-MX10 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68010 %s 2>&1 | FileCheck --check-prefix=CHECK-MX10 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68010 %s 2>&1 | FileCheck --check-prefix=CHECK-MX10 %s
+// CHECK-MX10: "-target-cpu" "M68010"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68020 %s 2>&1 | FileCheck --check-prefix=CHECK-MX20 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68020 %s 2>&1 | FileCheck --check-prefix=CHECK-MX20 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68020 %s 2>&1 | FileCheck --check-prefix=CHECK-MX20 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68020 %s 2>&1 | FileCheck --check-prefix=CHECK-MX20 %s
+// CHECK-MX20: "-target-cpu" "M68020"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68030 %s 2>&1 | FileCheck --check-prefix=CHECK-MX30 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68030 %s 2>&1 | FileCheck --check-prefix=CHECK-MX30 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68030 %s 2>&1 | FileCheck --check-prefix=CHECK-MX30 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68030 %s 2>&1 | FileCheck --check-prefix=CHECK-MX30 %s
+// CHECK-MX30: "-target-cpu" "M68030"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68040 %s 2>&1 | FileCheck --check-prefix=CHECK-MX40 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68040 %s 2>&1 | FileCheck --check-prefix=CHECK-MX40 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68040 %s 2>&1 | FileCheck --check-prefix=CHECK-MX40 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68040 %s 2>&1 | FileCheck --check-prefix=CHECK-MX40 %s
+// CHECK-MX40: "-target-cpu" "M68040"
Index: clang/test/Driver/m68k-features.cpp
===
--- /dev/null
+++ clang/test/Driver/m68k-features.cpp
@@ -0,0 +1,37 @@
+// Check macro definitions
+// RUN: %clang -target m68k-unknown-linux -m68000 -dM -E %s | FileCheck --check-prefix=CHECK-MX %s
+// CHECK-MX: #define __mc68000 1
+// CHECK-MX: #define __mc68000__ 1
+// CHECK-MX: #define mc68000 1
+
+// RUN: %clang -target m68k-unknown-linux -m68010 -dM -E %s | FileCheck --check-prefix=CHECK-MX10 %s
+// CHECK-MX10: #define __mc68000 1
+// CHECK-MX10: #define __mc68000__ 1
+// CHECK-MX10: #define __mc68010 1
+// CHECK-MX10: #define __mc68010__ 1
+// CHECK-MX10: #define mc68000 1
+// CHECK-MX10: #define mc68010 1
+
+// RUN: %clang -target m68k-unknown-linux -m68020 -dM -E %s | FileCheck --check-prefix=CHECK-MX20 %s
+// CHECK-MX20: #define __mc68000 1
+// CHECK-MX20: #define __mc68000__ 1
+// CHECK-MX20: #define __mc68020 1
+// CHECK-MX20: #define __mc68020__ 1
+// CHECK-MX20: #define mc68000 1
+// CHECK-MX20: #define mc68020 1
+
+// RUN: %clang -target m68k-unknown-linux -m68030 -dM -E %s | FileCheck --check-prefix=CHECK-MX30 %s
+// CHECK-MX30: #define __mc68000 1
+// CHECK-MX30: #define __mc68000__ 1
+// CHECK-MX30: #define __mc68030 1
+// CHECK-MX30: #define __mc68030__ 1
+// CHECK-MX30: #define mc68000 1
+// CHECK-MX30: #define mc68030 1
+
+// RUN: %clang -target m68k-unknown-linux -m68040 -dM -E %s | FileCheck --check-prefix=CHECK-MX40 %s
+// CHECK-MX40: #define __mc68000 1
+// CHECK-MX40: #define __mc68000__ 1
+// CHECK-MX40: #define __mc68040 1
+// CHECK-MX40: #define __mc68040__ 1
+// CHECK-MX40: #define mc68000 1
+// CHECK-MX40: #define mc68040 1
Index: clang/lib/Driver/ToolChains/Linux.cpp

[PATCH] D88393: [cfe][M68k] (Patch 7/8) Basic Clang support

2020-11-30 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 308550.
myhsu marked 5 inline comments as done.
myhsu added a comment.

- Rebased to latest changes
- Addressed some of the feedbacks


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

https://reviews.llvm.org/D88393

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/M68k.cpp
  clang/lib/Basic/Targets/M68k.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp

Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6306,6 +6306,39 @@
   D->addAttr(::new (S.Context) MipsInterruptAttr(S.Context, AL, Kind));
 }
 
+static void handleM68kInterruptAttr(Sema , Decl *D, const ParsedAttr ) {
+  if (!checkAttributeNumArgs(S, AL, 1))
+return;
+
+  if (!AL.isArgExpr(0)) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIntegerConstant;
+return;
+  }
+
+  // FIXME: Check for decl - it should be void ()(void).
+
+  Expr *NumParamsExpr = static_cast(AL.getArgAsExpr(0));
+  auto MaybeNumParams = NumParamsExpr->getIntegerConstantExpr(S.Context);
+  if (!MaybeNumParams) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIntegerConstant
+<< NumParamsExpr->getSourceRange();
+return;
+  }
+
+  unsigned Num = MaybeNumParams->getLimitedValue(255);
+  if ((Num & 1) || Num > 30) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
+<< AL << (int)MaybeNumParams->getSExtValue()
+<< NumParamsExpr->getSourceRange();
+return;
+  }
+
+  D->addAttr(::new (S.Context) M68kInterruptAttr(S.Context, AL, Num));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
+}
+
 static void handleAnyX86InterruptAttr(Sema , Decl *D, const ParsedAttr ) {
   // Semantic checks for a function with the 'interrupt' attribute.
   // a) Must be a function.
@@ -6578,6 +6611,9 @@
   case llvm::Triple::mips:
 handleMipsInterruptAttr(S, D, AL);
 break;
+  case llvm::Triple::m68k:
+handleM68kInterruptAttr(S, D, AL);
+break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 handleAnyX86InterruptAttr(S, D, AL);
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8066,6 +8066,45 @@
   return false;
 }
 
+//===--===//
+// M68k ABI Implementation
+//===--===//
+
+namespace {
+
+class M68kTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  M68kTargetCodeGenInfo(CodeGenTypes )
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule ) const override;
+};
+
+} // namespace
+
+// TODO Does not actually work right now
+void M68kTargetCodeGenInfo::setTargetAttributes(
+const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
+  if (const auto *FD = dyn_cast_or_null(D)) {
+if (const auto *attr = FD->getAttr()) {
+  // Handle 'interrupt' attribute:
+  llvm::Function *F = cast(GV);
+
+  // Step 1: Set ISR calling convention.
+  F->setCallingConv(llvm::CallingConv::M68k_INTR);
+
+  // Step 2: Add attributes goodness.
+  F->addFnAttr(llvm::Attribute::NoInline);
+
+  // ??? is this right
+  // Step 3: Emit ISR vector alias.
+  unsigned Num = attr->getNumber() / 2;
+  llvm::GlobalAlias::create(llvm::Function::ExternalLinkage,
+"__isr_" + Twine(Num), F);
+}
+  }
+}
+
 //===--===//
 // AVR ABI Implementation.
 //===--===//
Index: clang/lib/Basic/Targets/M68k.h
===
--- /dev/null
+++ clang/lib/Basic/Targets/M68k.h
@@ -0,0 +1,56 @@
+//===--- M68k.h - Declare M68k target feature support ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file declares M68k TargetInfo objects.
+//
+//===--===//
+
+#ifndef M680X0_H_LTNCIPAD
+#define M680X0_H_LTNCIPAD
+
+#include "OSTargets.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h"
+
+namespace clang {

[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-11-30 Thread Wei Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93dc1b5b8cb2: [Remarks][2/2] Expand remarks hotness 
threshold option support in more tools (authored by weiwang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/opt-record.c
  clang/test/Frontend/Inputs/remarks-hotness.prof
  clang/test/Frontend/remarks-hotness.cpp
  llvm/include/llvm/Analysis/ProfileSummaryInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/IR/Module.cpp
  llvm/test/Other/optimization-remarks-auto.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks-hotness.prof
  llvm/test/Transforms/SampleProfile/remarks-hotness.ll

Index: llvm/test/Transforms/SampleProfile/remarks-hotness.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/remarks-hotness.ll
@@ -0,0 +1,96 @@
+;; This test verifies 'auto' hotness threshold when profile file is provided.
+;;
+;; new PM
+; RUN: rm -f %t.yaml %t.hot.yaml
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.yaml \
+; RUN: -pass-remarks-with-hotness --disable-output
+; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml
+; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml
+
+;; test 'auto' threshold
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.hot.yaml \
+; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output
+; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.hot.yaml
+; RUN: not FileCheck %s -check-prefix=YAML-MISS < %t.hot.yaml
+
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks=inline --pass-remarks-missed=inline --pass-remarks-analysis=inline \
+; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-RPASS
+
+; YAML-PASS:  --- !Passed
+; YAML-PASS-NEXT: Pass:inline
+; YAML-PASS-NEXT: Name:Inlined
+; YAML-PASS-NEXT: DebugLoc:{ File: remarks-hotness.cpp, Line: 10, Column: 10 }
+; YAML-PASS-NEXT: Function:_Z7caller1v
+; YAML-PASS-NEXT: Hotness: 401
+
+; YAML-MISS:  --- !Missed
+; YAML-MISS-NEXT: Pass:inline
+; YAML-MISS-NEXT: Name:NeverInline
+; YAML-MISS-NEXT: DebugLoc:{ File: remarks-hotness.cpp, Line: 14, Column: 10 }
+; YAML-MISS-NEXT: Function:_Z7caller2v
+; YAML-MISS-NEXT: Hotness: 2
+
+; CHECK-RPASS: _Z7callee1v inlined into _Z7caller1v with (cost=-30, threshold=4500) at callsite _Z7caller1v:1 (hotness: 401)
+; CHECK-RPASS-NOT: _Z7callee2v not inlined into _Z7caller2v because it should never be inlined (cost=never): noinline function attribute (hotness: 2)
+
+; ModuleID = 'remarks-hotness.cpp'
+source_filename = "remarks-hotness.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7callee1v() #0 !dbg !7 {
+  ret i32 1, !dbg !11
+}
+
+; Function Attrs: noinline nounwind uwtable use-sample-profile
+define dso_local i32 @_Z7callee2v() #1 !dbg !12 {
+  ret i32 2, !dbg !13
+}
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7caller1v() #0 !dbg !14 {
+  %1 = call i32 @_Z7callee1v(), !dbg !15
+  ret i32 %1, !dbg !16
+}
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7caller2v() #0 !dbg !17 {
+  %1 = call i32 @_Z7callee2v(), !dbg !18
+  ret i32 %1, !dbg !19
+}
+
+attributes #0 = { "use-sample-profile" }
+attributes #1 = { noinline nounwind uwtable "use-sample-profile" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
+!1 = !DIFile(filename: "remarks-hotness.cpp", directory: ".")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, 

[clang] 93dc1b5 - [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-11-30 Thread Wei Wang via cfe-commits

Author: Wei Wang
Date: 2020-11-30T21:55:50-08:00
New Revision: 93dc1b5b8cb2f85d0d347f39e49a7150accd4e70

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

LOG: [Remarks][2/2] Expand remarks hotness threshold option support in more 
tools

This is the #2 of 2 changes that make remarks hotness threshold option
available in more tools. The changes also allow the threshold to sync with
hotness threshold from profile summary with special value 'auto'.

This change expands remarks hotness threshold option
-fdiagnostics-hotness-threshold in clang and *-remarks-hotness-threshold in
other tools to utilize hotness threshold from profile summary.

Remarks hotness filtering relies on several driver options. Table below lists
how different options are correlated and affect final remarks outputs:

| profile | hotness | threshold | remarks printed |
|-|-|---|-|
| No  | No  | No| All |
| No  | No  | Yes   | None|
| No  | Yes | No| All |
| No  | Yes | Yes   | None|
| Yes | No  | No| All |
| Yes | No  | Yes   | None|
| Yes | Yes | No| All |
| Yes | Yes | Yes   | >=threshold |

In the presence of profile summary, it is often more desirable to directly use
the hotness threshold from profile summary. The new argument value 'auto'
indicates threshold will be synced with hotness threshold from profile summary
during compilation. The "auto" threshold relies on the availability of profile
summary. In case of missing such information, no remarks will be generated.

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

Added: 
clang/test/Frontend/Inputs/remarks-hotness.prof
clang/test/Frontend/remarks-hotness.cpp
llvm/test/Other/optimization-remarks-auto.ll
llvm/test/Transforms/SampleProfile/Inputs/remarks-hotness.prof
llvm/test/Transforms/SampleProfile/remarks-hotness.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/opt-record.c
llvm/include/llvm/Analysis/ProfileSummaryInfo.h
llvm/include/llvm/IR/LLVMContext.h
llvm/include/llvm/IR/Module.h
llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/IR/Module.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 8c4a70ba4125..d4bbdbfa13b5 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -366,10 +366,6 @@ VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0)
 /// Whether to report the hotness of the code region for optimization remarks.
 CODEGENOPT(DiagnosticsWithHotness, 1, 0)
 
-/// The minimum hotness value a diagnostic needs in order to be included in
-/// optimization diagnostics.
-VALUE_CODEGENOPT(DiagnosticsHotnessThreshold, 32, 0)
-
 /// Whether copy relocations support is available when building as PIE.
 CODEGENOPT(PIECopyRelocations, 1, 0)
 

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index e710c5792d76..5c540812ed31 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -346,6 +346,21 @@ class CodeGenOptions : public CodeGenOptionsBase {
   const char *Argv0 = nullptr;
   ArrayRef CommandLineArgs;
 
+  /// The minimum hotness value a diagnostic needs in order to be included in
+  /// optimization diagnostics.
+  ///
+  /// The threshold is an Optional value, which maps to one of the 3 states:
+  /// 1. 0=> threshold disabled. All remarks will be printed.
+  /// 2. positive int => manual threshold by user. Remarks with hotness exceed
+  ///threshold will be printed.
+  /// 3. None => 'auto' threshold by user. The actual value is not
+  ///available at command line, but will be synced with
+  ///hotness threshold from profile summary during
+  ///compilation.
+  ///
+  /// If threshold option is not specified, it is disabled by default.
+  Optional DiagnosticsHotnessThreshold = 0;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 

[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-11-30 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.



In D85808#2424588 , @tejohnson wrote:

> lgtm with a couple of minor nits noted below that you can fix before 
> submitting

Thanks for pointing them out. Really appreciate it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

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


[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-11-30 Thread Wei Wang via Phabricator via cfe-commits
weiwang updated this revision to Diff 308536.
weiwang added a comment.

1. Fix typo.
2. Minor order adjustment in testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/opt-record.c
  clang/test/Frontend/Inputs/remarks-hotness.prof
  clang/test/Frontend/remarks-hotness.cpp
  llvm/include/llvm/Analysis/ProfileSummaryInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/IR/Module.cpp
  llvm/test/Other/optimization-remarks-auto.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks-hotness.prof
  llvm/test/Transforms/SampleProfile/remarks-hotness.ll

Index: llvm/test/Transforms/SampleProfile/remarks-hotness.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/remarks-hotness.ll
@@ -0,0 +1,96 @@
+;; This test verifies 'auto' hotness threshold when profile file is provided.
+;;
+;; new PM
+; RUN: rm -f %t.yaml %t.hot.yaml
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.yaml \
+; RUN: -pass-remarks-with-hotness --disable-output
+; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml
+; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml
+
+;; test 'auto' threshold
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.hot.yaml \
+; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output
+; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.hot.yaml
+; RUN: not FileCheck %s -check-prefix=YAML-MISS < %t.hot.yaml
+
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks=inline --pass-remarks-missed=inline --pass-remarks-analysis=inline \
+; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-RPASS
+
+; YAML-PASS:  --- !Passed
+; YAML-PASS-NEXT: Pass:inline
+; YAML-PASS-NEXT: Name:Inlined
+; YAML-PASS-NEXT: DebugLoc:{ File: remarks-hotness.cpp, Line: 10, Column: 10 }
+; YAML-PASS-NEXT: Function:_Z7caller1v
+; YAML-PASS-NEXT: Hotness: 401
+
+; YAML-MISS:  --- !Missed
+; YAML-MISS-NEXT: Pass:inline
+; YAML-MISS-NEXT: Name:NeverInline
+; YAML-MISS-NEXT: DebugLoc:{ File: remarks-hotness.cpp, Line: 14, Column: 10 }
+; YAML-MISS-NEXT: Function:_Z7caller2v
+; YAML-MISS-NEXT: Hotness: 2
+
+; CHECK-RPASS: _Z7callee1v inlined into _Z7caller1v with (cost=-30, threshold=4500) at callsite _Z7caller1v:1 (hotness: 401)
+; CHECK-RPASS-NOT: _Z7callee2v not inlined into _Z7caller2v because it should never be inlined (cost=never): noinline function attribute (hotness: 2)
+
+; ModuleID = 'remarks-hotness.cpp'
+source_filename = "remarks-hotness.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7callee1v() #0 !dbg !7 {
+  ret i32 1, !dbg !11
+}
+
+; Function Attrs: noinline nounwind uwtable use-sample-profile
+define dso_local i32 @_Z7callee2v() #1 !dbg !12 {
+  ret i32 2, !dbg !13
+}
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7caller1v() #0 !dbg !14 {
+  %1 = call i32 @_Z7callee1v(), !dbg !15
+  ret i32 %1, !dbg !16
+}
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7caller2v() #0 !dbg !17 {
+  %1 = call i32 @_Z7callee2v(), !dbg !18
+  ret i32 %1, !dbg !19
+}
+
+attributes #0 = { "use-sample-profile" }
+attributes #1 = { noinline nounwind uwtable "use-sample-profile" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
+!1 = !DIFile(filename: "remarks-hotness.cpp", directory: ".")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 11.0.0"}
+!7 = distinct !DISubprogram(name: "callee1", linkageName: "_Z7callee1v", scope: !1, 

[PATCH] D92016: [ASTImporter] Make the Import() return value consistent with the map of imported decls when merging ClassTemplateSpecializationDecls

2020-11-30 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Great catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92016

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


[PATCH] D92363: [HIP] Warn no --offload-arch option

2020-11-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

This patch let clang emit a warning when no --offload-arch option is specified, 
which
usually indicates that users forget to specify this option.


https://reviews.llvm.org/D92363

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-no-offload-arch.hip


Index: clang/test/Driver/hip-no-offload-arch.hip
===
--- /dev/null
+++ clang/test/Driver/hip-no-offload-arch.hip
@@ -0,0 +1,9 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target, 
nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=WARN %s
+// WARN: warning: no offload arch is specified. Assuming gfx803. Use 
--offload-arch= to specify offload arch [-Whip-option-missing]
+
+// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \
+// RUN:   -x cuda %s 2>&1 | FileCheck -check-prefix=NOWARN %s
+// NOWARN-NOT: warning
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2646,8 +2646,12 @@
   // Default to sm_20 which is the lowest common denominator for
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
-  if (GpuArchList.empty())
+  if (GpuArchList.empty()) {
 GpuArchList.push_back(DefaultCudaArch);
+if (AssociatedOffloadKind == Action::OFK_HIP)
+  C.getDriver().Diag(clang::diag::warn_drv_no_offload_arch)
+  << CudaArchToString(DefaultCudaArch);
+  }
 
   return Error;
 }
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1174,6 +1174,9 @@
 // ignored by CUDA.
 def HIPOnly : DiagGroup<"hip-only">;
 
+// A warning group for warnings about missing HIP options.
+def HIPOptionMising : DiagGroup<"hip-option-missing">;
+
 // Warnings which cause linking of the runtime libraries like
 // libc and the CRT to be skipped.
 def AVRRtlibLinkingQuirks : DiagGroup<"avr-rtlib-linking-quirks">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -82,6 +82,8 @@
   "by colon, e.g. 'gfx908:sram-ecc+:xnack-')">;
 def err_drv_bad_offload_arch_combo : Error<"Invalid offload arch combinations: 
%0 and %1 (For a specific "
   "processor, a feature should either exist in all offload archs, or not exist 
in any offload archs)">;
+def warn_drv_no_offload_arch : Warning<"no offload arch is specified. Assuming 
%0. Use --offload-arch= to"
+  " specify offload arch">, InGroup;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<


Index: clang/test/Driver/hip-no-offload-arch.hip
===
--- /dev/null
+++ clang/test/Driver/hip-no-offload-arch.hip
@@ -0,0 +1,9 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target, nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=WARN %s
+// WARN: warning: no offload arch is specified. Assuming gfx803. Use --offload-arch= to specify offload arch [-Whip-option-missing]
+
+// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \
+// RUN:   -x cuda %s 2>&1 | FileCheck -check-prefix=NOWARN %s
+// NOWARN-NOT: warning
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2646,8 +2646,12 @@
   // Default to sm_20 which is the lowest common denominator for
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
-  if (GpuArchList.empty())
+  if (GpuArchList.empty()) {
 GpuArchList.push_back(DefaultCudaArch);
+if (AssociatedOffloadKind == Action::OFK_HIP)
+  C.getDriver().Diag(clang::diag::warn_drv_no_offload_arch)
+  << CudaArchToString(DefaultCudaArch);
+  }
 
   return Error;
 }
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1174,6 +1174,9 @@
 // ignored by CUDA.
 def HIPOnly : DiagGroup<"hip-only">;
 
+// 

[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 308526.
zoecarver added a comment.

- Update wording in AttrDocs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

Index: clang/test/SemaObjCXX/attr-trivial-abi.mm
===
--- clang/test/SemaObjCXX/attr-trivial-abi.mm
+++ clang/test/SemaObjCXX/attr-trivial-abi.mm
@@ -101,34 +101,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-  struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted a;
-  };
-
-  struct __attribute__((trivial_abi)) CopyDeleted {
-CopyDeleted(const CopyDeleted &) = delete;
-CopyDeleted(CopyDeleted &&) = default;
-  };
-
-  struct __attribute__((trivial_abi)) MoveDeleted {
-MoveDeleted(const MoveDeleted &) = default;
-MoveDeleted(MoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyDeleted a;
-MoveDeleted b;
-  };
-
-  // This is fine since the move constructor isn't deleted.
-  struct __attribute__((trivial_abi)) S20 {
-int & // a member of rvalue reference type deletes the copy constructor.
-  };
-}
Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -79,34 +79,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted a;
-};
-
-struct __attribute__((trivial_abi)) CopyDeleted {
-  CopyDeleted(const CopyDeleted &) = delete;
-  CopyDeleted(CopyDeleted &&) = default;
-};
-
-struct __attribute__((trivial_abi)) MoveDeleted {
-  MoveDeleted(const MoveDeleted &) = default;
-  MoveDeleted(MoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyDeleted a;
-  MoveDeleted b;
-};
-
-// This is fine since the move constructor isn't deleted.
-struct __attribute__((trivial_abi)) S20 {
-  int & // a member of rvalue reference type deletes the copy constructor.
-};
-} // namespace deletedCopyMoveConstructor
Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -5,6 +5,10 @@
 // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
 // CHECK: %[[STRUCT_TRIVIAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_NONTRIVIAL:.*]] = type { i32 }
+// CHECK: [[STRUCT_COPY_MOVE_DELETED:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_1:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_2:%.*]] = type { i8 }
+// CHECK: [[STRUCT_HAS_MEMBER_COPY_MOVE_DELETED:%.*]] = type { [[STRUCT_COPY_MOVE_DELETED]] }
 
 struct __attribute__((trivial_abi)) Small {
   int *p;
@@ -55,6 +59,45 @@
   Small m0() override;
 };
 
+struct __attribute__((trivial_abi)) CopyMoveDeleted {
+  CopyMoveDeleted(CopyMoveDeleted const&) = delete;
+  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
+  CopyMoveDeleted(int) {}
+  ~CopyMoveDeleted() {}
+};
+
+struct __attribute__((trivial_abi)) TemplatedMoveLikeCtor {
+  TemplatedMoveLikeCtor(TemplatedMoveLikeCtor const&) = delete;
+  TemplatedMoveLikeCtor(TemplatedMoveLikeCtor &&) = delete;
+  template TemplatedMoveLikeCtor(T&&) { }
+  ~TemplatedMoveLikeCtor() {}
+};
+
+struct __attribute__((trivial_abi)) TemplatedMoveLikeCtor2 {
+  TemplatedMoveLikeCtor2(TemplatedMoveLikeCtor2 const&) = delete;
+  template 

[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2986
 purpose of calls.
-A class annotated with ``trivial_abi`` can have non-trivial destructors or
-copy/move constructors without automatically becoming non-trivial for the
-purposes of calls. For example:
+A class annotated with trivial_abi can have non-trivial destructors or 
copy/move
+constructors or deleted move and copy constructors without automatically

rjmccall wrote:
> zoecarver wrote:
> > rjmccall wrote:
> > > zoecarver wrote:
> > > > I need to add back the back-ticks. 
> > > This also needs to be turned into a comma-separated list now that it has 
> > > three clauses.
> > The way I read this is as two clauses, so maybe the first "or" should 
> > become an "and." Because non-trivial destructors and non-trivial copy/move 
> > constructors sort of go together, and the deleted copy //and// move 
> > constructors are the second clause. But then again, maybe not because the 
> > "non-trivial destructor" part of it can apply to both. What do you think of:
> > 
> > > A class annotated with ``trivial_abi`` can have non-trivial copy/move 
> > > constructors or deleted copy and move constructors, and a non-trivial 
> > > destructor without automatically becoming non-trivial for the purposes of 
> > > calls.
> > 
> > And then the example clarifies that the attribute may be applied to a type 
> > with non-trivial copy/move constructors and a non-trivial destructor. 
> How about "can have non-trivial (or completely deleted) copy/move 
> constructors or a non-trivial destructor without..."?
Perfect. I'll do that. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2986
 purpose of calls.
-A class annotated with ``trivial_abi`` can have non-trivial destructors or
-copy/move constructors without automatically becoming non-trivial for the
-purposes of calls. For example:
+A class annotated with trivial_abi can have non-trivial destructors or 
copy/move
+constructors or deleted move and copy constructors without automatically

zoecarver wrote:
> rjmccall wrote:
> > zoecarver wrote:
> > > I need to add back the back-ticks. 
> > This also needs to be turned into a comma-separated list now that it has 
> > three clauses.
> The way I read this is as two clauses, so maybe the first "or" should become 
> an "and." Because non-trivial destructors and non-trivial copy/move 
> constructors sort of go together, and the deleted copy //and// move 
> constructors are the second clause. But then again, maybe not because the 
> "non-trivial destructor" part of it can apply to both. What do you think of:
> 
> > A class annotated with ``trivial_abi`` can have non-trivial copy/move 
> > constructors or deleted copy and move constructors, and a non-trivial 
> > destructor without automatically becoming non-trivial for the purposes of 
> > calls.
> 
> And then the example clarifies that the attribute may be applied to a type 
> with non-trivial copy/move constructors and a non-trivial destructor. 
How about "can have non-trivial (or completely deleted) copy/move constructors 
or a non-trivial destructor without..."?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-11-30 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added a comment.

In D91455#2424584 , 
@hubert.reinterpretcast wrote:

>> 2. AIX uses a new personality routine, named __xlcxx_personality_v1. It 
>> doesn't use the GCC personality rountine, because the intractability is not 
>> there yet on AIX.
>
> @jasonliu, is "intractability" a typo/autocorrect problem?

Yep. Fixed!


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

https://reviews.llvm.org/D91455

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-11-30 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: llvm/lib/MC/MCObjectFileInfo.cpp:889
+  CompactUnwindSection =
+  Ctx->getXCOFFSection(".eh_info_table", 
XCOFF::StorageMappingClass::XMC_RW,
+   XCOFF::XTY_SD, SectionKind::getData());

daltenty wrote:
> jasonliu wrote:
> > daltenty wrote:
> > > I think this may have been discussed elsewhere, but why do we want to 
> > > emit this as a RW section?
> > Yes, this has been discussed before. And it's a good question.
> > If we emit this as an RO section, then we could not put 
> > ```
> > .vbyte  4, GCC_except_table1
> > .vbyte  4, __xlcxx_personality_v1[DS]
> > ```
> > into this csect directly. 
> > If we do that, we would hit linker error during link time. It seems that 
> > for read only csects (RO, PR mapping classes), we could not have relocation 
> > types like `R_POS` or `R_NEG` because the result coming out of it is not 
> > link-time constant. And the relocation types in read only csects needs to 
> > be link time constant.
> > 
> > Extra work (both compiler and runtime) will be needed if we want to make 
> > this RO.
> Thanks for clarifying. I guess we'd presumably need to add the TOC 
> indirections to get to the LSDA and personality routine's function 
> descriptor,  similar  to elsewhere. 
> 
> Since this structure is version'd, seems like we have the flexibility to 
> defer that work, so I guess that's OK.
> add the TOC indirections to get to the LSDA and personality routine's 
> function descriptor
Yep, that's one potential way to solve it. The downside of it would be 
1. We might have more TC entries than we desired.
2. A small performance penalty to pay for the extra indirection. (But since we 
already on the EH path, and it's slow anyway, might not be that big of a deal).
But as you already mentioned, we don't have to solve this issue right now. 


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

https://reviews.llvm.org/D91455

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 308523.
zoecarver edited the summary of this revision.
zoecarver added a comment.

- Fix wording in AttrDocs
- Add more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

Index: clang/test/SemaObjCXX/attr-trivial-abi.mm
===
--- clang/test/SemaObjCXX/attr-trivial-abi.mm
+++ clang/test/SemaObjCXX/attr-trivial-abi.mm
@@ -101,34 +101,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-  struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted a;
-  };
-
-  struct __attribute__((trivial_abi)) CopyDeleted {
-CopyDeleted(const CopyDeleted &) = delete;
-CopyDeleted(CopyDeleted &&) = default;
-  };
-
-  struct __attribute__((trivial_abi)) MoveDeleted {
-MoveDeleted(const MoveDeleted &) = default;
-MoveDeleted(MoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyDeleted a;
-MoveDeleted b;
-  };
-
-  // This is fine since the move constructor isn't deleted.
-  struct __attribute__((trivial_abi)) S20 {
-int & // a member of rvalue reference type deletes the copy constructor.
-  };
-}
Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -79,34 +79,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted a;
-};
-
-struct __attribute__((trivial_abi)) CopyDeleted {
-  CopyDeleted(const CopyDeleted &) = delete;
-  CopyDeleted(CopyDeleted &&) = default;
-};
-
-struct __attribute__((trivial_abi)) MoveDeleted {
-  MoveDeleted(const MoveDeleted &) = default;
-  MoveDeleted(MoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyDeleted a;
-  MoveDeleted b;
-};
-
-// This is fine since the move constructor isn't deleted.
-struct __attribute__((trivial_abi)) S20 {
-  int & // a member of rvalue reference type deletes the copy constructor.
-};
-} // namespace deletedCopyMoveConstructor
Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -5,6 +5,10 @@
 // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
 // CHECK: %[[STRUCT_TRIVIAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_NONTRIVIAL:.*]] = type { i32 }
+// CHECK: [[STRUCT_COPY_MOVE_DELETED:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_1:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_2:%.*]] = type { i8 }
+// CHECK: [[STRUCT_HAS_MEMBER_COPY_MOVE_DELETED:%.*]] = type { [[STRUCT_COPY_MOVE_DELETED]] }
 
 struct __attribute__((trivial_abi)) Small {
   int *p;
@@ -55,6 +59,45 @@
   Small m0() override;
 };
 
+struct __attribute__((trivial_abi)) CopyMoveDeleted {
+  CopyMoveDeleted(CopyMoveDeleted const&) = delete;
+  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
+  CopyMoveDeleted(int) {}
+  ~CopyMoveDeleted() {}
+};
+
+struct __attribute__((trivial_abi)) TemplatedMoveLikeCtor {
+  TemplatedMoveLikeCtor(TemplatedMoveLikeCtor const&) = delete;
+  TemplatedMoveLikeCtor(TemplatedMoveLikeCtor &&) = delete;
+  template TemplatedMoveLikeCtor(T&&) { }
+  ~TemplatedMoveLikeCtor() {}
+};
+
+struct __attribute__((trivial_abi)) TemplatedMoveLikeCtor2 {
+  TemplatedMoveLikeCtor2(TemplatedMoveLikeCtor2 

[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2986
 purpose of calls.
-A class annotated with ``trivial_abi`` can have non-trivial destructors or
-copy/move constructors without automatically becoming non-trivial for the
-purposes of calls. For example:
+A class annotated with trivial_abi can have non-trivial destructors or 
copy/move
+constructors or deleted move and copy constructors without automatically

rjmccall wrote:
> zoecarver wrote:
> > I need to add back the back-ticks. 
> This also needs to be turned into a comma-separated list now that it has 
> three clauses.
The way I read this is as two clauses, so maybe the first "or" should become an 
"and." Because non-trivial destructors and non-trivial copy/move constructors 
sort of go together, and the deleted copy //and// move constructors are the 
second clause. But then again, maybe not because the "non-trivial destructor" 
part of it can apply to both. What do you think of:

> A class annotated with ``trivial_abi`` can have non-trivial copy/move 
> constructors or deleted copy and move constructors, and a non-trivial 
> destructor without automatically becoming non-trivial for the purposes of 
> calls.

And then the example clarifies that the attribute may be applied to a type with 
non-trivial copy/move constructors and a non-trivial destructor. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This seems like a good change, but we should make sure we test cases that may 
previously have been covered by the implicit deletion of all copy/move 
constructors.  That may just be a matter of auditing tests.




Comment at: clang/include/clang/Basic/AttrDocs.td:2986
 purpose of calls.
-A class annotated with ``trivial_abi`` can have non-trivial destructors or
-copy/move constructors without automatically becoming non-trivial for the
-purposes of calls. For example:
+A class annotated with trivial_abi can have non-trivial destructors or 
copy/move
+constructors or deleted move and copy constructors without automatically

zoecarver wrote:
> I need to add back the back-ticks. 
This also needs to be turned into a comma-separated list now that it has three 
clauses.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-11-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm with a couple of minor nits noted below that you can fix before submitting




Comment at: clang/include/clang/Basic/CodeGenOptions.h:353
+  /// The threshold is an Optional value, which maps to one of the 3 states:
+  /// 1. 0=> threshold disabled. All emarks will be printed.
+  /// 2. positive int => manual threshold by user. Remarks with hotness exceed

nit: s/emarks/remarks/



Comment at: clang/include/clang/Basic/CodeGenOptions.h:358
+  ///available at command line, but will be synced with
+  ///hotness threhold from profile summary during
+  ///compilation.

nit: s/threhold/threshold/



Comment at: clang/test/Frontend/remarks-hotness.cpp:27
+// HOT_CALL: _Z7callee1v inlined into _Z7caller1v
+// HOT_CALL-NOT: _Z7callee2v not inlined into _Z7caller2v
+int caller1() {

nit: move this down by the corresponding REMARKS line below? (makes the 
difference between the 2 cases clearer)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-11-30 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

> 2. AIX uses a new personality routine, named __xlcxx_personality_v1. It 
> doesn't use the GCC personality rountine, because the intractability is not 
> there yet on AIX.

@jasonliu, is "intractability" a typo/autocorrect problem?


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

https://reviews.llvm.org/D91455

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2986
 purpose of calls.
-A class annotated with ``trivial_abi`` can have non-trivial destructors or
-copy/move constructors without automatically becoming non-trivial for the
-purposes of calls. For example:
+A class annotated with trivial_abi can have non-trivial destructors or 
copy/move
+constructors or deleted move and copy constructors without automatically

I need to add back the back-ticks. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

2020-11-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:1944
+  // host variable in a device or host device lambda.
+  auto IsCapturingReferenceToHostVarInCUDADeviceLambda = [&](VarDecl *VD) {
+if (!getLangOpts().CUDA || !VD->hasInit())

tra wrote:
> Nit: I'd make it a free function.
> The large-ish lambda handling a niche case makes the original simple function 
> less readable. I think keeping capture check separate would be a bit cleaner.
done



Comment at: clang/lib/Sema/SemaExpr.cpp:1982
 !(getLangOpts().OpenMP && isOpenMPCapturedDecl(D)) &&
+!IsCapturingReferenceToHostVarInCUDADeviceLambda(VD) &&
 VD->isUsableInConstantExpressions(Context))

tra wrote:
> This could use some Sema tests.
the negative cases of the condition that incur diagnostics are referencing host 
variable in device or host device functions. The sema tests have been added in 
https://reviews.llvm.org/D91281.

The other negative cases of the condition (capturing host reference in host 
lambda, referencing host var in host function, capturing device reference in 
host lambda, referencing device var in host function, etc) do not cause 
diagnostics, which are covered by codegen tests.


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

https://reviews.llvm.org/D91088

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-11-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
Herald added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zoecarver requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92361

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

Index: clang/test/SemaObjCXX/attr-trivial-abi.mm
===
--- clang/test/SemaObjCXX/attr-trivial-abi.mm
+++ clang/test/SemaObjCXX/attr-trivial-abi.mm
@@ -101,34 +101,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-  struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted a;
-  };
-
-  struct __attribute__((trivial_abi)) CopyDeleted {
-CopyDeleted(const CopyDeleted &) = delete;
-CopyDeleted(CopyDeleted &&) = default;
-  };
-
-  struct __attribute__((trivial_abi)) MoveDeleted {
-MoveDeleted(const MoveDeleted &) = default;
-MoveDeleted(MoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyDeleted a;
-MoveDeleted b;
-  };
-
-  // This is fine since the move constructor isn't deleted.
-  struct __attribute__((trivial_abi)) S20 {
-int & // a member of rvalue reference type deletes the copy constructor.
-  };
-}
Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -79,34 +79,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted a;
-};
-
-struct __attribute__((trivial_abi)) CopyDeleted {
-  CopyDeleted(const CopyDeleted &) = delete;
-  CopyDeleted(CopyDeleted &&) = default;
-};
-
-struct __attribute__((trivial_abi)) MoveDeleted {
-  MoveDeleted(const MoveDeleted &) = default;
-  MoveDeleted(MoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyDeleted a;
-  MoveDeleted b;
-};
-
-// This is fine since the move constructor isn't deleted.
-struct __attribute__((trivial_abi)) S20 {
-  int & // a member of rvalue reference type deletes the copy constructor.
-};
-} // namespace deletedCopyMoveConstructor
Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -5,6 +5,9 @@
 // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
 // CHECK: %[[STRUCT_TRIVIAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_NONTRIVIAL:.*]] = type { i32 }
+// CHECK: [[STRUCT_COPY_MOVE_DELETED:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_1:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_2:%.*]] = type { i8 }
 
 struct __attribute__((trivial_abi)) Small {
   int *p;
@@ -55,6 +58,26 @@
   Small m0() override;
 };
 
+struct __attribute__((trivial_abi)) CopyMoveDeleted {
+  CopyMoveDeleted(CopyMoveDeleted const&) = delete;
+  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
+  CopyMoveDeleted(int) {}
+  ~CopyMoveDeleted() {}
+};
+
+struct __attribute__((trivial_abi)) TemplatedMoveLikeCtor {
+  TemplatedMoveLikeCtor(TemplatedMoveLikeCtor const&) = delete;
+  TemplatedMoveLikeCtor(TemplatedMoveLikeCtor &&) = delete;
+  template TemplatedMoveLikeCtor(T&&) { }
+  ~TemplatedMoveLikeCtor() {}
+};
+
+struct __attribute__((trivial_abi)) TemplatedMoveLikeCtor2 {
+  TemplatedMoveLikeCtor2(TemplatedMoveLikeCtor2 const&) = delete;
+  template TemplatedMoveLikeCtor2(TemplatedMoveLikeCtor2&&) { }
+  ~TemplatedMoveLikeCtor2() {}
+};
+
 // CHECK-LABEL: 

[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

2020-11-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 308519.
yaxunl marked an inline comment as done.
yaxunl added a comment.

extract lambda as a function


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

https://reviews.llvm.org/D91088

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/lambda-reference-var.cu

Index: clang/test/CodeGenCUDA/lambda-reference-var.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda-reference-var.cu
@@ -0,0 +1,126 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu \
+// RUN:   | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// HOST: %[[T1:.*]] = type <{ i32*, i32, [4 x i8] }>
+// HOST: %[[T2:.*]] = type { i32*, i32** }
+// HOST: %[[T3:.*]] = type <{ i32*, i32, [4 x i8] }>
+// DEV: %[[T1:.*]] = type { i32* }
+// DEV: %[[T2:.*]] = type { i32** }
+// DEV: %[[T3:.*]] = type <{ i32*, i32, [4 x i8] }>
+int global_host_var;
+__device__ int global_device_var;
+
+template
+__global__ void kern(F f) { f(); }
+
+// DEV-LABEL: @_ZZ27dev_capture_dev_ref_by_copyPiENKUlvE_clEv(
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_capture_dev_ref_by_copy(int *out) {
+  int  = global_device_var;
+  [=](){ *out = ref;}();
+}
+
+// DEV-LABEL: @_ZZ26dev_capture_dev_ref_by_refPiENKUlvE_clEv(
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// DEV: store i32 %[[VAL2]], i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_capture_dev_ref_by_ref(int *out) {
+  int  = global_device_var;
+  [&](){ ref++; *out = ref;}();
+}
+
+// DEV-LABEL: define void @_Z7dev_refPi(
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// DEV: store i32 %[[VAL2]], i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_ref(int *out) {
+  int  = global_device_var;
+  ref++;
+  *out = ref;
+}
+
+// DEV-LABEL: @_ZZ14dev_lambda_refPiENKUlvE_clEv(
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// DEV: store i32 %[[VAL2]], i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_lambda_ref(int *out) {
+  [=](){
+int  = global_device_var;
+ref++;
+*out = ref;
+  }();
+}
+
+// HOST-LABEL: @_ZZ29host_capture_host_ref_by_copyPiENKUlvE_clEv(
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_capture_host_ref_by_copy(int *out) {
+  int  = global_host_var;
+  [=](){ *out = ref;}();
+}
+
+// HOST-LABEL: @_ZZ28host_capture_host_ref_by_refPiENKUlvE_clEv(
+// HOST: %[[CAP:.*]] = getelementptr inbounds %[[T2]], %[[T2]]* %this1, i32 0, i32 0
+// HOST: %[[REF:.*]] = load i32*, i32** %[[CAP]]
+// HOST: %[[VAL:.*]] = load i32, i32* %[[REF]]
+// HOST: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// HOST: store i32 %[[VAL2]], i32* %[[REF]]
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_capture_host_ref_by_ref(int *out) {
+  int  = global_host_var;
+  [&](){ ref++; *out = ref;}();
+}
+
+// HOST-LABEL: define void @_Z8host_refPi(
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// HOST: store i32 %[[VAL2]], i32* @global_host_var
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_ref(int *out) {
+  int  = global_host_var;
+  ref++;
+  *out = ref;
+}
+
+// HOST-LABEL: @_ZZ15host_lambda_refPiENKUlvE_clEv(
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// HOST: store i32 %[[VAL2]], i32* @global_host_var
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_lambda_ref(int *out) {
+  [=](){
+int  = global_host_var;
+ref++;
+*out = ref;
+  }();
+}
+
+// HOST-LABEL: define void @_Z28dev_capture_host_ref_by_copyPi(
+// HOST: %[[CAP:.*]] = getelementptr inbounds %[[T3]], %[[T3]]* %{{.*}}, i32 0, i32 1
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: 

[PATCH] D91884: clang+lld: Improve clang+ld.darwinnew.lld interaction, pass -demangle

2020-11-30 Thread Greg McGary via Phabricator via cfe-commits
gkm added a comment.

Thank you for this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91884

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


[PATCH] D72184: [BPF] support atomic instructions

2020-11-30 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 308517.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

- remove atomic_fetch_sub which can be implemented with neg + atomic_fetch_add
- add support for xand, xor, xxor (xadd already been supported)
- for any given __sync_fetch_and_{add, and, or, xor}, llvm will generate either 
atomic_fetch_ or x depending on whether the return value is used or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

Files:
  clang/lib/Basic/Targets/BPF.cpp
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/BPF/BPF.td
  llvm/lib/Target/BPF/BPFInstrFormats.td
  llvm/lib/Target/BPF/BPFInstrInfo.td
  llvm/lib/Target/BPF/BPFMIChecking.cpp
  llvm/lib/Target/BPF/BPFSubtarget.cpp
  llvm/lib/Target/BPF/BPFSubtarget.h
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
  llvm/test/CodeGen/BPF/atomics.ll
  llvm/test/CodeGen/BPF/atomics_2.ll

Index: llvm/test/CodeGen/BPF/atomics_2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/atomics_2.ll
@@ -0,0 +1,254 @@
+; RUN: llc < %s -march=bpfel -verify-machineinstrs -show-mc-encoding -mcpu=v4 | FileCheck %s
+;
+; Source:
+;   int test_load_add_32(int *p, int v) {
+; return __sync_fetch_and_add(p, v);
+;   }
+;   int test_load_add_64(long *p, long v) {
+; return __sync_fetch_and_add(p, v);
+;   }
+;   int test_load_sub_32(int *p, int v) {
+; return __sync_fetch_and_sub(p, v);
+;   }
+;   int test_load_sub_64(long *p, long v) {
+; return __sync_fetch_and_sub(p, v);
+;   }
+;   // from https://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html
+;   // __sync_lock_test_and_set() actually does atomic xchg and returns
+;   // old contents.
+;   int test_xchg_32(int *p, int v) {
+; return __sync_lock_test_and_set(p, v);
+;   }
+;   int test_xchg_64(long *p, long v) {
+; return __sync_lock_test_and_set(p, v);
+;   }
+;   int test_cas_32(int *p, int old, int new) {
+; return __sync_val_compare_and_swap(p, old, new);
+;   }
+;   long test_cas_64(long *p, long old, long new) {
+; return __sync_val_compare_and_swap(p, old, new);
+;   }
+;   int test_load_and_32(int *p, int v) {
+; return __sync_fetch_and_and(p, v);
+;   }
+;   int test_load_and_64(long *p, long v) {
+; return __sync_fetch_and_and(p, v);
+;   }
+;   int test_load_or_32(int *p, int v) {
+; return __sync_fetch_and_or(p, v);
+;   }
+;   int test_load_or_64(long *p, long v) {
+; return __sync_fetch_and_or(p, v);
+;   }
+;   int test_load_xor_32(int *p, int v) {
+; return __sync_fetch_and_xor(p, v);
+;   }
+;   int test_load_xor_64(long *p, long v) {
+; return __sync_fetch_and_xor(p, v);
+;   }
+;   int test_atomic_xor_32(int *p, int v) {
+; __sync_fetch_and_xor(p, v);
+; return 0;
+;   }
+;   int test_atomic_xor_64(long *p, long v) {
+; __sync_fetch_and_xor(p, v);
+; return 0;
+;   }
+;   int test_atomic_and_64(long *p, long v) {
+; __sync_fetch_and_and(p, v);
+; return 0;
+;   }
+;   int test_atomic_or_64(long *p, long v) {
+; __sync_fetch_and_or(p, v);
+; return 0;
+;   }
+
+; CHECK-LABEL: test_load_add_32
+; CHECK: w0 = w2
+; CHECK: w0 = atomic_fetch_add((u32 *)(r1 + 0), w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_add_32(i32* nocapture %p, i32 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw add i32* %p, i32 %v seq_cst
+  ret i32 %0
+}
+
+; CHECK-LABEL: test_load_add_64
+; CHECK: r0 = r2
+; CHECK: r0 = atomic_fetch_add((u64 *)(r1 + 0), r0)
+; CHECK: encoding: [0xdb,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_add_64(i64* nocapture %p, i64 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw add i64* %p, i64 %v seq_cst
+  %conv = trunc i64 %0 to i32
+  ret i32 %conv
+}
+
+; CHECK-LABEL: test_load_sub_32
+; CHECK: w0 = w2
+; CHECK: w0 = -w0
+; CHECK: w0 = atomic_fetch_add((u32 *)(r1 + 0), w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_sub_32(i32* nocapture %p, i32 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw sub i32* %p, i32 %v seq_cst
+  ret i32 %0
+}
+
+; CHECK-LABEL: test_load_sub_64
+; CHECK: r0 = r2
+; CHECK: r0 = -r0
+; CHECK: r0 = atomic_fetch_add((u64 *)(r1 + 0), r0)
+; CHECK: encoding: [0xdb,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_sub_64(i64* nocapture %p, i64 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw sub i64* %p, i64 %v seq_cst
+  %conv = trunc i64 %0 to i32
+  ret i32 %conv
+}
+
+; CHECK-LABEL: test_xchg_32
+; CHECK: w0 = w2
+; CHECK: w0 = xchg32_32(r1 + 0, w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0xe1,0x00,0x00,0x00]
+define dso_local i32 @test_xchg_32(i32* nocapture %p, i32 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw xchg i32* %p, i32 %v seq_cst
+  ret 

[PATCH] D92339: Add help text for -nogpuinc

2020-11-30 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG011bf4f55630: Add help text for -nogpuinc (authored by 
yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92339

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


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2873,7 +2873,8 @@
 def no__dead__strip__inits__and__terms : Flag<["-"], 
"no_dead_strip_inits_and_terms">;
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
-def nogpuinc : Flag<["-"], "nogpuinc">;
+def nogpuinc : Flag<["-"], "nogpuinc">, HelpText<"Do not add include paths for 
CUDA/HIP and"
+  " do not include the default CUDA/HIP wrapper headers">;
 def : Flag<["-"], "nocudainc">, Alias;
 def nogpulib : Flag<["-"], "nogpulib">,
   HelpText<"Do not link device library for CUDA/HIP device compilation">;


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2873,7 +2873,8 @@
 def no__dead__strip__inits__and__terms : Flag<["-"], "no_dead_strip_inits_and_terms">;
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
-def nogpuinc : Flag<["-"], "nogpuinc">;
+def nogpuinc : Flag<["-"], "nogpuinc">, HelpText<"Do not add include paths for CUDA/HIP and"
+  " do not include the default CUDA/HIP wrapper headers">;
 def : Flag<["-"], "nocudainc">, Alias;
 def nogpulib : Flag<["-"], "nogpulib">,
   HelpText<"Do not link device library for CUDA/HIP device compilation">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 011bf4f - Add help text for -nogpuinc

2020-11-30 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-11-30T22:31:16-05:00
New Revision: 011bf4f55630858111e5f0504b3f7390eaf41e09

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

LOG: Add help text for -nogpuinc

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

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 ac0761ec773f..cd660aef1662 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2873,7 +2873,8 @@ def no_pedantic : Flag<["-", "--"], "no-pedantic">, 
Group;
 def no__dead__strip__inits__and__terms : Flag<["-"], 
"no_dead_strip_inits_and_terms">;
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
-def nogpuinc : Flag<["-"], "nogpuinc">;
+def nogpuinc : Flag<["-"], "nogpuinc">, HelpText<"Do not add include paths for 
CUDA/HIP and"
+  " do not include the default CUDA/HIP wrapper headers">;
 def : Flag<["-"], "nocudainc">, Alias;
 def nogpulib : Flag<["-"], "nogpulib">,
   HelpText<"Do not link device library for CUDA/HIP device compilation">;



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


[clang] 7bc944c - Revert "[clang][Fuchsia] Add relative-vtables multilib"

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T19:21:35-08:00
New Revision: 7bc944c102c2bdb009da4fe7d53dda15ea19ee71

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

LOG: Revert "[clang][Fuchsia] Add relative-vtables multilib"

This reverts commit fdbd84c6c819d4462546961f6086c1524d5d5ae8.

Reverting due to failing CI builders for Fuchsia's toolchain:
https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8862150211240186992?

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so



diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 74c393fa7a8b..6e9ae85e7318 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,24 +211,14 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 29ad3f0dbf80..79d3a8d554de 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,13 +210,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
-  // Use the relative vtables ABI.
-  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
-  .flag("+fexperimental-relative-c++-abi-vtables"));
-  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
-  .flag("+fexperimental-relative-c++-abi-vtables")
-  .flag("-fexceptions")
-  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -229,13 +222,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
-
-  addMultilibFlag(
-  

[PATCH] D80450: [CUDA][HIP] Fix HD function resolution

2020-11-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 308515.
yaxunl edited the summary of this revision.
yaxunl added a comment.
Herald added subscribers: dexonsmith, dang.

Add -ffix-overload-resolution and fix a regression.


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

https://reviews.llvm.org/D80450

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Overload.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Driver/hip-options.hip
  clang/test/SemaCUDA/deferred-oeverload.cu
  clang/test/SemaCUDA/function-overload.cu

Index: clang/test/SemaCUDA/function-overload.cu
===
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -1,8 +1,16 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify=host,expected %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify=dev,expected %s
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:   -verify=host,hostdefer,devdefer,expected %s
+// RUN: %clang_cc1 -std=c++14 -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:   -fcuda-is-device -verify=dev,devnodeferonly,hostdefer,devdefer,expected %s
+// RUN: %clang_cc1 -ffix-overload-resolution -fgpu-defer-diag -DDEFER=1 \
+// RUN:-std=c++14 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-verify=host,hostdefer,expected %s
+// RUN: %clang_cc1 -ffix-overload-resolution -fgpu-defer-diag -DDEFER=1 \
+// RUN:-std=c++14 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device \
+// RUN:-verify=dev,devdeferonly,devdefer,expected %s
 
 #include "Inputs/cuda.h"
 
@@ -76,37 +84,37 @@
 // Helper functions to verify calling restrictions.
 __device__ DeviceReturnTy d() { return DeviceReturnTy(); }
 // host-note@-1 1+ {{'d' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
+// hostdefer-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __device__ function from __host__ __device__ function}}
 
 __host__ HostReturnTy h() { return HostReturnTy(); }
 // dev-note@-1 1+ {{'h' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
+// devdefer-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __host__ function from __host__ __device__ function}}
-// expected-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
+// devdefer-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
 
 __global__ void g() {}
 // dev-note@-1 1+ {{'g' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __global__ function from __device__ function}}
+// devdefer-note@-2 1+ {{candidate function not viable: call to __global__ function from __device__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __global__ function from __host__ __device__ function}}
-// expected-note@-4 1+ {{candidate function not viable: call to __global__ function from __global__ function}}
+// devdefer-note@-4 1+ {{candidate function not viable: call to __global__ function from __global__ function}}
 
 extern "C" __device__ DeviceReturnTy cd() { return DeviceReturnTy(); }
 // host-note@-1 1+ {{'cd' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
+// hostdefer-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __device__ function from __host__ __device__ function}}
 
 extern "C" __host__ HostReturnTy ch() { return HostReturnTy(); }
 // dev-note@-1 1+ {{'ch' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
+// devdefer-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __host__ function from __host__ __device__ function}}
-// expected-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
+// devdefer-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
 
 __host__ void hostf() {
   DeviceFnPtr fp_d = d; // host-error {{reference to __device__ function 'd' in __host__ function}}
-  

[PATCH] D92357: clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew

2020-11-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D92357#2424484 , @keith wrote:

> It looks like at least in the `-Wl` case clang passes the file through 
> directly,

Right, that's my point: We see crashes around response files even if we let 
clang write it.

> I _don't_ actually see this reproing when using `clang 
> @shell_dialogs_unittests.rsp`:

Yes, it's much more fickle to repro . See 
https://bugs.chromium.org/p/chromium/issues/detail?id=1147968 (linked to from 
the openrdar): We tried passing response files to clang instead of 
`-Wl,-filelist` like we currently do in Chromium and after a while (within 
about a day after the change landing; after hours after 2nd attempt) ld64 
started crashing. I failed to repro this locally. With `-Wl,@foo.rsp` the crash 
reprod locally immediately (and appeared on the bots immediately), so that's 
what I used for filing the rdar. But even with clang writing the response file, 
we found ld64 to be unusuably crashy.


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

https://reviews.llvm.org/D92357

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-11-30 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: llvm/lib/MC/MCObjectFileInfo.cpp:889
+  CompactUnwindSection =
+  Ctx->getXCOFFSection(".eh_info_table", 
XCOFF::StorageMappingClass::XMC_RW,
+   XCOFF::XTY_SD, SectionKind::getData());

jasonliu wrote:
> daltenty wrote:
> > I think this may have been discussed elsewhere, but why do we want to emit 
> > this as a RW section?
> Yes, this has been discussed before. And it's a good question.
> If we emit this as an RO section, then we could not put 
> ```
> .vbyte4, GCC_except_table1
> .vbyte4, __xlcxx_personality_v1[DS]
> ```
> into this csect directly. 
> If we do that, we would hit linker error during link time. It seems that for 
> read only csects (RO, PR mapping classes), we could not have relocation types 
> like `R_POS` or `R_NEG` because the result coming out of it is not link-time 
> constant. And the relocation types in read only csects needs to be link time 
> constant.
> 
> Extra work (both compiler and runtime) will be needed if we want to make this 
> RO.
Thanks for clarifying. I guess we'd presumably need to add the TOC indirections 
to get to the LSDA and personality routine's function descriptor,  similar  to 
elsewhere. 

Since this structure is version'd, seems like we have the flexibility to defer 
that work, so I guess that's OK.


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

https://reviews.llvm.org/D91455

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


[PATCH] D85576: [clang][Fuchsia] Add relative-vtables multilib

2020-11-30 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfdbd84c6c819: [clang][Fuchsia] Add relative-vtables multilib 
(authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85576

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so
  clang/test/Driver/fuchsia.cpp


Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -86,8 +86,20 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s 
-check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-NOEXCEPT-X86
+// RUN: %clangxx %s -### --target=x86_64-fuchsia 
-fexperimental-relative-c++-abi-vtables \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1\
+// RUN: | FileCheck %s 
-check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-RELATIVE-VTABLES-X86
+// RUN: %clangxx %s -### --target=x86_64-fuchsia 
-fexperimental-relative-c++-abi-vtables -fno-exceptions \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1\
+// RUN: | FileCheck %s 
-check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-RELATIVE-VTABLES-NOEXCEPT-X86
 // CHECK-MULTILIB-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-MULTILIB-ASAN-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}c++{{/|}}asan"
 // CHECK-MULTILIB-NOEXCEPT-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}c++{{/|}}noexcept"
 // CHECK-MULTILIB-ASAN-NOEXCEPT-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}c++{{/|}}asan+noexcept"
+// CHECK-MULTILIB-RELATIVE-VTABLES-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}c++{{/|}}relative-vtables"
+// CHECK-MULTILIB-RELATIVE-VTABLES-NOEXCEPT-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}c++{{/|}}relative-vtables+noexcept"
 // CHECK-MULTILIB-X86: 
"-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}c++"
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,6 +210,13 @@
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // Use the relative vtables ABI.
+  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
+  .flag("+fexperimental-relative-c++-abi-vtables"));
+  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -222,6 +229,13 @@
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
+
+  addMultilibFlag(
+  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
+   options::OPT_fno_experimental_relative_cxx_abi_vtables,
+   /*default=*/false),
+  "fexperimental-relative-c++-abi-vtables", Flags);
+
   Multilibs.setFilePathsCallback(FilePaths);
 
   if (Multilibs.select(Flags, SelectedMultilib))
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,14 +211,24 @@
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+

[clang] fdbd84c - [clang][Fuchsia] Add relative-vtables multilib

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T18:21:10-08:00
New Revision: fdbd84c6c819d4462546961f6086c1524d5d5ae8

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

LOG: [clang][Fuchsia] Add relative-vtables multilib

This adds multilibs for Fuchsia that is built with the relative vtables ABI,
one with and another without exceptions.

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

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so

Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 6e9ae85e7318..74c393fa7a8b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,14 +211,24 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 79d3a8d554de..29ad3f0dbf80 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,6 +210,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // Use the relative vtables ABI.
+  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
+  .flag("+fexperimental-relative-c++-abi-vtables"));
+  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -222,6 +229,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
+
+  addMultilibFlag(
+  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
+   

[clang] a160189 - Revert "[clang][Fuchsia] Add relative-vtables multilib"

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T18:20:01-08:00
New Revision: a160189c5dfaa6b3d7c3db71991e50eebea9a63d

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

LOG: Revert "[clang][Fuchsia] Add relative-vtables multilib"

This reverts commit 7c2bc3b71dc072987d43a2a86609871bd01f981f.

Forgot to add the ifferential revision.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so



diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 74c393fa7a8b..6e9ae85e7318 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,24 +211,14 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
-set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
+  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
-  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 29ad3f0dbf80..79d3a8d554de 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,13 +210,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
-  // Use the relative vtables ABI.
-  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
-  .flag("+fexperimental-relative-c++-abi-vtables"));
-  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
-  .flag("+fexperimental-relative-c++-abi-vtables")
-  .flag("-fexceptions")
-  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -229,13 +222,6 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
-
-  addMultilibFlag(
-  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
-   options::OPT_fno_experimental_relative_cxx_abi_vtables,
-   

[PATCH] D92357: clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew

2020-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

It looks like at least in the `-Wl` case clang passes the file through 
directly, so I'm not surprises that it repros there:

  % clang -Wl,@shell_dialogs_unittests.rsp -v
  Apple clang version 12.0.0 (clang-1200.0.32.27)
  Target: x86_64-apple-darwin19.6.0
  Thread model: posix
  InstalledDir: 
/Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
   
"/Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
 -demangle -lto_library 
/Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib
 -dynamic -arch x86_64 -platform_version macos 10.15.0 10.15.6 -syslibroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o a.out -L/usr/local/lib 
@shell_dialogs_unittests.rsp -lSystem 
/Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
  clang: error: unable to execute command: Segmentation fault: 11
  clang: error: linker command failed due to signal (use -v to see invocation)

I _don't_ actually see this reproing when using `clang 
@shell_dialogs_unittests.rsp`:

  % /Users/ksmiley/dev/llvm-project/build/bin/clang-12 
@shell_dialogs_unittests.rsp
  clang version 12.0.0 (https://github.com/llvm/llvm-project 
bbf02e18f53681c079f7a88b2726d0714d92e1a0)
  Target: x86_64-apple-darwin19.6.0
  Thread model: posix
  InstalledDir: /Users/ksmiley/dev/llvm-project/build/bin
   "/usr/bin/ld" 
@/var/folders/h6/6btvg47n7y1f5xxz4_n9rsd4gn/T/response-5a15ec.txt

Which I believe makes sense because clang is processing each argument and 
writing the response file itself.

Is there any other case you've hit besides the missing trailing newline that 
causes this issue? While I'm sure Apple will fix that in due time I wonder if 
that's considered a "valid enough" response to warrant the revert here.


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

https://reviews.llvm.org/D92357

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


[clang] 7c2bc3b - [clang][Fuchsia] Add relative-vtables multilib

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T18:17:38-08:00
New Revision: 7c2bc3b71dc072987d43a2a86609871bd01f981f

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

LOG: [clang][Fuchsia] Add relative-vtables multilib

This adds a multilib for Fuchsia that is built with the relative vtables
ABI.

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/relative-vtables/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables+noexcept/libc++.so

clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/relative-vtables/libc++.so

Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 6e9ae85e7318..74c393fa7a8b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -211,14 +211,24 @@ if(FUCHSIA_SDK)
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
 
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS 
OFF CACHE BOOL "")
 
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT 
OFF CACHE BOOL "")
+set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang 
-fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS
 
"${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS}
 -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS
 OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
   endforeach()
 
-  set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIBS 
"asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE 
STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
   set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+  set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS 
"x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
 endif()
 
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 79d3a8d554de..29ad3f0dbf80 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -210,6 +210,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   .flag("+fsanitize=address")
   .flag("-fexceptions")
   .flag("+fno-exceptions"));
+  // Use the relative vtables ABI.
+  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
+  .flag("+fexperimental-relative-c++-abi-vtables"));
+  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
+  .flag("+fexperimental-relative-c++-abi-vtables")
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
   Multilibs.FilterOut([&](const Multilib ) {
 std::vector RD = FilePaths(M);
 return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
@@ -222,6 +229,13 @@ Fuchsia::Fuchsia(const Driver , const llvm::Triple 
,
   Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, 
true),
   "fexceptions", Flags);
   addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", 
Flags);
+
+  addMultilibFlag(
+  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
+   options::OPT_fno_experimental_relative_cxx_abi_vtables,
+   /*default=*/false),
+  

[PATCH] D92357: clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew

2020-11-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D92357#2424422 , @keith wrote:

> Note in your repro case the issue is that the response file doesn't end in a 
> trailing newline

Hm, we also see crashes if we let clang write the response file that's passed 
to ld64 though. (ie we see this both with `clang @foo.rsp -o a.out` and `clang 
-Wl,@foo.rsp -o a.out`.


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

https://reviews.llvm.org/D92357

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-30 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

To connect the dots for posterity: the followup was landed in D92349 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D83940: [clang][cli] Port HeaderSearch option flags to new option parsing system

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM with one nit.




Comment at: clang/include/clang/Driver/Options.td:1514
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateDiagnosticOptions", 
"true">, IsNegative;
+// todo: simplify these into a version of OptInFFlag that accepts different 
flags for each record and does not imply group
 def fmodules_validate_system_headers : Flag<["-"], 
"fmodules-validate-system-headers">,

I think you can find cases like this later by looking for `def.*no_`, without 
the TODO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83940

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


[PATCH] D83979: [clang][cli] Port LangOpts option flags to new option parsing system

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

When are you planning to refactor `OptInFFlag` to support the use cases called 
out in this patch? If it's right away / soon, I think it'd be a bit cleaner for 
to land the refactoring first, then the options that use it, as opposed to 
fixing them up later. WDYT? (If you're not planning to do it until "later", I 
don't feel strongly, but as noted inline I'm not sure we need all the todos.)




Comment at: clang/include/clang/Driver/Options.td:2987
 def pthreads : Flag<["-"], "pthreads">;
+// todo: simplify these into a version of OptInFFlag that doesn't imply `f` 
name prefix
 def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,

I wonder if this `TODO` is helpful, or if you could find these later just by 
looking for `def no_` thanks to the consistent naming that's used?



Comment at: clang/include/clang/Driver/Options.td:3688
 // C++ SYCL options
+// todo: simplify these with a variant of OptInFFlag that doesn't add Group
 def fsycl : Flag<["-"], "fsycl">, Group, Flags<[CC1Option, 
CoreOption]>,

Similarly I think a grep for `def.*no_` would turn this one up (probably the 
rest too).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83979

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


[PATCH] D92357: clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew

2020-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Note in your repro case the issue is that the response file doesn't end in a 
trailing newline


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

https://reviews.llvm.org/D92357

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


[PATCH] D90485: Lex: Update Module::findHeader to return FileEntryRef, NFC

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf85db7f7ba68: Lex: Update Module::findHeader to return 
FileEntryRef, NFC (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90485

Files:
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/ModuleMap.cpp

Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -171,23 +171,23 @@
 llvm::sys::path::append(Path, "Frameworks", Paths[I-1] + ".framework");
 }
 
-const FileEntry *ModuleMap::findHeader(
+Optional ModuleMap::findHeader(
 Module *M, const Module::UnresolvedHeaderDirective ,
 SmallVectorImpl , bool ) {
   // Search for the header file within the module's home directory.
   auto *Directory = M->Directory;
   SmallString<128> FullPathName(Directory->getName());
 
-  auto GetFile = [&](StringRef Filename) -> const FileEntry * {
-auto File = SourceMgr.getFileManager().getFile(Filename);
-if (!File ||
-(Header.Size && (*File)->getSize() != *Header.Size) ||
-(Header.ModTime && (*File)->getModificationTime() != *Header.ModTime))
-  return nullptr;
+  auto GetFile = [&](StringRef Filename) -> Optional {
+auto File =
+expectedToOptional(SourceMgr.getFileManager().getFileRef(Filename));
+if (!File || (Header.Size && File->getSize() != *Header.Size) ||
+(Header.ModTime && File->getModificationTime() != *Header.ModTime))
+  return None;
 return *File;
   };
 
-  auto GetFrameworkFile = [&]() -> const FileEntry * {
+  auto GetFrameworkFile = [&]() -> Optional {
 unsigned FullPathLength = FullPathName.size();
 appendSubframeworkPaths(M, RelativePathName);
 unsigned RelativePathLength = RelativePathName.size();
@@ -195,7 +195,7 @@
 // Check whether this file is in the public headers.
 llvm::sys::path::append(RelativePathName, "Headers", Header.FileName);
 llvm::sys::path::append(FullPathName, RelativePathName);
-if (auto *File = GetFile(FullPathName))
+if (auto File = GetFile(FullPathName))
   return File;
 
 // Check whether this file is in the private headers.
@@ -227,7 +227,7 @@
   // Lookup for normal headers.
   llvm::sys::path::append(RelativePathName, Header.FileName);
   llvm::sys::path::append(FullPathName, RelativePathName);
-  auto *NormalHdrFile = GetFile(FullPathName);
+  auto NormalHdrFile = GetFile(FullPathName);
 
   if (!NormalHdrFile && Directory->getName().endswith(".framework")) {
 // The lack of 'framework' keyword in a module declaration it's a simple
@@ -241,7 +241,7 @@
   << Header.FileName << M->getFullModuleName();
   NeedsFramework = true;
 }
-return nullptr;
+return None;
   }
 
   return NormalHdrFile;
@@ -251,18 +251,18 @@
   const Module::UnresolvedHeaderDirective ,
   bool ) {
   SmallString<128> RelativePathName;
-  if (const FileEntry *File =
+  if (Optional File =
   findHeader(Mod, Header, RelativePathName, NeedsFramework)) {
 if (Header.IsUmbrella) {
-  const DirectoryEntry *UmbrellaDir = File->getDir();
+  const DirectoryEntry *UmbrellaDir = >getDir().getDirEntry();
   if (Module *UmbrellaMod = UmbrellaDirs[UmbrellaDir])
 Diags.Report(Header.FileNameLoc, diag::err_mmap_umbrella_clash)
   << UmbrellaMod->getFullModuleName();
   else
 // Record this umbrella header.
-setUmbrellaHeader(Mod, File, RelativePathName.str());
+setUmbrellaHeader(Mod, *File, RelativePathName.str());
 } else {
-  Module::Header H = {std::string(RelativePathName.str()), File};
+  Module::Header H = {std::string(RelativePathName.str()), *File};
   if (Header.Kind == Module::HK_Excluded)
 excludeHeader(Mod, H);
   else
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -328,10 +328,9 @@
   /// \param NeedsFramework If M is not a framework but a missing header would
   ///be found in case M was, set it to true. False otherwise.
   /// \return The resolved file, if any.
-  const FileEntry *findHeader(Module *M,
-  const Module::UnresolvedHeaderDirective ,
-  SmallVectorImpl ,
-  bool );
+  Optional
+  findHeader(Module *M, const Module::UnresolvedHeaderDirective ,
+ SmallVectorImpl , bool );
 
   /// Resolve the given header directive.
   ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f85db7f - Lex: Update Module::findHeader to return FileEntryRef, NFC

2020-11-30 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-11-30T17:13:03-08:00
New Revision: f85db7f7ba683b2450892fde247311d7a48adbd0

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

LOG: Lex: Update Module::findHeader to return FileEntryRef, NFC

Update `Module::findHeader` to return `Optional` and
fix its one caller.

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

Added: 


Modified: 
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 5b164039080b..f6423e5b4258 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -328,10 +328,9 @@ class ModuleMap {
   /// \param NeedsFramework If M is not a framework but a missing header would
   ///be found in case M was, set it to true. False otherwise.
   /// \return The resolved file, if any.
-  const FileEntry *findHeader(Module *M,
-  const Module::UnresolvedHeaderDirective ,
-  SmallVectorImpl ,
-  bool );
+  Optional
+  findHeader(Module *M, const Module::UnresolvedHeaderDirective ,
+ SmallVectorImpl , bool );
 
   /// Resolve the given header directive.
   ///

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index cb49173757d8..28dd7ed969ad 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -171,23 +171,23 @@ static void appendSubframeworkPaths(Module *Mod,
 llvm::sys::path::append(Path, "Frameworks", Paths[I-1] + ".framework");
 }
 
-const FileEntry *ModuleMap::findHeader(
+Optional ModuleMap::findHeader(
 Module *M, const Module::UnresolvedHeaderDirective ,
 SmallVectorImpl , bool ) {
   // Search for the header file within the module's home directory.
   auto *Directory = M->Directory;
   SmallString<128> FullPathName(Directory->getName());
 
-  auto GetFile = [&](StringRef Filename) -> const FileEntry * {
-auto File = SourceMgr.getFileManager().getFile(Filename);
-if (!File ||
-(Header.Size && (*File)->getSize() != *Header.Size) ||
-(Header.ModTime && (*File)->getModificationTime() != *Header.ModTime))
-  return nullptr;
+  auto GetFile = [&](StringRef Filename) -> Optional {
+auto File =
+expectedToOptional(SourceMgr.getFileManager().getFileRef(Filename));
+if (!File || (Header.Size && File->getSize() != *Header.Size) ||
+(Header.ModTime && File->getModificationTime() != *Header.ModTime))
+  return None;
 return *File;
   };
 
-  auto GetFrameworkFile = [&]() -> const FileEntry * {
+  auto GetFrameworkFile = [&]() -> Optional {
 unsigned FullPathLength = FullPathName.size();
 appendSubframeworkPaths(M, RelativePathName);
 unsigned RelativePathLength = RelativePathName.size();
@@ -195,7 +195,7 @@ const FileEntry *ModuleMap::findHeader(
 // Check whether this file is in the public headers.
 llvm::sys::path::append(RelativePathName, "Headers", Header.FileName);
 llvm::sys::path::append(FullPathName, RelativePathName);
-if (auto *File = GetFile(FullPathName))
+if (auto File = GetFile(FullPathName))
   return File;
 
 // Check whether this file is in the private headers.
@@ -227,7 +227,7 @@ const FileEntry *ModuleMap::findHeader(
   // Lookup for normal headers.
   llvm::sys::path::append(RelativePathName, Header.FileName);
   llvm::sys::path::append(FullPathName, RelativePathName);
-  auto *NormalHdrFile = GetFile(FullPathName);
+  auto NormalHdrFile = GetFile(FullPathName);
 
   if (!NormalHdrFile && Directory->getName().endswith(".framework")) {
 // The lack of 'framework' keyword in a module declaration it's a simple
@@ -241,7 +241,7 @@ const FileEntry *ModuleMap::findHeader(
   << Header.FileName << M->getFullModuleName();
   NeedsFramework = true;
 }
-return nullptr;
+return None;
   }
 
   return NormalHdrFile;
@@ -251,18 +251,18 @@ void ModuleMap::resolveHeader(Module *Mod,
   const Module::UnresolvedHeaderDirective ,
   bool ) {
   SmallString<128> RelativePathName;
-  if (const FileEntry *File =
+  if (Optional File =
   findHeader(Mod, Header, RelativePathName, NeedsFramework)) {
 if (Header.IsUmbrella) {
-  const DirectoryEntry *UmbrellaDir = File->getDir();
+  const DirectoryEntry *UmbrellaDir = >getDir().getDirEntry();
   if (Module *UmbrellaMod = UmbrellaDirs[UmbrellaDir])
 Diags.Report(Header.FileNameLoc, diag::err_mmap_umbrella_clash)
   << UmbrellaMod->getFullModuleName();
   else
 // Record this umbrella header.
-setUmbrellaHeader(Mod, File, 

[PATCH] D92357: clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew

2020-11-30 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: jyknight.
thakis requested review of this revision.

This morally reverts D82777  -- turns out that 
ld64 crashes with many
response files, so we must stop passing them to it until the crash is
fixed.

On the other hand, the new MachO lld just grew support for response
files in D92149 , so do pass response files to 
it.


https://reviews.llvm.org/D92357

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


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,13 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (LinkerIsLLDDarwinNew) {
+// Xcode12's ld64 added support for @response files, but it's crashy:
+// https://openradar.appspot.com/radar?id=4933317065441280
+// FIXME: Pass this for ld64 once it no longer crashes.
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method 
instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,13 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (LinkerIsLLDDarwinNew) {
+// Xcode12's ld64 added support for @response files, but it's crashy:
+// https://openradar.appspot.com/radar?id=4933317065441280
+// FIXME: Pass this for ld64 once it no longer crashes.
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

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

In D83892#2417903 , @jansvoboda11 
wrote:

> This is now ready to be reviewed. If you see a deleted option in the diff, 
> it's either because it was moved closer to its counterpart, or because it's 
> now generated by a multiclass.
> I've added a bunch of TODOs I plan to address in a future patch, most of them 
> aim to compress two options into a single multiclass that describes their 
> relationship (e.g. `OptOutPositiveFlag`).
> I'd like to make `OptInFFlag` et al. modular with something like `OptInFlag` 
> that does not imply `Flags<[CC1Option]>` and `Group` and can be 
> marked with `IsPositive` or `IsNegative`.

I think it will be easier to review if we work out the "right" scheme, land 
prep patches so the existing options match that scheme, and then land the 
CodeGen options with whatever additional functionality is useful. I think there 
are really two things to decide on for the scheme: what are the axes, and how 
are they represented by multiclass?

For the axes, I think this patch changes them to:

- matching of command-line+storage polarity: do the command-line and the 
storage have the same polarity? ("opt-in" means: "default==false" == "-fno-flag 
is implied").
- default storage value: does the command-line default correspond to `false` or 
`true`?

I find this a bit hard to reason about. I feel like "opt-in" vs. "opt-out" 
should refer purely to command-line option behaviour, independently of storage 
implementation. Then the second axis can map that somehow to storage / 
marshalling.

IIUC, the previous / in-tree axes are:

- command-line behaviour: is "flag" opt-in or opt-out in `-cc1`? (opt-in 
implies `-fno-flag`, opt-out implies `-fflag`)
- default storage value: does the command-line default correspond to `false` or 
`true`? (I think "Positive" means "default is false"?)

For me, that's a bit easier to reason about since the axes seem quite 
independent. Another option (I'm not sure it's as good) is:

- command-line behaviour: is "flag" opt-in or opt-out in `-cc1`? (opt-in 
implies `-fno-flag`, opt-out implies `-fflag`)
- flag storage value: does "flag" being on correspond to `true` or `false`?

For the second axis, I don't find the existing "positive" vs. "negative" 
intuitive. Maybe it could be `DefaultStoredAsFalse` vs. `DefaultStoredAsTrue` 
(or, if we changed the axis, `OnMeansTrue` vs `OnMeansFalse`) or maybe there 
are better/shorter names.

WDYT?

For the multiclass, I don't have a strong opinion, as long as it's declarative 
and clear. One possibility is to enumerate 
`Out{Out,In}FFlagDefaultStoredAs{False,True}` (or 
`Out{Out,In}FFlag{,DefaultStoredAsTrue}`); I think this would be fine. It's 
also fine to take the axes as arguments in a single multiclass, or have 
`Opt{Out,In}FFlag` and take the second axis as an argument.




Comment at: clang/include/clang/Driver/Options.td:250
+// (FastMath == false) and enabled by -ffast-math (FastMath == true).
+// todo: rename to OptInPositiveFFlag
 multiclass OptInFFlag flags=[], code 
keypath="",

I'm finding the suggested rename a bit confusing; per my inline comment above, 
this seems like it should be `OptOut...FFlag`, since (per my terminology) the 
command-line option `-fuse-jump-tables` is enabled by default.



Comment at: clang/include/clang/Driver/Options.td:293
MarshallingInfoFlag,
ImpliedByAnyOf;
 }

Should the new `OptOutPositiveFFlag` have disablers as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

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


[PATCH] D92291: clang/test: Remove platform-linker feature

2020-11-30 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61da501b6a1b: clang/test: Remove platform-linker feature 
(authored by thakis).
Herald added a subscriber: jrtc27.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92291

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c
  clang/test/lit.site.cfg.py.in
  llvm/utils/gn/secondary/clang/test/BUILD.gn

Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -46,7 +46,6 @@
 "LLVM_WITH_Z3=",  # Must be empty, not 0.
 "CLANG_BUILD_EXAMPLES=0",
 "CLANG_DEFAULT_CXX_STDLIB=",  # Empty string means "default value" here.
-"CLANG_DEFAULT_LINKER=",
 "CLANG_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
 "CLANG_VENDOR_UTI=org.llvm.clang",
 
Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -47,9 +47,6 @@
 import lit.llvm
 lit.llvm.initialize(lit_config, config)
 
-if not "@CLANG_DEFAULT_LINKER@":
-config.available_features.add('platform-linker')
-
 # Let the main config do the real work.
 lit_config.load_config(
 config, os.path.join(config.clang_src_dir, "test/lit.cfg.py"))
Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,5 +1,4 @@
 // A basic clang -cc1 command-line, and simple environment check.
-// REQUIRES: platform-linker
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
@@ -15,7 +14,7 @@
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
-// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
@@ -30,7 +29,7 @@
 // C-RV64-BAREMETAL-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
@@ -44,7 +43,7 @@
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN: %clangxx %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
@@ -60,7 +59,7 @@
 // CXX-RV64-BAREMETAL-LP64: "-lstdc++" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
 // CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN: %clangxx %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
@@ -75,7 +74,7 @@
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "-lstdc++" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
+// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld -fuse-ld= \
 // RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -mabi=lp64 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,7 +11,6 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if 

[clang] 61da501 - clang/test: Remove platform-linker feature

2020-11-30 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-11-30T20:00:46-05:00
New Revision: 61da501b6a1bf845c3da9a7e761a3c6a3b6cf21a

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

LOG: clang/test: Remove platform-linker feature

By explicitly requesting the system linker with `-fuse-ld=`, the
tests are able to CHECK for the system linker even with
CLANG_DEFAULT_LINKER=lld.

Alternative to D74704.

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

Added: 


Modified: 
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv32-toolchain.c
clang/test/Driver/riscv64-toolchain-extra.c
clang/test/Driver/riscv64-toolchain.c
clang/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/clang/test/BUILD.gn

Removed: 




diff  --git a/clang/test/Driver/riscv32-toolchain-extra.c 
b/clang/test/Driver/riscv32-toolchain-extra.c
index 64ff6a913e24..59e2560b09c7 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,7 +11,6 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// REQUIRES: platform-linker
 // RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc
 // RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
 // RUN: ln -s %clang %T/testroot-riscv32-baremetal-nogcc/bin/clang
@@ -19,11 +18,11 @@
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf 
%T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
 // RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
 // RUN:--gcc-toolchain=%T/testroot-riscv32-baremetal-nogcc/invalid \
-// RUN:-target riscv32-unknown-elf --rtlib=platform 2>&1 \
+// RUN:-target riscv32-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
 // RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:-target riscv32-unknown-elf --rtlib=platform 2>&1 \
+// RUN:-target riscv32-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"

diff  --git a/clang/test/Driver/riscv32-toolchain.c 
b/clang/test/Driver/riscv32-toolchain.c
index 59865af311ab..a5852f5f3997 100644
--- a/clang/test/Driver/riscv32-toolchain.c
+++ b/clang/test/Driver/riscv32-toolchain.c
@@ -1,5 +1,4 @@
 // A basic clang -cc1 command-line, and simple environment check.
-// REQUIRES: platform-linker
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
@@ -15,7 +14,7 @@
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
-// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv32-unknown-elf --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf 2>&1 \
@@ -30,7 +29,7 @@
 // C-RV32-BAREMETAL-ILP32: "--start-group" "-lc" "-lgloss" "--end-group" 
"-lgcc"
 // C-RV32-BAREMETAL-ILP32: 
"{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv32-unknown-elf --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
@@ -44,7 +43,7 @@
 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: "--start-group" "-lc" "-lgloss" 
"--end-group" "-lgcc"
 // C-RV32-BAREMETAL-NOSYSROOT-ILP32: 
"{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN: %clangxx %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv32-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf 2>&1 \
@@ -60,7 +59,7 @@
 // CXX-RV32-BAREMETAL-ILP32: "-lstdc++" "--start-group" "-lc" "-lgloss" 
"--end-group" "-lgcc"
 // CXX-RV32-BAREMETAL-ILP32: 
"{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN: %clangxx %s -### -no-canonical-prefixes -fuse-ld= \
 // RUN:   -target riscv32-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \

diff  

[PATCH] D92109: [ASTImporter] Support import of CXXDeductionGuideDecl

2020-11-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3336
+if (Fun->getExplicitSpecifier().getExpr()) {
+  ExplicitExpr = importChecked(Err, Fun->getExplicitSpecifier().getExpr());
+  if (Err)

GCC 5.3 complained about this, so I rewrote it a different way without generic 
lambdas in rG43b5b485a203f190ee4d5d3cab19c44ca865d316.

Error spew:
```
FAILED: tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o 
/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc530trusty/bin/g++  
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/AST 
-I/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST 
-I/b/s/w/ir/cache/builder/src/third_party/llvm/clang/include 
-Itools/clang/include -Iinclude 
-I/b/s/w/ir/cache/builder/src/third_party/llvm/llvm/include 
-DLLVM_FORCE_HEAD_REVISION -fvisibility-inlines-hidden -Werror=date-time -Wall 
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -fno-strict-aliasing -O3 -fno-exceptions 
-fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -UNDEBUG 
-std=c++14 -MD -MT 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o -MF 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o.d -o 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o -c 
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp: In 
instantiation of 
‘clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*)::
 [with auto:1 = clang::CXXConversionDecl; clang::ExpectedExpr = 
llvm::Expected]’:
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3384:66:
   required from here
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3336:20:
 error: cannot call member function ‘T 
clang::ASTNodeImporter::importChecked(llvm::Error&, const T&) [with T = 
clang::Expr*]’ without object
   ExplicitExpr = importChecked(Err, Fun->getExplicitSpecifier().getExpr());
^
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp: In 
instantiation of 
‘clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*)::
 [with auto:1 = clang::CXXDeductionGuideDecl; clang::ExpectedExpr = 
llvm::Expected]’:
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3402:57:
   required from here
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3336:20:
 error: cannot call member function ‘T 
clang::ASTNodeImporter::importChecked(llvm::Error&, const T&) [with T = 
clang::Expr*]’ without object
[3456/5141] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/InheritViz.cpp.o
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92109

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


[PATCH] D92291: clang/test: Remove platform-linker feature

2020-11-30 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka accepted this revision.
vvereschaka added a comment.

LGTM


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

https://reviews.llvm.org/D92291

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


[clang] 43b5b48 - Fix GCC 5.3 compile error in ASTImporter code

2020-11-30 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-11-30T16:29:29-08:00
New Revision: 43b5b485a203f190ee4d5d3cab19c44ca865d316

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

LOG: Fix GCC 5.3 compile error in ASTImporter code

Try to simplify this code a different way: use less Expected, more
outparams.

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 1b014314996b..7a1415b658b8 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -202,6 +202,9 @@ namespace clang {
   return *MaybeVal;
 }
 
+ExplicitSpecifier importExplicitSpecifier(Error ,
+  ExplicitSpecifier ESpec);
+
 // Wrapper for an overload set.
 template  struct CallOverloadedCreateFun {
   template  decltype(auto) operator()(Args &&... args) {
@@ -3153,6 +3156,14 @@ bool 
ASTNodeImporter::hasAutoReturnTypeDeclaredInside(FunctionDecl *D) {
   return false;
 }
 
+ExplicitSpecifier
+ASTNodeImporter::importExplicitSpecifier(Error , ExplicitSpecifier ESpec) {
+  Expr *ExplicitExpr = ESpec.getExpr();
+  if (ExplicitExpr)
+ExplicitExpr = importChecked(Err, ESpec.getExpr());
+  return ExplicitSpecifier(ExplicitExpr, ESpec.getKind());
+}
+
 ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
 
   SmallVector Redecls = getCanonicalForwardRedeclChain(D);
@@ -3329,34 +3340,17 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
   return ToPOrErr.takeError();
   }
 
-  // Common code to import an explicit specifier of 
diff erent kind of functions.
-  auto ImportExplicitExpr = [this, ](auto *Fun) -> ExpectedExpr {
-Expr *ExplicitExpr = nullptr;
-if (Fun->getExplicitSpecifier().getExpr()) {
-  ExplicitExpr = importChecked(Err, Fun->getExplicitSpecifier().getExpr());
-  if (Err)
-return std::move(Err);
-}
-return ExplicitExpr;
-  };
-
   // Create the imported function.
   FunctionDecl *ToFunction = nullptr;
   if (auto *FromConstructor = dyn_cast(D)) {
-Expr *ExplicitExpr = nullptr;
-if (FromConstructor->getExplicitSpecifier().getExpr()) {
-  auto Imp = import(FromConstructor->getExplicitSpecifier().getExpr());
-  if (!Imp)
-return Imp.takeError();
-  ExplicitExpr = *Imp;
-}
+ExplicitSpecifier ESpec =
+importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
+if (Err)
+  return std::move(Err);
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), cast(DC),
-ToInnerLocStart, NameInfo, T, TInfo,
-ExplicitSpecifier(
-ExplicitExpr,
-FromConstructor->getExplicitSpecifier().getKind()),
-D->isInlineSpecified(), D->isImplicit(), D->getConstexprKind(),
+ToInnerLocStart, NameInfo, T, TInfo, ESpec, D->isInlineSpecified(),
+D->isImplicit(), D->getConstexprKind(),
 InheritedConstructor(), // FIXME: Properly import inherited
 // constructor info
 TrailingRequiresClause))
@@ -3381,14 +3375,13 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
 ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg);
   } else if (CXXConversionDecl *FromConversion =
  dyn_cast(D)) {
-ExpectedExpr ExplicitExpr = ImportExplicitExpr(FromConversion);
-if (!ExplicitExpr)
-  return ExplicitExpr.takeError();
+ExplicitSpecifier ESpec =
+importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
+if (Err)
+  return std::move(Err);
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), cast(DC),
-ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(),
-ExplicitSpecifier(*ExplicitExpr,
-  
FromConversion->getExplicitSpecifier().getKind()),
+ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(), ESpec,
 D->getConstexprKind(), SourceLocation(), TrailingRequiresClause))
   return ToFunction;
   } else if (auto *Method = dyn_cast(D)) {
@@ -3399,13 +3392,12 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
 SourceLocation(), TrailingRequiresClause))
   return ToFunction;
   } else if (auto *Guide = dyn_cast(D)) {
-ExpectedExpr ExplicitExpr = ImportExplicitExpr(Guide);
-if (!ExplicitExpr)
-  return ExplicitExpr.takeError();
+ExplicitSpecifier ESpec =
+importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
+if (Err)
+  return std::move(Err);
 if (GetImportedOrCreateDecl(
-ToFunction, D, 

[PATCH] D92355: [clang] add a `swift_async_name` attribute

2020-11-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: erik.pilkington, aaron.ballman.
Herald added subscribers: ributzka, jkorous.
Herald added a project: clang.
arphaman requested review of this revision.

The `swift_async_name` attribute provides a name for a function/method that can 
be used to call the `async` overload of this method from Swift. This name 
specified in this attribute assumes that the last parameter in the 
function/method its applied to is removed when Swift invokes it, as the the 
Swift's await/async transformation implicitly constructs the callback.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92355

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaObjC/attr-swift_name.m

Index: clang/test/SemaObjC/attr-swift_name.m
===
--- clang/test/SemaObjC/attr-swift_name.m
+++ clang/test/SemaObjC/attr-swift_name.m
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc %s
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
 
 #define SWIFT_NAME(name) __attribute__((__swift_name__(name)))
+#define SWIFT_ASYNC_NAME(name) __attribute__((__swift_async_name__(name)))
 
 typedef struct {
   float x, y, z;
@@ -172,3 +173,28 @@
 // expected-error@+1 {{'swift_name' and 'swift_name' attributes are not compatible}}
 void g(int i) SWIFT_NAME("function(_:)") {
 }
+
+typedef int (^CallbackTy)(void);
+
+@interface AsyncI
+
+- (void)doSomethingWithCallback:(CallbackTy)callback SWIFT_ASYNC_NAME("doSomething()");
+- (void)doSomethingX:(int)x withCallback:(CallbackTy)callback SWIFT_ASYNC_NAME("doSomething(x:)");
+
+// expected-warning@+1 {{too many parameters in '__swift_async_name__' attribute (expected 1; got 2)}}
+- (void)doSomethingY:(int)x withCallback:(CallbackTy)callback SWIFT_ASYNC_NAME("doSomething(x:y:)");
+
+// expected-warning@+1 {{too few parameters in '__swift_async_name__' attribute (expected 1; got 0)}}
+- (void)doSomethingZ:(int)x withCallback:(CallbackTy)callback SWIFT_ASYNC_NAME("doSomething()");
+
+// expected-warning@+1 {{'__swift_async_name__' attribute cannot be applied to a method with no parameters}}
+- (void)doSomethingNone SWIFT_ASYNC_NAME("doSomething()");
+
+@end
+
+// expected-warning@+1 {{'__swift_async_name__' attribute cannot be applied to a function with no parameters}}
+void asyncNoParams(void) SWIFT_ASYNC_NAME("asyncNoParams()");
+
+// expected-warning@+1 {{'__swift_async_name__' attribute cannot be applied to this declaration}}
+SWIFT_ASYNC_NAME("NoAsync")
+@protocol NoAsync @end
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5922,7 +5922,7 @@
 }
 
 bool Sema::DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc,
- const ParsedAttr ) {
+ const ParsedAttr , bool IsAsync) {
   if (isa(D) || isa(D)) {
 ArrayRef Params;
 unsigned ParamCount;
@@ -5943,6 +5943,16 @@
   }
 }
 
+// The async name drops the last callback parameter.
+if (IsAsync) {
+  if (ParamCount == 0) {
+Diag(Loc, diag::warn_attr_swift_name_decl_missing_params)
+<< AL << (isa(D) ? 1 : 0);
+return false;
+  }
+  ParamCount -= 1;
+}
+
 unsigned SwiftParamCount;
 bool IsSingleParamInit;
 if (!validateSwiftFunctionName(*this, AL, Loc, Name,
@@ -5976,10 +5986,11 @@
   << SwiftParamCount;
   return false;
 }
-  } else if (isa(D) || isa(D) ||
- isa(D) || isa(D) ||
- isa(D) || isa(D) || isa(D) ||
- isa(D) || isa(D)) {
+  } else if ((isa(D) || isa(D) ||
+  isa(D) || isa(D) ||
+  isa(D) || isa(D) || isa(D) ||
+  isa(D) || isa(D)) &&
+ !IsAsync) {
 StringRef ContextName, BaseName;
 
 std::tie(ContextName, BaseName) = Name.split('.');
@@ -6004,16 +6015,20 @@
   return true;
 }
 
-static void handleSwiftName(Sema , Decl *D, const ParsedAttr ) {
+static void handleSwiftName(Sema , Decl *D, const ParsedAttr ,
+bool IsAsync = false) {
   StringRef Name;
   SourceLocation Loc;
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Name, ))
 return;
 
-  if (!S.DiagnoseSwiftName(D, Name, Loc, AL))
+  if (!S.DiagnoseSwiftName(D, Name, Loc, AL, IsAsync))
 return;
 
-  D->addAttr(::new (S.Context) SwiftNameAttr(S.Context, AL, Name));
+  D->addAttr(IsAsync ? (Attr *)::new (S.Context)
+   SwiftAsyncNameAttr(S.Context, AL, Name)
+ : (Attr *)::new (S.Context)
+   SwiftNameAttr(S.Context, AL, Name));
 }
 
 static void handleSwiftNewType(Sema , Decl *D, const ParsedAttr ) {
@@ -7951,6 

[PATCH] D92354: [clang] add a new `swift_attr` attribute

2020-11-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: erik.pilkington, aaron.ballman.
Herald added subscribers: ributzka, jkorous.
Herald added a project: clang.
arphaman requested review of this revision.

The `swift_attr` attribute is a generic annotation attribute that's not used by 
clang, but is used by the Swift compiler. The Swift compiler can use these 
annotations to provide various syntactic and semantic sugars for the imported 
Objective-C API declarations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92354

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/attr-swift_attr.m
  clang/test/SemaObjC/validate-attr-swift_attr.m


Index: clang/test/SemaObjC/validate-attr-swift_attr.m
===
--- /dev/null
+++ clang/test/SemaObjC/validate-attr-swift_attr.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+// expected-error@+1 {{'swift_attr' attribute takes one argument}}
+__attribute__((swift_attr))
+@interface I
+@end
+
+// expected-error@+1 {{'swift_attr' attribute requires a string}}
+__attribute__((swift_attr(1)))
+@interface J
+@end
Index: clang/test/AST/attr-swift_attr.m
===
--- /dev/null
+++ clang/test/AST/attr-swift_attr.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
+__attribute__((swift_attr("@actor")))
+@interface View
+@end
+
+// CHECK: InterfaceDecl {{.*}} View
+// CHECK-NEXT: SwiftAttrAttr {{.*}} "@actor"
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5607,6 +5607,16 @@
   D->addAttr(::new (S.Context) ObjCPreciseLifetimeAttr(S.Context, AL));
 }
 
+static void handleSwiftAttrAttr(Sema , Decl *D, const ParsedAttr ) {
+  // Make sure that there is a string literal as the annotation's single
+  // argument.
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
+return;
+
+  D->addAttr(::new (S.Context) SwiftAttrAttr(S.Context, AL, Str));
+}
+
 static void handleSwiftBridge(Sema , Decl *D, const ParsedAttr ) {
   // Make sure that there is a string literal as the annotation's single
   // argument.
@@ -7941,6 +7951,9 @@
 break;
 
   // Swift attributes.
+  case ParsedAttr::AT_SwiftAttr:
+handleSwiftAttrAttr(S, D, AL);
+break;
   case ParsedAttr::AT_SwiftBridge:
 handleSwiftBridge(S, D, AL);
 break;
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3628,6 +3628,18 @@
   }];
 }
 
+def SwiftAttrDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_attr";
+  let Content = [{
+The ``swift_attr`` provides a Swift-specific annotation for the declaration
+to which the attribute appertains to. This kind of annotation is ignored by
+clang as it doesn't have any semantic meaning in languages supported by clang.
+The Swift compiler can interpret these annotations according to its own rules
+when importing C or Objective-C declarations.
+}];
+}
+
 def SwiftBridgeDocs : Documentation {
   let Category = SwiftDocs;
   let Heading = "swift_bridge";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2149,6 +2149,12 @@
   let ASTNode = 0;
 }
 
+def SwiftAttr : InheritableAttr {
+  let Spellings = [Clang<"swift_attr">];
+  let Args = [StringArgument<"Attribute">];
+  let Documentation = [SwiftAttrDocs];
+}
+
 def SwiftBridge : InheritableAttr {
   let Spellings = [GNU<"swift_bridge">];
   let Args = [StringArgument<"SwiftType">];


Index: clang/test/SemaObjC/validate-attr-swift_attr.m
===
--- /dev/null
+++ clang/test/SemaObjC/validate-attr-swift_attr.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+// expected-error@+1 {{'swift_attr' attribute takes one argument}}
+__attribute__((swift_attr))
+@interface I
+@end
+
+// expected-error@+1 {{'swift_attr' attribute requires a string}}
+__attribute__((swift_attr(1)))
+@interface J
+@end
Index: clang/test/AST/attr-swift_attr.m
===
--- /dev/null
+++ clang/test/AST/attr-swift_attr.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
+__attribute__((swift_attr("@actor")))
+@interface View
+@end
+
+// CHECK: InterfaceDecl {{.*}} View
+// CHECK-NEXT: SwiftAttrAttr {{.*}} "@actor"
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ 

[PATCH] D83812: [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs

2020-11-30 Thread Leonard Chan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf8ff75bade7: [clang][RelativeVTablesABI] Use 
dso_local_equivalent rather than emitting stubs (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83812

Files:
  clang/lib/CodeGen/CGVTables.cpp
  
clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Index: clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
@@ -6,8 +6,6 @@
 // CHECK: %class.B = type { %class.A }
 // CHECK: %"class.std::type_info" = type { i32 (...)**, i8* }
 
-// CHECK: $_ZN1A3fooEv.stub = comdat any
-// CHECK: $_ZN1B3fooEv.stub = comdat any
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 // CHECK: $_ZTI1B.rtti_proxy = comdat any
 
Index: clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// If the linkage of the class is internal, then the stubs and proxies should
-// also be internally linked.
-
-// RUN: %clang_cc1 %s -triple=x86_64-unknown-fuchsia -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
-
-// External linkage.
-// CHECK: @_ZTI8External.rtti_proxy = hidden unnamed_addr constant { i8*, i8* }* @_ZTI8External, comdat
-
-class External {
-public:
-  virtual void func();
-};
-
-void External::func() {}
-
-// Internal linkage.
-// CHECK: @_ZTIN12_GLOBAL__N_18InternalE.rtti_proxy = internal unnamed_addr constant { i8*, i8* }* @_ZTIN12_GLOBAL__N_18InternalE
-namespace {
-
-class Internal {
-public:
-  virtual void func();
-};
-
-void Internal::func() {}
-
-} // namespace
-
-// This gets the same treatment as an externally available vtable.
-// CHECK: @_ZTI11LinkOnceODR.rtti_proxy = hidden unnamed_addr constant { i8*, i8* }* @_ZTI11LinkOnceODR, comdat
-class LinkOnceODR {
-public:
-  virtual void func() {} // A method defined in the class definition results in this linkage for the vtable.
-};
-
-// Force an emission of a vtable for Internal by using it here.
-void manifest_internal() {
-  Internal internal;
-  (void)internal;
-  LinkOnceODR linkonceodr;
-  (void)linkonceodr;
-}
-
-// Aliases are typically emitted after the vtable definitions but before the
-// function definitions.
-// CHECK: @_ZTV8External = unnamed_addr alias { [3 x i32] }, { [3 x i32] }* @_ZTV8External.local
-// CHECK: @_ZTV11LinkOnceODR = linkonce_odr unnamed_addr alias { [3 x i32] }, { [3 x i32] }* @_ZTV11LinkOnceODR.local
-
-// CHECK: define void @_ZN8External4funcEv
-// CHECK: define internal void @_ZN12_GLOBAL__N_18Internal4funcEv.stub
-// CHECK: define hidden void @_ZN11LinkOnceODR4funcEv.stub
Index: clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
@@ -2,35 +2,23 @@
 
 // RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O1 -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
 
-// We should be emitting comdats for each of the virtual function stubs and RTTI proxies
-// CHECK: $_ZN1A3fooEv.stub = comdat any
+// We should be emitting comdats 

[clang] cf8ff75 - [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs

2020-11-30 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-11-30T16:02:35-08:00
New Revision: cf8ff75bade763b054476321dcb82dcb2e7744c7

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

LOG: [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting 
stubs

Thanks to D77248, we can bypass the use of stubs altogether and use PLT
relocations if they are available for the target. LLVM and LLD support the
R_AARCH64_PLT32 relocation, so we can also guarantee a static PLT relocation on 
AArch64.
Not emitting these stubs saves a lot of extra binary size.

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

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp

clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Removed: 
clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp



diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 75afc860cc47..bef9a293b7ed 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -641,7 +641,7 @@ void 
CodeGenVTables::addRelativeComponent(ConstantArrayBuilder ,
 
   llvm::Constant *target;
   if (auto *func = dyn_cast(globalVal)) {
-target = getOrCreateRelativeStub(func, stubLinkage, isCompleteDtor);
+target = llvm::DSOLocalEquivalent::get(func);
   } else {
 llvm::SmallString<16> rttiProxyName(globalVal->getName());
 rttiProxyName.append(".rtti_proxy");
@@ -669,74 +669,6 @@ void 
CodeGenVTables::addRelativeComponent(ConstantArrayBuilder ,
   /*position=*/vtableAddressPoint);
 }
 
-llvm::Function *CodeGenVTables::getOrCreateRelativeStub(
-llvm::Function *func, llvm::GlobalValue::LinkageTypes stubLinkage,
-bool isCompleteDtor) const {
-  // A complete object destructor can later be substituted in the vtable for an
-  // appropriate base object destructor when optimizations are enabled. This 
can
-  // happen for child classes that don't have their own destructor. In the case
-  // where a parent virtual destructor is not guaranteed to be in the same
-  // linkage unit as the child vtable, it's possible for an external reference
-  // for this destructor to be substituted into the child vtable, preventing it
-  // from being in rodata. If this function is a complete virtual destructor, 
we
-  // can just force a stub to be emitted for it.
-  if (func->isDSOLocal() && !isCompleteDtor)
-return func;
-
-  llvm::SmallString<16> stubName(func->getName());
-  stubName.append(".stub");
-
-  // Instead of taking the offset between the vtable and virtual function
-  // directly, we emit a dso_local stub that just contains a tail call to the
-  // original virtual function and take the offset between that and the
-  // vtable. We do this because there are some cases where the original
-  // function that would've been inserted into the vtable is not dso_local
-  // which may require some kind of dynamic relocation which prevents the
-  // vtable from being readonly. On x86_64, taking the offset between the
-  // function and the vtable gets lowered to the offset between the PLT entry
-  // for the function and the vtable which gives us a PLT32 reloc. On AArch64,
-  // right now only CALL26 and JUMP26 instructions generate PLT relocations,
-  // so we manifest them with stubs that are just jumps to the original
-  // function.
-  auto  = CGM.getModule();
-  llvm::Function *stub = module.getFunction(stubName);
-  if (stub) {
-

[PATCH] D91840: OpaquePtr: Require byval on x86_intrcc parameter 0

2020-11-30 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

(generally I'd suggest splitting the clangc and llvm patches if at all possible 
- in this case I'm guessing the clang patch could go first (adding the 
attribute which would be redundant/unused initially), then the LLVM one?)


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

https://reviews.llvm.org/D91840

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


[PATCH] D91270: [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

2020-11-30 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Seems good other than additional comments regarding code clarity.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:10577
 NeededArgGPRs++;
-  return IsCandidate;
+  return true;
 }

This NFC hunk definitely makes this clearer :)



Comment at: clang/lib/CodeGen/TargetInfo.cpp:10603
   CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(Field2Ty));
-  CharUnits Field1Size =
-  CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty));
-  CharUnits Field2OffNoPadNoPack = Field1Size.alignTo(Field2Align);
+  CharUnits Field1EffectiveSize =
+  CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty)) +

lenary wrote:
> Please may you update this name to reflect what it really is - the offset of 
> the *end* of Field1, rather than its size. This code is complex enough 
> without confusing names. :)
+1 to Field1End or similar



Comment at: clang/lib/CodeGen/TargetInfo.cpp:10604-10605
+  CharUnits Field1EffectiveSize =
+  CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty)) +
+  Field1Off;
+  CharUnits Field2OffNoPadNoPack = Field1EffectiveSize.alignTo(Field2Align);

Swapping the order of the operands would be the more natural way to express 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91270

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


[PATCH] D91270: [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

2020-11-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a reviewer: jrtc27.
lenary added a comment.

I *think* this is looking good, but I'd like a second pair of eyes from @jrtc27 
as I know she's fixed bugs around this area recently too. We would like to have 
this ready for 11.0.1 if possible.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:10603
   CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(Field2Ty));
-  CharUnits Field1Size =
-  CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty));
-  CharUnits Field2OffNoPadNoPack = Field1Size.alignTo(Field2Align);
+  CharUnits Field1EffectiveSize =
+  CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty)) +

Please may you update this name to reflect what it really is - the offset of 
the *end* of Field1, rather than its size. This code is complex enough without 
confusing names. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91270

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


[PATCH] D92103: [ASTImporter] Import the default argument of TemplateTypeParmDecl

2020-11-30 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: 
lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py:25
 
-deque_type = "std::deque >"
 size_type = deque_type + "::size_type"

Why do the default arguments not show up in the results anymore?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92103

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


[PATCH] D90484: FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

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

Thanks again for the review, landed in 1b042de5b29af4869a77ecbc632029fba0313dec 
.




Comment at: clang/unittests/Basic/FileEntryTest.cpp:95
 
   OptionalFileEntryRefDegradesToFileEntryPtr M0;
   OptionalFileEntryRefDegradesToFileEntryPtr M1 = R1;

dexonsmith wrote:
> jansvoboda11 wrote:
> > Dead variable, do we need it?
> Thanks, nice catch, that looks vestigial. I'll delete that line in a 
> follow-up.
Deleted this stray line in 94f537c6b2bb55c8e058a9989d02ab0d68a0c61a; turns out 
it was originally a copy/paste bug from 
ac49500cd0484e1b2dcf37fa4c0dade6f113c2c9.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90484

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


[PATCH] D90484: FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b042de5b29a: FileManager: Add FileEntryRef::getDir, 
returning DirectoryEntryRef (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90484

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  clang/lib/Basic/FileManager.cpp
  clang/unittests/Basic/FileEntryTest.cpp

Index: clang/unittests/Basic/FileEntryTest.cpp
===
--- clang/unittests/Basic/FileEntryTest.cpp
+++ clang/unittests/Basic/FileEntryTest.cpp
@@ -15,85 +15,97 @@
 
 namespace {
 
-using MapEntry = FileEntryRef::MapEntry;
-using MapValue = FileEntryRef::MapValue;
-using MapType = StringMap>;
-
-FileEntryRef addRef(MapType , StringRef Name, FileEntry ) {
-  return FileEntryRef(*M.insert({Name, MapValue(E)}).first);
-}
+using FileMap = StringMap>;
+using DirMap = StringMap>;
+
+struct RefMaps {
+  FileMap Files;
+  DirMap Dirs;
+
+  DirectoryEntry D;
+  DirectoryEntryRef DR;
+  SmallVector, 5> FEs;
+
+  RefMaps() : DR(*Dirs.insert({"dir", D}).first) {}
+
+  FileEntryRef addFile(StringRef Name) {
+FEs.push_back(std::make_unique());
+return FileEntryRef(
+*Files.insert({Name, FileEntryRef::MapValue(*FEs.back().get(), DR)})
+ .first);
+  }
+  FileEntryRef addFileAlias(StringRef Name, FileEntryRef Base) {
+return FileEntryRef(
+*Files
+ .insert(
+ {Name, FileEntryRef::MapValue(
+const_cast(Base.getFileEntry()), DR)})
+ .first);
+  }
+};
 
 TEST(FileEntryTest, FileEntryRef) {
-  MapType Refs;
-  FileEntry E1, E2;
-  FileEntryRef R1 = addRef(Refs, "1", E1);
-  FileEntryRef R2 = addRef(Refs, "2", E2);
-  FileEntryRef R1Also = addRef(Refs, "1-also", E1);
+  RefMaps Refs;
+  FileEntryRef R1 = Refs.addFile("1");
+  FileEntryRef R2 = Refs.addFile("2");
+  FileEntryRef R1Also = Refs.addFileAlias("1-also", R1);
 
   EXPECT_EQ("1", R1.getName());
   EXPECT_EQ("2", R2.getName());
   EXPECT_EQ("1-also", R1Also.getName());
 
-  EXPECT_EQ(, ());
-  EXPECT_EQ(, ());
-  EXPECT_EQ(, ());
+  EXPECT_NE((), ());
+  EXPECT_EQ((), ());
 
   const FileEntry *CE1 = R1;
-  EXPECT_EQ(CE1, );
+  EXPECT_EQ(CE1, ());
 }
 
 TEST(FileEntryTest, OptionalFileEntryRefDegradesToFileEntryPtr) {
-  MapType Refs;
-  FileEntry E1, E2;
+  RefMaps Refs;
   OptionalFileEntryRefDegradesToFileEntryPtr M0;
-  OptionalFileEntryRefDegradesToFileEntryPtr M1 = addRef(Refs, "1", E1);
-  OptionalFileEntryRefDegradesToFileEntryPtr M2 = addRef(Refs, "2", E2);
+  OptionalFileEntryRefDegradesToFileEntryPtr M1 = Refs.addFile("1");
+  OptionalFileEntryRefDegradesToFileEntryPtr M2 = Refs.addFile("2");
   OptionalFileEntryRefDegradesToFileEntryPtr M0Also = None;
   OptionalFileEntryRefDegradesToFileEntryPtr M1Also =
-  addRef(Refs, "1-also", E1);
+  Refs.addFileAlias("1-also", *M1);
 
   EXPECT_EQ(M0, M0Also);
   EXPECT_EQ(StringRef("1"), M1->getName());
   EXPECT_EQ(StringRef("2"), M2->getName());
   EXPECT_EQ(StringRef("1-also"), M1Also->getName());
 
-  EXPECT_EQ(, >getFileEntry());
-  EXPECT_EQ(, >getFileEntry());
-  EXPECT_EQ(, >getFileEntry());
-
   const FileEntry *CE1 = M1;
-  EXPECT_EQ(CE1, );
+  EXPECT_EQ(CE1, >getFileEntry());
 }
 
 TEST(FileEntryTest, equals) {
-  MapType Refs;
-  FileEntry E1, E2;
-  FileEntryRef R1 = addRef(Refs, "1", E1);
-  FileEntryRef R2 = addRef(Refs, "2", E2);
-  FileEntryRef R1Also = addRef(Refs, "1-also", E1);
-
-  EXPECT_EQ(R1, );
-  EXPECT_EQ(, R1);
+  RefMaps Refs;
+  FileEntryRef R1 = Refs.addFile("1");
+  FileEntryRef R2 = Refs.addFile("2");
+  FileEntryRef R1Also = Refs.addFileAlias("1-also", R1);
+
+  EXPECT_EQ(R1, ());
+  EXPECT_EQ((), R1);
   EXPECT_EQ(R1, R1Also);
-  EXPECT_NE(R1, );
-  EXPECT_NE(, R1);
+  EXPECT_NE(R1, ());
+  EXPECT_NE((), R1);
   EXPECT_NE(R1, R2);
 
   OptionalFileEntryRefDegradesToFileEntryPtr M0;
   OptionalFileEntryRefDegradesToFileEntryPtr M1 = R1;
 
-  EXPECT_EQ(M1, );
-  EXPECT_EQ(, M1);
-  EXPECT_NE(M1, );
-  EXPECT_NE(, M1);
+  EXPECT_EQ(M1, ());
+  EXPECT_EQ((), M1);
+  EXPECT_NE(M1, ());
+  EXPECT_NE((), M1);
 }
 
 TEST(FileEntryTest, isSameRef) {
-  MapType Refs;
-  FileEntry E1, E2;
-  FileEntryRef R1 = addRef(Refs, "1", E1);
-  FileEntryRef R2 = addRef(Refs, "2", E2);
-  FileEntryRef R1Also = addRef(Refs, "1-also", E1);
+  RefMaps Refs;
+  FileEntryRef R1 = Refs.addFile("1");
+  FileEntryRef R2 = Refs.addFile("2");
+  FileEntryRef R1Also = Refs.addFileAlias("1-also", R1);
 
   EXPECT_TRUE(R1.isSameRef(FileEntryRef(R1)));
   EXPECT_TRUE(R1.isSameRef(FileEntryRef(R1.getMapEntry(;
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -69,21 +69,22 @@
 
 /// 

[clang] 94f537c - Remove dead code added in ac49500cd0484e1b2dcf37fa4c0dade6f113c2c9, NFC

2020-11-30 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-11-30T14:50:46-08:00
New Revision: 94f537c6b2bb55c8e058a9989d02ab0d68a0c61a

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

LOG: Remove dead code added in ac49500cd0484e1b2dcf37fa4c0dade6f113c2c9, NFC

This was a copy/paste bug; `M0` is never referenced later.

Added: 


Modified: 
clang/unittests/Basic/FileEntryTest.cpp

Removed: 




diff  --git a/clang/unittests/Basic/FileEntryTest.cpp 
b/clang/unittests/Basic/FileEntryTest.cpp
index b759d3ea36d6..f2619a21def7 100644
--- a/clang/unittests/Basic/FileEntryTest.cpp
+++ b/clang/unittests/Basic/FileEntryTest.cpp
@@ -92,7 +92,6 @@ TEST(FileEntryTest, equals) {
   EXPECT_NE((), R1);
   EXPECT_NE(R1, R2);
 
-  OptionalFileEntryRefDegradesToFileEntryPtr M0;
   OptionalFileEntryRefDegradesToFileEntryPtr M1 = R1;
 
   EXPECT_EQ(M1, ());



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


[clang] 1b042de - FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

2020-11-30 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-11-30T14:50:46-08:00
New Revision: 1b042de5b29af4869a77ecbc632029fba0313dec

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

LOG: FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

Add `FileEntryRef::getDir`, which returns a `DirectoryEntryRef`. This
includes a few changes:

- Customize `OptionalStorage` so that `Optional` is
  pointer-sized (like the change made to `Optional`).
  Factored out a common class, `FileMgr::MapEntryOptionalStorage`, to
  reduce the code duplication.
- Store an `Optional` in `FileEntryRef::MapValue`.
  This is set if and only if `MapValue` has a real `FileEntry`.
- Change `FileManager::getFileRef` and `getVirtualFileRef` to use
  `getDirectoryRef` and store it in the `StringMap` for `FileEntryRef`.

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

Added: 


Modified: 
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/lib/Basic/FileManager.cpp
clang/unittests/Basic/FileEntryTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DirectoryEntry.h 
b/clang/include/clang/Basic/DirectoryEntry.h
index 7c634709ca9b..a6ec5f89aa28 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -20,6 +20,11 @@
 #include "llvm/Support/ErrorOr.h"
 
 namespace clang {
+namespace FileMgr {
+
+template  class MapEntryOptionalStorage;
+
+} // end namespace FileMgr
 
 /// Cached information about one directory (either on disk or in
 /// the virtual file system).
@@ -37,20 +42,109 @@ class DirectoryEntry {
 /// as it was accessed by the FileManager's client.
 class DirectoryEntryRef {
 public:
-  const DirectoryEntry () const { return *Entry->getValue(); }
+  const DirectoryEntry () const { return *ME->getValue(); }
+
+  StringRef getName() const { return ME->getKey(); }
+
+  using MapEntry = llvm::StringMapEntry>;
 
-  StringRef getName() const { return Entry->getKey(); }
+  const MapEntry () const { return *ME; }
+
+  DirectoryEntryRef() = delete;
+  DirectoryEntryRef(MapEntry ) : ME() {}
 
 private:
-  friend class FileManager;
+  friend class FileMgr::MapEntryOptionalStorage;
+  struct optional_none_tag {};
 
-  DirectoryEntryRef(
-  llvm::StringMapEntry> *Entry)
-  : Entry(Entry) {}
+  // Private constructor for use by OptionalStorage.
+  DirectoryEntryRef(optional_none_tag) : ME(nullptr) {}
+  bool hasOptionalValue() const { return ME; }
 
-  const llvm::StringMapEntry> *Entry;
+  const MapEntry *ME;
 };
 
+namespace FileMgr {
+
+/// Customized storage for refs derived from map entires in FileManager, using
+/// the private optional_none_tag to keep it to the size of a single pointer.
+template  class MapEntryOptionalStorage {
+  using optional_none_tag = typename RefTy::optional_none_tag;
+  RefTy MaybeRef;
+
+public:
+  MapEntryOptionalStorage() : MaybeRef(optional_none_tag()) {}
+
+  template 
+  explicit MapEntryOptionalStorage(llvm::optional_detail::in_place_t,
+   ArgTypes &&...Args)
+  : MaybeRef(std::forward(Args)...) {}
+
+  void reset() { MaybeRef = optional_none_tag(); }
+
+  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+
+  RefTy () LLVM_LVALUE_FUNCTION {
+assert(hasValue());
+return MaybeRef;
+  }
+  RefTy const () const LLVM_LVALUE_FUNCTION {
+assert(hasValue());
+return MaybeRef;
+  }
+#if LLVM_HAS_RVALUE_REFERENCE_THIS
+  RefTy &() && {
+assert(hasValue());
+return std::move(MaybeRef);
+  }
+#endif
+
+  template  void emplace(Args &&...args) {
+MaybeRef = RefTy(std::forward(args)...);
+  }
+
+  MapEntryOptionalStorage =(RefTy Ref) {
+MaybeRef = Ref;
+return *this;
+  }
+};
+
+} // end namespace FileMgr
 } // end namespace clang
 
+namespace llvm {
+namespace optional_detail {
+
+/// Customize OptionalStorage to use DirectoryEntryRef and
+/// its optional_none_tag to keep it the size of a single pointer.
+template <>
+class OptionalStorage
+: public clang::FileMgr::MapEntryOptionalStorage 
{
+  using StorageImpl =
+  clang::FileMgr::MapEntryOptionalStorage;
+
+public:
+  OptionalStorage() = default;
+
+  template 
+  explicit OptionalStorage(in_place_t, ArgTypes &&...Args)
+  : StorageImpl(in_place_t{}, std::forward(Args)...) {}
+
+  OptionalStorage =(clang::DirectoryEntryRef Ref) {
+StorageImpl::operator=(Ref);
+return *this;
+  }
+};
+
+static_assert(sizeof(Optional) ==
+  sizeof(clang::DirectoryEntryRef),
+  "Optional must avoid size overhead");
+
+static_assert(
+std::is_trivially_copyable>::value,
+"Optional should be trivially copyable");
+
+} // end namespace optional_detail
+} // end namespace llvm
+
 #endif // 

[PATCH] D91997: APINotes: add bitcode format schema definitions

2020-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Gentle post-holiday reminder :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91997

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


[PATCH] D91278: [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct and complex

2020-11-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

LGTM - the big hint is that the new test is handled the same as 
`f_empty_double2` as required by the ABI.




Comment at: clang/test/CodeGen/riscv32-ilp32d-abi.cpp:36
+
+struct empty_complex { struct {}; double _Complex fc; };
+

Please can you add a test of `{ struct {}; float _Complex fc;}` too, just for 
regression purposes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91278

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


[PATCH] D91673: [PGO] Enable preinline and cleanup when optimize for size

2020-11-30 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D91673#2401578 , @xur wrote:

> This is probably OK for -Os (SizeLevel == 1), but we need to be careful with 
> Oz (SizeLevel == 2).
> We already know that enabling preinliner in general will reduce size -- as 
> the preinliner is pretty conservative. But there will be cases size will be 
> increased.
>
> I would like more test results (like bootstrap clang) before committing.

I don't see binary size difference (<1%), when bootstrap clang with this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91673

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


[PATCH] D92106: [ASTImporter] Import the default argument of NonTypeTemplateParmDecl

2020-11-30 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:965
+TEST_P(ASTImporterOptionSpecificTestBase, NonTypeTemplateParmDeclDefaultArg) {
+  Decl *FromTU = getTuDecl("template struct X {};", Lang_CXX03);
+  auto From = FirstDeclMatcher().match(

Might make sense to test multiple default arguments and types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92106

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


[PATCH] D90484: FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/unittests/Basic/FileEntryTest.cpp:95
 
   OptionalFileEntryRefDegradesToFileEntryPtr M0;
   OptionalFileEntryRefDegradesToFileEntryPtr M1 = R1;

jansvoboda11 wrote:
> Dead variable, do we need it?
Thanks, nice catch, that looks vestigial. I'll delete that line in a follow-up.


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

https://reviews.llvm.org/D90484

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


[clang] ac40a2d - Serialization: Change InputFile to use FileEntryRef and add getVirtualFileRef, NFC

2020-11-30 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-11-30T14:04:48-08:00
New Revision: ac40a2d8f16b8a8c68fc811d67f647740e965cb8

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

LOG: Serialization: Change InputFile to use FileEntryRef and add 
getVirtualFileRef, NFC

Change the `InputFile` class to store `Optional` instead
of `FileEntry*`. This paged in a few API changes:

- Added `FileManager::getVirtualFileRef`, and converted `getVirtualFile`
  to a wrapper of it.
- Updated `SourceManager::bypassFileContentsOverride` to take
  `FileEntryRef` and return `Optional`
  (`ASTReader::getInputFile` is the only caller).

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

Added: 


Modified: 
clang/include/clang/Basic/FileManager.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Serialization/ModuleFile.h
clang/lib/Basic/FileManager.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/FileManager.h 
b/clang/include/clang/Basic/FileManager.h
index d7135a4f0ac3..449aec2b3541 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -239,6 +239,9 @@ class FileManager : public RefCountedBase {
   /// if there were a file with the given name on disk.
   ///
   /// The file itself is not accessed.
+  FileEntryRef getVirtualFileRef(StringRef Filename, off_t Size,
+ time_t ModificationTime);
+
   const FileEntry *getVirtualFile(StringRef Filename, off_t Size,
   time_t ModificationTime);
 

diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index b231644330ed..459bd088f0d7 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -35,6 +35,7 @@
 #define LLVM_CLANG_BASIC_SOURCEMANAGER_H
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileEntry.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"
@@ -60,8 +61,6 @@ namespace clang {
 class ASTReader;
 class ASTWriter;
 class FileManager;
-class FileEntry;
-class FileEntryRef;
 class LineTableInfo;
 class SourceManager;
 
@@ -982,11 +981,11 @@ class SourceManager : public 
RefCountedBase {
   }
 
   /// Bypass the overridden contents of a file.  This creates a new FileEntry
-  /// and initializes the content cache for it.  Returns nullptr if there is no
+  /// and initializes the content cache for it.  Returns None if there is no
   /// such file in the filesystem.
   ///
   /// This should be called before parsing has begun.
-  const FileEntry *bypassFileContentsOverride(const FileEntry );
+  Optional bypassFileContentsOverride(FileEntryRef File);
 
   /// Specify that a file is transient.
   void setFileIsTransient(const FileEntry *SourceFile);

diff  --git a/clang/include/clang/Serialization/ModuleFile.h 
b/clang/include/clang/Serialization/ModuleFile.h
index a309c1143350..a641a26661ae 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -67,13 +67,13 @@ class InputFile {
 OutOfDate = 2,
 NotFound = 3
   };
-  llvm::PointerIntPair Val;
+  llvm::PointerIntPair Val;
 
 public:
   InputFile() = default;
 
-  InputFile(const FileEntry *File,
-bool isOverridden = false, bool isOutOfDate = false) {
+  InputFile(FileEntryRef File, bool isOverridden = false,
+bool isOutOfDate = false) {
 assert(!(isOverridden && isOutOfDate) &&
"an overridden cannot be out-of-date");
 unsigned intVal = 0;
@@ -81,7 +81,7 @@ class InputFile {
   intVal = Overridden;
 else if (isOutOfDate)
   intVal = OutOfDate;
-Val.setPointerAndInt(File, intVal);
+Val.setPointerAndInt((), intVal);
   }
 
   static InputFile getNotFound() {
@@ -90,7 +90,11 @@ class InputFile {
 return File;
   }
 
-  const FileEntry *getFile() const { return Val.getPointer(); }
+  OptionalFileEntryRefDegradesToFileEntryPtr getFile() const {
+if (auto *P = Val.getPointer())
+  return FileEntryRef(*P);
+return None;
+  }
   bool isOverridden() const { return Val.getInt() == Overridden; }
   bool isOutOfDate() const { return Val.getInt() == OutOfDate; }
   bool isNotFound() const { return Val.getInt() == NotFound; }

diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 38d9403eadb9..ef0c69ae0107 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -335,9 +335,13 @@ FileManager::getFileRef(StringRef Filename, bool openFile, 
bool CacheFailure) {
   return ReturnedRef;
 }
 
-const FileEntry *

[PATCH] D90053: Serialization: Change InputFile to use FileEntryRef and add getVirtualFileRef, NFC

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac40a2d8f16b: Serialization: Change InputFile to use 
FileEntryRef and add getVirtualFileRef… (authored by dexonsmith).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D90053?vs=301399=308477#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90053

Files:
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2296,27 +2296,25 @@
   StringRef Filename = FI.Filename;
   uint64_t StoredContentHash = FI.ContentHash;
 
-  const FileEntry *File = nullptr;
-  if (auto FE = FileMgr.getFile(Filename, /*OpenFile=*/false))
-File = *FE;
+  OptionalFileEntryRefDegradesToFileEntryPtr File =
+  expectedToOptional(FileMgr.getFileRef(Filename, /*OpenFile=*/false));
 
   // If we didn't find the file, resolve it relative to the
   // original directory from which this AST file was created.
-  if (File == nullptr && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
+  if (!File && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
   F.OriginalDir != F.BaseDirectory) {
 std::string Resolved = resolveFileRelativeToOriginalDir(
 std::string(Filename), F.OriginalDir, F.BaseDirectory);
 if (!Resolved.empty())
-  if (auto FE = FileMgr.getFile(Resolved))
-File = *FE;
+  File = expectedToOptional(FileMgr.getFileRef(Resolved));
   }
 
   // For an overridden file, create a virtual file with the stored
   // size/timestamp.
-  if ((Overridden || Transient) && File == nullptr)
-File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
+  if ((Overridden || Transient) && !File)
+File = FileMgr.getVirtualFileRef(Filename, StoredSize, StoredTime);
 
-  if (File == nullptr) {
+  if (!File) {
 if (Complain) {
   std::string ErrorStr = "could not find file '";
   ErrorStr += Filename;
@@ -2418,7 +2416,7 @@
   // FIXME: If the file is overridden and we've already opened it,
   // issue an error (or split it into a separate FileEntry).
 
-  InputFile IF = InputFile(File, Overridden || Transient, IsOutOfDate);
+  InputFile IF = InputFile(*File, Overridden || Transient, IsOutOfDate);
 
   // Note that we've loaded this input file.
   F.InputFilesLoaded[ID-1] = IF;
@@ -9274,7 +9272,7 @@
 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
 if (IFI.TopLevelModuleMap)
   // FIXME: This unnecessarily re-reads the InputFileInfo.
-  if (auto *FE = getInputFile(MF, I + 1).getFile())
+  if (auto FE = getInputFile(MF, I + 1).getFile())
 Visitor(FE);
   }
 }
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -698,19 +698,17 @@
   getOverriddenFilesInfo().OverriddenFiles[SourceFile] = NewFile;
 }
 
-const FileEntry *
-SourceManager::bypassFileContentsOverride(const FileEntry ) {
-  assert(isFileOverridden());
-  llvm::Optional BypassFile =
-  FileMgr.getBypassFile(File.getLastRef());
+Optional
+SourceManager::bypassFileContentsOverride(FileEntryRef File) {
+  assert(isFileOverridden(()));
+  llvm::Optional BypassFile = FileMgr.getBypassFile(File);
 
   // If the file can't be found in the FS, give up.
   if (!BypassFile)
-return nullptr;
+return None;
 
-  const FileEntry *FE = >getFileEntry();
-  (void)getOrCreateContentCache(FE);
-  return FE;
+  (void)getOrCreateContentCache(>getFileEntry());
+  return BypassFile;
 }
 
 void SourceManager::setFileIsTransient(const FileEntry *File) {
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -335,9 +335,13 @@
   return ReturnedRef;
 }
 
-const FileEntry *
-FileManager::getVirtualFile(StringRef Filename, off_t Size,
-time_t ModificationTime) {
+const FileEntry *FileManager::getVirtualFile(StringRef Filename, off_t Size,
+ time_t ModificationTime) {
+  return (Filename, Size, ModificationTime).getFileEntry();
+}
+
+FileEntryRef FileManager::getVirtualFileRef(StringRef Filename, off_t Size,
+time_t ModificationTime) {
   ++NumFileLookups;
 
   // See if there is already an entry in the map for an existing file.
@@ -345,12 +349,10 @@
   {Filename, std::errc::no_such_file_or_directory}).first;
   if (NamedFileEnt.second) {
   

[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-11-30 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: llvm/lib/MC/MCObjectFileInfo.cpp:889
+  CompactUnwindSection =
+  Ctx->getXCOFFSection(".eh_info_table", 
XCOFF::StorageMappingClass::XMC_RW,
+   XCOFF::XTY_SD, SectionKind::getData());

daltenty wrote:
> I think this may have been discussed elsewhere, but why do we want to emit 
> this as a RW section?
Yes, this has been discussed before. And it's a good question.
If we emit this as an RO section, then we could not put 
```
.vbyte  4, GCC_except_table1
.vbyte  4, __xlcxx_personality_v1[DS]
```
into this csect directly. 
If we do that, we would hit linker error during link time. It seems that for 
read only csects (RO, PR mapping classes), we could not have relocation types 
like `R_POS` or `R_NEG` because the result coming out of it is not link-time 
constant. And the relocation types in read only csects needs to be link time 
constant.

Extra work (both compiler and runtime) will be needed if we want to make this 
RO.


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

https://reviews.llvm.org/D91455

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D91747#2423987 , @zequanwu wrote:

> So, we could remove the checking for if `__STDCPP_THREADS__` and 
> `_LIBCPP_HAS_NO_THREADS` are both set. And let libcxx adds flag 
> `-mthread-model single` to use single thread (but this is compiler specific 
> flag, might need a better solution).

Yes, and I think we also need to audit to see if there is any code in libc++ 
that checks `__STDCPP_THREADS__`. Actually, I went ahead and did that. It like 
no other code checks it, so we're probably OK to remove the libc++ check.

It's worth noting that this change will prevent users of older libc++ versions 
from disabling thread support with new clang. I think that's probably OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-30 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D91747#2423960 , @rnk wrote:

> If we believe the standard says that the compiler is supposed to set 
> `__STDCPP_THREADS__`, then I think the libc++ #error needs to be adjusted. 
> libcxxabi, or any other client, should be able to define 
> `_LIBCPP_HAS_NO_THREADS`, and it should work, even if the compiler thinks 
> they are allowed.

So, we could remove the checking for if `__STDCPP_THREADS__` and 
`_LIBCPP_HAS_NO_THREADS` are both set. And let libcxx adds flag `-mthread-model 
single` to use single thread (but this is compiler specific flag, might need a 
better solution).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-11-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Windows has effectively always had stack clash protection: we've always emitted 
those little chkstk probe calls for stack frames larger than a page. Would it 
make more sense to ignore this flag on Windows, since it opts into always-on 
behavior? If so, this doesn't seem like the right place to ignore it.

I see your comment here, but I don't really understand it:
https://reviews.llvm.org/D92100#2422729
What goes wrong on Windows? Can it be made to just work instead? It should be 
simple.

How do things go wrong on Darwin? I was under the impression that this was 
implemented in LLVM as strictly inline code, no runtime support required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

If we believe the standard says that the compiler is supposed to set 
`__STDCPP_THREADS__`, then I think the libc++ #error needs to be adjusted. 
libcxxabi, or any other client, should be able to define 
`_LIBCPP_HAS_NO_THREADS`, and it should work, even if the compiler thinks they 
are allowed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

2020-11-30 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM in general.




Comment at: clang/lib/Sema/SemaExpr.cpp:1944
+  // host variable in a device or host device lambda.
+  auto IsCapturingReferenceToHostVarInCUDADeviceLambda = [&](VarDecl *VD) {
+if (!getLangOpts().CUDA || !VD->hasInit())

Nit: I'd make it a free function.
The large-ish lambda handling a niche case makes the original simple function 
less readable. I think keeping capture check separate would be a bit cleaner.



Comment at: clang/lib/Sema/SemaExpr.cpp:1982
 !(getLangOpts().OpenMP && isOpenMPCapturedDecl(D)) &&
+!IsCapturingReferenceToHostVarInCUDADeviceLambda(VD) &&
 VD->isUsableInConstantExpressions(Context))

This could use some Sema tests.


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

https://reviews.llvm.org/D91088

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


[PATCH] D91840: OpaquePtr: Require byval on x86_intrcc parameter 0

2020-11-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

Thanks for removing that special case.


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

https://reviews.llvm.org/D91840

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


[PATCH] D80450: [CUDA][HIP] Fix HD function resolution

2020-11-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/test/SemaCUDA/function-overload.cu:616
+// HDs have type mismatch whereas H has type match.
+// In device compilation, H wins when -fgpu-defer-diag is off and two HD win
+// when -fgpu-defer-diags is on. In both cases the diagnostic should be

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > One thing that bothers me about this comment is that `-fgpu-defer-diag` 
> > > apparently changes the result of the overload resolution, not just 
> > > deferring diags.
> > without -fgpu-defer-diag we have to keep the old incorrect overloading 
> > resolution since otherwise it breaks existing code.
> > 
> > We can only have correct overloading resolution with -fgpu-defer-diag on.
> > 
> > If we want to have correct overloading resolution, not depending on whether 
> > -fgpu-defer-diag is on or off, we have to turn on -fgpu-defer-diag by 
> > default. In this case no existing code will be broken.
> > We can only have correct overloading resolution with -fgpu-defer-diag on.
> 
> `-fgpu-defer-diags` is a **prerequisite** for fixing overload resolution. I'm 
> fine with that.
> Making it serve the double duty of **affecting** the overload resolution is 
> what I was pointing at.
> 
> We should have a knob `fix-overload-resolution` which would then turn 
> `-fgpu-defer-diag` on, not the other way around.
That makes sense. Will add -ffix-overload-resolution.


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

https://reviews.llvm.org/D80450

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


[PATCH] D91861: [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

This LGTM. Thanks again for the cleanup, I think the new syntax is more 
intuitive.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4027-4031
+  if (((FLAGS)::CC1Option) &&  
\
+  (ALWAYS_EMIT ||  
\
+   (EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE && !(IMPLIED_CHECK { 
\
 DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
   }

dexonsmith wrote:
> jansvoboda11 wrote:
> > jansvoboda11 wrote:
> > > dexonsmith wrote:
> > > > I'm not sure this logic is quite right. It looks to me like if an 
> > > > option can very be implied, it will never be seriazed to `-cc1`, even 
> > > > if its current value is not an implied one.
> > > > 
> > > > Or have I understood the conditions under which `IMPLIED_CHECK` returns 
> > > > `true`?
> > > > 
> > > > IIUC, then this logic seems closer:
> > > > ```
> > > > if (((FLAGS)::CC1Option) && 
> > > >  \
> > > > (ALWAYS_EMIT || 
> > > >  \
> > > >  (EXTRACTOR(this->KEYPATH) !=   
> > > >  \
> > > >   (IMPLIED_CHECK ? (DEFAULT_VALUE)  
> > > >  \
> > > >  : (MERGER(DEFAULT_VALUE, IMPLIED_VALUE)) { 
> > > >  \
> > > >   DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, 
> > > > EXTRACTOR(this->KEYPATH));   \
> > > > }
> > > > ```
> > > > 
> > > > It would be great to see tests in particular for a bitset (or similar) 
> > > > option where the merger does a union.
> > > `IMPLIED_CHECK` is a logical disjunction of the implying option keypaths. 
> > > It evaluates to `true` whenever at least one of the implying keypaths 
> > > evaluates to `true`.
> > > 
> > > I think I know what you're concerned about. Let me paraphrase it and 
> > > check if my understanding is correct:
> > > Suppose option `a` has default value of `x`, and flag `b` can imply the 
> > > value of `a` to be `y`. If we have a command line `-b -a=z`, then `-a=z` 
> > > would not be generated with the current logic: `EXTRACTOR(this->KEYPATH) 
> > > != DEFAULT_VALUE` evaluates to true, but `!(IMPLIED_CHECK)` to `false`.
> > > 
> > > Your conditions gets close, but I think the ternary branches should be 
> > > the other way around.
> > > 
> > > Here's a table exploring all cases:
> > > 
> > > ```
> > > IMPLIED_CHECK | EXTRACTOR(this->KEYPATH) == | SHOULD_EMIT
> > > --+-+-
> > > true  | IMPLIED_VALUE   | NO - emitting only the 
> > > implying option is enough
> > > true  | DEFAULT_VALUE   | YES - value explicitly 
> > > specified (and it's DEFAULT_VALUE just by chance)
> > > true  | ??? | YES - value explicitly 
> > > specified
> > > false | IMPLIED_VALUE   | YES - value explicitly 
> > > specified (and it's IMPLIED_VALUE just by chance)
> > > false | DEFAULT_VALUE   | NO - default value handles 
> > > this automatically
> > > false | ??? | YES - value explicitly 
> > > specified
> > > ```
> > > 
> > > I think this logic is what we're looking for:
> > > 
> > > ```
> > >   if (((FLAGS)::CC1Option) && 
> > >  \
> > >   (ALWAYS_EMIT || 
> > >  \
> > >(EXTRACTOR(this->KEYPATH) !=   
> > >  \
> > > ((IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE) {
> > >  \
> > > DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, 
> > > EXTRACTOR(this->KEYPATH));   \
> > >   }
> > > ```
> > It would be great to be able to test this logic even when no Clang options 
> > exercise it properly yet. Any ideas on that front?
> > Including a different `Options.inc` in `CompilerInvocation.cpp` for tests 
> > and re-linking the whole library seems wasteful.
> That'd be great, but I don't see a simple way. Can you find a flag that would 
> exercise it properly? If so, I suggest converting just that one flag as part 
> of this patch, and then you can test it.
On second read, perhaps the tests you added are good enough for now, as long as 
you're careful to improve the test coverage when you land the patches with 
options that have interesting merger/bitset logic. I'll leave it up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91861

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-11-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:2077
 
   QualType TransformTypedefType(TypeLocBuilder , TypedefTypeLoc TL) {
 ASTContext  = SemaRef.getASTContext();

The check to see if we should clone a typedef or not should be moved into this 
function.



Comment at: clang/lib/Sema/SemaTemplate.cpp:2352
   llvm::SmallVectorImpl ) {
 TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo();
+

Hmm, we're only applying the logic in the case where the top-level type of a 
parameter is a typedef type. That doesn't seem right; this won't do the right 
thing for `Constructor(Typedef*)` and similar. Also, we don't want to skip the 
parameter transform entirely if we find a such a typedef; instead, we should 
only skip cloning the typedef itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92101

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


[PATCH] D83694: [clang][cli] Port DependencyOutput option flags to new option parsing system

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

This LGTM, with one more nit to consider.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:163
+static constexpr bool is_int_convertible() {
+  return sizeof(T) <= sizeof(std::uint64_t) &&
+ std::is_trivially_constructible::value &&

I don't remember seeing `std::uint*_t` elsewhere in LLVM code; I think we tend 
to just say `uint64_t` (getting it from the C namespace). Unless you have a 
specific reason for adding it I suggest dropping the qualifier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83694

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


[PATCH] D92291: clang/test: Remove platform-linker feature

2020-11-30 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D92291#2423417 , @leonardchan wrote:

> @phosek This shouldn't affect supporting riscv with our toolchain, right?

Yes, it shouldn't have any impact.


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

https://reviews.llvm.org/D92291

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


[PATCH] D92342: [HIP] Fix HIP test on windows due to lld suffix

2020-11-30 Thread Aaron Enye Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf89e9c8201ea: [HIP] Fix HIP test on windows due to lld 
suffix (authored by ashi1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92342

Files:
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip


Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -95,7 +95,7 @@
 // CHECK-SAME: 
"-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" 
"-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
+// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
 
 // output the executable
 // CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] 
[[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -47,7 +47,7 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: [[LLD: ".*lld"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
+// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] 
[[B_BC1]]
 
 // generate image for device side path on gfx900
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -78,6 +78,6 @@
 // CHECK-SAME: 
"-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" 
"-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
+// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
 
 // CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] 
[[B_OBJ_HOST]] [[OBJBUNDLE]]


Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -95,7 +95,7 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // output the executable
 // CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -47,7 +47,7 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: [[LLD: ".*lld"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
+// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -78,6 +78,6 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f89e9c8 - [HIP] Fix HIP test on windows due to lld suffix

2020-11-30 Thread Aaron En Ye Shi via cfe-commits

Author: Aaron En Ye Shi
Date: 2020-11-30T21:05:26Z
New Revision: f89e9c8201ea5a5b63af854c92ed26bc7ab4b8db

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

LOG: [HIP] Fix HIP test on windows due to lld suffix

On Windows, lld is instead named lld.exe, therefore
a few HIP tests are failing. Instead the wildcard should
be modified to .*lld.* to handle .exe. This fixes the
bug: https://bugs.llvm.org/show_bug.cgi?id=48289.

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

Added: 


Modified: 
clang/test/Driver/hip-toolchain-rdc-static-lib.hip
clang/test/Driver/hip-toolchain-rdc.hip

Removed: 




diff  --git a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip 
b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
index dc29b0f87e36..533d3457d5b4 100644
--- a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -47,7 +47,7 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: [[LLD: ".*lld"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
+// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] 
[[B_BC1]]
 
 // generate image for device side path on gfx900
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -78,6 +78,6 @@
 // CHECK-SAME: 
"-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" 
"-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
+// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
 
 // CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] 
[[B_OBJ_HOST]] [[OBJBUNDLE]]

diff  --git a/clang/test/Driver/hip-toolchain-rdc.hip 
b/clang/test/Driver/hip-toolchain-rdc.hip
index 8d8e67514035..d6d47ec1b07e 100644
--- a/clang/test/Driver/hip-toolchain-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-rdc.hip
@@ -95,7 +95,7 @@
 // CHECK-SAME: 
"-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" 
"-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
+// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" 
"--filetype=obj"
 
 // output the executable
 // CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] 
[[B_OBJ_HOST]] [[OBJBUNDLE]]



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


[PATCH] D80450: [CUDA][HIP] Fix HD function resolution

2020-11-30 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/SemaCUDA/function-overload.cu:616
+// HDs have type mismatch whereas H has type match.
+// In device compilation, H wins when -fgpu-defer-diag is off and two HD win
+// when -fgpu-defer-diags is on. In both cases the diagnostic should be

yaxunl wrote:
> tra wrote:
> > One thing that bothers me about this comment is that `-fgpu-defer-diag` 
> > apparently changes the result of the overload resolution, not just 
> > deferring diags.
> without -fgpu-defer-diag we have to keep the old incorrect overloading 
> resolution since otherwise it breaks existing code.
> 
> We can only have correct overloading resolution with -fgpu-defer-diag on.
> 
> If we want to have correct overloading resolution, not depending on whether 
> -fgpu-defer-diag is on or off, we have to turn on -fgpu-defer-diag by 
> default. In this case no existing code will be broken.
> We can only have correct overloading resolution with -fgpu-defer-diag on.

`-fgpu-defer-diags` is a **prerequisite** for fixing overload resolution. I'm 
fine with that.
Making it serve the double duty of **affecting** the overload resolution is 
what I was pointing at.

We should have a knob `fix-overload-resolution` which would then turn 
`-fgpu-defer-diag` on, not the other way around.


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

https://reviews.llvm.org/D80450

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


[PATCH] D83697: [clang][cli] Port Frontend option flags to new option parsing system

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83697

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


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-11-30 Thread Ravi via Phabricator via cfe-commits
ravikandhadai added inline comments.



Comment at: clang/lib/Analysis/CalledOnceCheck.cpp:889
+
+  /// Return true if th analyzed function is actually a default implementation
+  /// of the method that has to be overriden.

typo: th -> the


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

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


[PATCH] D92297: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG164410324d8b: [CodeGen] -fno-delete-null-pointer-checks: 
change dereferenceable to… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92297

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/this-nonnull.cpp


Index: clang/test/CodeGenCXX/this-nonnull.cpp
===
--- clang/test/CodeGenCXX/this-nonnull.cpp
+++ clang/test/CodeGenCXX/this-nonnull.cpp
@@ -12,8 +12,9 @@
   s.ReturnsVoid();
 
   // CHECK-YES: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12) %0)
-  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12) %0)
+  /// FIXME Use dereferenceable after dereferenceable respects 
NullPointerIsValid.
+  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12) %0)
 }
 
 // CHECK-YES: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12))
-// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12))
+// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12))
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2168,13 +2168,21 @@
 if (!CodeGenOpts.NullPointerIsValid &&
 getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
   Attrs.addAttribute(llvm::Attribute::NonNull);
+  Attrs.addDereferenceableAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid. However, dereferenceable currently does not always
+  // respect NullPointerIsValid and may imply nonnull and break the 
program.
+  // See https://reviews.llvm.org/D66618 for discussions.
+  Attrs.addDereferenceableOrNullAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
 }
 
-Attrs.addDereferenceableAttr(
-getMinimumObjectSize(
-FI.arg_begin()->type.castAs()->getPointeeType())
-.getQuantity());
-
 ArgAttrs[IRArgs.first] = llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 


Index: clang/test/CodeGenCXX/this-nonnull.cpp
===
--- clang/test/CodeGenCXX/this-nonnull.cpp
+++ clang/test/CodeGenCXX/this-nonnull.cpp
@@ -12,8 +12,9 @@
   s.ReturnsVoid();
 
   // CHECK-YES: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull dereferenceable(12) %0)
-  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable(12) %0)
+  /// FIXME Use dereferenceable after dereferenceable respects NullPointerIsValid.
+  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable_or_null(12) %0)
 }
 
 // CHECK-YES: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull dereferenceable(12))
-// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable(12))
+// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable_or_null(12))
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2168,13 +2168,21 @@
 if (!CodeGenOpts.NullPointerIsValid &&
 getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
   Attrs.addAttribute(llvm::Attribute::NonNull);
+  Attrs.addDereferenceableAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid. However, dereferenceable currently does not always
+  // respect NullPointerIsValid and may imply nonnull and break the program.
+  // See https://reviews.llvm.org/D66618 for discussions.
+  Attrs.addDereferenceableOrNullAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
 }
 
-Attrs.addDereferenceableAttr(
-getMinimumObjectSize(
-FI.arg_begin()->type.castAs()->getPointeeType())
-.getQuantity());
-
 ArgAttrs[IRArgs.first] = llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] 1644103 - [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-11-30T12:44:35-08:00
New Revision: 164410324d8bf3b5a99e39f7dfe3c6d6972dab30

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

LOG: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to 
dereferenceable_or_null

After D17993, with -fno-delete-null-pointer-checks we add the dereferenceable 
attribute to the `this` pointer.

We have observed that one internal target which worked before fails even with 
-fno-delete-null-pointer-checks.
Switching to dereferenceable_or_null fixes the problem.

dereferenceable currently does not always respect NullPointerIsValid and may
imply nonnull and lead to aggressive optimization. The optimization may be
related to `CallBase::isReturnNonNull`, `Argument::hasNonNullAttr`, or
`Value::getPointerDereferenceableBytes`. See D4 and D66618 for some 
discussions.

Reviewed By: bkramer, rsmith

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGenCXX/this-nonnull.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 78740018d416..2b9bfb6a6c88 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2168,13 +2168,21 @@ void CodeGenModule::ConstructAttributeList(
 if (!CodeGenOpts.NullPointerIsValid &&
 getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
   Attrs.addAttribute(llvm::Attribute::NonNull);
+  Attrs.addDereferenceableAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid. However, dereferenceable currently does not always
+  // respect NullPointerIsValid and may imply nonnull and break the 
program.
+  // See https://reviews.llvm.org/D66618 for discussions.
+  Attrs.addDereferenceableOrNullAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
 }
 
-Attrs.addDereferenceableAttr(
-getMinimumObjectSize(
-FI.arg_begin()->type.castAs()->getPointeeType())
-.getQuantity());
-
 ArgAttrs[IRArgs.first] = llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 

diff  --git a/clang/test/CodeGenCXX/this-nonnull.cpp 
b/clang/test/CodeGenCXX/this-nonnull.cpp
index 9b074e2bdda1..63873388b070 100644
--- a/clang/test/CodeGenCXX/this-nonnull.cpp
+++ b/clang/test/CodeGenCXX/this-nonnull.cpp
@@ -12,8 +12,9 @@ void TestReturnsVoid(Struct ) {
   s.ReturnsVoid();
 
   // CHECK-YES: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12) %0)
-  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12) %0)
+  /// FIXME Use dereferenceable after dereferenceable respects 
NullPointerIsValid.
+  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12) %0)
 }
 
 // CHECK-YES: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12))
-// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12))
+// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12))



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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D91311#2418881 , @ldionne wrote:

> In D91311#2417293 , @rsmith wrote:
>
>> In D91311#2416940 , @ldionne wrote:
>>
>>> LGTM from the libc++ point of view. The CI is passing -- those failures are 
>>> flaky modules tests that we need to fix.
>>
>> Perhaps we need to specify `-fmodules-validate-system-headers` in the test 
>> so Clang doesn't assume that system headers are unchanged?
>
> Oh, would that be it? We're not including libc++ headers as system headers 
> when running the tests, though (and we're disabling the system header 
> pragma). Do you think that might still be the issue?

The module map lists `std` as being `[system]` module, so I think the headers 
will still end up being treated as system headers. So yes, I think there's a 
possibility that is still the issue.

> I tried a dumb workaround with D92131 , but 
> it's arguably not great. I'd love to have your thoughts on that.

I'm not sure that'll make any difference: at least in my setup, `%t` expands to 
the same path on subsequent invocations of the same test, so you'll still reuse 
module caches from one test run to the next. In Clang tests for this sort of 
thing, we have explicit `RUN: rm -rf %t/ModuleCache` lines to clean up any 
stale module cache before running a test... but that shouldn't really be 
necessary; Clang should be able to detect when the files are out of date.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D92297: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 308454.
MaskRay marked an inline comment as done.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Fix a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92297

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/this-nonnull.cpp


Index: clang/test/CodeGenCXX/this-nonnull.cpp
===
--- clang/test/CodeGenCXX/this-nonnull.cpp
+++ clang/test/CodeGenCXX/this-nonnull.cpp
@@ -12,8 +12,9 @@
   s.ReturnsVoid();
 
   // CHECK-YES: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12) %0)
-  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12) %0)
+  /// FIXME Use dereferenceable after dereferenceable respects 
NullPointerIsValid.
+  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12) %0)
 }
 
 // CHECK-YES: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12))
-// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12))
+// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12))
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2168,13 +2168,21 @@
 if (!CodeGenOpts.NullPointerIsValid &&
 getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
   Attrs.addAttribute(llvm::Attribute::NonNull);
+  Attrs.addDereferenceableAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid. However, dereferenceable currently does not always
+  // respect NullPointerIsValid and may imply nonnull and break the 
program.
+  // See https://reviews.llvm.org/D66618 for discussions.
+  Attrs.addDereferenceableOrNullAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
 }
 
-Attrs.addDereferenceableAttr(
-getMinimumObjectSize(
-FI.arg_begin()->type.castAs()->getPointeeType())
-.getQuantity());
-
 ArgAttrs[IRArgs.first] = llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 


Index: clang/test/CodeGenCXX/this-nonnull.cpp
===
--- clang/test/CodeGenCXX/this-nonnull.cpp
+++ clang/test/CodeGenCXX/this-nonnull.cpp
@@ -12,8 +12,9 @@
   s.ReturnsVoid();
 
   // CHECK-YES: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull dereferenceable(12) %0)
-  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable(12) %0)
+  /// FIXME Use dereferenceable after dereferenceable respects NullPointerIsValid.
+  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable_or_null(12) %0)
 }
 
 // CHECK-YES: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull dereferenceable(12))
-// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable(12))
+// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable_or_null(12))
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2168,13 +2168,21 @@
 if (!CodeGenOpts.NullPointerIsValid &&
 getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
   Attrs.addAttribute(llvm::Attribute::NonNull);
+  Attrs.addDereferenceableAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid. However, dereferenceable currently does not always
+  // respect NullPointerIsValid and may imply nonnull and break the program.
+  // See https://reviews.llvm.org/D66618 for discussions.
+  Attrs.addDereferenceableOrNullAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
 }
 
-Attrs.addDereferenceableAttr(
-getMinimumObjectSize(
-FI.arg_begin()->type.castAs()->getPointeeType())
-.getQuantity());
-
 ArgAttrs[IRArgs.first] = llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80450: [CUDA][HIP] Fix HD function resolution

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



Comment at: clang/test/SemaCUDA/function-overload.cu:616
+// HDs have type mismatch whereas H has type match.
+// In device compilation, H wins when -fgpu-defer-diag is off and two HD win
+// when -fgpu-defer-diags is on. In both cases the diagnostic should be

tra wrote:
> One thing that bothers me about this comment is that `-fgpu-defer-diag` 
> apparently changes the result of the overload resolution, not just deferring 
> diags.
without -fgpu-defer-diag we have to keep the old incorrect overloading 
resolution since otherwise it breaks existing code.

We can only have correct overloading resolution with -fgpu-defer-diag on.

If we want to have correct overloading resolution, not depending on whether 
-fgpu-defer-diag is on or off, we have to turn on -fgpu-defer-diag by default. 
In this case no existing code will be broken.


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

https://reviews.llvm.org/D80450

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


[PATCH] D92297: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Looks good. There are a few other places where we unconditionally insert 
`dereferenceable` attributes (for reference parameters / return types, and for 
C99's `T [static]` array parameters). We should presumably apply the same 
workaround everywhere we add `dereferenceable`.




Comment at: clang/lib/CodeGen/CGCall.cpp:2178
+  // NullPointerIsValid.  However, dereferenceable currently does not 
always
+  // respect NullPointerIsValid and may imply nonnul and break the program.
+  // See https://reviews.llvm.org/D4 for discussions.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92297

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-11-30 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/BreakableToken.cpp:790
+  (Style.Language != FormatStyle::LK_TextProto ||
+   OriginalPrefix[i].substr(0, 2) != "##")) {
+Prefix[i] = IndentPrefix.str();

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > is this case covered by a unit test at all? sorry can you explain why you 
> > are looking for "##"?
> It is covered by multiple tests, that's how I was made aware of it. :)
> If you look at the code before it only adds a space if the old prefix is "#" 
> not "##" which is also found by `getLineCommentIndentPrefix`. As it seems in 
> `TextProto` "##" should not be touched. I can of course add a test in my test 
> function.
> 
> Now I see a change, in the code before "#" was only accepted when the 
> language is `TextProto`, now it is always. But I think for that to happen the 
> parser (or lexer?) should have assigned something starting with"#" as 
> comment, right? But I can change that.
Okay # # is formatted, I try again:
If you look at the code before it only adds a space if the old prefix is "#" 
not "`##`" which is also found by `getLineCommentIndentPrefix`. As it seems in 
`TextProto` "`##`" should not be touched.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-11-30 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked 2 inline comments as done.
HazardyKnusperkeks added a comment.

In D92257#2422381 , @MyDeveloperDay 
wrote:

> I think fundamentally from my perspective this seem ok, out of interest can I 
> ask what drove you to require it?
>
> My assumption is that some people write comments like
>
>   // Free comment without space
>
> and you want to be able to consistently format it to be (N spaces, as 
> clang-format already does 1 space correct?)
>
>   //  Free comment without space
>
> is that correct? is there a common style guide asking for that? what is the 
> rationale

I will go for `{0,0}`, so no space between `//` and the text, I don't know 
about a style guide asking for it, other than my own. (Which I can dictate in 
my company.) :)
I have just recently started using clang-format and it does not everything the 
the way I want to, on some aspects I have adapted, but on others I try to "fix" 
it, you can expect some more changes from me in the next time.




Comment at: clang/lib/Format/BreakableToken.cpp:790
+  (Style.Language != FormatStyle::LK_TextProto ||
+   OriginalPrefix[i].substr(0, 2) != "##")) {
+Prefix[i] = IndentPrefix.str();

MyDeveloperDay wrote:
> is this case covered by a unit test at all? sorry can you explain why you are 
> looking for "##"?
It is covered by multiple tests, that's how I was made aware of it. :)
If you look at the code before it only adds a space if the old prefix is "#" 
not "##" which is also found by `getLineCommentIndentPrefix`. As it seems in 
`TextProto` "##" should not be touched. I can of course add a test in my test 
function.

Now I see a change, in the code before "#" was only accepted when the language 
is `TextProto`, now it is always. But I think for that to happen the parser (or 
lexer?) should have assigned something starting with"#" as comment, right? But 
I can change that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D91874: [GNU ObjC] Fix a regression listing methods twice.

2020-11-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Functionally LGTM.  I don't know if 11 is still taking changes, but if it is, 
you have code-owner approval.




Comment at: clang/test/CodeGenObjC/gnu-method-only-once.m:8
+// merging happened was missed in the move and so we ended up emitting two
+// copies of method metadata for everything that appeared in the 
+

Comment trails off.  Not sure the bug history is necessary here; you could just 
make this part of the commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91874

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


[PATCH] D92340: [libTooling][NFC] Remove deprecated Clang Transformer declarations

2020-11-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfdff677a9557: [libTooling] Remove deprecated Clang 
Transformer declarations (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92340

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -21,12 +21,21 @@
 using namespace tooling;
 using namespace ast_matchers;
 namespace {
+using ::clang::transformer::addInclude;
+using ::clang::transformer::applyFirst;
+using ::clang::transformer::before;
+using ::clang::transformer::cat;
+using ::clang::transformer::changeTo;
+using ::clang::transformer::makeRule;
+using ::clang::transformer::member;
+using ::clang::transformer::name;
+using ::clang::transformer::node;
+using ::clang::transformer::remove;
+using ::clang::transformer::rewriteDescendants;
+using ::clang::transformer::RewriteRule;
+using ::clang::transformer::statement;
 using ::testing::ElementsAre;
 using ::testing::IsEmpty;
-using transformer::cat;
-using transformer::changeTo;
-using transformer::rewriteDescendants;
-using transformer::RewriteRule;
 
 constexpr char KHeaderContents[] = R"cc(
   struct string {
@@ -339,8 +348,9 @@
 
 TEST_F(TransformerTest, NodePartMember) {
   StringRef E = "expr";
-  RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
-  changeTo(member(std::string(E)), cat("good")));
+  RewriteRule Rule =
+  makeRule(memberExpr(clang::ast_matchers::member(hasName("bad"))).bind(E),
+   changeTo(member(std::string(E)), cat("good")));
 
   std::string Input = R"cc(
 struct S {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -439,7 +439,3 @@
 }
 
 const llvm::StringRef RewriteRule::RootID = ::clang::transformer::RootID;
-
-TextGenerator tooling::text(std::string M) {
-  return std::make_shared(std::move(M));
-}
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -446,28 +446,6 @@
  const RewriteRule );
 } // namespace detail
 } // namespace transformer
-
-namespace tooling {
-// DEPRECATED: These are temporary aliases supporting client migration to the
-// `transformer` namespace.
-/// Wraps a string as a TextGenerator.
-using TextGenerator = transformer::TextGenerator;
-
-TextGenerator text(std::string M);
-
-using transformer::addInclude;
-using transformer::applyFirst;
-using transformer::change;
-using transformer::insertAfter;
-using transformer::insertBefore;
-using transformer::makeRule;
-using transformer::remove;
-using transformer::RewriteRule;
-using transformer::IncludeFormat;
-namespace detail {
-using namespace transformer::detail;
-} // namespace detail
-} // namespace tooling
 } // namespace clang
 
 #endif // LLVM_CLANG_TOOLING_TRANSFORMER_REWRITE_RULE_H_
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -103,26 +103,6 @@
 /// `SourceManager::getExpansionRange`.
 RangeSelector expansion(RangeSelector S);
 } // namespace transformer
-
-namespace tooling {
-// DEPRECATED: These are temporary aliases supporting client migration to the
-// `transformer` namespace.
-using RangeSelector = transformer::RangeSelector;
-
-using transformer::after;
-using transformer::before;
-using transformer::callArgs;
-using transformer::charRange;
-using transformer::elseBranch;
-using transformer::expansion;
-using transformer::initListElements;
-using transformer::member;
-using transformer::name;
-using transformer::node;
-using transformer::range;
-using transformer::statement;
-using transformer::statements;
-} // namespace tooling
 } // namespace clang
 
 #endif // LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_
Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- 

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-30 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

> I didn't sense any agreement or any sort of a conclusion on the RFC. 
> Moreover, I didn't feel at all that the existing address space attribute was 
> a good fit. I was suggesting to add a different attribute that isn't an 
> address space attribute from Embedded C. I don't understand what you gain 
> from the existing address space attribute at the moment.

We re-use a lot functionality across clang libraries: parser (re-use existing 
attributes), semantic analysis (e.g. applying multiple AS attributes, type 
conversion, etc), code generation (mapping address space attribute to LLVM 
address spaces required by LLVM-SPIRV translator). We will have to duplicate 
this functionality for a new attribute set.

> It was mentioned that the changes in the type system with address spaces is 
> undesirable for SYCL because you indend to parse existing C++ code as-is. 
> This contradicts the intended semantic of address spaces where the whole 
> point of it is to modify the standard types and therefore a compilation of 
> C++ with the standard semantic is only guaranteed when the attribute is not 
> used at all.

Right, but I don't think it's related to the address space attributes. It was 
mentioned in the context of re-using OpenCL *mode* for SYCL device compilation, 
which modifies types which does use address space attribute explicitly. 
"Existing C++ code" doesn't use address space attributes and our solution does 
differentiate explicitly annotated type. The difference with OpenCL mode is 
that SYCL doesn't change types by modifying "default" address space attribute 
and allows conversion from/to "default" address space. As I mentioned in RFC, 
according to my understanding this patch doesn't contradict Embedded C 
requirements regarding address space attribute usage. I think the spec allows 
an implementation to define conversion rules between address spaces and doesn't 
imply type change based on the declaration scope - it's OpenCL specific 
behavior.

> I understand that you workaround this issue by adding the implicit 
> conversions to obtain a flat address space and then recover the address 
> spaces back in CodeGen, but this is doesn't seem like a good use of this 
> attribute.

I'm not sure we understand it the same way. We use this attribute the same way 
OpenCL does. Compiler adds implicit conversion for mismatched types in OpenCL 
mode as well, the difference is in additional type modifications clang applies 
in OpenCL, which are not applied in SYCL mode to keep C++ templates functional.

> If we all start to alter the semantic of the attribute then we won't be able 
> to make any sense out of it. This will impact future development as any 
> refactoring, improvements and evolution would require the understanding of 
> the special cases that we add.  I am worried about the impact on the 
> community for future work. This is why I was suggesting to add a completely 
> new attribute.

You suggest adding new parsed attributes, right? This patch adds new semantic 
attributes, so they should not alter semantic of any existing attributes 
anymore.
 

> Perhaps to unblock your work it would be good to have a summary of what 
> functionality you require from the address space attribute and what needs to 
> work differently. Then at least it would be more clear if the attribute is a 
> good fit here and if so what difference in its semantic will be brought by 
> SYCL customizations. Whichever route we decide to go ahead, the documentation 
> of intended language semantic should be added somewhere publicly accessible 
> to facilitate adequate code review and maintenance because as far as I am 
> aware it is not documented as part of the SYCL spec or any other 
> documentation resource.

The only difference directly related to clang's "opencl_*" address space 
attributes is that SYCL allows conversion between types with OpenCL address 
space attributes and "default" address space, but it's an implementation 
detail. The main sematic difference is that SYCL doesn't change "default" 
address space and it's "visible" with template metaprogramming or type 
deduction at compile time. It looks like the best place to describe this 
difference is a separate document similar to 
https://clang.llvm.org/docs/OpenCLSupport.html, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[clang] fdff677 - [libTooling] Remove deprecated Clang Transformer declarations

2020-11-30 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-11-30T20:15:26Z
New Revision: fdff677a955730b3e85b870ff1b30d7f8ea5719c

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

LOG: [libTooling] Remove deprecated Clang Transformer declarations

A number of declarations were leftover after the move from `clang::tooling` to
`clang::transformer`. This patch removes those declarations and upgrades the
handful of references to the deprecated declarations.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
clang/include/clang/Tooling/Transformer/RangeSelector.h
clang/include/clang/Tooling/Transformer/RewriteRule.h
clang/lib/Tooling/Transformer/RewriteRule.cpp
clang/unittests/Tooling/TransformerTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
index 87af9ea6cd5a..cd890e4837e0 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
@@ -29,6 +29,7 @@ using ::clang::transformer::cat;
 using ::clang::transformer::change;
 using ::clang::transformer::makeRule;
 using ::clang::transformer::node;
+using ::clang::transformer::RewriteRule;
 
 static const char DefaultStringLikeClasses[] = "::std::basic_string;"
"::std::basic_string_view;"
@@ -69,7 +70,7 @@ MakeRule(const LangOptions ,
 hasArgument(1, cxxDefaultArgExpr())),
   onImplicitObjectArgument(expr().bind("string_being_searched")));
 
-  tooling::RewriteRule rule = applyFirst(
+  RewriteRule rule = applyFirst(
   {makeRule(binaryOperator(hasOperatorName("=="),
hasOperands(ignoringParenImpCasts(StringNpos),
ignoringParenImpCasts(StringFind))),

diff  --git 
a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
index 536d6f8ef275..e8df4bb60071 100644
--- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -23,6 +23,7 @@ using namespace ::clang::ast_matchers;
 using transformer::cat;
 using transformer::change;
 using transformer::IncludeFormat;
+using transformer::makeRule;
 using transformer::node;
 using transformer::RewriteRule;
 using transformer::statement;
@@ -30,14 +31,14 @@ using transformer::statement;
 // Invert the code of an if-statement, while maintaining its semantics.
 RewriteRule invertIf() {
   StringRef C = "C", T = "T", E = "E";
-  RewriteRule Rule = tooling::makeRule(
-  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
- hasElse(stmt().bind(E))),
-  change(statement(std::string(RewriteRule::RootID)),
- cat("if(!(", node(std::string(C)), ")) ",
- statement(std::string(E)), " else ",
- statement(std::string(T,
-  cat("negate condition and reverse `then` and `else` branches"));
+  RewriteRule Rule =
+  makeRule(ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+  hasElse(stmt().bind(E))),
+   change(statement(std::string(RewriteRule::RootID)),
+  cat("if(!(", node(std::string(C)), ")) ",
+  statement(std::string(E)), " else ",
+  statement(std::string(T,
+   cat("negate condition and reverse `then` and `else` branches"));
   return Rule;
 }
 
@@ -70,10 +71,9 @@ TEST(TransformerClangTidyCheckTest, Basic) {
 class IntLitCheck : public TransformerClangTidyCheck {
 public:
   IntLitCheck(StringRef Name, ClangTidyContext *Context)
-  : TransformerClangTidyCheck(tooling::makeRule(integerLiteral(),
-change(cat("LIT")),
-cat("no message")),
-  Name, Context) {}
+  : TransformerClangTidyCheck(
+makeRule(integerLiteral(), change(cat("LIT")), cat("no message")),
+Name, Context) {}
 };
 
 // Tests that two changes in a single macro expansion do not lead to conflicts
@@ -95,7 +95,7 @@ class BinOpCheck : public TransformerClangTidyCheck {
 public:
   BinOpCheck(StringRef Name, ClangTidyContext *Context)
   : TransformerClangTidyCheck(
-tooling::makeRule(
+makeRule(
 

[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-11-30 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D71124#2423633 , @oceanfish81 wrote:

> @khchen ,
> how should I obtain available (v)CPU features?
> Any sample code, that should work on RISC-V?

Probably `getauxval(AT_HWCAP)`; both Linux and FreeBSD put the ISA string in 
the low 26 bits in the same vein as `misa`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124

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


  1   2   3   >