[clang] dac582a - DebugInfo: Name class templates with default arguments consistently (both direct naming, and as a template argument for a function template)

2021-07-17 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-07-17T23:58:15-07:00
New Revision: dac582ad3a78b18bdd2e6615f1ec105ee05adfe1

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

LOG: DebugInfo: Name class templates with default arguments consistently (both 
direct naming, and as a template argument for a function template)

It's noteworthy that GCC has the same bug here, which is a bit
surprising. Both Clang and GCC's bug is only for function template
arguments that are themselves templates with default template arguments
(f1>). Probably because function name
matching isn't generally necessary - whereas type matching is necessary
for DWARF consumers to associate declarations and definitions across
translation units, so the bug's been addressed there already - but
continued to exist for function templates since it's fairly benign
there.

I came across this while working on a change that could reconstitute
these pretty printed names based on the rest of the DWARF, reducing the
size of the DWARF by not having to encode all the template parameters in
the name string. That reconstitution code can't tell the difference
between a defaulted argument or not, so couldn't create the current
buggy-ish output.

Making the names more consistent between direct and indirect references,
and between function and class templates seems all to the good.

(I fixed the function template version of this a few years back in
9fdd09a4ccd01feb8e00be22b17e944e46807746 - clearly I should've looked
more closely and generalized the code better so it only had to be fixed
once - well, doing that here now)

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index e4c3af07e664..432e2400a440 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -249,26 +249,7 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
 }
 
 StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) {
-  assert(FD && "Invalid FunctionDecl!");
-  IdentifierInfo *FII = FD->getIdentifier();
-  FunctionTemplateSpecializationInfo *Info =
-  FD->getTemplateSpecializationInfo();
-
-  if (!Info && FII)
-return FII->getName();
-
-  SmallString<128> NS;
-  llvm::raw_svector_ostream OS(NS);
-  FD->printName(OS);
-
-  // Add any template specialization args.
-  if (Info) {
-const TemplateArgumentList *TArgs = Info->TemplateArguments;
-printTemplateArgumentList(OS, TArgs->asArray(), getPrintingPolicy());
-  }
-
-  // Copy this name on the side and use its reference.
-  return internString(OS.str());
+  return internString(GetName(FD));
 }
 
 StringRef CGDebugInfo::getObjCMethodName(const ObjCMethodDecl *OMD) {
@@ -301,16 +282,8 @@ StringRef CGDebugInfo::getSelectorName(Selector S) {
 
 StringRef CGDebugInfo::getClassName(const RecordDecl *RD) {
   if (isa(RD)) {
-SmallString<128> Name;
-llvm::raw_svector_ostream OS(Name);
-PrintingPolicy PP = getPrintingPolicy();
-PP.PrintCanonicalTypes = true;
-PP.SuppressInlineNamespace = false;
-RD->getNameForDiagnostic(OS, PP,
- /*Qualified*/ false);
-
 // Copy this name on the side and use its reference.
-return internString(Name);
+return internString(GetName(RD));
   }
 
   // quick optimization to avoid having to intern strings that are already
@@ -4003,12 +3976,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, 
SourceLocation Loc,
 return;
 
   llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {
-std::string Name;
-llvm::raw_string_ostream OS(Name);
-if (const NamedDecl *ND = dyn_cast(D))
-  ND->getNameForDiagnostic(OS, getPrintingPolicy(),
-   /*Qualified=*/true);
-return Name;
+return GetName(D, true);
   });
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
@@ -4776,6 +4744,18 @@ llvm::DIGlobalVariableExpression 
*CGDebugInfo::CollectAnonRecordDecls(
   return GVE;
 }
 
+std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const {
+  std::string Name;
+  llvm::raw_string_ostream OS(Name);
+  if (const NamedDecl *ND = dyn_cast(D)) {
+PrintingPolicy PP = getPrintingPolicy();
+PP.PrintCanonicalTypes = true;
+PP.SuppressInlineNamespace = false;
+ND->getNameForDiagnostic(OS, PP, Qualified);
+  }
+  return Name;
+}
+
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
  const VarDecl *D) {
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
@@ -4783,11 +4763,7 @@ void 
CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
 return;
 
   llvm::TimeTraceScope TimeS

[PATCH] D106119: [Driver] Detect libstdc++ include paths for native gcc on 32-bit non-Debian Linux

2021-07-17 Thread Luke Benes via Phabricator via cfe-commits
lbenes added a comment.

Updated OpenSUSE which bumped gcc from 10 to 11. Still failing with the latest 
patch.

https://controlc.com/c4a19d64


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106119

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


[PATCH] D105911: [CallGraphSection] Introduce CGSectionFuncComdatCreator pass

2021-07-17 Thread Necip Fazil Yildiran via Phabricator via cfe-commits
necipfazil abandoned this revision.
necipfazil added a comment.

In D105911#2878345 , @morehouse wrote:

> Are comdats needed?  Can we get proper dead stripping with just 
> `SHF_LINK_ORDER`?

It looks like we can. I am abandoning this revision. I will shortly push the 
changes to related revisions for not using comdats.

> @MaskRay recently updated the documentation for associated metadata 
>  to imply that our 
> symbol doesn't need to share a comdat with its associated function when the 
> function doesn't have a comdat.
>
> Also, @MaskRay: Can adding comdats like this change the final code in the 
> fully-linked binary?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105911

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


[PATCH] D105907: [CallGraphSection] Add call graph section options and documentation

2021-07-17 Thread Necip Fazil Yildiran via Phabricator via cfe-commits
necipfazil updated this revision to Diff 359592.
necipfazil added a comment.

Change call graph section layout

- Changed the call graph section layout
- Extended the example
- Updated the documentation

In the previous version, the call graph section layout was optimized for
entries with unique type ids in which to list any indirect calls and targets
with such type id. However, the implementation requirements prevented sharing
information from different functions in the same entry. The main reason is
the need for separate entries per functions to allow dead-stripping.

As the previous layout was suboptimal for per-function call graph section
entries, a new layout is created. Please see the updated documentation for the
new layout.

The new layout has the following advantages:

- The previous layout allowed multiple indirect targets to be listed in a 
single entry. However, there was no use since each entry was created for a 
single function. With the new layout, an entry is said to belong to a function, 
and lists info on the function and its indirect callsites. Consequently, the 
layout is designed for per-function entry approach.
- The previous layout listed callsites per type id as `(TypeId, 
CallSitesWithTypeIdCount, [CallSite1WithTypeId, ...])`. However, now that the 
callsites are listed per function, a small number of callsites are expected for 
each type id. Therefore, they are now listed as `(TypeId, CallSite)` pairs to 
avoid wasting space on count values that are usually 1.
- In the previous layout, if a function was not an indirect target, its entry 
PC was not included. This prevented making the distinction between
  1. the non-indirect target functions and 2) those functions that we had no 
information about (e.g., functions from linked objects with no call graph 
section). With the new layout, the function entry PC is always listed. It is 
marked as non-indirect target if so. For completeness, the user still needs to 
take any function with missing information as receiver to any indirect calls. 
However, the user can avoid doing the same for the non-indirect targets as 
their entry PCs are now listed, which improves the precision for the resulting 
call graph.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105907

Files:
  clang/docs/CallGraphSection.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp

Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -86,6 +86,7 @@
 CGOPT(DebuggerKind, DebuggerTuningOpt)
 CGOPT(bool, EnableStackSizeSection)
 CGOPT(bool, EnableAddrsig)
+CGOPT(bool, EnableCallGraphSection)
 CGOPT(bool, EmitCallSiteInfo)
 CGOPT(bool, EnableMachineFunctionSplitter)
 CGOPT(bool, EnableDebugEntryValues)
@@ -407,6 +408,11 @@
   cl::init(false));
   CGBINDOPT(EnableAddrsig);
 
+  static cl::opt EnableCallGraphSection(
+  "call-graph-section", cl::desc("Emit a call graph section"),
+  cl::init(false));
+  CGBINDOPT(EnableCallGraphSection);
+
   static cl::opt EmitCallSiteInfo(
   "emit-call-site-info",
   cl::desc(
@@ -520,6 +526,7 @@
   Options.EmitStackSizeSection = getEnableStackSizeSection();
   Options.EnableMachineFunctionSplitter = getEnableMachineFunctionSplitter();
   Options.EmitAddrsig = getEnableAddrsig();
+  Options.EmitCallGraphSection = getEnableCallGraphSection();
   Options.EmitCallSiteInfo = getEmitCallSiteInfo();
   Options.EnableDebugEntryValues = getEnableDebugEntryValues();
   Options.PseudoProbeForProfiling = getPseudoProbeForProfiling();
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -127,11 +127,11 @@
   EmulatedTLS(false), ExplicitEmulatedTLS(false), EnableIPRA(false),
   EmitStackSizeSection(false), EnableMachineOutliner(false),
   EnableMachineFunctionSplitter(false), SupportsDefaultOutlining(false),
-  EmitAddrsig(false), EmitCallSiteInfo(false),
-  SupportsDebugEntryValues(false), EnableDebugEntryValues(false),
-  PseudoProbeForProfiling(false), ValueTrackingVariableLocations(false),
-  ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false),
-  DebugStrictDwarf(false),
+  EmitAddrsig(false), EmitCallGraphSection(false),
+  EmitCallSiteInfo(false), SupportsDebugEntryValues(false),
+  EnableDebugEntryValues(false), PseudoProbeForProfiling(false),
+  ValueTrackingVariableLocations(false), F

[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-07-17 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 359590.

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

https://reviews.llvm.org/D103426

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/FormatString.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp

Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -1962,18 +1962,6 @@
   return false;
 }
 
-bool Type::isType(const std::string TypeName) const {
-  QualType Desugar = this->getLocallyUnqualifiedSingleStepDesugaredType();
-  
-  
-  while (!Desugar->isCanonicalUnqualified()) {
-if (Desugar.getAsString() == TypeName) {
-  return true;
-}
-Desugar = Desugar->getLocallyUnqualifiedSingleStepDesugaredType();
-  }
-}
-
 bool Type::isChar8Type() const {
   if (const BuiltinType *BT = dyn_cast(CanonicalType))
 return BT->getKind() == BuiltinType::Char8;
@@ -1985,7 +1973,15 @@
 if (BT->getKind() == BuiltinType::Char16)
   return true;
   if (!LangOpts.CPlusPlus) {
-return isType("char16_t");
+QualType Desugar = this->getLocallyUnqualifiedSingleStepDesugaredType();
+
+
+while (!Desugar->isCanonicalUnqualified()) {
+  if (Desugar.getAsString() == "char16_t") {
+return true;
+  }
+  Desugar = Desugar->getLocallyUnqualifiedSingleStepDesugaredType();
+}
   }
   return false;
 }
@@ -1995,7 +1991,14 @@
 if (BT->getKind() == BuiltinType::Char32)
   return true;
   if (!LangOpts.CPlusPlus) {
-return isType("char32_t");
+QualType Desugar = this->getLocallyUnqualifiedSingleStepDesugaredType();
+
+while (!Desugar->isCanonicalUnqualified()) {
+  if (Desugar.getAsString() == "char32_t") {
+return true;
+  }
+  Desugar = Desugar->getLocallyUnqualifiedSingleStepDesugaredType();
+}
   }
   return false;
 }
Index: clang/lib/AST/PrintfFormatString.cpp
===
--- clang/lib/AST/PrintfFormatString.cpp
+++ clang/lib/AST/PrintfFormatString.cpp
@@ -643,6 +643,9 @@
  "const unichar *");
 return ArgType(ArgType::WCStrTy, "wchar_t *");
   }
+  if (LM.getKind() == LengthModifier::AsWide) {
+return ArgType(ArgType::WCStrTy, "wchar_t *");
+  }
   if (LM.getKind() == LengthModifier::AsUTF16)
 return ArgType(ArgType::Char16Ty, "char16_t *");
   if (LM.getKind() == LengthModifier::AsUTF32)
@@ -860,6 +863,9 @@
 LM.setKind(LengthModifier::AsLongDouble);
 break;
   
+  case BuiltinType::Char8:
+LM.setKind(LengthModifier::AsUTF8);
+  
   case BuiltinType::Char16:
 LM.setKind(LengthModifier::AsUTF16);
 break;
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1331,6 +1331,8 @@
  const LangOptions &Features,
  const TargetInfo &Target, unsigned *StartToken,
  unsigned *StartTokenByteOffset) const {
+  assert((getKind() == StringLiteral::Ascii || getKind() == StringLiteral::UTF8) &&
+ "Only narrow string literals are currently supported");
   // Loop over all of the tokens in this string until we find the one that
   // contains the byte we're looking for.
   unsigned TokNo = 0;
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1972,7 +1972,6 @@
   /// Determine whether this type is a scoped enumeration type.
   bool isScopedEnumeralType() const;
   bool isBooleanType() const;
-  bool isType(const std::string TypeName) const;
   bool isCharType() const;
   bool isChar8Type() const;
   bool isWideCharType() const;
Index: clang/include/clang/AST/FormatString.h
===
--- clang/include/clang/AST/FormatString.h
+++ clang/include/clang/AST/FormatString.h
@@ -80,8 +80,8 @@
 AsLongDouble, // 'L'
 AsAllocate,   // for '%as', GNU extension to C90 scanf
 AsMAllocate,  // for '%ms', GNU extension to scanf
-AsUTF16,  // for '%l16(c|s)', soon to be standardized
-AsUTF32,  // for '%l32(c|s)', soon to be standardized
+AsUTF16,  // for '%l16(c|s)', Clang extension
+AsUTF32,  // for '%l32(c|s)', Clang extension
 AsWide,   // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
 AsWideChar = AsLong // for '%ls', only makes sense for printf
   };
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -1850,21 +1850,18 @@
   std::u16string getStringAsChar16() const {
 assert(g

[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-07-17 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added inline comments.



Comment at: clang/include/clang/AST/Expr.h:1846-1871
+  std::string getStringAsChar() const {
+assert(getCharByteWidth() == 1 &&
+   "This function is used in places that assume strings use char");
+return std::string(getTrailingObjects(), getTrailingObjects() 
+ getByteLength());
+  }
+  
+  std::u16string getStringAsChar16() const {

cor3ntin wrote:
> aaron.ballman wrote:
> > One potential issue to this is that in C++, these types are defined to be 
> > UTF-16 and UTF-32, whereas in C, that isn't always the case. Currently, 
> > Clang defines `__STDC_UTF_16__` and `__STDC_UTF_32__` on all targets, but 
> > we may need to add some sanity checks to catch if a target overrides that 
> > behavior. Currently, all the targets in Clang are keeping that promise, but 
> > I have no idea what shenanigans downstream users get up to and whether 
> > their targets remove the macro definition or define it to `0` instead of 
> > `1`.
> Is it possible that the host and target wchar_t have a different size here?
I've honestly been wondering how Clang handled that, in the codebase vs at 
runtime myself for a while.



Comment at: clang/include/clang/AST/FormatString.h:83
 AsMAllocate,  // for '%ms', GNU extension to scanf
+AsUTF16,  // for '%l16(c|s)', soon to be standardized
+AsUTF32,  // for '%l32(c|s)', soon to be standardized

aaron.ballman wrote:
> May want to drop the "soon to be standardized" given that the proposal hasn't 
> been seen by WG14 yet. I think it's fine to say "Clang extension", though. 
> More on the format specifier itself, below.
Done,

and here is the link to the document, I haven't heard any feedback?

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2761.pdf



Comment at: clang/include/clang/AST/Type.h:1975
   bool isBooleanType() const;
+  bool isType(const std::string TypeName) const;
   bool isCharType() const;

aaron.ballman wrote:
> It's not clear from the header file what this function actually *does*. 
> Presumably, everything that can be represented by a `Type` is a type, so I'd 
> assume this returns `true` always. Or should this be a static function?
Yeah, could choose a better name just not sure what.

It takes a type name as the argument, and then it desugars the type one step at 
a time, and if it finds a match it returns true.

so, let's say we're in C++, and someone typedef'd char8_t to String.

This function will say yes, String is compatible with char8_t for example.

it's mostly for C mode's typedef's of char16_t and char32_t



Comment at: clang/lib/AST/Expr.cpp:1197
  unsigned *StartTokenByteOffset) const {
-  assert((getKind() == StringLiteral::Ascii ||
-  getKind() == StringLiteral::UTF8) &&

aaron.ballman wrote:
> I don't see changes that make this assertion valid to remove -- have I missed 
> something?
Nope you didn't miss anything, I did.

this is a remnant from when I was trying to templatize all the format checking 
code instead of converting the format strings.

Restored the assert.



Comment at: clang/lib/AST/FormatString.cpp:235-240
+  if (LO.C2x && I + 1 != E && I[0] == '1' && I[1] == '6') {
+++I;
+++I;
+lmKind = LengthModifier::AsUTF16;
+break;
+  } else if (LO.C2x && I + 1 != E && I[0] == '3' && I[1] == '2') {

aaron.ballman wrote:
> I don't think this is a conforming extension to C -- lowercase length 
> modifiers and conversion specifiers are reserved for the standard, and 
> uppercase length modifiers and conversion specifiers are reserved for the 
> implementation. `l16` starts with a lowercase letter, so it's reserved for 
> the standard.
> 
> Note: WG14 has been considering extensions in a closely-related space 
> (integer types rather than string or character types) that you may be 
> interested in, if you're not already aware of it: 
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2511.pdf. This proposal was 
> not adopted, but did have strong sentiment for something along these lines.
Yeah, honestly not really sure what to do about the reservation, L is also used 
for wide characters and some integers too, and (U|u)(16|32) wasn't taken well 
by the community.



Comment at: clang/lib/AST/OSLog.cpp:212
+  } else if (Lit->isUTF16()) {
+std::wstring_convert, char16_t> Convert;
+std::u16string U16 = Lit->getStringAsChar16();

aaron.ballman wrote:
> MarcusJohnson91 wrote:
> > aaron.ballman wrote:
> > > cor3ntin wrote:
> > > > I'm not sure I have a better suggestion but `codecvt_utf8_utf16` is 
> > > > deprecated in C++17
> > > Good point -- this likely should be lifted into a common interface (as it 
> > > appears several times in the patch) and make use of the existing L

[PATCH] D106227: Fix duplicate checks in clangd documentation

2021-07-17 Thread Elton Leander Pinto via Phabricator via cfe-commits
1ntEgr8 created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
1ntEgr8 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106227

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


Index: clang-tools-extra/clangd/ParsedAST.h
===
--- clang-tools-extra/clangd/ParsedAST.h
+++ clang-tools-extra/clangd/ParsedAST.h
@@ -13,7 +13,7 @@
 // we have several customizations:
 //  - preamble handling
 //  - capturing diagnostics for later access
-//  - running clang-tidy checks checks
+//  - running clang-tidy checks
 //
 
//===--===//
 


Index: clang-tools-extra/clangd/ParsedAST.h
===
--- clang-tools-extra/clangd/ParsedAST.h
+++ clang-tools-extra/clangd/ParsedAST.h
@@ -13,7 +13,7 @@
 // we have several customizations:
 //  - preamble handling
 //  - capturing diagnostics for later access
-//  - running clang-tidy checks checks
+//  - running clang-tidy checks
 //
 //===--===//
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106112: [clang-format] Break an unwrapped line at a K&R C parameter decl

2021-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D106112#2883301 , @curdeius wrote:

> Looks okay, but I was wondering if we don't want to guard all K&R-related 
> changes behind e.g. ```Standard: Cpp78``, so as not to possibly introduce 
> strange bugs in newer modes.
> It may be an overkill if there are 2 patches like this, but if there are 
> more, that might become sensible to do so.
> WDYT?

I just reviewed the differences between K&R C (circa 1978) and ANSI/ISO C again 
and didn't see anything else that would impact clang-format, so a new Standard 
enum value for C78 is not needed. Nevertheless, we can add a boolean option 
e.g. C78ParameterDecl in the future if this patch causes regressions for some 
users. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106112

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


[clang] 6225d0c - [OpaquePtr] Remove uses of CreateInBoundsGEP() without element type

2021-07-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-07-17T21:27:16+02:00
New Revision: 6225d0cc6e6e3eef63261dda1efaf10689e33db7

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

LOG: [OpaquePtr] Remove uses of CreateInBoundsGEP() without element type

Remove uses of to-be-deprecated API.

Unfortunately this one mostly just makes the use of
getPointerElementType() explicit, as the correct type to use
wasn't immediately available (deriving it from QualType is left
as an excercise to the reader).

Added: 


Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprScalar.cpp
polly/lib/CodeGen/IslNodeBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index e9a7836bab470..de9f3f6f899c6 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2246,8 +2246,9 @@ void CodeGenFunction::emitArrayDestroy(llvm::Value *begin,
 
   // Shift the address back by one element.
   llvm::Value *negativeOne = llvm::ConstantInt::get(SizeTy, -1, true);
-  llvm::Value *element = Builder.CreateInBoundsGEP(elementPast, negativeOne,
-   "arraydestroy.element");
+  llvm::Value *element = Builder.CreateInBoundsGEP(
+  elementPast->getType()->getPointerElementType(), elementPast, 
negativeOne,
+  "arraydestroy.element");
 
   if (useEHCleanup)
 pushRegularPartialArrayCleanup(begin, element, elementType, elementAlign,
@@ -2287,8 +2288,11 @@ static void emitPartialArrayDestroy(CodeGenFunction &CGF,
 llvm::Value *zero = llvm::ConstantInt::get(CGF.SizeTy, 0);
 
 SmallVector gepIndices(arrayDepth+1, zero);
-begin = CGF.Builder.CreateInBoundsGEP(begin, gepIndices, "pad.arraybegin");
-end = CGF.Builder.CreateInBoundsGEP(end, gepIndices, "pad.arrayend");
+llvm::Type *elemTy = begin->getType()->getPointerElementType();
+begin = CGF.Builder.CreateInBoundsGEP(
+elemTy, begin, gepIndices, "pad.arraybegin");
+end = CGF.Builder.CreateInBoundsGEP(
+elemTy, end, gepIndices, "pad.arrayend");
   }
 
   // Destroy the array.  We don't ever need an EH cleanup because we

diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 5fdfa28984f74..1e81ad9f2dc7a 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -417,8 +417,8 @@ 
AggExprEmitter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
   LValue Start = CGF.EmitLValueForFieldInitialization(DestLV, *Field);
   llvm::Value *Zero = llvm::ConstantInt::get(CGF.PtrDiffTy, 0);
   llvm::Value *IdxStart[] = { Zero, Zero };
-  llvm::Value *ArrayStart =
-  Builder.CreateInBoundsGEP(ArrayPtr.getPointer(), IdxStart, "arraystart");
+  llvm::Value *ArrayStart = Builder.CreateInBoundsGEP(
+  ArrayPtr.getElementType(), ArrayPtr.getPointer(), IdxStart, 
"arraystart");
   CGF.EmitStoreThroughLValue(RValue::get(ArrayStart), Start);
   ++Field;
 
@@ -434,8 +434,8 @@ 
AggExprEmitter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
   ArrayType->getElementType())) {
 // End pointer.
 llvm::Value *IdxEnd[] = { Zero, Size };
-llvm::Value *ArrayEnd =
-Builder.CreateInBoundsGEP(ArrayPtr.getPointer(), IdxEnd, "arrayend");
+llvm::Value *ArrayEnd = Builder.CreateInBoundsGEP(
+ArrayPtr.getElementType(), ArrayPtr.getPointer(), IdxEnd, "arrayend");
 CGF.EmitStoreThroughLValue(RValue::get(ArrayEnd), EndOrLength);
   } else if (Ctx.hasSameType(Field->getType(), Ctx.getSizeType())) {
 // Length.
@@ -484,12 +484,14 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, 
llvm::ArrayType *AType,
   // down a level.
   llvm::Value *zero = llvm::ConstantInt::get(CGF.SizeTy, 0);
   llvm::Value *indices[] = { zero, zero };
-  llvm::Value *begin =
-Builder.CreateInBoundsGEP(DestPtr.getPointer(), indices, 
"arrayinit.begin");
+  llvm::Value *begin = Builder.CreateInBoundsGEP(
+  DestPtr.getElementType(), DestPtr.getPointer(), indices,
+  "arrayinit.begin");
 
   CharUnits elementSize = CGF.getContext().getTypeSizeInChars(elementType);
   CharUnits elementAlign =
 DestPtr.getAlignment().alignmentOfArrayElement(elementSize);
+  llvm::Type *llvmElementType = begin->getType()->getPointerElementType();
 
   // Consider initializing the array by copying from a global. For this to be
   // more efficient than per-element initialization, the size of the elements
@@ -552,7 +554,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, 
llvm::ArrayType *AType,
   for (uint64_t i = 0; i != NumInitElements; ++i) {
 // Advance to the next element.
 if (i > 0) {
-  element = Builder.CreateInBoundsGEP(element, one, "arrayinit.element");
+  ele

[PATCH] D106210: [MS] Preserve base register %esi around movs[bwl]

2021-07-17 Thread namazso via Phabricator via cfe-commits
namazso added a comment.

I don't have commit access, could someone commit this for me? Thanks in advance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106210

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


[PATCH] D106210: [MS] Preserve base register %esi around movs[bwl]

2021-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106210

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


[PATCH] D106184: [BPF] Use elementtype attribute for preserve.array/struct.index intrinsics

2021-07-17 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

I just tested the patch with kernel bpf selftests and it works fine. The patch 
looks good to me too.




Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:303
 CInfo.RecordAlignment =
 DL->getABITypeAlign(CInfo.Base->getType()->getPointerElementType());
 return true;

nikic wrote:
> I noticed too late that this intrinsic also uses the element type to get the 
> alignment. I'll have to follow up with the same change for this intrinsic.
> 
> Though I'm not completely sure if this is actually used, because no tests 
> fail if I replace this with dummy values like 1 or 128.
This is for llvm.preserve.union.access.index. It is used only if the union 
member type is a bitfield and we don't have any usecase and test case for that. 
That is why we didn't hit it.

It is okay for now. I probably will change to use getBaseElementType(Call) 
later by myself.


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

https://reviews.llvm.org/D106184

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


[clang] 4ace600 - [OpaquePtr] Remove uses of CreateStructGEP() without element type

2021-07-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-07-17T18:48:21+02:00
New Revision: 4ace6008f2fde781c1bedc7515e6380e449cb56a

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

LOG: [OpaquePtr] Remove uses of CreateStructGEP() without element type

Remove uses of to-be-deprecated API.

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGObjCGNU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 769501a036e6..f39a56f81d41 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1375,7 +1375,7 @@ static llvm::Constant *buildGlobalBlock(CodeGenModule 
&CGM,
 llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), "entry",
   Init));
 b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(),
- b.CreateStructGEP(literal, 0),
+ b.CreateStructGEP(literal->getValueType(), literal, 
0),
  CGM.getPointerAlign().getAsAlign());
 b.CreateRetVoid();
 // We can't use the normal LLVM global initialisation array, because we

diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 9e47dbf7bdf1..3f361f4e7931 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -945,7 +945,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   /// Generate the name of a symbol for a reference to a class.  Accesses to
   /// classes should be indirected via this.
 
-  typedef std::pair> 
EarlyInitPair;
+  typedef std::pair>
+  EarlyInitPair;
   std::vector EarlyInitList;
 
   std::string SymbolForClassRef(StringRef Name, bool isWeak) {
@@ -1096,7 +1097,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 }
   }
 }
-auto *ObjCStrGV =
+llvm::GlobalVariable *ObjCStrGV =
   Fields.finishAndCreateGlobal(
   isNamed ? StringRef(StringName) : ".objc_string",
   Align, false, isNamed ? llvm::GlobalValue::LinkOnceODRLinkage
@@ -1107,7 +1108,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   ObjCStrGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
 }
 if (CGM.getTriple().isOSBinFormatCOFF()) {
-  std::pair v{ObjCStrGV, 0};
+  std::pair v{ObjCStrGV, 0};
   EarlyInitList.emplace_back(Sym, v);
 }
 llvm::Constant *ObjCStr = llvm::ConstantExpr::getBitCast(ObjCStrGV, IdTy);
@@ -1654,9 +1655,10 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   for (const auto &lateInit : EarlyInitList) {
 auto *global = TheModule.getGlobalVariable(lateInit.first);
 if (global) {
+  llvm::GlobalVariable *GV = lateInit.second.first;
   b.CreateAlignedStore(
   global,
-  b.CreateStructGEP(lateInit.second.first, lateInit.second.second),
+  b.CreateStructGEP(GV->getValueType(), GV, 
lateInit.second.second),
   CGM.getPointerAlign().getAsAlign());
 }
   }
@@ -1938,7 +1940,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 // struct objc_property_list *properties
 classFields.add(GeneratePropertyList(OID, classDecl));
 
-auto *classStruct =
+llvm::GlobalVariable *classStruct =
   classFields.finishAndCreateGlobal(SymbolForClass(className),
 CGM.getPointerAlign(), false, llvm::GlobalValue::ExternalLinkage);
 
@@ -1949,12 +1951,12 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 if (IsCOFF) {
   // we can't import a class struct.
   if (OID->getClassInterface()->hasAttr()) {
-
cast(classStruct)->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+
classStruct->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
 
cast(classRefSymbol)->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
   }
 
   if (SuperClass) {
-std::pair v{classStruct, 1};
+std::pair v{classStruct, 1};
 EarlyInitList.emplace_back(std::string(SuperClass->getName()),
std::move(v));
   }



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


[clang] 6d3e7c7 - [OpaquePtr] Remove uses of CreateConstGEP1_32() without element type

2021-07-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-07-17T18:32:36+02:00
New Revision: 6d3e7c783b98e5663741152f046f14c934bcf612

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

LOG: [OpaquePtr] Remove uses of CreateConstGEP1_32() without element type

Remove uses of to-be-deprecated API. I've fallen back to calling
getPointerElementType() in some cases where the correct type wasn't
immediately obvious to me.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
llvm/lib/Target/AArch64/AArch64StackTagging.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7896b2a05a09..940c5888e4c7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14769,7 +14769,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 
 for (int i = 0; i < 6; ++i) {
   Value *Extract = Builder.CreateExtractValue(Call, i + 1);
-  Value *Ptr = Builder.CreateConstGEP1_32(Ops[2], i * 16);
+  Value *Ptr = Builder.CreateConstGEP1_32(Int8Ty, Ops[2], i * 16);
   Ptr = Builder.CreateBitCast(
   Ptr, llvm::PointerType::getUnqual(Extract->getType()));
   Builder.CreateAlignedStore(Extract, Ptr, Align(1));
@@ -14785,7 +14785,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 
 for (int i = 0; i < 7; ++i) {
   Value *Extract = Builder.CreateExtractValue(Call, i + 1);
-  Value *Ptr = Builder.CreateConstGEP1_32(Ops[3], i * 16);
+  Value *Ptr = Builder.CreateConstGEP1_32(Int8Ty, Ops[3], i * 16);
   Ptr = Builder.CreateBitCast(
   Ptr, llvm::PointerType::getUnqual(Extract->getType()));
   Builder.CreateAlignedStore(Extract, Ptr, Align(1));
@@ -14873,7 +14873,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 Value *InOps[9];
 InOps[0] = Ops[2];
 for (int i = 0; i != 8; ++i) {
-  Value *Ptr = Builder.CreateConstGEP1_32(Ops[1], i);
+  Value *Ptr = Builder.CreateConstGEP1_32(Ty, Ops[1], i);
   InOps[i + 1] = Builder.CreateAlignedLoad(Ty, Ptr, Align(16));
 }
 
@@ -14891,7 +14891,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 Builder.SetInsertPoint(NoError);
 for (int i = 0; i != 8; ++i) {
   Value *Extract = Builder.CreateExtractValue(Call, i + 1);
-  Value *Ptr = Builder.CreateConstGEP1_32(Ops[0], i);
+  Value *Ptr = Builder.CreateConstGEP1_32(Extract->getType(), Ops[0], i);
   Builder.CreateAlignedStore(Extract, Ptr, Align(16));
 }
 Builder.CreateBr(End);
@@ -14900,7 +14900,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 for (int i = 0; i != 8; ++i) {
   Value *Out = Builder.CreateExtractValue(Call, i + 1);
   Constant *Zero = llvm::Constant::getNullValue(Out->getType());
-  Value *Ptr = Builder.CreateConstGEP1_32(Ops[0], i);
+  Value *Ptr = Builder.CreateConstGEP1_32(Out->getType(), Ops[0], i);
   Builder.CreateAlignedStore(Zero, Ptr, Align(16));
 }
 Builder.CreateBr(End);

diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index bfd2c16c1282..88030fee501b 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -326,7 +326,8 @@ void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction 
&CGF,
 llvm::Value* VarPtr = CGF.GetAddrOfLocalVar(Args[i]).getPointer();
 llvm::Value *VoidVarPtr = CGF.Builder.CreatePointerCast(VarPtr, VoidPtrTy);
 CGF.Builder.CreateDefaultAlignedStore(
-VoidVarPtr, CGF.Builder.CreateConstGEP1_32(KernelArgs.getPointer(), 
i));
+VoidVarPtr,
+CGF.Builder.CreateConstGEP1_32(VoidPtrTy, KernelArgs.getPointer(), i));
   }
 
   llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index cc30add884f4..14129cc94ff3 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -743,13 +743,15 @@ static void EmitOMPAggregateInit(CodeGenFunction &CGF, 
Address DestAddr,
   if (DRD) {
 // Shift the address forward by one element.
 llvm::Value *SrcElementNext = CGF.Builder.CreateConstGEP1_32(
-SrcElementPHI, /*Idx0=*/1, "omp.arraycpy.dest.element");
+SrcAddr.getElementType(), SrcElementPHI, /*Idx0=*/1,
+"omp.arraycpy.dest.element");
 SrcElementPHI->addIncoming(SrcElementNext, CGF.Builder.GetInsertBlock());
   }
 
   // Shift the address forward by one element.
   llvm::Value *DestElementNext = CGF.Builder.CreateConstGEP1_32(
-  DestElementP

[clang] 5071360 - [OpaquePtr] Remove uses of CGF.Builder.CreateConstInBoundsGEP1_64() without type

2021-07-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-07-17T17:07:46+02:00
New Revision: 5071360eb1cf4a93ab72fd4ba47680a9eda98e39

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

LOG: [OpaquePtr] Remove uses of CGF.Builder.CreateConstInBoundsGEP1_64() 
without type

Remove uses of to-be-deprecated API.

Added: 


Modified: 
clang/lib/CodeGen/CGCXX.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 641740c37a68..86f548191d65 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -262,7 +262,7 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction 
&CGF,
   VTableIndex += VTLayout.getVTableOffset(AddressPoint.VTableIndex) +
  AddressPoint.AddressPointIndex;
   llvm::Value *VFuncPtr =
-CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
+CGF.Builder.CreateConstInBoundsGEP1_64(Ty, VTable, VTableIndex, "vfnkxt");
   llvm::Value *VFunc = CGF.Builder.CreateAlignedLoad(
   Ty, VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
   CGCallee Callee(GD, VFunc);

diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 19fae7657669..c998707a883f 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -493,7 +493,7 @@ llvm::Value *CodeGenFunction::GetVTTParameter(GlobalDecl GD,
   if (CGM.getCXXABI().NeedsVTTParameter(CurGD)) {
 // A VTT parameter was passed to the constructor, use it.
 llvm::Value *VTT = LoadCXXVTT();
-return Builder.CreateConstInBoundsGEP1_64(VTT, SubVTTIndex);
+return Builder.CreateConstInBoundsGEP1_64(VoidPtrTy, VTT, SubVTTIndex);
   } else {
 // We're the complete constructor, so get the VTT by name.
 llvm::GlobalValue *VTT = CGM.getVTables().GetAddrOfVTT(RD);

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 8d355a8efd50..88b189319763 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1254,7 +1254,7 @@ void 
ItaniumCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF,
 
 // Track back to entry -2 and pull out the offset there.
 llvm::Value *OffsetPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
-VTable, -2, "complete-offset.ptr");
+CGF.IntPtrTy, VTable, -2, "complete-offset.ptr");
 llvm::Value *Offset = CGF.Builder.CreateAlignedLoad(CGF.IntPtrTy, 
OffsetPtr,
CGF.getPointerAlign());
 
 // Apply the offset.
@@ -1466,7 +1466,8 @@ llvm::Value *ItaniumCXXABI::EmitTypeid(CodeGenFunction 
&CGF,
 Value = CGF.Builder.CreateBitCast(Value, StdTypeInfoPtrTy->getPointerTo());
   } else {
 // Load the type info.
-Value = CGF.Builder.CreateConstInBoundsGEP1_64(Value, -1ULL);
+Value =
+CGF.Builder.CreateConstInBoundsGEP1_64(StdTypeInfoPtrTy, Value, -1ULL);
   }
   return CGF.Builder.CreateAlignedLoad(StdTypeInfoPtrTy, Value,
CGF.getPointerAlign());
@@ -1547,7 +1548,8 @@ llvm::Value 
*ItaniumCXXABI::EmitDynamicCastToVoid(CodeGenFunction &CGF,
 CGF.GetVTablePtr(ThisAddr, PtrDiffLTy->getPointerTo(), ClassDecl);
 
 // Get the offset-to-top from the vtable.
-OffsetToTop = CGF.Builder.CreateConstInBoundsGEP1_64(VTable, -2ULL);
+OffsetToTop =
+CGF.Builder.CreateConstInBoundsGEP1_64(PtrDiffLTy, VTable, -2ULL);
 OffsetToTop = CGF.Builder.CreateAlignedLoad(
 PtrDiffLTy, OffsetToTop, CGF.getPointerAlign(), "offset.to.top");
   }
@@ -1872,7 +1874,8 @@ llvm::Value 
*ItaniumCXXABI::getVTableAddressPointInStructorWithVTT(
   /// Load the VTT.
   llvm::Value *VTT = CGF.LoadCXXVTT();
   if (VirtualPointerIndex)
-VTT = CGF.Builder.CreateConstInBoundsGEP1_64(VTT, VirtualPointerIndex);
+VTT = CGF.Builder.CreateConstInBoundsGEP1_64(
+CGF.VoidPtrTy, VTT, VirtualPointerIndex);
 
   // And load the address point from the VTT.
   return CGF.Builder.CreateAlignedLoad(CGF.VoidPtrTy, VTT,
@@ -1943,9 +1946,10 @@ CGCallee 
ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
   Address This,
   llvm::Type *Ty,
   SourceLocation Loc) {
+  llvm::Type *TyPtr = Ty->getPointerTo();
   auto *MethodDecl = cast(GD.getDecl());
   llvm::Value *VTable = CGF.GetVTablePtr(
-  This, Ty->getPointerTo()->getPointerTo(), MethodDecl->getParent());
+  This, TyPtr->getPointerTo(), MethodDecl->getParent());
 
   uint64_t VTableIndex = 
CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
   llvm::Va

[clang] 357756e - [OpaquePtr] Remove uses of CreateConstGEP1_64() without element type

2021-07-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-07-17T16:43:20+02:00
New Revision: 357756ecf67817c3db81b285b9fce0663d9ed875

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

LOG: [OpaquePtr] Remove uses of CreateConstGEP1_64() without element type

Remove uses of to-be-deprecated API.

Added: 


Modified: 
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index e5c5e5babf23..b6722ad4e4f1 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -85,7 +85,7 @@ namespace {
 (C.toCharUnitsFromBits(OrigBFI.Offset) / lvalue.getAlignment()) *
 lvalue.getAlignment();
 VoidPtrAddr = CGF.Builder.CreateConstGEP1_64(
-VoidPtrAddr, OffsetInChars.getQuantity());
+CGF.Int8Ty, VoidPtrAddr, OffsetInChars.getQuantity());
 auto Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
 VoidPtrAddr,
 CGF.Builder.getIntNTy(AtomicSizeInBits)->getPointerTo(),

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 697feafc7369..8d355a8efd50 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1576,8 +1576,9 @@ ItaniumCXXABI::GetVirtualBaseClassOffset(CodeGenFunction 
&CGF,
   CGM.getItaniumVTableContext().getVirtualBaseOffsetOffset(ClassDecl,
BaseClassDecl);
   llvm::Value *VBaseOffsetPtr =
-CGF.Builder.CreateConstGEP1_64(VTablePtr, VBaseOffsetOffset.getQuantity(),
-   "vbase.offset.ptr");
+CGF.Builder.CreateConstGEP1_64(
+CGF.Int8Ty, VTablePtr, VBaseOffsetOffset.getQuantity(),
+"vbase.offset.ptr");
 
   llvm::Value *VBaseOffset;
   if (CGM.getItaniumVTableContext().isRelativeLayout()) {

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
index e57d971b6ef7..4971b010870d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
@@ -165,8 +165,10 @@ bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) 
{
   PointerType *Int32PtrTy = Type::getInt32PtrTy(LI.getContext(), AS);
   PointerType *Int8PtrTy = Type::getInt8PtrTy(LI.getContext(), AS);
   auto *NewPtr = IRB.CreateBitCast(
-  IRB.CreateConstGEP1_64(IRB.CreatePointerBitCastOrAddrSpaceCast(Base, 
Int8PtrTy),
- Offset - Adjust),
+  IRB.CreateConstGEP1_64(
+  IRB.getInt8Ty(),
+  IRB.CreatePointerBitCastOrAddrSpaceCast(Base, Int8PtrTy),
+  Offset - Adjust),
   Int32PtrTy);
   LoadInst *NewLd = IRB.CreateAlignedLoad(IRB.getInt32Ty(), NewPtr, Align(4));
   NewLd->copyMetadata(LI);



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


[clang] 4737eeb - [OpaquePtr] Remove uses of CreateConstInBoundsGEP2_64() without type

2021-07-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-07-17T16:42:10+02:00
New Revision: 4737eebc0d05a42bd5a27e325d3846bd90a4d1b5

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

LOG: [OpaquePtr] Remove uses of CreateConstInBoundsGEP2_64() without type

Remove uses of to-be-deprecated API.

Added: 


Modified: 
clang/lib/CodeGen/CGClass.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 3551c5e51f3a..19fae7657669 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -467,8 +467,6 @@ llvm::Value *CodeGenFunction::GetVTTParameter(GlobalDecl GD,
   const CXXRecordDecl *RD = cast(CurCodeDecl)->getParent();
   const CXXRecordDecl *Base = cast(GD.getDecl())->getParent();
 
-  llvm::Value *VTT;
-
   uint64_t SubVTTIndex;
 
   if (Delegating) {
@@ -494,15 +492,14 @@ llvm::Value *CodeGenFunction::GetVTTParameter(GlobalDecl 
GD,
 
   if (CGM.getCXXABI().NeedsVTTParameter(CurGD)) {
 // A VTT parameter was passed to the constructor, use it.
-VTT = LoadCXXVTT();
-VTT = Builder.CreateConstInBoundsGEP1_64(VTT, SubVTTIndex);
+llvm::Value *VTT = LoadCXXVTT();
+return Builder.CreateConstInBoundsGEP1_64(VTT, SubVTTIndex);
   } else {
 // We're the complete constructor, so get the VTT by name.
-VTT = CGM.getVTables().GetAddrOfVTT(RD);
-VTT = Builder.CreateConstInBoundsGEP2_64(VTT, 0, SubVTTIndex);
+llvm::GlobalValue *VTT = CGM.getVTables().GetAddrOfVTT(RD);
+return Builder.CreateConstInBoundsGEP2_64(
+VTT->getValueType(), VTT, 0, SubVTTIndex);
   }
-
-  return VTT;
 }
 
 namespace {



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


[PATCH] D106215: Make wide multi-character character literals ill-formed in C++ mode

2021-07-17 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 359559.
cor3ntin added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106215

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CodeGen/char-literal.c
  clang/test/CodeGen/string-literal-short-wstring.c
  clang/test/Lexer/char-literal.cpp
  clang/test/Preprocessor/Weverything_pragma.c

Index: clang/test/Preprocessor/Weverything_pragma.c
===
--- clang/test/Preprocessor/Weverything_pragma.c
+++ clang/test/Preprocessor/Weverything_pragma.c
@@ -10,21 +10,21 @@
 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
 {
  // A diagnostic without DefaultIgnore, and not part of a group.
- (void) L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+ (void) 'ab'; // expected-warning {{multi-character character constant}}
 
 #pragma clang diagnostic warning "-Weverything" // Should not change anyhting.
 #define UNUSED_MACRO2 1 // expected-warning{{macro is not used}}
- (void) L'cd'; // expected-warning {{extraneous characters in character constant ignored}}
+ (void) 'cd'; // expected-warning {{multi-character character constant}}
 
 #pragma clang diagnostic ignored "-Weverything" // Ignore warnings now.
 #define UNUSED_MACRO2 1 // no warning
- (void) L'ef'; // no warning here
+ (void) 'ef'; // no warning here
 
 #pragma clang diagnostic warning "-Weverything" // Revert back to warnings.
 #define UNUSED_MACRO3 1 // expected-warning{{macro is not used}}
- (void) L'gh'; // expected-warning {{extraneous characters in character constant ignored}}
+ (void) 'gh'; // expected-warning {{multi-character character constant}}
 
 #pragma clang diagnostic error "-Weverything"  // Give errors now.
 #define UNUSED_MACRO4 1 // expected-error{{macro is not used}}
- (void) L'ij'; // expected-error {{extraneous characters in character constant ignored}}
+ (void) 'ij'; // expected-error {{multi-character character constant}}
 }
Index: clang/test/Lexer/char-literal.cpp
===
--- clang/test/Lexer/char-literal.cpp
+++ clang/test/Lexer/char-literal.cpp
@@ -21,7 +21,12 @@
 char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
 char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
 
+#ifdef __cplusplus
+wchar_t i = L'ab'; // expected-error {{wide character literals may not contain multiple characters}}
+
+#else
 wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+#endif
 wchar_t j = L'\U0010FFFD';
 
 char32_t k = U'\U0010FFFD';
Index: clang/test/CodeGen/string-literal-short-wstring.c
===
--- clang/test/CodeGen/string-literal-short-wstring.c
+++ clang/test/CodeGen/string-literal-short-wstring.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
-// RUN: %clang_cc1 -x c++ -triple %ms_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
-// Runs in c++ mode so that wchar_t is available.
+// RUN: %clang_cc1 -x c -triple %itanium_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
+// RUN: %clang_cc1 -x c -triple %ms_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
+
+// Run in C mode as wide multichar literals are not valid in C++
 
 // XFAIL: hexagon
 // Hexagon aligns arrays of size 8+ bytes to a 64-bit boundary, which fails
@@ -13,27 +14,25 @@
 
   // ITANIUM: private unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
   // MSABI: linkonce_odr dso_local unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
-  const wchar_t *foo = L"AB";
+  const unsigned short *foo = L"AB";
 
   // This should convert to utf16.
   // ITANIUM: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0]
   // MSABI: linkonce_odr dso_local unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0]
-  const wchar_t *bar = L"\u1120\u0220\U00102030";
-
-
+  const unsigned short *bar = L"\u1120\u0220\U00102030";
 
   // Should pick second character.
   // CHECK: store i8 98
   char c = 'ab';
 
   // CHECK: store i16 97
-  wchar_t wa = L'a';
+  unsigned short wa = L'a';
 
   // Should pick second character.
   // CHECK: store i16 98
-  wchar_t wb = L'ab';
+  unsigned short wb = L'ab';
 
   // -4085 == 0xf00b
   // CHECK: store i16 -4085
-  wchar_

[PATCH] D106216: Disallow narrowing conversions to bool in explicit specififers.

2021-07-17 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 359558.
cor3ntin added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106216

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5";>P1401R5
-  Clang 13
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -727,3 +727,18 @@
 Str b = "not so short";// expected-error {{no viable conversion}}
 
 }
+
+namespace P1401 {
+
+const int *ptr;
+
+struct S {
+  explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier 
argument evaluates to 2, which cannot be narrowed to type 'bool'}}
+  explicit(ptr) S(long); // expected-error {{conversion from 
'const int *' to 'bool' is not allowed in a converted constant expression}}
+  explicit(nullptr) S(int);  // expected-error {{value of type 
'nullptr_t' is not implicitly convertible to 'bool'}}
+  explicit(42L) S(int, int); // expected-error {{explicit specifier 
argument evaluates to 42, which cannot be narrowed to type 'bool'}}
+  explicit(sizeof(char)) S();
+  explicit(0) S(char, char);
+  explicit(1L) S(char, char, char);
+};
+} // namespace P1401
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5635,13 +5635,11 @@
   //  expression is a constant expression and the implicit conversion
   //  sequence contains only [... list of conversions ...].
   ImplicitConversionSequence ICS =
-  CCE == Sema::CCEK_ExplicitBool
-  ? TryContextuallyConvertToBool(S, From)
-  : TryCopyInitialization(S, From, T,
-  /*SuppressUserConversions=*/false,
-  /*InOverloadResolution=*/false,
-  /*AllowObjCWritebackConversion=*/false,
-  /*AllowExplicit=*/false);
+  TryCopyInitialization(S, From, T,
+/*SuppressUserConversions=*/false,
+/*InOverloadResolution=*/false,
+/*AllowObjCWritebackConversion=*/false,
+/*AllowExplicit=*/false);
   StandardConversionSequence *SCS = nullptr;
   switch (ICS.getKind()) {
   case ImplicitConversionSequence::StandardConversion:


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5";>P1401R5
-  Clang 13
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -727,3 +727,18 @@
 Str b = "not so short";// expected-error {{no viable conversion}}
 
 }
+
+namespace P1401 {
+
+const int *ptr;
+
+struct S {
+  explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
+  explicit(ptr) S(long); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}}
+  explicit(nullptr) S(int);  // expected-error {{value of type 'nullptr_t' is not implicitly convertible to 'bool'}}
+  explicit(42L) S(int, int); // expected-error {{explicit specifier argument evaluates to 42, which cannot be narrowed to type 'bool'}}
+  explicit(sizeof(char)) S();
+  explicit(0) S(char, char);
+  explicit(1L) S(char, char, char);
+};
+} // namespace P1401
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5635,13 +5635,11 @@
   //  expression is a constant expression and the implicit conversion
   //  sequence contains only [... list of conversions ...].
   ImplicitConversionSequence ICS =
-  CCE == Sema::CCEK_ExplicitBool
-  ? TryContextuallyConvertToBool(S, From)
-  : TryCopyInitialization(S, From, T,
-  /*SuppressUserConversions=*/false,
-  

[PATCH] D106216: Disallow narrowing conversions to bool in explicit specififers.

2021-07-17 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Completes the support for P1401R5


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106216

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5";>P1401R5
-  Clang 13
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -727,3 +727,18 @@
 Str b = "not so short";// expected-error {{no viable conversion}}
 
 }
+
+namespace P1401 {
+
+const int *ptr;
+
+struct S {
+  explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier 
argument evaluates to 2, which cannot be narrowed to type 'bool'}}
+  explicit(ptr) S(long); // expected-error {{conversion from 
'const int *' to 'bool' is not allowed in a converted constant expression}}
+  explicit(nullptr) S(int);  // expected-error {{value of type 
'nullptr_t' is not implicitly convertible to 'bool'}}
+  explicit(42L) S(int, int); // expected-error {{explicit specifier 
argument evaluates to 42, which cannot be narrowed to type 'bool'}}
+  explicit(sizeof(char)) S();
+  explicit(0) S(char, char);
+  explicit(1L) S(char, char, char);
+};
+} // namespace P1401
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5635,13 +5635,11 @@
   //  expression is a constant expression and the implicit conversion
   //  sequence contains only [... list of conversions ...].
   ImplicitConversionSequence ICS =
-  CCE == Sema::CCEK_ExplicitBool
-  ? TryContextuallyConvertToBool(S, From)
-  : TryCopyInitialization(S, From, T,
-  /*SuppressUserConversions=*/false,
-  /*InOverloadResolution=*/false,
-  /*AllowObjCWritebackConversion=*/false,
-  /*AllowExplicit=*/false);
+  TryCopyInitialization(S, From, T,
+/*SuppressUserConversions=*/false,
+/*InOverloadResolution=*/false,
+/*AllowObjCWritebackConversion=*/false,
+/*AllowExplicit=*/false);
   StandardConversionSequence *SCS = nullptr;
   switch (ICS.getKind()) {
   case ImplicitConversionSequence::StandardConversion:


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5";>P1401R5
-  Clang 13
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -727,3 +727,18 @@
 Str b = "not so short";// expected-error {{no viable conversion}}
 
 }
+
+namespace P1401 {
+
+const int *ptr;
+
+struct S {
+  explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
+  explicit(ptr) S(long); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}}
+  explicit(nullptr) S(int);  // expected-error {{value of type 'nullptr_t' is not implicitly convertible to 'bool'}}
+  explicit(42L) S(int, int); // expected-error {{explicit specifier argument evaluates to 42, which cannot be narrowed to type 'bool'}}
+  explicit(sizeof(char)) S();
+  explicit(0) S(char, char);
+  explicit(1L) S(char, char, char);
+};
+} // namespace P1401
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5635,13 +5635,11 @@
   //  expression is a constant expression and the implicit conversion
   //  sequence contains only [... list of conversions ...].
   ImplicitConversionSequence ICS =
-  CCE == Sema::CCEK_ExplicitBool
-  ? TryContextuallyConvertToBool(S, From)
-  : TryCopyInitialization(S, From, T,
-  /*SuppressUserConversions=*/false,
-

[PATCH] D105926: [PowerPC] Extra test case for LDARX

2021-07-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

Sorry for raising an unrelated topic here, but I can't reach @Conanap directly 
via the mail from the git commits: @Conanap could you please create the git 
branches for your patches in your own Github fork instead of the main LLVM 
repo? LLVM's policy is to have working branches in everyone's private fork 
(even though I don't think we explicitly tell people that when they get commit 
access). I'll go ahead and delete your created branches end of next week, but 
let me know if I should wait a bit longer with that. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105926

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


[PATCH] D106215: Make wide multi-character character literals ill-formed in C++ mode

2021-07-17 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This implements P2362 , which has not het been 
approved by the
C++ committee, but because wide-multi character literals are
implementation defined, clang might not have to wait for WG21.

While I think this change could be applied to all languages - notably
C, I do not know whether there would be breakage from it.

The other part of P2362 , making 
non-representable character
literals ill-formed, is already implemented by clang


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106215

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CodeGen/char-literal.c
  clang/test/CodeGen/string-literal-short-wstring.c
  clang/test/Lexer/char-literal.cpp
  clang/test/Preprocessor/Weverything_pragma.c

Index: clang/test/Preprocessor/Weverything_pragma.c
===
--- clang/test/Preprocessor/Weverything_pragma.c
+++ clang/test/Preprocessor/Weverything_pragma.c
@@ -10,21 +10,21 @@
 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
 {
  // A diagnostic without DefaultIgnore, and not part of a group.
- (void) L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+ (void) 'ab'; // expected-warning {{multi-character character constant}}
 
 #pragma clang diagnostic warning "-Weverything" // Should not change anyhting.
 #define UNUSED_MACRO2 1 // expected-warning{{macro is not used}}
- (void) L'cd'; // expected-warning {{extraneous characters in character constant ignored}}
+ (void) 'cd'; // expected-warning {{multi-character character constant}}
 
 #pragma clang diagnostic ignored "-Weverything" // Ignore warnings now.
 #define UNUSED_MACRO2 1 // no warning
- (void) L'ef'; // no warning here
+ (void) 'ef'; // no warning here
 
 #pragma clang diagnostic warning "-Weverything" // Revert back to warnings.
 #define UNUSED_MACRO3 1 // expected-warning{{macro is not used}}
- (void) L'gh'; // expected-warning {{extraneous characters in character constant ignored}}
+ (void) 'gh'; // expected-warning {{multi-character character constant}}
 
 #pragma clang diagnostic error "-Weverything"  // Give errors now.
 #define UNUSED_MACRO4 1 // expected-error{{macro is not used}}
- (void) L'ij'; // expected-error {{extraneous characters in character constant ignored}}
+ (void) 'ij'; // expected-error {{multi-character character constant}}
 }
Index: clang/test/Lexer/char-literal.cpp
===
--- clang/test/Lexer/char-literal.cpp
+++ clang/test/Lexer/char-literal.cpp
@@ -21,7 +21,12 @@
 char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
 char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
 
+#ifdef __cplusplus
+wchar_t i = L'ab'; // expected-error {{wide character literals may not contain multiple characters}}
+
+#else
 wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+#endif
 wchar_t j = L'\U0010FFFD';
 
 char32_t k = U'\U0010FFFD';
Index: clang/test/CodeGen/string-literal-short-wstring.c
===
--- clang/test/CodeGen/string-literal-short-wstring.c
+++ clang/test/CodeGen/string-literal-short-wstring.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
-// RUN: %clang_cc1 -x c++ -triple %ms_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
-// Runs in c++ mode so that wchar_t is available.
+// RUN: %clang_cc1 -x c -triple %itanium_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
+// RUN: %clang_cc1 -x c -triple %ms_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
+
+// Run in C mode as wide multichar literals are not valid in C++
 
 // XFAIL: hexagon
 // Hexagon aligns arrays of size 8+ bytes to a 64-bit boundary, which fails
@@ -13,27 +14,25 @@
 
   // ITANIUM: private unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
   // MSABI: linkonce_odr dso_local unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
-  const wchar_t *foo = L"AB";
+  const unsigned short *foo = L"AB";
 
   // This should convert to utf16.
   // ITANIUM: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0]
   // MSABI: linkonce_odr dso_local unnamed_addr constant [5 x i16] [i16

[PATCH] D106184: [BPF] Use elementtype attribute for preserve.array/struct.index intrinsics

2021-07-17 Thread Nikita Popov via Phabricator via cfe-commits
nikic closed this revision.
nikic added a comment.

Landed as 
https://github.com/llvm/llvm-project/commit/be5af50e7d028849bf2fab5f4b0f2ad36ae56e11,
 missed the "Differential Revision" tag.

For the record, the problem with the autoupgrade test was PEBKAC: The textual 
diff that gets uploaded to Phabricator didn't include the contents of the 
binary bitcode file, and apparently LLVM happily interprets an empty bitcode 
file as an empty module.


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

https://reviews.llvm.org/D106184

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


[PATCH] D106210: [MS] Preserve base register %esi around movs[bwl]

2021-07-17 Thread namazso via Phabricator via cfe-commits
namazso updated this revision to Diff 359550.
namazso added a comment.

fix linter warnings, update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106210

Files:
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/ms-intrinsics.c


Index: clang/test/CodeGen/ms-intrinsics.c
===
--- clang/test/CodeGen/ms-intrinsics.c
+++ clang/test/CodeGen/ms-intrinsics.c
@@ -36,7 +36,7 @@
   return __movsb(Dest, Src, Count);
 }
 // CHECK-I386-LABEL: define{{.*}} void @test__movsb
-// CHECK-I386:   call { i8*, i8*, i32 } asm sideeffect "rep movsb", 
"={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* 
%Src, i32 %Count)
+// CHECK-I386:   tail call { i8*, i8*, i32 } asm sideeffect "xchg %esi, 
$1\0Arep movsb\0Axchg %esi, $1", 
"={di},=r,={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* 
%Src, i32 %Count)
 // CHECK-I386:   ret void
 // CHECK-I386: }
 
@@ -62,7 +62,7 @@
   return __movsw(Dest, Src, Count);
 }
 // CHECK-I386-LABEL: define{{.*}} void @test__movsw
-// CHECK-I386:   call { i16*, i16*, i32 } asm sideeffect "rep movsw", 
"={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i16* %Dest, 
i16* %Src, i32 %Count)
+// CHECK-I386:   tail call { i16*, i16*, i32 } asm sideeffect "xchg %esi, 
$1\0Arep movsw\0Axchg %esi, $1", 
"={di},=r,={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i16* %Dest, i16* 
%Src, i32 %Count)
 // CHECK-I386:   ret void
 // CHECK-I386: }
 
@@ -88,7 +88,7 @@
   return __movsd(Dest, Src, Count);
 }
 // CHECK-I386-LABEL: define{{.*}} void @test__movsd
-// CHECK-I386:   call { i32*, i32*, i32 } asm sideeffect "rep movsl", 
"={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Dest, 
i32* %Src, i32 %Count)
+// CHECK-I386:   tail call { i32*, i32*, i32 } asm sideeffect "xchg %esi, 
$1\0Arep movsl\0Axchg %esi, $1", 
"={di},=r,={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Dest, i32* 
%Src, i32 %Count)
 // CHECK-I386:   ret void
 // CHECK-I386: }
 
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -451,24 +451,47 @@
 static __inline__ void __DEFAULT_FN_ATTRS __movsb(unsigned char *__dst,
   unsigned char const *__src,
   size_t __n) {
-  __asm__ __volatile__("rep movsb" : "+D"(__dst), "+S"(__src), "+c"(__n)
-   : : "memory");
+#if defined(__x86_64__)
+  __asm__ __volatile__("rep movsb"
+   : "+D"(__dst), "+S"(__src), "+c"(__n)
+   :
+   : "memory");
+#else
+  __asm__ __volatile__("xchg %%esi, %1\nrep movsb\nxchg %%esi, %1"
+   : "+D"(__dst), "+r"(__src), "+c"(__n)
+   :
+   : "memory");
+#endif
 }
 static __inline__ void __DEFAULT_FN_ATTRS __movsd(unsigned long *__dst,
   unsigned long const *__src,
   size_t __n) {
+#if defined(__x86_64__)
   __asm__ __volatile__("rep movsl"
: "+D"(__dst), "+S"(__src), "+c"(__n)
:
: "memory");
+#else
+  __asm__ __volatile__("xchg %%esi, %1\nrep movsl\nxchg %%esi, %1"
+   : "+D"(__dst), "+r"(__src), "+c"(__n)
+   :
+   : "memory");
+#endif
 }
 static __inline__ void __DEFAULT_FN_ATTRS __movsw(unsigned short *__dst,
   unsigned short const *__src,
   size_t __n) {
+#if defined(__x86_64__)
   __asm__ __volatile__("rep movsw"
: "+D"(__dst), "+S"(__src), "+c"(__n)
:
: "memory");
+#else
+  __asm__ __volatile__("xchg %%esi, %1\nrep movsw\nxchg %%esi, %1"
+   : "+D"(__dst), "+r"(__src), "+c"(__n)
+   :
+   : "memory");
+#endif
 }
 static __inline__ void __DEFAULT_FN_ATTRS __stosd(unsigned long *__dst,
   unsigned long __x,


Index: clang/test/CodeGen/ms-intrinsics.c
===
--- clang/test/CodeGen/ms-intrinsics.c
+++ clang/test/CodeGen/ms-intrinsics.c
@@ -36,7 +36,7 @@
   return __movsb(Dest, Src, Count);
 }
 // CHECK-I386-LABEL: define{{.*}} void @test__movsb
-// CHECK-I386:   call { i8*, i8*, i32 } asm sideeffect "rep movsb", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i32 %Count)
+// CHECK-I386:   tail call { i8*, i8*, i32 } asm sideeffect "xchg %esi, $1\0Arep movsb\0Axchg %esi, $1", "={di},=r,={cx},0,1,2,~{me