r314364 - [Preprocessor] Preserve #pragma clang assume_nonnull in preprocessed output

2017-09-27 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Sep 27 16:29:37 2017
New Revision: 314364

URL: http://llvm.org/viewvc/llvm-project?rev=314364&view=rev
Log:
[Preprocessor] Preserve #pragma clang assume_nonnull in preprocessed output

Patch by Zbigniew Sarbinowski!

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


Added:
cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c
Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=314364&r1=314363&r2=314364&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Sep 27 16:29:37 2017
@@ -235,6 +235,14 @@ public:
   virtual void PragmaWarningPop(SourceLocation Loc) {
   }
 
+  /// \brief Callback invoked when a \#pragma clang assume_nonnull begin 
directive
+  /// is read.
+  virtual void PragmaAssumeNonNullBegin(SourceLocation Loc) {}
+
+  /// \brief Callback invoked when a \#pragma clang assume_nonnull end 
directive
+  /// is read.
+  virtual void PragmaAssumeNonNullEnd(SourceLocation Loc) {}
+
   /// \brief Called by Preprocessor::HandleMacroExpandedIdentifier when a
   /// macro invocation is found.
   virtual void MacroExpands(const Token &MacroNameTok,
@@ -446,6 +454,16 @@ public:
 Second->PragmaWarningPop(Loc);
   }
 
+  void PragmaAssumeNonNullBegin(SourceLocation Loc) override {
+First->PragmaAssumeNonNullBegin(Loc);
+Second->PragmaAssumeNonNullBegin(Loc);
+  }
+
+  void PragmaAssumeNonNullEnd(SourceLocation Loc) override {
+First->PragmaAssumeNonNullEnd(Loc);
+Second->PragmaAssumeNonNullEnd(Loc);
+  }
+
   void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
 SourceRange Range, const MacroArgs *Args) override {
 First->MacroExpands(MacroNameTok, MD, Range, Args);

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=314364&r1=314363&r2=314364&view=diff
==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Sep 27 16:29:37 2017
@@ -143,6 +143,8 @@ public:
  ArrayRef Ids) override;
   void PragmaWarningPush(SourceLocation Loc, int Level) override;
   void PragmaWarningPop(SourceLocation Loc) override;
+  void PragmaAssumeNonNullBegin(SourceLocation Loc) override;
+  void PragmaAssumeNonNullEnd(SourceLocation Loc) override;
 
   bool HandleFirstTokOnLine(Token &Tok);
 
@@ -549,6 +551,22 @@ void PrintPPOutputPPCallbacks::PragmaWar
   setEmittedDirectiveOnThisLine();
 }
 
+void PrintPPOutputPPCallbacks::
+PragmaAssumeNonNullBegin(SourceLocation Loc) {
+  startNewLineIfNeeded();
+  MoveToLine(Loc);
+  OS << "#pragma clang assume_nonnull begin";
+  setEmittedDirectiveOnThisLine();
+}
+
+void PrintPPOutputPPCallbacks::
+PragmaAssumeNonNullEnd(SourceLocation Loc) {
+  startNewLineIfNeeded();
+  MoveToLine(Loc);
+  OS << "#pragma clang assume_nonnull end";
+  setEmittedDirectiveOnThisLine();
+}
+
 /// HandleFirstTokOnLine - When emitting a preprocessed file in -E mode, this
 /// is called for the first token on each new line.  If this really is the 
start
 /// of a new logical line, handle it and return true, otherwise return false.

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=314364&r1=314363&r2=314364&view=diff
==
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Wed Sep 27 16:29:37 2017
@@ -1725,6 +1725,7 @@ struct PragmaAssumeNonNullHandler : publ
 
 // The start location we want after processing this.
 SourceLocation NewLoc;
+PPCallbacks *Callbacks = PP.getPPCallbacks();
 
 if (IsBegin) {
   // Complain about attempts to re-enter an audit.
@@ -1733,6 +1734,8 @@ struct PragmaAssumeNonNullHandler : publ
 PP.Diag(BeginLoc, diag::note_pragma_entered_here);
   }
   NewLoc = Loc;
+  if (Callbacks)
+Callbacks->PragmaAssumeNonNullBegin(NewLoc);
 } else {
   // Complain about attempts to leave an audit that doesn't exist.
   if (!BeginLoc.isValid()) {
@@ -1740,6 +1743,8 @@ struct PragmaAssumeNonNullHandler : publ
 return;
   }
   NewLoc = SourceLocation();
+  if (Callbacks)
+Callbacks->PragmaAssumeNonNullEnd(NewLoc);
 }
 
 PP.setPragmaAssumeNonNullLoc(NewLoc);

Added: cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c?rev=314

r340640 - [LTO] Fix -save-temps with LTO and unnamed globals.

2018-08-24 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Fri Aug 24 12:31:52 2018
New Revision: 340640

URL: http://llvm.org/viewvc/llvm-project?rev=340640&view=rev
Log:
[LTO] Fix -save-temps with LTO and unnamed globals.

If all LLVM passes are disabled, we can't emit a summary because there
could be unnamed globals in the IR.

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


Added:
cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=340640&r1=340639&r2=340640&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Aug 24 12:31:52 2018
@@ -783,7 +783,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.PrepareForThinLTO) {
+if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
 if (!ThinLinkOS)
@@ -796,6 +796,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   // targets
   bool EmitLTOSummary =
   (CodeGenOpts.PrepareForLTO &&
+   !CodeGenOpts.DisableLLVMPasses &&
llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
llvm::Triple::Apple);
   if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO"))
@@ -1014,7 +1015,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.PrepareForThinLTO) {
+if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
 if (!ThinLinkOS)
@@ -1027,6 +1028,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   // targets
   bool EmitLTOSummary =
   (CodeGenOpts.PrepareForLTO &&
+   !CodeGenOpts.DisableLLVMPasses &&
llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
llvm::Triple::Apple);
   if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO"))

Added: cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll?rev=340640&view=auto
==
--- cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll (added)
+++ cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll Fri Aug 24 12:31:52 
2018
@@ -0,0 +1,10 @@
+; RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc 
-disable-llvm-passes -x ir < %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+; RUN: %clang_cc1 -flto=thin -triple x86_64-pc-linux-gnu -emit-llvm-bc 
-disable-llvm-passes -x ir < %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+; RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -triple 
x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | 
llvm-bcanalyzer -dump | FileCheck %s
+; RUN: %clang_cc1 -fexperimental-new-pass-manager -flto=thin -triple 
x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | 
llvm-bcanalyzer -dump | FileCheck %s
+
+; CHECK-NOT:GLOBALVAL_SUMMARY_BLOCK
+
+; Make sure this doesn't crash, and we don't try to emit a module summary.
+; (The command is roughly emulating what -save-temps would do.)
+@0 = global i32 0


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


r340644 - Add REQUIRES: x86-registered-target to test.

2018-08-24 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Fri Aug 24 13:18:34 2018
New Revision: 340644

URL: http://llvm.org/viewvc/llvm-project?rev=340644&view=rev
Log:
Add REQUIRES: x86-registered-target to test.

(This isn't really x86-specific, but we have to pick some non-Apple
triple to exercise the right codepath.)


Modified:
cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll

Modified: cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll?rev=340644&r1=340643&r2=340644&view=diff
==
--- cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll (original)
+++ cfe/trunk/test/CodeGen/summary-index-unnamed-global.ll Fri Aug 24 13:18:34 
2018
@@ -2,6 +2,7 @@
 ; RUN: %clang_cc1 -flto=thin -triple x86_64-pc-linux-gnu -emit-llvm-bc 
-disable-llvm-passes -x ir < %s -o - | llvm-bcanalyzer -dump | FileCheck %s
 ; RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -triple 
x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | 
llvm-bcanalyzer -dump | FileCheck %s
 ; RUN: %clang_cc1 -fexperimental-new-pass-manager -flto=thin -triple 
x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | 
llvm-bcanalyzer -dump | FileCheck %s
+; REQUIRES: x86-registered-target
 
 ; CHECK-NOT:GLOBALVAL_SUMMARY_BLOCK
 


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


r338931 - Diagnose invalid cv-qualifiers for friend decls.

2018-08-03 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Fri Aug  3 15:09:44 2018
New Revision: 338931

URL: http://llvm.org/viewvc/llvm-project?rev=338931&view=rev
Log:
Diagnose invalid cv-qualifiers for friend decls.

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


Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/class.access/class.friend/p3-cxx0x.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=338931&r1=338930&r2=338931&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Aug  3 15:09:44 2018
@@ -14017,6 +14017,29 @@ Decl *Sema::ActOnFriendTypeDecl(Scope *S
   assert(DS.isFriendSpecified());
   assert(DS.getStorageClassSpec() == DeclSpec::SCS_unspecified);
 
+  // C++ [class.friend]p3:
+  // A friend declaration that does not declare a function shall have one of
+  // the following forms:
+  // friend elaborated-type-specifier ;
+  // friend simple-type-specifier ;
+  // friend typename-specifier ;
+  //
+  // Any declaration with a type qualifier does not have that form. (It's
+  // legal to specify a qualified type as a friend, you just can't write the
+  // keywords.)
+  if (DS.getTypeQualifiers()) {
+if (DS.getTypeQualifiers() & DeclSpec::TQ_const)
+  Diag(DS.getConstSpecLoc(), diag::err_friend_decl_spec) << "const";
+if (DS.getTypeQualifiers() & DeclSpec::TQ_volatile)
+  Diag(DS.getVolatileSpecLoc(), diag::err_friend_decl_spec) << "volatile";
+if (DS.getTypeQualifiers() & DeclSpec::TQ_restrict)
+  Diag(DS.getRestrictSpecLoc(), diag::err_friend_decl_spec) << "restrict";
+if (DS.getTypeQualifiers() & DeclSpec::TQ_atomic)
+  Diag(DS.getAtomicSpecLoc(), diag::err_friend_decl_spec) << "_Atomic";
+if (DS.getTypeQualifiers() & DeclSpec::TQ_unaligned)
+  Diag(DS.getUnalignedSpecLoc(), diag::err_friend_decl_spec) << 
"__unaligned";
+  }
+
   // Try to convert the decl specifier to a type.  This works for
   // friend templates because ActOnTag never produces a ClassTemplateDecl
   // for a TUK_Friend.

Modified: cfe/trunk/test/CXX/class.access/class.friend/p3-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.friend/p3-cxx0x.cpp?rev=338931&r1=338930&r2=338931&view=diff
==
--- cfe/trunk/test/CXX/class.access/class.friend/p3-cxx0x.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.friend/p3-cxx0x.cpp Fri Aug  3 
15:09:44 2018
@@ -52,14 +52,25 @@ struct {
   // Ill-formed
   int friend; // expected-error {{'friend' must appear first in a non-function 
declaration}}
   unsigned friend int; // expected-error {{'friend' must appear first in a 
non-function declaration}}
-  const volatile friend int; // expected-error {{'friend' must appear first in 
a non-function declaration}}
+  const volatile friend int; // expected-error {{'friend' must appear first in 
a non-function declaration}} \
+ // expected-error {{'const' is invalid in friend 
declarations}} \
+ // expected-error {{'volatile' is invalid in 
friend declarations}}
   int
   friend; // expected-error {{'friend' must appear first in a 
non-function declaration}}
+  friend const int; // expected-error {{'const' is invalid in friend 
declarations}}
+  friend volatile int; // expected-error {{'volatile' is invalid in friend 
declarations}}
+  template  friend const class X; // expected-error {{'const' is 
invalid in friend declarations}}
+  // C++ doesn't have restrict and _Atomic, but they're both the same sort
+  // of qualifier.
+  typedef int *PtrToInt;
+  friend __restrict PtrToInt; // expected-error {{'restrict' is invalid in 
friend declarations}} \
+  // expected-error {{restrict requires a pointer 
or reference}}
+  friend _Atomic int; // expected-error {{'_Atomic' is invalid in friend 
declarations}}
 
   // OK
   int friend foo(void);
+  const int friend foo2(void);
   friend int;
-  friend const volatile int;
   friend
 
   float;

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=338931&r1=338930&r2=338931&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Aug  3 15:09:44 2018
@@ -2244,22 +2244,6 @@ S2 s2;
 #endif
 
 #if defined(FIRST)
-struct T3 {};
-struct S3 {
-  friend const T3;
-};
-#elif defined(SECOND)
-struct T3 {};
-struct S3 {
-  friend T3;
-};
-#else
-S3 s3;
-// expected-error@second.h:* {{'Friend::S3' has different definitions in 
different modules; first difference is definition in module 'SecondModule' 
found friend

r321052 - [Coverage] Fix use-after free in coverage emission

2017-12-18 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Dec 18 17:54:09 2017
New Revision: 321052

URL: http://llvm.org/viewvc/llvm-project?rev=321052&view=rev
Log:
[Coverage] Fix use-after free in coverage emission

Fixes regression from r320533.

This fixes the undefined behavior, but I'm not sure it's really right...
I think we end up with missing coverage for code in modules.

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


Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=321052&r1=321051&r2=321052&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Dec 18 17:54:09 2017
@@ -4289,7 +4289,11 @@ void CodeGenModule::ClearUnusedCoverageM
 }
 
 void CodeGenModule::EmitDeferredUnusedCoverageMappings() {
-  for (const auto &Entry : DeferredEmptyCoverageMappingDecls) {
+  // We call takeVector() here to avoid use-after-free.
+  // FIXME: DeferredEmptyCoverageMappingDecls is getting mutated because
+  // we deserialize function bodies to emit coverage info for them, and that
+  // deserializes more declarations. How should we handle that case?
+  for (const auto &Entry : DeferredEmptyCoverageMappingDecls.takeVector()) {
 if (!Entry.second)
   continue;
 const Decl *D = Entry.first;


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


r344710 - [AArch64] Define __ELF__ for aarch64-none-elf and other similar triples.

2018-10-17 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Oct 17 14:07:11 2018
New Revision: 344710

URL: http://llvm.org/viewvc/llvm-project?rev=344710&view=rev
Log:
[AArch64] Define __ELF__ for aarch64-none-elf and other similar triples.

"aarch64-none-elf" is commonly used for AArch64 baremetal toolchains.

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


Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=344710&r1=344709&r2=344710&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Wed Oct 17 14:07:11 2018
@@ -122,10 +122,9 @@ void AArch64TargetInfo::getTargetDefines
  MacroBuilder &Builder) const {
   // Target identification.
   Builder.defineMacro("__aarch64__");
-  // For bare-metal none-eabi.
+  // For bare-metal.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
-  (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+  getTriple().isOSBinFormatELF())
 Builder.defineMacro("__ELF__");
 
   // Target properties.

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=344710&r1=344709&r2=344710&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Oct 17 14:07:11 2018
@@ -2590,6 +2590,7 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabihf < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabi < /dev/null 
| FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabihf < 
/dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-elf < /dev/null 
| FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
 // ARM-NONE-EABI: #define __ELF__ 1
 
 // No MachO targets use the full EABI, even if AAPCS is used.


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


r345354 - [AArch64] Support Windows stack probe command-line arguments.

2018-10-25 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Oct 25 18:31:57 2018
New Revision: 345354

URL: http://llvm.org/viewvc/llvm-project?rev=345354&view=rev
Log:
[AArch64] Support Windows stack probe command-line arguments.

Adds support for -mno-stack-arg-probe and -mstack-probe-size.

(Not really happy copy-pasting code, but that's what we do for all the
other Windows targets.)

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


Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/stack-arg-probe.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=345354&r1=345353&r2=345354&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Oct 25 18:31:57 2018
@@ -5001,6 +5001,9 @@ public:
   WindowsAArch64TargetCodeGenInfo(CodeGenTypes &CGT, AArch64ABIInfo::ABIKind K)
   : AArch64TargetCodeGenInfo(CGT, K) {}
 
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule &CGM) const override;
+
   void getDependentLibraryOption(llvm::StringRef Lib,
  llvm::SmallString<24> &Opt) const override {
 Opt = "/DEFAULTLIB:" + qualifyWindowsLibrary(Lib);
@@ -5011,6 +5014,14 @@ public:
 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
   }
 };
+
+void WindowsAArch64TargetCodeGenInfo::setTargetAttributes(
+const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
+  AArch64TargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
+  if (GV->isDeclaration())
+return;
+  addStackProbeTargetAttributes(D, GV, CGM);
+}
 }
 
 ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty) const {

Modified: cfe/trunk/test/CodeGen/stack-arg-probe.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stack-arg-probe.c?rev=345354&r1=345353&r2=345354&view=diff
==
--- cfe/trunk/test/CodeGen/stack-arg-probe.c (original)
+++ cfe/trunk/test/CodeGen/stack-arg-probe.c Thu Oct 25 18:31:57 2018
@@ -1,8 +1,15 @@
 // RUN: %clang_cc1 %s -triple=i686-windows-msvc -emit-llvm -o - 
-mno-stack-arg-probe | FileCheck %s -check-prefix=NO-STACKPROBE
+// RUN: %clang_cc1 %s -triple=x86_64-windows-msvc -emit-llvm -o - 
-mno-stack-arg-probe | FileCheck %s -check-prefix=NO-STACKPROBE
+// RUN: %clang_cc1 %s -triple=armv7-windows-msvc -emit-llvm -o - 
-mno-stack-arg-probe | FileCheck %s -check-prefix=NO-STACKPROBE
+// RUN: %clang_cc1 %s -triple=aarch64-windows-msvc -emit-llvm -o - 
-mno-stack-arg-probe | FileCheck %s -check-prefix=NO-STACKPROBE
 // RUN: %clang_cc1 %s -triple=i686-windows-msvc -emit-llvm -o - | FileCheck %s 
-check-prefix=STACKPROBE
+// RUN: %clang_cc1 %s -triple=x86_64-windows-msvc -emit-llvm -o - | FileCheck 
%s -check-prefix=STACKPROBE
+// RUN: %clang_cc1 %s -triple=armv7-windows-msvc -emit-llvm -o - | FileCheck 
%s -check-prefix=STACKPROBE
+// RUN: %clang_cc1 %s -triple=aarch64-windows-msvc -emit-llvm -o - | FileCheck 
%s -check-prefix=STACKPROBE
+
 
 // NO-STACKPROBE: attributes #{{[0-9]+}} = {{{.*}} "no-stack-arg-probe"
-// STACKPROBE-NOT: attributes #{{[0-9]+}} = {{{.*}} "no-stack-arg-probe"
+// STACKPROBE-NOT: "no-stack-arg-probe"
 
 void test1() {
 }


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


r351284 - [EH] Rename llvm.x86.seh.recoverfp intrinsic to llvm.eh.recoverfp

2019-01-15 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Tue Jan 15 16:50:44 2019
New Revision: 351284

URL: http://llvm.org/viewvc/llvm-project?rev=351284&view=rev
Log:
[EH] Rename llvm.x86.seh.recoverfp intrinsic to llvm.eh.recoverfp

This is the clang counterpart to D56747.

Patch by Mandeep Singh Grang.

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


Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGen/exceptions-seh.c
cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=351284&r1=351283&r2=351284&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Jan 15 16:50:44 2019
@@ -1781,7 +1781,7 @@ void CodeGenFunction::EmitCapturedLocals
 // frame pointer of the parent function. We only need to do this in 
filters,
 // since finally funclets recover the parent FP for us.
 llvm::Function *RecoverFPIntrin =
-CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
+CGM.getIntrinsic(llvm::Intrinsic::eh_recoverfp);
 llvm::Constant *ParentI8Fn =
 llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
 ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP});

Modified: cfe/trunk/test/CodeGen/exceptions-seh.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh.c?rev=351284&r1=351283&r2=351284&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh.c Tue Jan 15 16:50:44 2019
@@ -52,7 +52,7 @@ int safe_div(int numerator, int denomina
 //
 // X86-LABEL: define internal i32 @"?filt$0@0@safe_div@@"()
 // X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress(i32 1)
-// X86: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 
(i32, i32, i32*)* @safe_div to i8*), i8* %[[ebp]])
+// X86: %[[fp:[^ ]*]] = call i8* @llvm.eh.recoverfp(i8* bitcast (i32 (i32, 
i32, i32*)* @safe_div to i8*), i8* %[[ebp]])
 // X86: call i8* @llvm.localrecover(i8* bitcast (i32 (i32, i32, i32*)* 
@safe_div to i8*), i8* %[[fp]], i32 0)
 // X86: load i8*, i8**
 // X86: load i32*, i32**
@@ -95,16 +95,16 @@ int filter_expr_capture(void) {
 // CHECK: ret i32 %[[rv]]
 
 // X64-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"(i8* 
%exception_pointers, i8* %frame_pointer)
-// X64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
+// X64: %[[fp:[^ ]*]] = call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
 // X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture 
to i8*), i8* %[[fp]], i32 0)
 //
 // ARM64-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"(i8* 
%exception_pointers, i8* %frame_pointer)
-// ARM64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 
()* @filter_expr_capture to i8*), i8* %frame_pointer)
+// ARM64: %[[fp:[^ ]*]] = call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
 // ARM64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %[[fp]], i32 0)
 //
 // X86-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"()
 // X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress(i32 1)
-// X86: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %[[ebp]])
+// X86: %[[fp:[^ ]*]] = call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %[[ebp]])
 // X86: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture 
to i8*), i8* %[[fp]], i32 0)
 //
 // CHECK: store i32 -1, i32* %{{.*}}
@@ -166,13 +166,13 @@ int nested_try(void) {
 // CHECK: br label %[[inner_try_cont]]
 //
 // CHECK-LABEL: define internal i32 @"?filt$0@0@nested_try@@"({{.*}})
-// X86: call i8* @llvm.x86.seh.recoverfp({{.*}})
+// X86: call i8* @llvm.eh.recoverfp({{.*}})
 // CHECK: load i32*, i32**
 // CHECK: load i32, i32*
 // CHECK: icmp eq i32 %{{.*}}, 456
 //
 // CHECK-LABEL: define internal i32 @"?filt$1@0@nested_try@@"({{.*}})
-// X86: call i8* @llvm.x86.seh.recoverfp({{.*}})
+// X86: call i8* @llvm.eh.recoverfp({{.*}})
 // CHECK: load i32*, i32**
 // CHECK: load i32, i32*
 // CHECK: icmp eq i32 %{{.*}}, 123

Modified: cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp?rev=351284&r1=351283&r2=351284&view=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captu

r351766 - [CodeGen] Always use string computed in Sema for PredefinedExpr

2019-01-21 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Jan 21 16:11:17 2019
New Revision: 351766

URL: http://llvm.org/viewvc/llvm-project?rev=351766&view=rev
Log:
[CodeGen] Always use string computed in Sema for PredefinedExpr

We can't use any other string, anyway, because its type wouldn't
match the type of the PredefinedExpr.

With this change, we don't compute a "nice" name for the __func__ global
when it's used in the initializer for a constant. This doesn't seem like
a great loss, and I'm not sure how to fix it without either storing more
information in the AST, or somehow threading through the information
from ExprConstant.cpp.

This could break some situations involving BlockDecl; currently,
CodeGenFunction::EmitPredefinedLValue has some logic to intentionally
emit a string different from what Sema computed.  This code skips that
logic... but that logic can't work correctly in general anyway.  (For
example, sizeof(__func__) returns the wrong result.) Hopefully this
doesn't affect practical code.

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

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


Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGen/const-init.c
cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=351766&r1=351765&r2=351766&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Mon Jan 21 16:11:17 2019
@@ -1788,17 +1788,7 @@ ConstantLValueEmitter::VisitObjCStringLi
 
 ConstantLValue
 ConstantLValueEmitter::VisitPredefinedExpr(const PredefinedExpr *E) {
-  if (auto CGF = Emitter.CGF) {
-LValue Res = CGF->EmitPredefinedLValue(E);
-return cast(Res.getAddress());
-  }
-
-  auto kind = E->getIdentKind();
-  if (kind == PredefinedExpr::PrettyFunction) {
-return CGM.GetAddrOfConstantCString("top level", ".tmp");
-  }
-
-  return CGM.GetAddrOfConstantCString("", ".tmp");
+  return CGM.GetAddrOfConstantStringFromLiteral(E->getFunctionName());
 }
 
 ConstantLValue

Modified: cfe/trunk/test/CodeGen/const-init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/const-init.c?rev=351766&r1=351765&r2=351766&view=diff
==
--- cfe/trunk/test/CodeGen/const-init.c (original)
+++ cfe/trunk/test/CodeGen/const-init.c Mon Jan 21 16:11:17 2019
@@ -121,8 +121,8 @@ struct g22 {int x;} __attribute((packed)
 struct g23 {char a; short b; char c; struct g22 d;};
 struct g23 g24 = {1,2,3,4};
 
-// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8], [4 
x i8]* @__func__.g25, i32 0, i32 0)
-// CHECK: @__func__.g25 = private unnamed_addr constant [4 x i8] c"g25\00"
+// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8], [4 
x i8]* @[[FUNC:.*]], i32 0, i32 0)
+// CHECK: @[[FUNC]] = private unnamed_addr constant [4 x i8] c"g25\00"
 int g25() {
   static const char *g26 = __func__;
   return *g26;
@@ -153,7 +153,7 @@ void g29() {
   DCC_PASSWD passwd;
   } DCC_SRVR_NM;
   // CHECK: @g29.a = internal global %struct.DCC_SRVR_NM { [2 x i8] c"@\00" }, 
align 1
-  // CHECK: @g29.b = internal global [1 x i32] [i32 ptrtoint ([5 x i8]* @.str 
to i32)], align 4
+  // CHECK: @g29.b = internal global [1 x i32] [i32 ptrtoint ([5 x i8]* 
@.str.1 to i32)], align 4
   // CHECK: @g29.c = internal global [1 x i32] [i32 97], align 4
   static DCC_SRVR_NM a = { {"@"} };
   static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to 
integer conversion initializing 'int' with an expression of type 'char [5]'}}

Modified: cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp?rev=351766&r1=351765&r2=351766&view=diff
==
--- cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp Mon Jan 21 16:11:17 2019
@@ -20,6 +20,8 @@
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private 
unnamed_addr constant [31 x i8] c"~ClassBlockConstr_block_invoke\00"
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private 
unnamed_addr constant [30 x i8] c"ClassBlockConstr_block_invoke\00"
 
+// CHECK-DAG: private unnamed_addr constant [32 x i8] c"const char 
*ConstexprPrettyFn()\00"
+
 int printf(const char * _Format, ...);
 
 class ClassInTopLevelNamespace {
@@ -83,6 +85,11 @@ public:
   const char *getFunc() const { return Func; }
 };
 
+constexpr const char* ConstexprPrettyFn() {
+  return __PRETTY_FUNCTION__;
+}
+const char* ConstexprPrettyVar = ConstexprPrettyFn();
+
 int
 main() {
   int a;


___
cfe-commits

r345779 - [ARM64] [Windows] Implement _InterlockedExchangeAdd*_* builtins.

2018-10-31 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Oct 31 14:31:09 2018
New Revision: 345779

URL: http://llvm.org/viewvc/llvm-project?rev=345779&view=rev
Log:
[ARM64] [Windows] Implement _InterlockedExchangeAdd*_* builtins.

These apparently need to be proper builtins to handle the Windows
SDK.

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/ms-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=345779&r1=345778&r2=345779&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Wed Oct 31 14:31:09 2018
@@ -104,6 +104,19 @@ TARGET_HEADER_BUILTIN(_InterlockedIncrem
 TARGET_HEADER_BUILTIN(_InterlockedOr64,  "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_acq, "LiLiD*Li", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_rel, "LiLiD*Li", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_nf, "LiLiD*Li", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_acq, "ccD*c", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_rel, "ccD*c", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_nf, "ccD*c", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd16_acq, "ssD*s", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd16_rel, "ssD*s", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd16_nf, "ssD*s", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64_acq, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64_rel, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64_nf, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+
 TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__getReg, "ULLii", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
 TARGET_HEADER_BUILTIN(_ReadStatusReg,  "ii",  "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=345779&r1=345778&r2=345779&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Wed Oct 31 14:31:09 2018
@@ -230,6 +230,19 @@ TARGET_HEADER_BUILTIN(_InterlockedIncrem
 TARGET_HEADER_BUILTIN(_InterlockedOr64,  "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_acq, "LiLiD*Li", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_rel, "LiLiD*Li", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_nf, "LiLiD*Li", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_acq, "ccD*c", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_rel, "ccD*c", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_nf, "ccD*c", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd16_acq, "ssD*s", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd16_rel, "ssD*s", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd16_nf, "ssD*s", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64_acq, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64_rel, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64_nf, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef LANGBUILTIN
 #undef TARGET_HEADER_BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=345779&r1=345778&r2=345779&view=diff
===

r345781 - [AArch64] [Windows] Emit unwind tables by default.

2018-10-31 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Oct 31 14:39:41 2018
New Revision: 345781

URL: http://llvm.org/viewvc/llvm-project?rev=345781&view=rev
Log:
[AArch64] [Windows] Emit unwind tables by default.

Unwind tables are necessary even in code that doesn't support
exceptions.  The tables are used for setjmp(), and by debuggers.

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


Modified:
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=345781&r1=345780&r2=345781&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Wed Oct 31 14:39:41 2018
@@ -722,15 +722,15 @@ bool MSVCToolChain::IsIntegratedAssemble
 }
 
 bool MSVCToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
-  // Emit unwind tables by default on Win64. All non-x86_32 Windows platforms
-  // such as ARM and PPC actually require unwind tables, but LLVM doesn't know
-  // how to generate them yet.
-
   // Don't emit unwind tables by default for MachO targets.
   if (getTriple().isOSBinFormatMachO())
 return false;
 
-  return getArch() == llvm::Triple::x86_64;
+  // All non-x86_32 Windows targets require unwind tables. However, LLVM
+  // doesn't know how to generate them for all targets, so only enable
+  // the ones that are actually implemented.
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool MSVCToolChain::isPICDefault() const {


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


r356196 - [CodeGen] Consider tied operands when adjusting inline asm operands.

2019-03-14 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Mar 14 12:46:51 2019
New Revision: 356196

URL: http://llvm.org/viewvc/llvm-project?rev=356196&view=rev
Log:
[CodeGen] Consider tied operands when adjusting inline asm operands.

The constraint "0" in the following asm did not consider the its
relationship with "=y" when try to replace the type of the operands.

asm ("nop" : "=y"(Mu8_1 ) : "0"(Mu8_0 ));

Patch by Xiang Zhang.

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



Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/test/CodeGen/asm-inout.c

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=356196&r1=356195&r2=356196&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Mar 14 12:46:51 2019
@@ -1939,6 +1939,9 @@ void CodeGenFunction::EmitAsmStmt(const
   std::vector InOutArgs;
   std::vector InOutArgTypes;
 
+  // Keep track of out constraints for tied input operand.
+  std::vector OutputConstraints;
+
   // An inline asm can be marked readonly if it meets the following conditions:
   //  - it doesn't have any sideeffects
   //  - it doesn't clobber memory
@@ -1961,7 +1964,7 @@ void CodeGenFunction::EmitAsmStmt(const
 OutputConstraint = AddVariableConstraints(OutputConstraint, *OutExpr,
   getTarget(), CGM, S,
   Info.earlyClobber());
-
+OutputConstraints.push_back(OutputConstraint);
 LValue Dest = EmitLValue(OutExpr);
 if (!Constraints.empty())
   Constraints += ',';
@@ -2079,6 +2082,7 @@ void CodeGenFunction::EmitAsmStmt(const
 InputConstraint, *InputExpr->IgnoreParenNoopCasts(getContext()),
 getTarget(), CGM, S, false /* No EarlyClobber */);
 
+std::string ReplaceConstraint (InputConstraint);
 llvm::Value *Arg = EmitAsmInput(Info, InputExpr, Constraints);
 
 // If this input argument is tied to a larger output result, extend the
@@ -2106,9 +2110,11 @@ void CodeGenFunction::EmitAsmStmt(const
   Arg = Builder.CreateFPExt(Arg, OutputTy);
 }
   }
+  // Deal with the tied operands' constraint code in adjustInlineAsmType.
+  ReplaceConstraint = OutputConstraints[Output];
 }
 if (llvm::Type* AdjTy =
-  getTargetHooks().adjustInlineAsmType(*this, InputConstraint,
+  getTargetHooks().adjustInlineAsmType(*this, ReplaceConstraint,
Arg->getType()))
   Arg = Builder.CreateBitCast(Arg, AdjTy);
 else

Modified: cfe/trunk/test/CodeGen/asm-inout.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm-inout.c?rev=356196&r1=356195&r2=356196&view=diff
==
--- cfe/trunk/test/CodeGen/asm-inout.c (original)
+++ cfe/trunk/test/CodeGen/asm-inout.c Thu Mar 14 12:46:51 2019
@@ -46,3 +46,12 @@ __m64 test5(__m64 __A, __m64 __B) {
   asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
   return __A;
 }
+
+// CHECK: @test6
+int test6(void) {
+  typedef unsigned char __attribute__((vector_size(8))) _m64u8;
+  _m64u8 __attribute__((aligned(16))) Mu8_0, __attribute__((aligned(16))) 
Mu8_1;
+  // CHECK: call x86_mmx asm "nop", "=y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx 
%1)
+  asm ("nop" : "=y"(Mu8_1 ) : "0"(Mu8_0 ));
+  return 0;
+}


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


RE: r351629 - Emit !callback metadata and introduce the callback attribute

2019-01-31 Thread Eli Friedman via cfe-commits
(Comments inline.)

> -Original Message-
> From: cfe-commits  On Behalf Of
> Doerfert, Johannes Rudolf via cfe-commits
> Sent: Tuesday, January 22, 2019 9:29 AM
> To: Chandler Carruth 
> Cc: cfe-commits cfe 
> Subject: Re: r351629 - Emit !callback metadata and introduce the callback
> attribute
> 
> > Another thing I notecide is that this code assumes the system has
> > `pthread.h` -- what about systems without it? I mean, you can disable the
> > test, but it seems bad to lose test coverage just because of that.
> 
> So far, I disabled the test with a later addition which makes sure this
> test is only run under Linux. I'm unsure why we loose coverage because
> of that?

There isn't any way to safely disable the test without disabling it everywhere. 
 Specifically, the current version requires both that the host is Unix, and 
that the default target is the host.  Otherwise, the compiler might not be able 
to find and/or build pthread.h .

> 
> > I would much prefer that you provide your own stub `pthread.h` in the
> > Inputs/... tree of the test suite and use that to test this in a portable
> > way.
> 
> I do not completely follow but I'm open to improving the test. Basically
> I have to make sure the builtin recognition will trigger on the header
> file and the contained declaration. If we can somehow do this in a
> portable way I'm all for it. Is that how we test other builtin gnu extensions?

You don't need a header file; clang doesn't actually care where the builtin is 
declared.  You can just write "void pthread_create(void*,void*,void*(void*), 
void*);" or whatever directly in the C file.  It'll trigger a warning, but with 
your patch, there's no way to declare pthread_create without triggering a 
warning, so that hardly matters.

On a related note, code generation tests should use %clang_cc1.  Among other 
things, this avoids accidentally including headers from the host system.

-Eli 

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


Re: [PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-05 Thread Eli Friedman via cfe-commits
What sort of outputs, specifically?  Memory outputs are easy; I think the LLVM 
IR patch actually supports them already.  Register outputs are complicated... I 
guess they're also possible, but we would need to come up with some frontend 
rule that allows sane code generation.  Consider the case where two or more asm 
gotos jump to the same destination, and output a value to the same register, 
but a different variable.  In general, it's possible to lower by rewriting the 
PHI nodes to match, then inserting a switch at the beginning of the destination 
to fix the rewritten PHIs.  But that's both expensive at runtime and difficult 
to implement, so we probably want a rule that prohibits constructs which would 
require that sort of lowering.


If we do intend to implement register outputs at some point, we might want to 
draft a design at the LLVM IR level now, so we have some confidence the current 
IR is forward-compatible.


Obviously we should have diagnostics in the parser if the user tries to write 
an asm goto with an output.  I'm not worried about the difficulty of fixing the 
frontend otherwise; this patch isn't that big in the first place.


-Eli



From: Nick Desaulniers 
Sent: Tuesday, February 5, 2019 1:14 AM
To: reviews+d56571+public+1482c3abd76a8...@reviews.llvm.org
Cc: Yu, Jennifer; Keane, Erich; chandl...@gmail.com; syaghm...@apple.com; 
craig.top...@gmail.com; h...@chromium.org; e5ten.a...@gmail.com; 
d...@golovin.in; natechancel...@gmail.com; tstel...@redhat.com; Eli Friedman; 
srhi...@google.com; era...@google.com; cfe-commits@lists.llvm.org
Subject: [EXT] Re: [PATCH] D56571: [RFC prototype] Implementation of asm-goto 
support in clang

Note that kernel developers are requesting output support with ASM goto. 
Doesn't need to be in V1 of ASM go-to support, but we should expect it to be 
implemented in the future. We should help users with diagnostics that this is 
not supported, and add asserts that will help us implement such a feature in 
the future.


On Tue, Feb 5, 2019, 3:32 AM Richard Smith - zygoloid via Phabricator 
mailto:revi...@reviews.llvm.org> wrote:
rsmith added inline comments.



Comment at: lib/AST/Stmt.cpp:457-460
   this->NumOutputs = NumOutputs;
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
+  this->NumLabels = NumLabels;

jyu2 wrote:
> rsmith wrote:
> > Please assert that you don't have both outputs and labels here. (If you 
> > did, you would assign them the same slots within `Exprs`.)
> >
> > You also seem to be missing `Sema` enforcement of the rule that you cannot 
> > have both outputs and labels. (If you want to actually support that as an 
> > intentional extension to the GCC functionality, you should change the 
> > implementation of `GCCAsmStmt` to use different slots for outputs and 
> > labels, add some tests, and add a `-Wgcc-compat` warning for that case. 
> > Seems better to just add an error for it for now.)
> This is enforcement during the parer.
>
> for example:
> a.c:12:23: error: expected ':'
> asm goto ("decl %0;" :"a": "m"(cond) : "memory" );
>
> Do you think this is enough for now?
> Thanks.
> Jennifer
Thanks, I see it now. Please still add the assert here.

I'd also like a custom diagnostic for that parse error; it'd seem easy and 
useful to add an "asm goto cannot have output constraints" error.


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

https://reviews.llvm.org/D56571



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


r353493 - [COFF, ARM64] Fix types for _ReadStatusReg, _WriteStatusReg

2019-02-07 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Feb  7 17:17:49 2019
New Revision: 353493

URL: http://llvm.org/viewvc/llvm-project?rev=353493&view=rev
Log:
[COFF, ARM64] Fix types for _ReadStatusReg, _WriteStatusReg

r344765 added those intrinsics, but used the wrong types.

Patch by Mike Hommey

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=353493&r1=353492&r2=353493&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Thu Feb  7 17:17:49 2019
@@ -203,8 +203,8 @@ TARGET_HEADER_BUILTIN(_InterlockedDecrem
 
 TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__getReg, "ULLii", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
-TARGET_HEADER_BUILTIN(_ReadStatusReg,  "ii",  "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_WriteStatusReg, "vii", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_ReadStatusReg,  "LLii",  "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_WriteStatusReg, "viLLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
 #undef BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=353493&r1=353492&r2=353493&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Feb  7 17:17:49 2019
@@ -7076,19 +7076,16 @@ Value *CodeGenFunction::EmitAArch64Built
 llvm::Value *Metadata = llvm::MetadataAsValue::get(Context, RegName);
 
 llvm::Type *RegisterType = Int64Ty;
-llvm::Type *ValueType = Int32Ty;
 llvm::Type *Types[] = { RegisterType };
 
 if (BuiltinID == AArch64::BI_ReadStatusReg) {
   llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::read_register, 
Types);
-  llvm::Value *Call = Builder.CreateCall(F, Metadata);
 
-  return Builder.CreateTrunc(Call, ValueType);
+  return Builder.CreateCall(F, Metadata);
 }
 
 llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::write_register, 
Types);
 llvm::Value *ArgValue = EmitScalarExpr(E->getArg(1));
-ArgValue = Builder.CreateZExt(ArgValue, RegisterType);
 
 return Builder.CreateCall(F, { Metadata, ArgValue });
   }

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=353493&r1=353492&r2=353493&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Thu Feb  7 17:17:49 2019
@@ -554,8 +554,8 @@ __nop(void) {
 #if defined(__aarch64__)
 unsigned __int64 __getReg(int);
 long _InterlockedAdd(long volatile *Addend, long Value);
-int _ReadStatusReg(int);
-void _WriteStatusReg(int, int);
+__int64 _ReadStatusReg(int);
+void _WriteStatusReg(int, __int64);
 
 static inline unsigned short _byteswap_ushort (unsigned short val) {
   return __builtin_bswap16(val);

Modified: cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp?rev=353493&r1=353492&r2=353493&view=diff
==
--- cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp (original)
+++ cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp Thu Feb  7 17:17:49 
2019
@@ -23,88 +23,112 @@
 #define ARM64_TPIDRRO_EL0   ARM64_SYSREG(3,3,13, 0,3)  // Thread ID 
Register, User Read Only [CP15_TPIDRURO]
 #define ARM64_TPIDR_EL1 ARM64_SYSREG(3,0,13, 0,4)  // Thread ID 
Register, Privileged Only [CP15_TPIDRPRW]
 
-void check_ReadWriteStatusReg(int v) {
-  int ret;
+// From intrin.h
+__int64 _ReadStatusReg(int);
+void _WriteStatusReg(int, __int64);
+
+void check_ReadWriteStatusReg(__int64 v) {
+  __int64 ret;
   ret = _ReadStatusReg(ARM64_CNTVCT);
-// CHECK-ASM: mrs x8, CNTVCT_EL0
-// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
+// CHECK-ASM: mrs x0, CNTVCT_EL0
+// CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD2:.*]])
+// CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMCCNTR_EL0);
-// CHECK-ASM: mrs x8, PMCCNTR_EL0
-// CHECK-IR: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
+// CHECK-ASM: mrs x0, PMCCNTR_EL0
+// CHECK-IR: %[[VAR:.*]] = call 

r353569 - [Sema] Make string literal init an rvalue.

2019-02-08 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Fri Feb  8 13:18:46 2019
New Revision: 353569

URL: http://llvm.org/viewvc/llvm-project?rev=353569&view=rev
Log:
[Sema] Make string literal init an rvalue.

This allows substantially simplifying the expression evaluation code,
because we don't have to special-case lvalues which are actually string
literal initialization.

This currently throws away an optimization where we would avoid creating
an array APValue for string literal initialization.  If we really want
to optimize this case, we should fix APValue so it can store simple
arrays more efficiently, like llvm::ConstantDataArray.  This shouldn't
affect the memory usage for other string literals.  (Not sure if this is
a blocker; I don't think string literal init is common enough for this
to be a serious issue, but I could be wrong.)

The change to test/CodeGenObjC/encode-test.m is a weird side-effect of
these changes: we currently don't constant-evaluate arrays in C, so the
strlen call shouldn't be folded, but lvalue string init managed to get
around that check.  I this this is fine.

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


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/AST/ast-dump-wchar.cpp
cfe/trunk/test/CodeGenObjC/encode-test.m
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=353569&r1=353568&r2=353569&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb  8 13:18:46 2019
@@ -2688,9 +2688,11 @@ static APSInt extractStringLiteralCharac
 }
 
 // Expand a string literal into an array of characters.
-static void expandStringLiteral(EvalInfo &Info, const Expr *Lit,
+//
+// FIXME: This is inefficient; we should probably introduce something similar
+// to the LLVM ConstantDataArray to make this cheaper.
+static void expandStringLiteral(EvalInfo &Info, const StringLiteral *S,
 APValue &Result) {
-  const StringLiteral *S = cast(Lit);
   const ConstantArrayType *CAT =
   Info.Ctx.getAsConstantArrayType(S->getType());
   assert(CAT && "string literal isn't an array");
@@ -2884,18 +2886,6 @@ findSubobject(EvalInfo &Info, const Expr
 
   ObjType = CAT->getElementType();
 
-  // An array object is represented as either an Array APValue or as an
-  // LValue which refers to a string literal.
-  if (O->isLValue()) {
-assert(I == N - 1 && "extracting subobject of character?");
-assert(!O->hasLValuePath() || O->getLValuePath().empty());
-if (handler.AccessKind != AK_Read)
-  expandStringLiteral(Info, O->getLValueBase().get(),
-  *O);
-else
-  return handler.foundString(*O, ObjType, Index);
-  }
-
   if (O->getArrayInitializedElts() > Index)
 O = &O->getArrayInitializedElt(Index);
   else if (handler.AccessKind != AK_Read) {
@@ -3008,11 +2998,6 @@ struct ExtractSubobjectHandler {
 Result = APValue(Value);
 return true;
   }
-  bool foundString(APValue &Subobj, QualType SubobjType, uint64_t Character) {
-Result = APValue(extractStringLiteralCharacter(
-Info, Subobj.getLValueBase().get(), Character));
-return true;
-  }
 };
 } // end anonymous namespace
 
@@ -3070,9 +3055,6 @@ struct ModifySubobjectHandler {
 Value = NewVal.getFloat();
 return true;
   }
-  bool foundString(APValue &Subobj, QualType SubobjType, uint64_t Character) {
-llvm_unreachable("shouldn't encounter string elements with ExpandArrays");
-  }
 };
 } // end anonymous namespace
 
@@ -3386,12 +3368,20 @@ static bool handleLValueToRValueConversi
   CompleteObject LitObj(&Lit, Base->getType(), false);
   return extractSubobject(Info, Conv, LitObj, LVal.Designator, RVal);
 } else if (isa(Base) || isa(Base)) {
-  // We represent a string literal array as an lvalue pointing at the
-  // corresponding expression, rather than building an array of chars.
-  // FIXME: Support ObjCEncodeExpr, MakeStringConstant
-  APValue Str(Base, CharUnits::Zero(), APValue::NoLValuePath(), 0);
-  CompleteObject StrObj(&Str, Base->getType(), false);
-  return extractSubobject(Info, Conv, StrObj, LVal.Designator, RVal);
+  // Special-case character extraction so we don't have to construct an
+  // APValue for the whole string.
+  assert(LVal.Designator.Entries.size() == 1 &&
+ "Can only read characters from string literals");
+  if (LVal.Designator.isOnePastTheEnd()) {
+if (Info.getLangOpts().CPlusPlus11)
+  Info.FFDiag(Conv, diag::note_constexpr_access_past_end) << AK_Read;
+else
+  Info.FFDiag(Conv);
+return false;
+  }
+  uint64_t C

r353571 - [CodeGen][NFC] Update comments in CGExprConstant.cpp.

2019-02-08 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Fri Feb  8 13:36:04 2019
New Revision: 353571

URL: http://llvm.org/viewvc/llvm-project?rev=353571&view=rev
Log:
[CodeGen][NFC] Update comments in CGExprConstant.cpp.


Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=353571&r1=353570&r2=353571&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Feb  8 13:36:04 2019
@@ -700,10 +700,12 @@ EmitArrayConstant(CodeGenModule &CGM, co
   return llvm::ConstantStruct::get(SType, Elements);
 }
 
-/// This class only needs to handle two cases:
-/// 1) Literals (this is used by APValue emission to emit literals).
-/// 2) Arrays, structs and unions (outside C++11 mode, we don't currently
-///constant fold these types).
+// This class only needs to handle arrays, structs and unions. Outside C++11
+// mode, we don't currently constant fold those types.  All other types are
+// handled by constant folding.
+//
+// Constant folding is currently missing support for a few features supported
+// here: CK_ToUnion, CK_ReinterpretMemberPointer, and DesignatedInitUpdateExpr.
 class ConstExprEmitter :
   public StmtVisitor {
   CodeGenModule &CGM;
@@ -1076,6 +1078,7 @@ public:
   }
 
   llvm::Constant *VisitStringLiteral(StringLiteral *E, QualType T) {
+// This is a string literal initializing an array in an initializer.
 return CGM.GetConstantArrayFromStringLiteral(E);
   }
 
@@ -1649,7 +1652,7 @@ private:
 llvm::Constant *ConstantLValueEmitter::tryEmit() {
   const APValue::LValueBase &base = Value.getLValueBase();
 
-  // Otherwise, the destination type should be a pointer or reference
+  // The destination type should be a pointer or reference
   // type, but it might also be a cast thereof.
   //
   // FIXME: the chain of casts required should be reflected in the APValue.


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


RE: r353569 - [Sema] Make string literal init an rvalue.

2019-02-08 Thread Eli Friedman via cfe-commits
s4-ubuntu-
> fast/llvm.src/tools/clang/tools/extra/test/../test/clang-
> tidy/check_clang_tidy.py", line 147, in main
> subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
>   File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
> raise CalledProcessError(retcode, cmd, output=output)
> subprocess.CalledProcessError: Command '['clang-tidy', '/home/buildslave/ps4-
> buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-
> fast/llvm.obj/tools/clang/tools/extra/test/clang-tidy/Output/bugprone-string-
> constructor.cpp.tmp.cpp', '-fix', '--checks=-*,bugprone-string-constructor', 
> '--',
> '--std=c++11', '-nostdinc++']' returned non-zero exit status -6
> 
> Douglas Yung
> 
> -Original Message-
> From: cfe-commits  On Behalf Of Eli
> Friedman via cfe-commits
> Sent: Friday, February 8, 2019 13:19
> To: cfe-commits@lists.llvm.org
> Subject: r353569 - [Sema] Make string literal init an rvalue.
> 
> Author: efriedma
> Date: Fri Feb  8 13:18:46 2019
> New Revision: 353569
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=353569&view=rev
> Log:
> [Sema] Make string literal init an rvalue.
> 
> This allows substantially simplifying the expression evaluation code, because 
> we
> don't have to special-case lvalues which are actually string literal 
> initialization.
> 
> This currently throws away an optimization where we would avoid creating an
> array APValue for string literal initialization.  If we really want to 
> optimize this
> case, we should fix APValue so it can store simple arrays more efficiently, 
> like
> llvm::ConstantDataArray.  This shouldn't affect the memory usage for other
> string literals.  (Not sure if this is a blocker; I don't think string 
> literal init is
> common enough for this to be a serious issue, but I could be wrong.)
> 
> The change to test/CodeGenObjC/encode-test.m is a weird side-effect of these
> changes: we currently don't constant-evaluate arrays in C, so the strlen call
> shouldn't be folded, but lvalue string init managed to get around that check. 
>  I
> this this is fine.
> 
> Fixes https://bugs.llvm.org/show_bug.cgi?id=40430 .
> 
> 
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/test/AST/ast-dump-wchar.cpp
> cfe/trunk/test/CodeGenObjC/encode-test.m
> cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
> 
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=353569&r1=353568&r2=35356
> 9&view=diff
> =
> =
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb  8 13:18:46 2019
> @@ -2688,9 +2688,11 @@ static APSInt extractStringLiteralCharac  }
> 
>  // Expand a string literal into an array of characters.
> -static void expandStringLiteral(EvalInfo &Info, const Expr *Lit,
> +//
> +// FIXME: This is inefficient; we should probably introduce something
> +similar // to the LLVM ConstantDataArray to make this cheaper.
> +static void expandStringLiteral(EvalInfo &Info, const StringLiteral *S,
>  APValue &Result) {
> -  const StringLiteral *S = cast(Lit);
>const ConstantArrayType *CAT =
>Info.Ctx.getAsConstantArrayType(S->getType());
>assert(CAT && "string literal isn't an array"); @@ -2884,18 +2886,6 @@
> findSubobject(EvalInfo &Info, const Expr
> 
>ObjType = CAT->getElementType();
> 
> -  // An array object is represented as either an Array APValue or as an
> -  // LValue which refers to a string literal.
> -  if (O->isLValue()) {
> -assert(I == N - 1 && "extracting subobject of character?");
> -assert(!O->hasLValuePath() || O->getLValuePath().empty());
> -if (handler.AccessKind != AK_Read)
> -  expandStringLiteral(Info, O->getLValueBase().get(),
> -  *O);
> -else
> -  return handler.foundString(*O, ObjType, Index);
> -  }
> -
>if (O->getArrayInitializedElts() > Index)
>  O = &O->getArrayInitializedElt(Index);
>else if (handler.AccessKind != AK_Read) { @@ -3008,11 +2998,6 @@ struct
> ExtractSubobjectHandler {
>  Result = APValue(Value);
>  return true;
>}
> -  bool foundString(APValue &Subobj, QualType Su

r353598 - Fix buildbot failure from r353569.

2019-02-08 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Fri Feb  8 18:22:17 2019
New Revision: 353598

URL: http://llvm.org/viewvc/llvm-project?rev=353598&view=rev
Log:
Fix buildbot failure from r353569.

I assumed lvalue-to-rvalue conversions of array type would never
happen, but apparently clang-tidy tries in some cases.


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=353598&r1=353597&r2=353598&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb  8 18:22:17 2019
@@ -3370,8 +3370,15 @@ static bool handleLValueToRValueConversi
 } else if (isa(Base) || isa(Base)) {
   // Special-case character extraction so we don't have to construct an
   // APValue for the whole string.
-  assert(LVal.Designator.Entries.size() == 1 &&
+  assert(LVal.Designator.Entries.size() <= 1 &&
  "Can only read characters from string literals");
+  if (LVal.Designator.Entries.empty()) {
+// Fail for now for LValue to RValue conversion of an array.
+// (This shouldn't show up in C/C++, but it could be triggered by a
+// weird EvaluateAsRValue call from a tool.)
+Info.FFDiag(Conv);
+return false;
+  }
   if (LVal.Designator.isOnePastTheEnd()) {
 if (Info.getLangOpts().CPlusPlus11)
   Info.FFDiag(Conv, diag::note_constexpr_access_past_end) << AK_Read;


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


RE: r353569 - [Sema] Make string literal init an rvalue.

2019-02-08 Thread Eli Friedman via cfe-commits
Fixed in r353598.

-Eli

> -Original Message-
> From: cfe-commits  On Behalf Of Eli
> Friedman via cfe-commits
> Sent: Friday, February 8, 2019 6:06 PM
> To: douglas.y...@sony.com
> Cc: cfe-commits@lists.llvm.org
> Subject: [EXT] RE: r353569 - [Sema] Make string literal init an rvalue.
> 
> Looking.  It looks like this only fails with clang-tidy, so I'll give myself 
> a few
> minutes to look before reverting.
> 
> -Eli
> 
> > -Original Message-
> > From: douglas.y...@sony.com 
> > Sent: Friday, February 8, 2019 3:58 PM
> > To: Eli Friedman 
> > Cc: cfe-commits@lists.llvm.org
> > Subject: [EXT] RE: r353569 - [Sema] Make string literal init an rvalue.
> >
> > Hi Eli,
> >
> > Your commit is causing a failure on the PS4 linux bot, can you please take a
> > look?
> >
> > http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-
> > fast/builds/43625
> >
> > FAIL: Clang Tools :: clang-tidy/bugprone-string-constructor.cpp (14325 of
> > 46835)
> >  TEST 'Clang Tools :: clang-tidy/bugprone-string-
> > constructor.cpp' FAILED 
> > Script:
> > --
> > : 'RUN: at line 1';   /usr/bin/python2.7 
> > /home/buildslave/ps4-buildslave4/llvm-
> > clang-lld-x86_64-scei-ps4-ubuntu-
> > fast/llvm.src/tools/clang/tools/extra/test/../test/clang-
> > tidy/check_clang_tidy.py /home/buildslave/ps4-buildslave4/llvm-clang-lld-
> > x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/tools/extra/test/clang-
> > tidy/bugprone-string-constructor.cpp bugprone-string-constructor
> > /home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-
> > fast/llvm.obj/tools/clang/tools/extra/test/clang-tidy/Output/bugprone-string-
> > constructor.cpp.tmp
> > --
> > Exit Code: 1
> >
> > Command Output (stdout):
> > --
> > Running ['clang-tidy', '/home/buildslave/ps4-buildslave4/llvm-clang-lld-
> x86_64-
> > scei-ps4-ubuntu-fast/llvm.obj/tools/clang/tools/extra/test/clang-
> > tidy/Output/bugprone-string-constructor.cpp.tmp.cpp', '-fix', '--checks=-
> > *,bugprone-string-constructor', '--', '--std=c++11', '-nostdinc++']...
> > clang-tidy failed:
> > clang-tidy: /home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-
> > ubuntu-fast/llvm.src/tools/clang/lib/AST/ExprConstant.cpp:3374: bool
> > handleLValueToRValueConversion((anonymous namespace)::EvalInfo &, const
> > clang::Expr *, clang::QualType, const (anonymous namespace)::LValue &,
> > clang::APValue &): Assertion `LVal.Designator.Entries.size() == 1 && "Can 
> > only
> > read characters from string literals"' failed.
> >  #0 0x004ad2c4 (clang-tidy+0x4ad2c4)
> >  #1 0x004ab03c (clang-tidy+0x4ab03c)
> >  #2 0x004ad878 (clang-tidy+0x4ad878)
> >  #3 0x7f034560b890 __restore_rt (/lib/x86_64-linux-
> > gnu/libpthread.so.0+0x12890)
> >  #4 0x7f03442d1e97 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x3ee97)
> >  #5 0x7f03442d3801 abort (/lib/x86_64-linux-gnu/libc.so.6+0x40801)
> >  #6 0x7f03442c339a (/lib/x86_64-linux-gnu/libc.so.6+0x3039a)
> >  #7 0x7f03442c3412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
> >  #8 0x01941c9d (clang-tidy+0x1941c9d)
> >  #9 0x0192b797 (clang-tidy+0x192b797)
> > #10 0x019266be (clang-tidy+0x19266be)
> > #11 0x005771f9 (clang-tidy+0x5771f9)
> > #12 0x01769d11 (clang-tidy+0x1769d11)
> > #13 0x01782d4b (clang-tidy+0x1782d4b)
> > #14 0x01769497 (clang-tidy+0x1769497)
> > #15 0x01774613 (clang-tidy+0x1774613)
> > #16 0x0177161f (clang-tidy+0x177161f)
> > #17 0x01782ad2 (clang-tidy+0x1782ad2)
> > #18 0x0176b3e6 (clang-tidy+0x176b3e6)
> > #19 0x0177f17d (clang-tidy+0x177f17d)
> > #20 0x0177161f (clang-tidy+0x177161f)
> > #21 0x017829f3 (clang-tidy+0x17829f3)
> > #22 0x0176b0bd (clang-tidy+0x176b0bd)
> > #23 0x0176e8b7 (clang-tidy+0x176e8b7)
> > #24 0x0176cfae (clang-tidy+0x176cfae)
> > #25 0x0174981f (clang-tidy+0x174981f)
> > #26 0x00c5020c (clang-tidy+0xc5020c)
> > #27 0x00d98873 (clang-tidy+0xd98873)
> > #28 0x00c381c0 (clang-tidy+0xc381c0)
> > #29 0x00bdcd31 (clang-tidy+0xbdcd31)
> > #30 0x00834386 (clang-tidy+0x834386)
> > #31 0x004ccba5 (clang-tidy+0x4ccba5)
> > #32 0x008340f6 (clang-tidy+0x8340f

r353762 - [Sema] Mark GNU compound literal array init as an rvalue.

2019-02-11 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Feb 11 14:54:27 2019
New Revision: 353762

URL: http://llvm.org/viewvc/llvm-project?rev=353762&view=rev
Log:
[Sema] Mark GNU compound literal array init as an rvalue.

Basically the same issue as string init, except it didn't really have
any visible consequences before I removed the implicit lvalue-to-rvalue
conversion from CodeGen.

While I'm here, a couple minor drive-by cleanups: IgnoreParens never
returns a ConstantExpr, and there was a potential crash with string init
involving a ChooseExpr.

The analyzer test change maybe indicates we could simplify the analyzer
code a little with this fix?  Apparently a hack was added to support
lvalues in initializers in r315750, but I'm not really familiar with the
relevant code.

Fixes regression reported in the kernel build at
https://bugs.llvm.org/show_bug.cgi?id=40430#c6 .

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


Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Analysis/compound-literals.c
cfe/trunk/test/CodeGen/compound-literal.c

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=353762&r1=353761&r2=353762&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Feb 11 14:54:27 2019
@@ -145,16 +145,42 @@ static void updateStringLiteralType(Expr
   while (true) {
 E->setType(Ty);
 E->setValueKind(VK_RValue);
-if (isa(E) || isa(E))
+if (isa(E) || isa(E)) {
   break;
-else if (ParenExpr *PE = dyn_cast(E))
+} else if (ParenExpr *PE = dyn_cast(E)) {
   E = PE->getSubExpr();
-else if (UnaryOperator *UO = dyn_cast(E))
+} else if (UnaryOperator *UO = dyn_cast(E)) {
+  assert(UO->getOpcode() == UO_Extension);
   E = UO->getSubExpr();
-else if (GenericSelectionExpr *GSE = dyn_cast(E))
+} else if (GenericSelectionExpr *GSE = dyn_cast(E)) {
   E = GSE->getResultExpr();
-else
+} else if (ChooseExpr *CE = dyn_cast(E)) {
+  E = CE->getChosenSubExpr();
+} else {
   llvm_unreachable("unexpected expr in string literal init");
+}
+  }
+}
+
+/// Fix a compound literal initializing an array so it's correctly marked
+/// as an rvalue.
+static void updateGNUCompoundLiteralRValue(Expr *E) {
+  while (true) {
+E->setValueKind(VK_RValue);
+if (isa(E)) {
+  break;
+} else if (ParenExpr *PE = dyn_cast(E)) {
+  E = PE->getSubExpr();
+} else if (UnaryOperator *UO = dyn_cast(E)) {
+  assert(UO->getOpcode() == UO_Extension);
+  E = UO->getSubExpr();
+} else if (GenericSelectionExpr *GSE = dyn_cast(E)) {
+  E = GSE->getResultExpr();
+} else if (ChooseExpr *CE = dyn_cast(E)) {
+  E = CE->getChosenSubExpr();
+} else {
+  llvm_unreachable("unexpected expr in array compound literal init");
+}
   }
 }
 
@@ -5542,8 +5568,7 @@ void InitializationSequence::InitializeF
 // array from a compound literal that creates an array of the same
 // type, so long as the initializer has no side effects.
 if (!S.getLangOpts().CPlusPlus && Initializer &&
-(isa(Initializer->IgnoreParens()) ||
- isa(Initializer->IgnoreParens())) &&
+isa(Initializer->IgnoreParens()) &&
 Initializer->getType()->isArrayType()) {
   const ArrayType *SourceAT
 = Context.getAsArrayType(Initializer->getType());
@@ -7956,6 +7981,7 @@ ExprResult InitializationSequence::Perfo
   S.Diag(Kind.getLocation(), diag::ext_array_init_copy)
 << Step->Type << CurInit.get()->getType()
 << CurInit.get()->getSourceRange();
+  updateGNUCompoundLiteralRValue(CurInit.get());
   LLVM_FALLTHROUGH;
 case SK_ArrayInit:
   // If the destination type is an incomplete array type, update the

Modified: cfe/trunk/test/Analysis/compound-literals.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/compound-literals.c?rev=353762&r1=353761&r2=353762&view=diff
==
--- cfe/trunk/test/Analysis/compound-literals.c (original)
+++ cfe/trunk/test/Analysis/compound-literals.c Mon Feb 11 14:54:27 2019
@@ -4,6 +4,5 @@ void clang_analyzer_eval(int);
 // pr28449: Used to crash.
 void foo(void) {
   static const unsigned short array[] = (const unsigned short[]){0x0F00};
-  // FIXME: Should be true.
-  clang_analyzer_eval(array[0] == 0x0F00); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(array[0] == 0x0F00); // expected-warning{{TRUE}}
 }

Modified: cfe/trunk/test/CodeGen/compound-literal.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/compound-literal.c?rev=353762&r1=353761&r2=353762&view=diff
==
--- cfe/trunk/test/CodeGen/compound-literal.c (original)
+++ cfe/trunk/test/CodeGen/compound-literal.c Mon Feb 11 14:5

RE: QualType

2019-08-15 Thread Eli Friedman via cfe-commits
Usually the cfe-dev mailing list is better for questions like this.

The type “int” is ASTContext::IntTy.  You can use QualType::withConst to add a 
“const” qualifier, and ASTContext::getPointerType to construct a pointer type.  
Putting that together, you can construct a “const int*” with something like 
“Context->getPointerType(Context->IntTy.withConst())”.

If you haven’t looked at the documentation yet, you might want to read 
https://clang.llvm.org/docs/IntroductionToTheClangAST.html and 
https://clang.llvm.org/docs/InternalsManual.html .

-Eli

From: cfe-commits  On Behalf Of Monalisa 
Rout via cfe-commits
Sent: Thursday, August 15, 2019 7:03 AM
To: cfe-commits@lists.llvm.org
Subject: [EXT] QualType

Hello,
I want to create QualType instances for const int, int* const,  and const int* 
const.
How can I do that??

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


r372187 - [ARM] Update clang for removal of vfp2d16 and vfp2d16sp

2019-09-17 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Tue Sep 17 14:43:19 2019
New Revision: 372187

URL: http://llvm.org/viewvc/llvm-project?rev=372187&view=rev
Log:
[ARM] Update clang for removal of vfp2d16 and vfp2d16sp

Matching fix for https://reviews.llvm.org/D67375 (r372186).

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


Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/CodeGen/arm-target-features.c
cfe/trunk/test/Driver/arm-mfpu.c

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=372187&r1=372186&r2=372187&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Tue Sep 17 14:43:19 2019
@@ -428,11 +428,10 @@ bool ARMTargetInfo::handleTargetFeatures
   for (const auto &Feature : Features) {
 if (Feature == "+soft-float") {
   SoftFloat = true;
-} else if (Feature == "+vfp2sp" || Feature == "+vfp2d16sp" ||
-   Feature == "+vfp2" || Feature == "+vfp2d16") {
+} else if (Feature == "+vfp2sp" || Feature == "+vfp2") {
   FPU |= VFP2FPU;
   HW_FP |= HW_FP_SP;
-  if (Feature == "+vfp2" || Feature == "+vfp2d16")
+  if (Feature == "+vfp2")
   HW_FP |= HW_FP_DP;
 } else if (Feature == "+vfp3sp" || Feature == "+vfp3d16sp" ||
Feature == "+vfp3" || Feature == "+vfp3d16") {

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=372187&r1=372186&r2=372187&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Tue Sep 17 14:43:19 2019
@@ -460,7 +460,7 @@ fp16_fml_fallthrough:
 //now just be explicit and disable all known dependent features
 //as well.
 for (std::string Feature : {
-"vfp2", "vfp2sp", "vfp2d16", "vfp2d16sp",
+"vfp2", "vfp2sp",
 "vfp3", "vfp3sp", "vfp3d16", "vfp3d16sp",
 "vfp4", "vfp4sp", "vfp4d16", "vfp4d16sp",
 "fp-armv8", "fp-armv8sp", "fp-armv8d16", "fp-armv8d16sp",

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=372187&r1=372186&r2=372187&view=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Tue Sep 17 14:43:19 2019
@@ -1,23 +1,23 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: 
"target-features"="+armv7-a,+d32,+dsp,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp"
+// CHECK-VFP3: 
"target-features"="+armv7-a,+d32,+dsp,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm 
-o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-2
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
-// CHECK-VFP4-DIV-2: 
"target-features"="+armv7s,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2d16,+vfp2d16sp,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4-DIV: 
"target-features"="+armv7-a,+d32,+dsp,+fp16,+fp64,+fpregs,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,+vfp4,+vfp4d16,+vfp4d16sp,+vfp4sp"
+// CHECK-VFP4-DIV-2: 
"target-features"="+armv7s,+d32,+dsp,+fp16,+f

RE: r370123 - [preprocessor] Add an opportunity to retain excluded conditional blocks

2019-09-25 Thread Eli Friedman via cfe-commits
-Original Message-
From: cfe-commits  On Behalf Of Evgeny 
Mankov via cfe-commits
Sent: Tuesday, August 27, 2019 3:16 PM
To: cfe-commits@lists.llvm.org
Subject: [EXT] r370123 - [preprocessor] Add an opportunity to retain excluded 
conditional blocks

Added: cfe/trunk/test/Index/retain-excluded-conditional-blocks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/retain-excluded-conditional-blocks.m?rev=370123&view=auto
==
--- cfe/trunk/test/Index/retain-excluded-conditional-blocks.m (added)
+++ cfe/trunk/test/Index/retain-excluded-conditional-blocks.m Tue Aug 27 
15:15:32 2019
@@ -0,0 +1,132 @@
+// RUN: c-index-test -retain-excluded-conditional-blocks %s | FileCheck %s
+
+#include 

Including libc headers, like stdint.h, in regression tests is not allowed. The 
compiler might not find an appropriate header if clang is built with a 
non-native default target.

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


r329965 - Remove -cc1 option "-backend-option".

2018-04-12 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Apr 12 15:21:36 2018
New Revision: 329965

URL: http://llvm.org/viewvc/llvm-project?rev=329965&view=rev
Log:
Remove -cc1 option "-backend-option".

It means the same thing as -mllvm; there isn't any reason to have two
options which do the same thing.

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


Removed:
cfe/trunk/test/Frontend/backend-option.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/thinlto-backend-option.ll
cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu
cfe/trunk/test/Driver/aarch64-fix-cortex-a53-835769.c
cfe/trunk/test/Driver/apple-kext-mkernel.c
cfe/trunk/test/Driver/arm-restrict-it.c
cfe/trunk/test/Driver/debug-options.c
cfe/trunk/test/Driver/mglobal-merge.c
cfe/trunk/test/Driver/woa-restrict-it.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=329965&r1=329964&r2=329965&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Apr 12 15:21:36 2018
@@ -275,8 +275,6 @@ def split_stacks : Flag<["-"], "split-st
   HelpText<"Try to use a split stack if possible.">;
 def mno_zero_initialized_in_bss : Flag<["-"], "mno-zero-initialized-in-bss">,
   HelpText<"Do not put zero initialized data in the BSS">;
-def backend_option : Separate<["-"], "backend-option">,
-  HelpText<"Additional arguments to forward to LLVM backend (during code 
gen)">;
 def mregparm : Separate<["-"], "mregparm">,
   HelpText<"Limit the number of registers available for integer arguments">;
 def munwind_tables : Flag<["-"], "munwind-tables">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=329965&r1=329964&r2=329965&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Thu Apr 12 15:21:36 2018
@@ -177,9 +177,6 @@ public:
   /// function instead of to trap instructions.
   std::string TrapFuncName;
 
-  /// A list of command-line options to forward to the LLVM backend.
-  std::vector BackendOptions;
-
   /// A list of dependent libraries.
   std::vector DependentLibraries;
 

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=329965&r1=329964&r2=329965&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Apr 12 15:21:36 2018
@@ -658,8 +658,6 @@ static void setCommandLineOpts(const Cod
 BackendArgs.push_back("-limit-float-precision");
 BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
   }
-  for (const std::string &BackendOption : CodeGenOpts.BackendOptions)
-BackendArgs.push_back(BackendOption.c_str());
   BackendArgs.push_back(nullptr);
   llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
 BackendArgs.data());

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=329965&r1=329964&r2=329965&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Apr 12 15:21:36 2018
@@ -1350,7 +1350,7 @@ void Clang::AddARMTargetArgs(const llvm:
   // Forward the -mglobal-merge option for explicit control over the pass.
   if (Arg *A = Args.getLastArg(options::OPT_mglobal_merge,
options::OPT_mno_global_merge)) {
-CmdArgs.push_back("-backend-option");
+CmdArgs.push_back("-mllvm");
 if (A->getOption().matches(options::OPT_mno_global_merge))
   CmdArgs.push_back("-arm-global-merge=false");
 else
@@ -1464,21 +1464,21 @@ void Clang::AddAArch64TargetArgs(const A
 
   if (Arg *A = Args.getLastArg(options::OPT_mfix_cortex_a53_835769,
options::OPT_mno_fix_cortex_a53_835769)) {
-CmdArgs.push_back("-backend-option");
+CmdArgs.push_back("-mllvm");
 if (A->getOption().matches(options::OPT_mfix_cortex_a53_835769))
   CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=1");
 else
   CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=0");
   } else if (Triple.isAndroid()) {
 // Enabled A53 errata (835769) workaround by default on android
-CmdArgs.push_b

r329968 - Fix test failure caused by r329965.

2018-04-12 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Apr 12 15:50:50 2018
New Revision: 329968

URL: http://llvm.org/viewvc/llvm-project?rev=329968&view=rev
Log:
Fix test failure caused by r329965.

"-mllvm" options get parsed slightly earlier, and -arm-restrict-it is
only available if the ARM target is compiled in. Invoke "clang -cc1"
directly to avoid the issue.


Modified:
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=329968&r1=329967&r2=329968&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Apr 12 15:50:50 2018
@@ -2652,7 +2652,7 @@
 // Thumbebv7: #define __THUMB_INTERWORK__ 1
 // Thumbebv7: #define __thumb2__ 1
 
-// RUN: %clang -E -dM -ffreestanding -target thumbv7-pc-mingw32 %s -o - | 
FileCheck -match-full-lines -check-prefix THUMB-MINGW %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv7-pc-windows-gnu 
-fdwarf-exceptions %s -o - | FileCheck -match-full-lines -check-prefix 
THUMB-MINGW %s
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 


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


[libcxxabi] r330162 - [libc++abi] Replace __sync_* functions with __libcpp_atomic_* functions.

2018-04-16 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Apr 16 15:00:14 2018
New Revision: 330162

URL: http://llvm.org/viewvc/llvm-project?rev=330162&view=rev
Log:
[libc++abi] Replace __sync_* functions with __libcpp_atomic_* functions.

This is basically part 2 of r313694.

It's a little unfortunate that I had to copy-paste atomic_support.h,
but I don't really see any alternative.

The refstring.h changes are the same as the libcxx changes in r313694.


Added:
libcxxabi/trunk/src/include/atomic_support.h
Modified:
libcxxabi/trunk/src/cxa_default_handlers.cpp
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_handlers.cpp
libcxxabi/trunk/src/include/refstring.h

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=330162&r1=330161&r2=330162&view=diff
==
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Mon Apr 16 15:00:14 2018
@@ -18,6 +18,7 @@
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
 #include "private_typeinfo.h"
+#include "include/atomic_support.h"
 
 #if !defined(LIBCXXABI_SILENT_TERMINATE)
 static const char* cause = "uncaught";
@@ -101,10 +102,6 @@ std::terminate_handler __cxa_terminate_h
 _LIBCXXABI_DATA_VIS
 std::unexpected_handler __cxa_unexpected_handler = default_unexpected_handler;
 
-// In the future these will become:
-// std::atomic  
__cxa_terminate_handler(default_terminate_handler);
-// std::atomic 
__cxa_unexpected_handler(default_unexpected_handler);
-
 namespace std
 {
 
@@ -113,10 +110,8 @@ set_unexpected(unexpected_handler func)
 {
 if (func == 0)
 func = default_unexpected_handler;
-return __atomic_exchange_n(&__cxa_unexpected_handler, func,
-   __ATOMIC_ACQ_REL);
-//  Using of C++11 atomics this should be rewritten
-//  return __cxa_unexpected_handler.exchange(func, memory_order_acq_rel);
+return __libcpp_atomic_exchange(&__cxa_unexpected_handler, func,
+_AO_Acq_Rel);
 }
 
 terminate_handler
@@ -124,10 +119,8 @@ set_terminate(terminate_handler func) _N
 {
 if (func == 0)
 func = default_terminate_handler;
-return __atomic_exchange_n(&__cxa_terminate_handler, func,
-   __ATOMIC_ACQ_REL);
-//  Using of C++11 atomics this should be rewritten
-//  return __cxa_terminate_handler.exchange(func, memory_order_acq_rel);
+return __libcpp_atomic_exchange(&__cxa_terminate_handler, func,
+_AO_Acq_Rel);
 }
 
 }

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=330162&r1=330161&r2=330162&view=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Mon Apr 16 15:00:14 2018
@@ -20,6 +20,7 @@
 #include "cxa_exception.hpp"
 #include "cxa_handlers.hpp"
 #include "fallback_malloc.h"
+#include "include/atomic_support.h"
 
 #if __has_feature(address_sanitizer)
 extern "C" void __asan_handle_no_return(void);
@@ -618,7 +619,7 @@ __cxa_increment_exception_refcount(void
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = 
cxa_exception_from_thrown_object(thrown_object);
-__sync_add_and_fetch(&exception_header->referenceCount, 1);
+std::__libcpp_atomic_add(&exception_header->referenceCount, size_t(1));
 }
 }
 
@@ -635,7 +636,7 @@ void __cxa_decrement_exception_refcount(
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = 
cxa_exception_from_thrown_object(thrown_object);
-if (__sync_sub_and_fetch(&exception_header->referenceCount, size_t(1)) 
== 0)
+if (std::__libcpp_atomic_add(&exception_header->referenceCount, 
size_t(-1)) == 0)
 {
 if (NULL != exception_header->exceptionDestructor)
 exception_header->exceptionDestructor(thrown_object);

Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=330162&r1=330161&r2=330162&view=diff
==
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Mon Apr 16 15:00:14 2018
@@ -18,6 +18,7 @@
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
 #include "private_typeinfo.h"
+#include "include/atomic_support.h"
 
 namespace std
 {
@@ -25,10 +26,7 @@ namespace std
 unexpected_handler
 get_unexpected() _NOEXCEPT
 {
-return __sync_fetch_and_add(&__cxa_unexpected_handler, 
(unexpected_handler)0);
-//  The above is safe but overkill on x86
-//  Using of C++11 atomics this should be rewritten
-//  return __cxa_unexpected_handler.load(memo

r330169 - [ARM] Compute a target feature which corresponds to the ARM version.

2018-04-16 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Apr 16 16:52:58 2018
New Revision: 330169

URL: http://llvm.org/viewvc/llvm-project?rev=330169&view=rev
Log:
[ARM] Compute a target feature which corresponds to the ARM version.

Currently, the interaction between the triple, the CPU, and the
supported features is a mess: the driver edits the triple to indicate
the supported architecture version, and the LLVM backend uses this to
figure out what instructions are legal.  This makes it difficult to
understand what's happening, and makes it impossible to LTO together two
modules with different computed architectures.

Instead of relying on triple rewriting to get the correct target
features, we should add the right target features explicitly.

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


Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/test/CodeGen/arm-long-calls.c
cfe/trunk/test/CodeGen/arm-no-movt.c
cfe/trunk/test/CodeGen/arm-target-features.c
cfe/trunk/test/CodeGen/arm-thumb-mode-target-feature.c

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=330169&r1=330168&r2=330169&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Mon Apr 16 16:52:58 2018
@@ -334,9 +334,20 @@ bool ARMTargetInfo::initFeatureMap(
 llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
 const std::vector &FeaturesVec) const {
 
+  std::string ArchFeature;
   std::vector TargetFeatures;
   llvm::ARM::ArchKind Arch = llvm::ARM::parseArch(getTriple().getArchName());
 
+  // Map the base architecture to an appropriate target feature, so we don't
+  // rely on the target triple.
+  llvm::ARM::ArchKind CPUArch = llvm::ARM::parseCPUArch(CPU);
+  if (CPUArch == llvm::ARM::ArchKind::INVALID)
+CPUArch = Arch;
+  if (CPUArch != llvm::ARM::ArchKind::INVALID) {
+ArchFeature = ("+" + llvm::ARM::getArchName(CPUArch)).str();
+TargetFeatures.push_back(ArchFeature);
+  }
+
   // get default FPU features
   unsigned FPUKind = llvm::ARM::getDefaultFPU(CPU, Arch);
   llvm::ARM::getFPUFeatures(FPUKind, TargetFeatures);

Modified: cfe/trunk/test/CodeGen/arm-long-calls.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-long-calls.c?rev=330169&r1=330168&r2=330169&view=diff
==
--- cfe/trunk/test/CodeGen/arm-long-calls.c (original)
+++ cfe/trunk/test/CodeGen/arm-long-calls.c Mon Apr 16 16:52:58 2018
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5  -target-feature +long-calls 
-emit-llvm -o - %s | FileCheck -check-prefix=LONGCALL %s
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck 
-check-prefix=NOLONGCALL %s
 
-// LONGCALL: attributes #0 = { {{.*}} 
"target-features"="+long-calls,+thumb-mode"
-// NOLONGCALL-NOT: attributes #0 = { {{.*}} 
"target-features"="+long-calls,+thumb-mode"
+// LONGCALL: attributes #0 = { {{.*}} 
"target-features"="+armv7-a,+long-calls,+thumb-mode"
+// NOLONGCALL-NOT: attributes #0 = { {{.*}} 
"target-features"="+armv7-a,+long-calls,+thumb-mode"
 
 int foo1(int a) { return a; }

Modified: cfe/trunk/test/CodeGen/arm-no-movt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-no-movt.c?rev=330169&r1=330168&r2=330169&view=diff
==
--- cfe/trunk/test/CodeGen/arm-no-movt.c (original)
+++ cfe/trunk/test/CodeGen/arm-no-movt.c Mon Apr 16 16:52:58 2018
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5  -target-feature +no-movt 
-emit-llvm -o - %s | FileCheck -check-prefix=NO-MOVT %s
 // RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck 
-check-prefix=MOVT %s
 
-// NO-MOVT: attributes #0 = { {{.*}} "target-features"="+no-movt,+thumb-mode"
-// MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+no-movt,+thumb-mode"
+// NO-MOVT: attributes #0 = { {{.*}} 
"target-features"="+armv7-a,+no-movt,+thumb-mode"
+// MOVT-NOT: attributes #0 = { {{.*}} 
"target-features"="+armv7-a,+no-movt,+thumb-mode"
 
 int foo1(int a) { return a; }

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=330169&r1=330168&r2=330169&view=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Mon Apr 16 16:52:58 2018
@@ -1,22 +1,23 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+dsp,+neon,+thumb-mode
+// CHECK-VFP3: "target-features"="+armv7-a,+dsp,+neon,+thumb-mode,+vfp3"

r330861 - [TargetInfo] Sort target features before passing them to the backend

2018-04-25 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Apr 25 12:14:05 2018
New Revision: 330861

URL: http://llvm.org/viewvc/llvm-project?rev=330861&view=rev
Log:
[TargetInfo] Sort target features before passing them to the backend

Passing the features in random order will lead to unpredictable results
when some of the features are related (like the architecture-version
features on ARM).

It might be possible to fix this particular case in the ARM target code,
to avoid adding overlapping target features. But we should probably be
sorting in any case: the behavior shouldn't depend on StringMap's
hashing algorithm.

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


Added:
cfe/trunk/test/CodeGen/arm-build-attributes.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=330861&r1=330860&r2=330861&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Apr 25 12:14:05 2018
@@ -638,6 +638,9 @@ TargetInfo::CreateTargetInfo(Diagnostics
   Opts->Features.clear();
   for (const auto &F : Features)
 Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
+  // Sort here, so we handle the features in a predictable order. (This matters
+  // when we're dealing with features that overlap.)
+  llvm::sort(Opts->Features.begin(), Opts->Features.end());
 
   if (!Target->handleTargetFeatures(Opts->Features, Diags))
 return nullptr;

Added: cfe/trunk/test/CodeGen/arm-build-attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-build-attributes.c?rev=330861&view=auto
==
--- cfe/trunk/test/CodeGen/arm-build-attributes.c (added)
+++ cfe/trunk/test/CodeGen/arm-build-attributes.c Wed Apr 25 12:14:05 2018
@@ -0,0 +1,4 @@
+// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 
-mfpu=vfpv4-d16 | FileCheck %s
+// REQUIRES: arm-registered-target
+// CHECK: .fpu vfpv4-d16
+void foo() {}


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


r331570 - Add warning flag -Wordered-compare-function-pointers.

2018-05-04 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Fri May  4 17:09:51 2018
New Revision: 331570

URL: http://llvm.org/viewvc/llvm-project?rev=331570&view=rev
Log:
Add warning flag -Wordered-compare-function-pointers.

The C standard doesn't allow comparisons like "f1 < f2" (where f1 and f2
are function pointers), but we allow them as an extension.  Add a
warning flag to control this warning.

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


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331570&r1=331569&r2=331570&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May  4 17:09:51 
2018
@@ -5932,7 +5932,8 @@ def ext_typecheck_ordered_comparison_of_
 def err_typecheck_ordered_comparison_of_pointer_and_zero : Error<
   "ordered comparison between pointer and zero (%0 and %1)">;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
-  "ordered comparison of function pointers (%0 and %1)">;
+  "ordered comparison of function pointers (%0 and %1)">,
+  InGroup>;
 def ext_typecheck_comparison_of_fptr_to_void : Extension<
   "equality comparison between function pointer and void pointer (%0 and %1)">;
 def err_typecheck_comparison_of_fptr_to_void : Error<

Modified: cfe/trunk/test/Misc/warning-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=331570&r1=331569&r2=331570&view=diff
==
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Fri May  4 17:09:51 2018
@@ -18,7 +18,7 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (77):
+CHECK: Warnings without flags (76):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -31,7 +31,6 @@ CHECK-NEXT:   ext_plain_complex
 CHECK-NEXT:   ext_template_arg_extra_parens
 CHECK-NEXT:   ext_typecheck_comparison_of_pointer_integer
 CHECK-NEXT:   ext_typecheck_cond_incompatible_operands
-CHECK-NEXT:   ext_typecheck_ordered_comparison_of_function_pointers
 CHECK-NEXT:   ext_typecheck_ordered_comparison_of_pointer_integer
 CHECK-NEXT:   ext_using_undefined_std
 CHECK-NEXT:   pp_invalid_string_literal


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


r374419 - [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 2.

2019-10-10 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Oct 10 11:45:34 2019
New Revision: 374419

URL: http://llvm.org/viewvc/llvm-project?rev=374419&view=rev
Log:
[ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 2.

Just running -fsyntax-only over arm_neon.h doesn't cover some intrinsics
which are defined using macros.  Add more test coverage for that.

arm-neon-header.c wasn't checking the full set of available NEON target
features; change the target architecture of the test to account for
that.

Fix the generator for arm_neon.h to generate casts in more cases where
they are necessary.

Fix VFMLAL_LOW etc. to express their signatures differently, so the
builtins have the expected type. Maybe the TableGen backend should
detect intrinsics that are defined the wrong way, and produce an error.
The rules here are sort of strange.

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


Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
cfe/trunk/test/CodeGen/arm_neon_intrinsics.c
cfe/trunk/test/Headers/arm-neon-header.c
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=374419&r1=374418&r2=374419&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Thu Oct 10 11:45:34 2019
@@ -1651,10 +1651,10 @@ let ArchGuard = "defined(__ARM_FEATURE_D
 
 // v8.2-A FP16 fused multiply-add long instructions.
 let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && defined(__aarch64__)" in {
-  def VFMLAL_LOW  : SInst<"vfmlal_low",  "ffHH", "hQh">;
-  def VFMLSL_LOW  : SInst<"vfmlsl_low",  "ffHH", "hQh">;
-  def VFMLAL_HIGH : SInst<"vfmlal_high", "ffHH", "hQh">;
-  def VFMLSL_HIGH : SInst<"vfmlsl_high", "ffHH", "hQh">;
+  def VFMLAL_LOW  : SInst<"vfmlal_low",  "nndd", "hQh">;
+  def VFMLSL_LOW  : SInst<"vfmlsl_low",  "nndd", "hQh">;
+  def VFMLAL_HIGH : SInst<"vfmlal_high", "nndd", "hQh">;
+  def VFMLSL_HIGH : SInst<"vfmlsl_high", "nndd", "hQh">;
 
   def VFMLAL_LANE_LOW  : SOpInst<"vfmlal_lane_low",  "ffH0i", "hQh", 
OP_FMLAL_LN>;
   def VFMLSL_LANE_LOW  : SOpInst<"vfmlsl_lane_low",  "ffH0i", "hQh", 
OP_FMLSL_LN>;

Modified: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c?rev=374419&r1=374418&r2=374419&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c Thu Oct 10 11:45:34 2019
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
-// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone 
-emit-llvm -o - %s \
+// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone \
+// RUN:  -flax-vector-conversions=none -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 
@@ -406,7 +407,7 @@ int8x8_t test_vmla_s8(int8x8_t v1, int8x
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> [[ADD_I]] to <8 x i8>
 // CHECK:   ret <8 x i8> [[TMP0]]
 int8x8_t test_vmla_s16(int16x4_t v1, int16x4_t v2, int16x4_t v3) {
-  return vmla_s16(v1, v2, v3);
+  return (int8x8_t)vmla_s16(v1, v2, v3);
 }
 
 // CHECK-LABEL: @test_vmla_s32(
@@ -527,7 +528,7 @@ int8x8_t test_vmls_s8(int8x8_t v1, int8x
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> [[SUB_I]] to <8 x i8>
 // CHECK:   ret <8 x i8> [[TMP0]]
 int8x8_t test_vmls_s16(int16x4_t v1, int16x4_t v2, int16x4_t v3) {
-  return vmls_s16(v1, v2, v3);
+  return (int8x8_t)vmls_s16(v1, v2, v3);
 }
 
 // CHECK-LABEL: @test_vmls_s32(
@@ -978,7 +979,7 @@ int8x8_t test_vbsl_s8(uint8x8_t v1, int8
 // CHECK:   [[TMP4:%.*]] = bitcast <4 x i16> [[VBSL5_I]] to <8 x i8>
 // CHECK:   ret <8 x i8> [[TMP4]]
 int8x8_t test_vbsl_s16(uint16x4_t v1, int16x4_t v2, int16x4_t v3) {
-  return vbsl_s16(v1, v2, v3);
+  return (int8x8_t)vbsl_s16(v1, v2, v3);
 }
 
 // CHECK-LABEL: @test_vbsl_s32(
@@ -1003,7 +1004,7 @@ int32x2_t test_vbsl_s32(uint32x2_t v1, i
 // CHECK:   [[VBSL4_I:%.*]] = and <1 x i64> [[TMP3]], %v3
 // CHECK:   [[VBSL5_I:%.*]] = or <1 x i64> [[VBSL3_I]], [[VBSL4_I]]
 // CHECK:   ret <1 x i64> [[VBSL5_I]]
-uint64x1_t test_vbsl_s64(uint64x1_t v1, uint64x1_t v2, uint64x1_t v3) {
+int64x1_t test_vbsl_s64(uint64x1_t v1, int64x1_t v2, int64x1_t v3) {
   return vbsl_s64(v1, v2, v3);
 }
 
@@ -1057,19 +1058,18 @@ uint64x1_t test_vbsl_u64(uint64x1_t v1,
 }
 
 // CHECK-LABEL: @test_vbsl_f32(
-// CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %v1 to <2 x i32>
-// CHECK:   [[TMP1:%.*]] = bitcast <2 x i32> [[TMP0]] to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <2 x i32> %v1 to <8 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x float> %v2 to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x float> %v3 to <8 x

r374836 - [test] Fix test failure

2019-10-14 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Oct 14 15:44:42 2019
New Revision: 374836

URL: http://llvm.org/viewvc/llvm-project?rev=374836&view=rev
Log:
[test] Fix test failure

The version mismatch symbol is version 9 on 32 bit android. Since
this test isn't actually testing any android specific functionality,
we force the target triple to x86_64-unknown-unknown in order to have
a consistent version number. It seems the test was already trying to
do this, just not doing it right

Patch by Christopher Tetrault

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


Modified:
cfe/trunk/test/CodeGen/asan-new-pm.ll

Modified: cfe/trunk/test/CodeGen/asan-new-pm.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-new-pm.ll?rev=374836&r1=374835&r2=374836&view=diff
==
--- cfe/trunk/test/CodeGen/asan-new-pm.ll (original)
+++ cfe/trunk/test/CodeGen/asan-new-pm.ll Mon Oct 14 15:44:42 2019
@@ -1,12 +1,10 @@
 ; Test that ASan runs with the new pass manager
-; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=address %s | FileCheck %s --check-prefixes=CHECK,LTO,THINLTO
-; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=address -flto %s | FileCheck %s --check-prefixes=CHECK,LTO
-; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=address -flto=thin %s | FileCheck %s --check-prefixes=CHECK,THINLTO
-; RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=address %s | FileCheck %s --check-prefixes=CHECK,LTO,THINLTO
-; RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=address -flto %s | FileCheck %s --check-prefixes=CHECK,LTO
-; RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=address -flto=thin %s | FileCheck %s --check-prefixes=CHECK,THINLTO
-
-target triple = "x86_64-unknown-unknown"
+; RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=address %s | FileCheck %s 
--check-prefixes=CHECK,LTO,THINLTO
+; RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=address -flto %s | FileCheck %s 
--check-prefixes=CHECK,LTO
+; RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - 
-fexperimental-new-pass-manager -fsanitize=address -flto=thin %s | FileCheck %s 
--check-prefixes=CHECK,THINLTO
+; RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=address %s | FileCheck %s 
--check-prefixes=CHECK,LTO,THINLTO
+; RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=address -flto %s | FileCheck %s 
--check-prefixes=CHECK,LTO
+; RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - -O1 
-fexperimental-new-pass-manager -fsanitize=address -flto=thin %s | FileCheck %s 
--check-prefixes=CHECK,THINLTO
 
 ; DAG-CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor
 


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


r375179 - [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 3

2019-10-17 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Oct 17 14:57:28 2019
New Revision: 375179

URL: http://llvm.org/viewvc/llvm-project?rev=375179&view=rev
Log:
[ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 3

It's completely impossible to check that I've actually found all the
issues, due to the use of macros in arm_neon.h, but hopefully this time
it'll take more than a few hours for someone to find another issue.

I have no idea why, but apparently there's a rule that some, but not
all, builtins which should take an fp16 vector actually take an int8
vector as an argument.  Fix this, and add test coverage.

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


Modified:
cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c?rev=375179&r1=375178&r2=375179&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c Thu Oct 17 14:57:28 
2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon 
-target-feature +fullfp16 -target-feature +v8.2a\
-// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm 
-o - %s \
+// RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S 
-disable-O0-optnone -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=375179&r1=375178&r2=375179&view=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Thu Oct 17 14:57:28 2019
@@ -1442,7 +1442,8 @@ void Intrinsic::emitBodyAsBuiltinCall()
 }
 
 // Check if an explicit cast is needed.
-if (CastToType.isVector() && LocalCK == ClassB) {
+if (CastToType.isVector() &&
+(LocalCK == ClassB || (T.isHalf() && !T.isScalarForMangling( {
   CastToType.makeInteger(8, true);
   Arg = "(" + CastToType.str() + ")" + Arg;
 } else if (CastToType.isVector() && LocalCK == ClassI) {


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


[clang] 9292ece - [clang driver] Spell "--export-dynamic-symbol" with two dashes.

2020-05-25 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-05-23T15:46:28-07:00
New Revision: 9292ece9956c98acf0cfa6e188316243ffbf4bed

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

LOG: [clang driver] Spell "--export-dynamic-symbol" with two dashes.

This doesn't make a difference for linkers that support the option, but
it improves the error message from older linkers that don't support it.

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/sanitizer-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index d6451447a924..85a1a4e1ac07 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -774,7 +774,7 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
 CmdArgs.push_back("--export-dynamic");
 
   if (SanArgs.hasCrossDsoCfi() && !AddExportDynamic)
-CmdArgs.push_back("-export-dynamic-symbol=__cfi_check");
+CmdArgs.push_back("--export-dynamic-symbol=__cfi_check");
 
   return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 52a432ca1803..a3070d26d16c 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -571,7 +571,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-ANDROID %s
 // CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-DIAG-ANDROID: 
"{{[^"]*}}libclang_rt.ubsan_standalone-aarch64-android.so"
-// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "-export-dynamic-symbol=__cfi_check"
+// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "--export-dynamic-symbol=__cfi_check"
 
 // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -mmacosx-version-min=10.6 \



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


[clang] 83fa811 - [clang][opaque pointers] Fix up a bunch of "getType()->getElementType()"

2020-04-03 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-04-03T18:00:33-07:00
New Revision: 83fa811e5bf5b291eafd900f3072b961f64f039c

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

LOG: [clang][opaque pointers] Fix up a bunch of "getType()->getElementType()"

In contexts where we know an LLVM type is a pointer, there's generally
some simpler way to get the pointee type.

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 76520ba17541..3c44632dfd60 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1233,7 +1233,7 @@ static llvm::Value *CreateCoercedLoad(Address Src, 
llvm::Type *Ty,
 
   if (llvm::StructType *SrcSTy = dyn_cast(SrcTy)) {
 Src = EnterStructPointerForCoercedAccess(Src, SrcSTy, DstSize, CGF);
-SrcTy = Src.getType()->getElementType();
+SrcTy = Src.getElementType();
   }
 
   uint64_t SrcSize = CGF.CGM.getDataLayout().getTypeAllocSize(SrcTy);
@@ -1299,7 +1299,7 @@ static void CreateCoercedStore(llvm::Value *Src,
bool DstIsVolatile,
CodeGenFunction &CGF) {
   llvm::Type *SrcTy = Src->getType();
-  llvm::Type *DstTy = Dst.getType()->getElementType();
+  llvm::Type *DstTy = Dst.getElementType();
   if (SrcTy == DstTy) {
 CGF.Builder.CreateStore(Src, Dst, DstIsVolatile);
 return;
@@ -1309,7 +1309,7 @@ static void CreateCoercedStore(llvm::Value *Src,
 
   if (llvm::StructType *DstSTy = dyn_cast(DstTy)) {
 Dst = EnterStructPointerForCoercedAccess(Dst, DstSTy, SrcSize, CGF);
-DstTy = Dst.getType()->getElementType();
+DstTy = Dst.getElementType();
   }
 
   llvm::PointerType *SrcPtrTy = llvm::dyn_cast(SrcTy);
@@ -4304,7 +4304,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   llvm::StructType *STy =
 dyn_cast(ArgInfo.getCoerceToType());
   if (STy && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened()) {
-llvm::Type *SrcTy = Src.getType()->getElementType();
+llvm::Type *SrcTy = Src.getElementType();
 uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(SrcTy);
 uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(STy);
 

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index a9dbdb2e8713..45e9dc03b637 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -341,7 +341,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const 
VarDecl &D,
   // the global to match the initializer.  (We have to do this
   // because some types, like unions, can't be completely represented
   // in the LLVM type system.)
-  if (GV->getType()->getElementType() != Init->getType()) {
+  if (GV->getValueType() != Init->getType()) {
 llvm::GlobalVariable *OldGV = GV;
 
 GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 3986310eaa70..31ab7977b7d2 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -3634,7 +3634,7 @@ void CGObjCMac::GenerateClass(const 
ObjCImplementationDecl *ID) {
   // Check for a forward reference.
   llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
   if (GV) {
-assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
+assert(GV->getValueType() == ObjCTypes.ClassTy &&
"Forward metaclass reference has incorrect type.");
 values.finishAndSetAsInitializer(GV);
 GV->setSection(Section);
@@ -3697,7 +3697,7 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const 
ObjCImplementationDecl *ID,
   // Check for a forward reference.
   llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
   if (GV) {
-assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
+assert(GV->getValueType() == ObjCTypes.ClassTy &&
"Forward metaclass reference has incorrect type.");
 values.finishAndSetAsInitializer(GV);
   } else {
@@ -3728,7 +3728,7 @@ llvm::Constant *CGObjCMac::EmitMetaClassRef(const 
ObjCInterfaceDecl *ID) {
   llvm::GlobalValue::PrivateLinkage, nullptr,
   Name);
 
-  assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
+  assert(GV->getValueType() == ObjCTypes.ClassTy &&
  "Forward metaclass reference has incorrect type.");
   return GV;
 }
@@ -3742,7 +3742,7 @@ llvm::Value *CGObjCMac::EmitSuperClassRef(const 
ObjCInterfaceDecl *ID) {
   llvm::GlobalValue::PrivateLinkage, nullptr,
 

[clang] b11decc - [clang codegen][opaque pointers] Remove use of deprecated constructor

2020-04-03 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-04-03T18:00:33-07:00
New Revision: b11decc221a65d2c7290b93a4662a607a63b6d86

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

LOG: [clang codegen][opaque pointers] Remove use of deprecated constructor

(See also D76269.)

Added: 


Modified: 
clang/lib/CodeGen/CGCleanup.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index c117dd5c25c1..5e01100db163 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -309,7 +309,8 @@ static void createStoreInstBefore(llvm::Value *value, 
Address addr,
 
 static llvm::LoadInst *createLoadInstBefore(Address addr, const Twine &name,
 llvm::Instruction *beforeInst) {
-  auto load = new llvm::LoadInst(addr.getPointer(), name, beforeInst);
+  auto load = new llvm::LoadInst(addr.getElementType(), addr.getPointer(), 
name,
+ beforeInst);
   load->setAlignment(addr.getAlignment().getAsAlign());
   return load;
 }



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


[clang] 68b03ae - Remove SequentialType from the type heirarchy.

2020-04-06 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-04-06T17:03:49-07:00
New Revision: 68b03aee1a15678ab5b518148d5e75c9dc0436fd

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

LOG: Remove SequentialType from the type heirarchy.

Now that we have scalable vectors, there's a distinction that isn't
getting captured in the original SequentialType: some vectors don't have
a known element count, so counting the number of elements doesn't make
sense.

In some cases, there's a better way to express the commonality using
other methods. If we're dealing with GEPs, there's GEP methods; if we're
dealing with a ConstantDataSequential, we can query its element type
directly.

In the relatively few remaining cases, I just decided to write out
the type checks. We're talking about relatively few places, and I think
the abstraction doesn't really carry its weight. (See thread "[RFC]
Refactor class hierarchy of VectorType in the IR" on llvmdev.)

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp
llvm/include/llvm/IR/Constants.h
llvm/include/llvm/IR/DerivedTypes.h
llvm/include/llvm/IR/GetElementPtrTypeIterator.h
llvm/include/llvm/IR/Type.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/Type.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/FunctionComparator.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index da5d778a4922..fad7d754f551 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -318,12 +318,17 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   CharUnits Offset = Offsets[Index];
 
   if (auto *CA = dyn_cast(C)) {
+// Expand the sequence into its contained elements.
+// FIXME: This assumes vector elements are byte-sized.
 replace(Elems, Index, Index + 1,
 llvm::map_range(llvm::seq(0u, CA->getNumOperands()),
 [&](unsigned Op) { return CA->getOperand(Op); }));
-if (auto *Seq = dyn_cast(CA->getType())) {
+if (isa(CA->getType()) ||
+isa(CA->getType())) {
   // Array or vector.
-  CharUnits ElemSize = getSize(Seq->getElementType());
+  llvm::Type *ElemTy =
+  llvm::GetElementPtrInst::getTypeAtIndex(CA->getType(), (uint64_t)0);
+  CharUnits ElemSize = getSize(ElemTy);
   replace(
   Offsets, Index, Index + 1,
   llvm::map_range(llvm::seq(0u, CA->getNumOperands()),
@@ -344,6 +349,8 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   }
 
   if (auto *CDS = dyn_cast(C)) {
+// Expand the sequence into its contained elements.
+// FIXME: This assumes vector elements are byte-sized.
 // FIXME: If possible, split into two ConstantDataSequentials at Hint.
 CharUnits ElemSize = getSize(CDS->getElementType());
 replace(Elems, Index, Index + 1,
@@ -359,6 +366,7 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   }
 
   if (isa(C)) {
+// Split into two zeros at the hinted offset.
 CharUnits ElemSize = getSize(C);
 assert(Hint > Offset && Hint < Offset + ElemSize && "nothing to split");
 replace(Elems, Index, Index + 1,
@@ -368,6 +376,7 @@ bool ConstantAggregateBuilder::split(size_t Index, 
CharUnits Hint) {
   }
 
   if (isa(C)) {
+// Drop undef; it doesn't contribute to the final layout.
 replace(Elems, Index, Index + 1, {});
 replace(Offsets, Index, Index + 1, {});
 return true;

diff  --git a/llvm/include/llvm/IR/Constants.h 
b/llvm/include/llvm/IR/Constants.h
index 868b038b055d..c41d1582a834 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -44,7 +44,6 @@ namespace llvm {
 class ArrayType;
 class IntegerType;
 class PointerType;
-class SequentialType;
 class StructType;
 class VectorType;
 template  struct ConstantAggrKeyType;
@@ -631,12 +630,6 @@ class ConstantDataSequential : public ConstantData {
   /// efficient as getElementAsInteger/Float/Doub

[clang] 89e0662 - Make IRBuilder automatically set alignment on load/store/alloca.

2020-04-13 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-04-13T13:43:14-07:00
New Revision: 89e0662dee5fa541f284e6be0af9e36e7f39f947

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

LOG: Make IRBuilder automatically set alignment on load/store/alloca.

This is equivalent in terms of LLVM IR semantics, but we want to
transition away from using MaybeAlign to represent the alignment of
these instructions.

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

Added: 


Modified: 
clang/test/CodeGen/arm_neon_intrinsics.c
llvm/include/llvm/IR/IRBuilder.h
llvm/test/Bindings/llvm-c/atomics.ll
llvm/test/Bindings/llvm-c/echo.ll
llvm/test/Bindings/llvm-c/memops.ll
llvm/test/CodeGen/AMDGPU/widen_extending_scalar_loads.ll
llvm/test/Instrumentation/AddressSanitizer/debug-info-alloca.ll
llvm/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
llvm/test/Transforms/ArgumentPromotion/dbg.ll
llvm/test/Transforms/SROA/alignment.ll
llvm/test/Transforms/SROA/basictest.ll
llvm/test/Transforms/SROA/preserve-nonnull.ll
llvm/tools/llvm-c-test/echo.cpp
polly/test/Isl/CodeGen/invariant_load_alias_metadata.ll
polly/test/Isl/CodeGen/non-affine-phi-node-expansion-2.ll
polly/test/Isl/CodeGen/partial_write_array.ll
polly/test/Isl/CodeGen/partial_write_impossible_restriction.ll

Removed: 




diff  --git a/clang/test/CodeGen/arm_neon_intrinsics.c 
b/clang/test/CodeGen/arm_neon_intrinsics.c
index bff9f6a2e30f..18d59ffe0ae7 100644
--- a/clang/test/CodeGen/arm_neon_intrinsics.c
+++ b/clang/test/CodeGen/arm_neon_intrinsics.c
@@ -20227,10 +20227,10 @@ poly8x8_t test_vtbx4_p8(poly8x8_t a, poly8x8x4_t b, 
uint8x8_t c) {
 // CHECK:   [[TMP0:%.*]] = bitcast %struct.int8x8x2_t* [[AGG_RESULT]] to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <8 x i8>*
 // CHECK:   [[VTRN_I:%.*]] = shufflevector <8 x i8> %a, <8 x i8> %b, <8 x i32> 

-// CHECK:   store <8 x i8> [[VTRN_I]], <8 x i8>* [[TMP1]], !alias.scope !3
+// CHECK:   store <8 x i8> [[VTRN_I]], <8 x i8>* [[TMP1]], align 4, 
!alias.scope !3
 // CHECK:   [[TMP2:%.*]] = getelementptr inbounds <8 x i8>, <8 x i8>* 
[[TMP1]], i32 1
 // CHECK:   [[VTRN1_I:%.*]] = shufflevector <8 x i8> %a, <8 x i8> %b, <8 x 
i32> 
-// CHECK:   store <8 x i8> [[VTRN1_I]], <8 x i8>* [[TMP2]], !alias.scope !3
+// CHECK:   store <8 x i8> [[VTRN1_I]], <8 x i8>* [[TMP2]], align 4, 
!alias.scope !3
 // CHECK:   ret void
 int8x8x2_t test_vtrn_s8(int8x8_t a, int8x8_t b) {
   return vtrn_s8(a, b);
@@ -20242,10 +20242,10 @@ int8x8x2_t test_vtrn_s8(int8x8_t a, int8x8_t b) {
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> %b to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast i8* [[TMP0]] to <4 x i16>*
 // CHECK:   [[VTRN_I:%.*]] = shufflevector <4 x i16> %a, <4 x i16> %b, <4 x 
i32> 
-// CHECK:   store <4 x i16> [[VTRN_I]], <4 x i16>* [[TMP3]], !alias.scope !6
+// CHECK:   store <4 x i16> [[VTRN_I]], <4 x i16>* [[TMP3]], align 4, 
!alias.scope !6
 // CHECK:   [[TMP4:%.*]] = getelementptr inbounds <4 x i16>, <4 x i16>* 
[[TMP3]], i32 1
 // CHECK:   [[VTRN1_I:%.*]] = shufflevector <4 x i16> %a, <4 x i16> %b, <4 x 
i32> 
-// CHECK:   store <4 x i16> [[VTRN1_I]], <4 x i16>* [[TMP4]], !alias.scope !6
+// CHECK:   store <4 x i16> [[VTRN1_I]], <4 x i16>* [[TMP4]], align 4, 
!alias.scope !6
 // CHECK:   ret void
 int16x4x2_t test_vtrn_s16(int16x4_t a, int16x4_t b) {
   return vtrn_s16(a, b);
@@ -20257,10 +20257,10 @@ int16x4x2_t test_vtrn_s16(int16x4_t a, int16x4_t b) {
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> %b to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast i8* [[TMP0]] to <2 x i32>*
 // CHECK:   [[VTRN_I:%.*]] = shufflevector <2 x i32> %a, <2 x i32> %b, <2 x 
i32> 
-// CHECK:   store <2 x i32> [[VTRN_I]], <2 x i32>* [[TMP3]], !alias.scope !9
+// CHECK:   store <2 x i32> [[VTRN_I]], <2 x i32>* [[TMP3]], align 4, 
!alias.scope !9
 // CHECK:   [[TMP4:%.*]] = getelementptr inbounds <2 x i32>, <2 x i32>* 
[[TMP3]], i32 1
 // CHECK:   [[VTRN1_I:%.*]] = shufflevector <2 x i32> %a, <2 x i32> %b, <2 x 
i32> 
-// CHECK:   store <2 x i32> [[VTRN1_I]], <2 x i32>* [[TMP4]], !alias.scope !9
+// CHECK:   store <2 x i32> [[VTRN1_I]], <2 x i32>* [[TMP4]], align 4, 
!alias.scope !9
 // CHECK:   ret void
 int32x2x2_t test_vtrn_s32(int32x2_t a, int32x2_t b) {
   return vtrn_s32(a, b);
@@ -20270,10 +20270,10 @@ int32x2x2_t test_vtrn_s32(int32x2_t a, int32x2_t b) {
 // CHECK:   [[TMP0:%.*]] = bitcast %struct.uint8x8x2_t* [[AGG_RESULT]] to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <8 x i8>*
 // CHECK:   [[VTRN_I:%.*]] = shufflevector <8 x i8> %a, <8 x i8> %b, <8 x i32> 

-// CHECK:   store <8 x i8> [[VTRN_I]], <8 x i8>* [[TMP1]], !alias.scope !12
+// CHECK:   store <8 x i8> [[VTRN_I]], <8 x

[clang] c310bf8 - [Sema] Comparison of pointers to complete and incomplete types

2020-06-19 Thread Eli Friedman via cfe-commits

Author: Benson Chu
Date: 2020-06-19T17:01:03-07:00
New Revision: c310bf8256f83f365921562cebc5e4c9aec8e87e

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

LOG: [Sema] Comparison of pointers to complete and incomplete types

Clang is missing one of the conditions for C99 6.5.9p2, where comparison
between pointers must either both point to incomplete types or both
point to complete types. This patch adds an extra check to the clause
where two pointers are of compatible types.

This only applies to C89/C99; the relevant part of the standard was
rewritten for C11.

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

Added: 
clang/test/Sema/complete-incomplete-pointer-relational-c99.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a7b8a992f745..7c72eba8c2c1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6446,6 +6446,12 @@ def err_typecheck_ordered_comparison_of_pointer_and_zero 
: Error<
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def ext_typecheck_compare_complete_incomplete_pointers : Extension<
+  "pointer comparisons before C11 "
+  "need to be between two complete or two incomplete types; "
+  "%0 is %select{|in}2complete and "
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 59e7d88b7691..fdc050603188 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11584,11 +11584,22 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, 
ExprResult &RHS,
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if ((LCanPointeeTy->isIncompleteType() !=
+ RCanPointeeTy->isIncompleteType()) &&
+!getLangOpts().C11) {
+  Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
+  << LHS.get()->getSourceRange() << RHS.get()->getSourceRange()
+  << LHSType << RHSType << LCanPointeeTy->isIncompleteType()
+  << RCanPointeeTy->isIncompleteType();
+}
+if (LCanPointeeTy->isFunctionType()) {
+  // Valid unless a relational comparison of function pointers
+  Diag(Loc, 
diag::ext_typecheck_ordered_comparison_of_function_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
   }
 } else if (!IsRelational &&
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {

diff  --git a/clang/test/Sema/complete-incomplete-pointer-relational-c99.c 
b/clang/test/Sema/complete-incomplete-pointer-relational-c99.c
new file mode 100644
index ..ea6e4055eb52
--- /dev/null
+++ b/clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to 
have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return (&incomplete < &complete) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ (&incomplete <= &complete) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ (&incomplete > &complete) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ (&incomplet

[clang] bf8b63e - [clang codegen] Fix alignment of "Address" for incomplete array pointer.

2020-06-23 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-06-23T17:16:17-07:00
New Revision: bf8b63ed296c1ecad03c83b798ffbfa039cbceb4

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

LOG: [clang codegen] Fix alignment of "Address" for incomplete array pointer.

The code was assuming all incomplete types don't have meaningful
alignment, but incomplete arrays do have meaningful alignment.

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

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/alignment.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 7a9df700581e..f0ab5165584c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5990,6 +5990,9 @@ CharUnits CodeGenModule::getNaturalTypeAlignment(QualType 
T,
   if (TBAAInfo)
 *TBAAInfo = getTBAAAccessInfo(T);
 
+  // FIXME: This duplicates logic in ASTContext::getTypeAlignIfKnown. But
+  // that doesn't return the information we need to compute BaseInfo.
+
   // Honor alignment typedef attributes even on incomplete types.
   // We also honor them straight for C++ class types, even as pointees;
   // there's an expressivity gap here.
@@ -6001,32 +6004,46 @@ CharUnits 
CodeGenModule::getNaturalTypeAlignment(QualType T,
 }
   }
 
+  bool AlignForArray = T->isArrayType();
+
+  // Analyze the base element type, so we don't get confused by incomplete
+  // array types.
+  T = getContext().getBaseElementType(T);
+
+  if (T->isIncompleteType()) {
+// We could try to replicate the logic from
+// ASTContext::getTypeAlignIfKnown, but nothing uses the alignment if the
+// type is incomplete, so it's impossible to test. We could try to reuse
+// getTypeAlignIfKnown, but that doesn't return the information we need
+// to set BaseInfo.  So just ignore the possibility that the alignment is
+// greater than one.
+if (BaseInfo)
+  *BaseInfo = LValueBaseInfo(AlignmentSource::Type);
+return CharUnits::One();
+  }
+
   if (BaseInfo)
 *BaseInfo = LValueBaseInfo(AlignmentSource::Type);
 
   CharUnits Alignment;
-  if (T->isIncompleteType()) {
-Alignment = CharUnits::One(); // Shouldn't be used, but pessimistic is 
best.
+  // For C++ class pointees, we don't know whether we're pointing at a
+  // base or a complete object, so we generally need to use the
+  // non-virtual alignment.
+  const CXXRecordDecl *RD;
+  if (forPointeeType && !AlignForArray && (RD = T->getAsCXXRecordDecl())) {
+Alignment = getClassPointerAlignment(RD);
   } else {
-// For C++ class pointees, we don't know whether we're pointing at a
-// base or a complete object, so we generally need to use the
-// non-virtual alignment.
-const CXXRecordDecl *RD;
-if (forPointeeType && (RD = T->getAsCXXRecordDecl())) {
-  Alignment = getClassPointerAlignment(RD);
-} else {
-  Alignment = getContext().getTypeAlignInChars(T);
-  if (T.getQualifiers().hasUnaligned())
-Alignment = CharUnits::One();
-}
+Alignment = getContext().getTypeAlignInChars(T);
+if (T.getQualifiers().hasUnaligned())
+  Alignment = CharUnits::One();
+  }
 
-// Cap to the global maximum type alignment unless the alignment
-// was somehow explicit on the type.
-if (unsigned MaxAlign = getLangOpts().MaxTypeAlign) {
-  if (Alignment.getQuantity() > MaxAlign &&
-  !getContext().isAlignmentRequired(T))
-Alignment = CharUnits::fromQuantity(MaxAlign);
-}
+  // Cap to the global maximum type alignment unless the alignment
+  // was somehow explicit on the type.
+  if (unsigned MaxAlign = getLangOpts().MaxTypeAlign) {
+if (Alignment.getQuantity() > MaxAlign &&
+!getContext().isAlignmentRequired(T))
+  Alignment = CharUnits::fromQuantity(MaxAlign);
   }
   return Alignment;
 }

diff  --git a/clang/test/CodeGenCXX/alignment.cpp 
b/clang/test/CodeGenCXX/alignment.cpp
index 37509fcb4dd5..c9378bf20a47 100644
--- a/clang/test/CodeGenCXX/alignment.cpp
+++ b/clang/test/CodeGenCXX/alignment.cpp
@@ -308,4 +308,20 @@ namespace test1 {
 D d;
 AlignedArray result = d.bArray;
   }
+
+  // CHECK-LABEL: @_ZN5test11hEPA_NS_1BE
+  void h(B (*b)[]) {
+// CHECK: [[RESULT:%.*]] = alloca [[ARRAY]], align 64
+// CHECK: [[B_P:%.*]] = load [0 x [[B]]]*, [0 x [[B]]]**
+// CHECK: [[ELEMENT_P:%.*]] = getelementptr inbounds [0 x [[B]]], [0 x 
[[B]]]* [[B_P]], i64 0
+// CHECK: [[ARRAY_P:%.*]] = getelementptr inbounds [[B]], [[B]]* 
[[ELEMENT_P]], i32 0, i32 2
+// CHECK: [[T0:%.*]] = bitcast [[ARRAY]]* [[RESULT]] to i8*
+// CHECK: [[T1:%.*]] = bitcast [[ARRAY]]* [[ARRAY_P]] to i8*
+// CHECK: call void @

[clang] 8dfb5d7 - [clang codegen][AArch64] Use llvm.aarch64.neon.fcvtzs/u where it's necessary

2020-07-30 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-07-30T15:41:54-07:00
New Revision: 8dfb5d767e70dd862096c8872fd3e3bead99741d

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

LOG: [clang codegen][AArch64] Use llvm.aarch64.neon.fcvtzs/u where it's 
necessary

fptosi/fptoui have similar, but not identical, semantics.  In
particular, the behavior on overflow is different.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46844 for 64-bit.  (The
corresponding patch for 32-bit is more involved because the equivalent
intrinsics don't exist, as far as I can tell.)

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
clang/test/CodeGen/aarch64-neon-intrinsics.c
clang/test/CodeGen/aarch64-neon-misc.c
clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ecc0b5bf2dc4..042b41a09f19 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5251,6 +5251,8 @@ static const ARMVectorIntrinsicInfo 
AArch64SISDIntrinsicMap[] = {
   NEONMAP1(vcvtd_n_f64_u64, aarch64_neon_vcvtfxu2fp, AddRetType | Add1ArgType),
   NEONMAP1(vcvtd_n_s64_f64, aarch64_neon_vcvtfp2fxs, AddRetType | Add1ArgType),
   NEONMAP1(vcvtd_n_u64_f64, aarch64_neon_vcvtfp2fxu, AddRetType | Add1ArgType),
+  NEONMAP1(vcvtd_s64_f64, aarch64_neon_fcvtzs, AddRetType | Add1ArgType),
+  NEONMAP1(vcvtd_u64_f64, aarch64_neon_fcvtzu, AddRetType | Add1ArgType),
   NEONMAP1(vcvth_bf16_f32, aarch64_neon_bfcvt, 0),
   NEONMAP1(vcvtmd_s64_f64, aarch64_neon_fcvtms, AddRetType | Add1ArgType),
   NEONMAP1(vcvtmd_u64_f64, aarch64_neon_fcvtmu, AddRetType | Add1ArgType),
@@ -5268,6 +5270,8 @@ static const ARMVectorIntrinsicInfo 
AArch64SISDIntrinsicMap[] = {
   NEONMAP1(vcvts_n_f32_u32, aarch64_neon_vcvtfxu2fp, AddRetType | Add1ArgType),
   NEONMAP1(vcvts_n_s32_f32, aarch64_neon_vcvtfp2fxs, AddRetType | Add1ArgType),
   NEONMAP1(vcvts_n_u32_f32, aarch64_neon_vcvtfp2fxu, AddRetType | Add1ArgType),
+  NEONMAP1(vcvts_s32_f32, aarch64_neon_fcvtzs, AddRetType | Add1ArgType),
+  NEONMAP1(vcvts_u32_f32, aarch64_neon_fcvtzu, AddRetType | Add1ArgType),
   NEONMAP1(vcvtxd_f32_f64, aarch64_sisd_fcvtxn, 0),
   NEONMAP1(vmaxnmv_f32, aarch64_neon_fmaxnmv, AddRetType | Add1ArgType),
   NEONMAP1(vmaxnmvq_f32, aarch64_neon_fmaxnmv, AddRetType | Add1ArgType),
@@ -5426,6 +5430,10 @@ static const ARMVectorIntrinsicInfo 
AArch64SISDIntrinsicMap[] = {
   NEONMAP1(vcvth_n_s64_f16, aarch64_neon_vcvtfp2fxs, AddRetType | Add1ArgType),
   NEONMAP1(vcvth_n_u32_f16, aarch64_neon_vcvtfp2fxu, AddRetType | Add1ArgType),
   NEONMAP1(vcvth_n_u64_f16, aarch64_neon_vcvtfp2fxu, AddRetType | Add1ArgType),
+  NEONMAP1(vcvth_s32_f16, aarch64_neon_fcvtzs, AddRetType | Add1ArgType),
+  NEONMAP1(vcvth_s64_f16, aarch64_neon_fcvtzs, AddRetType | Add1ArgType),
+  NEONMAP1(vcvth_u32_f16, aarch64_neon_fcvtzu, AddRetType | Add1ArgType),
+  NEONMAP1(vcvth_u64_f16, aarch64_neon_fcvtzu, AddRetType | Add1ArgType),
   NEONMAP1(vcvtmh_s32_f16, aarch64_neon_fcvtms, AddRetType | Add1ArgType),
   NEONMAP1(vcvtmh_s64_f16, aarch64_neon_fcvtms, AddRetType | Add1ArgType),
   NEONMAP1(vcvtmh_u32_f16, aarch64_neon_fcvtmu, AddRetType | Add1ArgType),
@@ -8995,21 +9003,6 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
 Value *Ptr = Builder.CreateBitCast(Ops[0], Int128PTy);
 return Builder.CreateDefaultAlignedStore(EmitScalarExpr(E->getArg(1)), 
Ptr);
   }
-  case NEON::BI__builtin_neon_vcvts_u32_f32:
-  case NEON::BI__builtin_neon_vcvtd_u64_f64:
-usgn = true;
-LLVM_FALLTHROUGH;
-  case NEON::BI__builtin_neon_vcvts_s32_f32:
-  case NEON::BI__builtin_neon_vcvtd_s64_f64: {
-Ops.push_back(EmitScalarExpr(E->getArg(0)));
-bool Is64 = Ops[0]->getType()->getPrimitiveSizeInBits() == 64;
-llvm::Type *InTy = Is64 ? Int64Ty : Int32Ty;
-llvm::Type *FTy = Is64 ? DoubleTy : FloatTy;
-Ops[0] = Builder.CreateBitCast(Ops[0], FTy);
-if (usgn)
-  return Builder.CreateFPToUI(Ops[0], InTy);
-return Builder.CreateFPToSI(Ops[0], InTy);
-  }
   case NEON::BI__builtin_neon_vcvts_f32_u32:
   case NEON::BI__builtin_neon_vcvtd_f64_u64:
 usgn = true;
@@ -9047,44 +9040,16 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
   return Builder.CreateUIToFP(Ops[0], FTy);
 return Builder.CreateSIToFP(Ops[0], FTy);
   }
-  case NEON::BI__builtin_neon_vcvth_u16_f16:
-usgn = true;
-LLVM_FALLTHROUGH;
-  case NEON::BI__builtin_neon_vcvth_s16_f16: {
-Ops.push_back(EmitScalarExpr(E->getArg(0)));
-Ops[0] = Builder.CreateBitCast(Ops[0], HalfTy);
-if (usgn)
-  r

RE: [PATCH] D84703: [clang codegen][AArch64] Use llvm.aarch64.neon.fcvtzs/u where it's necessary

2020-08-03 Thread Eli Friedman via cfe-commits
Committed dca23ed; should be fixed now.

-Eli

From: Azhar Mohammed 
Sent: Monday, August 3, 2020 11:01 AM
To: Eli Friedman ; Eli 
Friedman via Phabricator ; Eli Friedman 

Cc: sander.desma...@arm.com; sjoerd.mei...@arm.com; t.p.northo...@gmail.com; 
cameron.mcina...@nyu.edu; blitzrak...@gmail.com; ju...@samsung.com; Anna Welker 
via Phabricator via llvm-commits ; 
mlek...@skidmore.edu; kanh...@a-bix.com; Jonathan Coe via cfe-commits 
; shen...@google.com; kristof.be...@arm.com; 
daniel.k...@arm.com
Subject: [EXT] Re: [PATCH] D84703: [clang codegen][AArch64] Use 
llvm.aarch64.neon.fcvtzs/u where it's necessary

Hey Eli,

Looks like this is causing the test-suite build to fail. Can you please take a 
look.
Refer to 
http://green.lab.llvm.org/green/job/test-suite-verify-machineinstrs-aarch64-O3/8035/consoleFull.
FAILED: 
SingleSource/UnitTests/Vector/AArch64/CMakeFiles/aarch64_neon_intrinsics.dir/aarch64_neon_intrinsics.c.o
/Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/test-suite-build/tools/timeit
 --summary 
SingleSource/UnitTests/Vector/AArch64/CMakeFiles/aarch64_neon_intrinsics.dir/aarch64_neon_intrinsics.c.o.time
 
/Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/compiler/bin/clang
 -DNDEBUG -B 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 -Wno-unused-command-line-argument -mllvm -verify-machineinstrs -O3 -arch arm64 
-isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk
 -w -Werror=date-time -std=c99 -MD -MT 
SingleSource/UnitTests/Vector/AArch64/CMakeFiles/aarch64_neon_intrinsics.dir/aarch64_neon_intrinsics.c.o
 -MF 
SingleSource/UnitTests/Vector/AArch64/CMakeFiles/aarch64_neon_intrinsics.dir/aarch64_neon_intrinsics.c.o.d
 -o 
SingleSource/UnitTests/Vector/AArch64/CMakeFiles/aarch64_neon_intrinsics.dir/aarch64_neon_intrinsics.c.o
 -c 
/Users/buildslave/jenkins/workspace/test-suite-verify-machineinstrs-aarch64-O3/test-suite/SingleSource/UnitTests/Vector/AArch64/aarch64_neon_intrinsics.c
fatal error: error in backend: Cannot select: intrinsic 
%llvm.aarch64.neon.fcvtzs

Thanks
Azhar


On Jul 30, 2020, at 3:42 PM, Eli Friedman via Phabricator via llvm-commits 
mailto:llvm-comm...@lists.llvm.org>> wrote:

This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dfb5d767e70: [clang codegen][AArch64] Use 
llvm.aarch64.neon.fcvtzs/u where it's necessary (authored by efriedma).

Changed prior to commit:
 https://reviews.llvm.org/D84703?vs=281052&id=282069#toc

Repository:
 rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84703

Files:
 clang/lib/CodeGen/CGBuiltin.cpp
 clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
 clang/test/CodeGen/aarch64-neon-intrinsics.c
 clang/test/CodeGen/aarch64-neon-misc.c
 clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
 clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c

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

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


[clang] 673dbe1 - [clang codegen] Use IR "align" attribute for static array arguments.

2020-08-18 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-08-18T12:51:16-07:00
New Revision: 673dbe1b5eef09db39783c828a84f1213a47bad0

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

LOG: [clang codegen] Use IR "align" attribute for static array arguments.

Without the "align" attribute, marking the argument dereferenceable is
basically useless.  See also D80166.

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

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/vla.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 9d225b23e3c3..98ba1efc20de 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2520,6 +2520,9 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo &FI,
 // bytes).
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
   if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
   ArrSize) {
@@ -2539,10 +2542,15 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo &FI,
 // For C99 VLAs with the static keyword, we don't know the size so
 // we can't use the dereferenceable attribute, but in addrspace(0)
 // we know that it must be nonnull.
-if (ArrTy->getSizeModifier() == VariableArrayType::Static &&
-!getContext().getTargetAddressSpace(ArrTy->getElementType()) &&
-!CGM.getCodeGenOpts().NullPointerIsValid)
-  AI->addAttr(llvm::Attribute::NonNull);
+if (ArrTy->getSizeModifier() == VariableArrayType::Static) {
+  QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
+  if (!getContext().getTargetAddressSpace(ETy) &&
+  !CGM.getCodeGenOpts().NullPointerIsValid)
+AI->addAttr(llvm::Attribute::NonNull);
+}
   }
 
   // Set `align` attribute if any.

diff  --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c
index 16b82f4acc7d..3142050149aa 100644
--- a/clang/test/CodeGen/vla.c
+++ b/clang/test/CodeGen/vla.c
@@ -200,13 +200,13 @@ void test7(int a[b(0)]) {
 // Make sure we emit dereferenceable or nonnull when the static keyword is
 // provided.
 void test8(int a[static 3]) { }
-// CHECK: define void @test8(i32* dereferenceable(12) %a)
+// CHECK: define void @test8(i32* align 4 dereferenceable(12) %a)
 
 void test9(int n, int a[static n]) { }
-// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
-// NULL-VALID: define void @test9(i32 %n, i32* %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull align 4 %a)
+// NULL-VALID: define void @test9(i32 %n, i32* align 4 %a)
 
 // Make sure a zero-sized static array extent is still required to be nonnull.
 void test10(int a[static 0]) {}
-// NULL-INVALID: define void @test10(i32* nonnull %a)
-// NULL-VALID: define void @test10(i32* %a)
+// NULL-INVALID: define void @test10(i32* nonnull align 4 %a)
+// NULL-VALID: define void @test10(i32* align 4 %a)



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


[clang] 428d0b6 - Fix clang test failures from D77454

2020-05-14 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-05-14T14:10:51-07:00
New Revision: 428d0b6f77986efd944df01bb4ae7888c6262c2f

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

LOG: Fix clang test failures from D77454

Added: 


Modified: 
clang/lib/CodeGen/CGCleanup.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 70eaa321a007..ab39d91e9173 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -309,10 +309,9 @@ static void createStoreInstBefore(llvm::Value *value, 
Address addr,
 
 static llvm::LoadInst *createLoadInstBefore(Address addr, const Twine &name,
 llvm::Instruction *beforeInst) {
-  auto load = new llvm::LoadInst(addr.getElementType(), addr.getPointer(), 
name,
- beforeInst);
-  load->setAlignment(addr.getAlignment().getAsAlign());
-  return load;
+  return new llvm::LoadInst(addr.getElementType(), addr.getPointer(), name,
+false, addr.getAlignment().getAsAlign(),
+beforeInst);
 }
 
 /// All the branch fixups on the EH stack have propagated out past the



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


r320533 - [Coverage] Always emit unused coverage mappings in the same order.

2017-12-12 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Tue Dec 12 16:14:17 2017
New Revision: 320533

URL: http://llvm.org/viewvc/llvm-project?rev=320533&view=rev
Log:
[Coverage] Always emit unused coverage mappings in the same order.

Non-determinism is confusing at best.

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


Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=320533&r1=320532&r2=320533&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Dec 12 16:14:17 2017
@@ -4286,20 +4286,10 @@ void CodeGenModule::ClearUnusedCoverageM
 }
 
 void CodeGenModule::EmitDeferredUnusedCoverageMappings() {
-  std::vector DeferredDecls;
-  for (const auto &I : DeferredEmptyCoverageMappingDecls) {
-if (!I.second)
+  for (const auto &Entry : DeferredEmptyCoverageMappingDecls) {
+if (!Entry.second)
   continue;
-DeferredDecls.push_back(I.first);
-  }
-  // Sort the declarations by their location to make sure that the tests get a
-  // predictable order for the coverage mapping for the unused declarations.
-  if (CodeGenOpts.DumpCoverageMapping)
-std::sort(DeferredDecls.begin(), DeferredDecls.end(),
-  [] (const Decl *LHS, const Decl *RHS) {
-  return LHS->getLocStart() < RHS->getLocStart();
-});
-  for (const auto *D : DeferredDecls) {
+const Decl *D = Entry.first;
 switch (D->getKind()) {
 case Decl::CXXConversion:
 case Decl::CXXMethod:

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=320533&r1=320532&r2=320533&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Dec 12 16:14:17 2017
@@ -490,7 +490,7 @@ private:
 
   /// @}
 
-  llvm::DenseMap DeferredEmptyCoverageMappingDecls;
+  llvm::MapVector DeferredEmptyCoverageMappingDecls;
 
   std::unique_ptr CoverageMapping;
 


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


[llvm] [clang] [AArch64][SME] Remove immediate argument restriction for svldr and svstr (PR #68565)

2023-11-06 Thread Eli Friedman via cfe-commits


@@ -1741,6 +1742,69 @@ void AArch64DAGToDAGISel::SelectCVTIntrinsic(SDNode *N, 
unsigned NumVecs,
   CurDAG->RemoveDeadNode(N);
 }
 
+void AArch64DAGToDAGISel::SelectSMELdrStrZA(SDNode *N, bool IsLoad) {
+  // Lower an SME LDR/STR ZA intrinsic to LDR_ZA_PSEUDO or STR_ZA.
+  // If the vector number is an immediate between 0 and 15 inclusive then we 
can
+  // put that directly into the immediate field of the instruction. If it's
+  // outside of that range then we modify the base and slice by the greatest
+  // multiple of 15 smaller than that number and put the remainder in the
+  // instruction field. If it's not an immediate then we modify the base and
+  // slice registers by that number and put 0 in the instruction.
+  SDLoc DL(N);
+
+  SDValue TileSlice = N->getOperand(2);
+  SDValue Base = N->getOperand(3);
+  SDValue VecNum = N->getOperand(4);
+  SDValue Remainder = CurDAG->getTargetConstant(0, DL, MVT::i32);
+
+  // true if the base and slice registers need to me modified
+  bool NeedsAdd = true;
+  if (auto ImmNode = dyn_cast(VecNum)) {
+int Imm = ImmNode->getSExtValue();
+if (Imm >= 0 && Imm <= 15) {
+  Remainder = CurDAG->getTargetConstant(Imm, DL, MVT::i32);
+  NeedsAdd = false;
+} else {
+  Remainder = CurDAG->getTargetConstant(Imm % 15, DL, MVT::i32);

efriedma-quic wrote:

`Imm % 16` is in the range 0-15.  `Imm % 15` is in the range 0-14.

https://github.com/llvm/llvm-project/pull/68565
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add codegen option to add passbuilder callback functions (PR #70171)

2023-11-06 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/70171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix linker error for function multiversioning (PR #71706)

2023-11-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic edited 
https://github.com/llvm/llvm-project/pull/71706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix linker error for function multiversioning (PR #71706)

2023-11-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic commented:

Added reviewers from https://reviews.llvm.org/D127812, for the AArch64 side.

https://github.com/llvm/llvm-project/pull/71706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix linker error for function multiversioning (PR #71706)

2023-11-08 Thread Eli Friedman via cfe-commits


@@ -4098,8 +4098,26 @@ void CodeGenModule::emitMultiVersionFunctions() {
 }
 
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
-if (auto *IFunc = dyn_cast(ResolverConstant))
+if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
+  // In Aarch64, default versions of multiversioned functions are mangled 
to
+  // their 'normal' assembly name. This deviates from other targets which
+  // append a '.default' string. As a result we need to continue appending
+  // .ifunc in Aarch64.
+  // FIXME: Should Aarch64 mangling for 'default' multiversion function and
+  // in turn ifunc function match that of other targets?
+  if (FD->isTargetClonesMultiVersion() &&
+  !getTarget().getTriple().isAArch64()) {
+const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
+llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI);
+std::string MangledName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+auto *Alias = llvm::GlobalAlias::create(
+DeclTy, 0, llvm::Function::WeakODRLinkage, MangledName + ".ifunc",

efriedma-quic wrote:

Why WeakODR?

https://github.com/llvm/llvm-project/pull/71706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Ensure consistent `mustprogress` attribute emission across all paths (PR #71452)

2023-11-08 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

The C equivalent to the C++11 rule is in 6.8.5, which says "An iteration 
statement may be assumed by the implementation to terminate if [...]".  There's 
no general rule that a program has to make progress if there isn't a loop 
involved.

https://github.com/llvm/llvm-project/pull/71452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Ensure consistent `mustprogress` attribute emission across all paths (PR #71452)

2023-11-08 Thread Eli Friedman via cfe-commits


@@ -1482,6 +1477,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, 
llvm::Function *Fn,
   } else
 llvm_unreachable("no definition for emitted function");
 
+  // This is checked after emitting the function body so we know if there
+  // are any permitted infinite loops.

efriedma-quic wrote:

Is this comment actually accurate?  I think the relevant code changed in 
6c312954

https://github.com/llvm/llvm-project/pull/71452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Ensure consistent `mustprogress` attribute emission across all paths (PR #71452)

2023-11-08 Thread Eli Friedman via cfe-commits


@@ -1482,6 +1477,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, 
llvm::Function *Fn,
   } else
 llvm_unreachable("no definition for emitted function");
 
+  // This is checked after emitting the function body so we know if there
+  // are any permitted infinite loops.

efriedma-quic wrote:

Fundamentally, I'm not sure there's any reason we need to do this after 
emitting the function body.  When the comment was written, it was referring to 
the FnIsMustProgress bit in CodeGenFunction, but that was removed.

https://github.com/llvm/llvm-project/pull/71452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Ensure consistent `mustprogress` attribute emission across all paths (PR #71452)

2023-11-08 Thread Eli Friedman via cfe-commits


@@ -1482,6 +1477,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, 
llvm::Function *Fn,
   } else
 llvm_unreachable("no definition for emitted function");
 
+  // This is checked after emitting the function body so we know if there
+  // are any permitted infinite loops.

efriedma-quic wrote:

No, I mean, there isn't a reason to specifically do it *after* emitting the 
function body, as opposed to before we emit it (when we compute most other 
attributes).

https://github.com/llvm/llvm-project/pull/71452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [PowerPC][X86] Make cpu id builtins target independent and lower for PPC (PR #68919)

2023-11-08 Thread Eli Friedman via cfe-commits


@@ -359,6 +359,13 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   bool isSPRegName(StringRef RegName) const override {
 return RegName.equals("r1") || RegName.equals("x1");
   }
+
+  // We support __builtin_cpu_supports/__builtin_cpu_is on targets that

efriedma-quic wrote:

Musl targets are supposed to use a "musl" triple.  We already have 
Triple::isMusl(). If it's somehow possible for both isOSGlibc() and isMusl() to 
be true, I'd consider that a bug in isOSGlibc().

https://github.com/llvm/llvm-project/pull/68919
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS-ABI] create unique vftable name for vftable defined with internal alias. (PR #71748)

2023-11-08 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Why are we creating a comdat here in the first place?  Creating a comdat 
associated with an internal symbol doesn't do anything useful: an internal 
symbol can't be defined in any other translation unit, so the comdat will never 
be discarded.

If we allow creating a comdat associated with an internal symbol, the backend 
should handle it correctly; it's a bug if it crashes like you've described.  
(I'm not sure how to reproduce the crash with your testcase, though.)

https://github.com/llvm/llvm-project/pull/71748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS-ABI] create unique vftable name for vftable defined with internal alias. (PR #71748)

2023-11-08 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> Why are we creating a comdat here in the first place? 

I guess that's b2615aa4... but I'm pretty sure we fixed -fdata-sections so the 
backend automatically generates comdats.  So maybe we should just revert that.

> If we allow creating a comdat associated with an internal symbol, the backend 
> should handle it correctly; it's a bug if it crashes like you've described. 
> (I'm not sure how to reproduce the crash with your testcase, though.)

LangRef says "Because the name of the object must match the name of the COMDAT 
group, the linkage of the global object must not be local; local symbols can 
get renamed if a collision occurs in the symbol table."  I think that means the 
IR clang generates is illegal, but I guess nothing in the backend actually 
checks this.

https://github.com/llvm/llvm-project/pull/71748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS-ABI] create unique vftable name for vftable defined with internal alias. (PR #71748)

2023-11-09 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> That seems reasonable, however, there are other QOI reasons for attempting to 
> generate globally unique names for lambdas

Sure.  But we wouldn't want to special-case vftables for that.

> I think our strategy to ensure internal lambdas like this are globally unique 
> is that they appear in some externally visible scope which can only be 
> defined once, and that scope gets mangled into the name of the lambda. Is 
> that happening here? I don't have an MS demangler handy to confirm against 
> the test case.

In the testcase, the lambda is just at global scope.  Not sure what you're 
expecting to happen here.

https://github.com/llvm/llvm-project/pull/71748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Ensure consistent `mustprogress` attribute emission across all paths (PR #71452)

2023-11-09 Thread Eli Friedman via cfe-commits


@@ -1482,6 +1477,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, 
llvm::Function *Fn,
   } else
 llvm_unreachable("no definition for emitted function");
 
+  // This is checked after emitting the function body so we know if there
+  // are any permitted infinite loops.

efriedma-quic wrote:

If you look at the implementation of checkIfFunctionMustProgress(), it's pretty 
easy to verify that it doesn't actually look at the body of the function

https://github.com/llvm/llvm-project/pull/71452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Avoid memcopy for small structure with padding under -ftrivial-auto-var-init (PR #71677)

2023-11-09 Thread Eli Friedman via cfe-commits


@@ -1244,29 +1244,28 @@ static void emitStoresForConstant(CodeGenModule &CGM, 
const VarDecl &D,
   // If the initializer is small, use a handful of stores.
   if (shouldSplitConstantStore(CGM, ConstantSize)) {
 if (auto *STy = dyn_cast(Ty)) {
-  // FIXME: handle the case when STy != Loc.getElementType().
-  if (STy == Loc.getElementType()) {
-for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-  Address EltPtr = Builder.CreateStructGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)),
-  IsAutoInit);
-}
-return;
+  const llvm::StructLayout *Layout = CGM.getDataLayout().getStructLayout(
+  cast(constant->getType()));

efriedma-quic wrote:

Is `cast(constant->getType())` not equivalent to `STy`?

https://github.com/llvm/llvm-project/pull/71677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Avoid memcopy for small structure with padding under -ftrivial-auto-var-init (PR #71677)

2023-11-09 Thread Eli Friedman via cfe-commits


@@ -1244,29 +1244,28 @@ static void emitStoresForConstant(CodeGenModule &CGM, 
const VarDecl &D,
   // If the initializer is small, use a handful of stores.
   if (shouldSplitConstantStore(CGM, ConstantSize)) {
 if (auto *STy = dyn_cast(Ty)) {
-  // FIXME: handle the case when STy != Loc.getElementType().
-  if (STy == Loc.getElementType()) {
-for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-  Address EltPtr = Builder.CreateStructGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)),
-  IsAutoInit);
-}
-return;
+  const llvm::StructLayout *Layout =
+  CGM.getDataLayout().getStructLayout(STy);
+  for (unsigned i = 0; i != constant->getNumOperands(); i++) {
+CharUnits CurOff = 
CharUnits::fromQuantity(Layout->getElementOffset(i));
+Address EltPtr = Builder.CreateConstInBoundsByteGEP(

efriedma-quic wrote:

Maybe consider using CreateStructGEP

https://github.com/llvm/llvm-project/pull/71677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Avoid memcopy for small structure with padding under -ftrivial-auto-var-init (PR #71677)

2023-11-09 Thread Eli Friedman via cfe-commits


@@ -1244,29 +1244,28 @@ static void emitStoresForConstant(CodeGenModule &CGM, 
const VarDecl &D,
   // If the initializer is small, use a handful of stores.
   if (shouldSplitConstantStore(CGM, ConstantSize)) {
 if (auto *STy = dyn_cast(Ty)) {
-  // FIXME: handle the case when STy != Loc.getElementType().
-  if (STy == Loc.getElementType()) {
-for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-  Address EltPtr = Builder.CreateStructGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)),
-  IsAutoInit);
-}
-return;
+  const llvm::StructLayout *Layout =
+  CGM.getDataLayout().getStructLayout(STy);
+  for (unsigned i = 0; i != constant->getNumOperands(); i++) {
+CharUnits CurOff = 
CharUnits::fromQuantity(Layout->getElementOffset(i));
+Address EltPtr = Builder.CreateConstInBoundsByteGEP(
+Loc.withElementType(CGM.Int8Ty), CurOff);
+emitStoresForConstant(
+CGM, D, EltPtr, isVolatile, Builder,
+cast(Builder.CreateExtractValue(constant, i)),
+IsAutoInit);
   }
+  return;
 } else if (auto *ATy = dyn_cast(Ty)) {
-  // FIXME: handle the case when ATy != Loc.getElementType().
-  if (ATy == Loc.getElementType()) {
-for (unsigned i = 0; i != ATy->getNumElements(); i++) {
-  Address EltPtr = Builder.CreateConstArrayGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)),
-  IsAutoInit);
-}
-return;
+  for (unsigned i = 0; i != ATy->getNumElements(); i++) {
+Address EltPtr = Builder.CreateConstGEP(
+Loc.withElementType(ATy->getElementType()), i);
+emitStoresForConstant(
+CGM, D, EltPtr, isVolatile, Builder,
+cast(Builder.CreateExtractValue(constant, i)),

efriedma-quic wrote:

`constant->getAggregateElement(i)`

https://github.com/llvm/llvm-project/pull/71677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Avoid memcopy for small structure with padding under -ftrivial-auto-var-init (PR #71677)

2023-11-09 Thread Eli Friedman via cfe-commits


@@ -1506,8 +1497,16 @@ TEST_CUSTOM(unmatchedreverse, unmatchedreverse, { .c = 
42  });
 // CHECK-O0:call void @llvm.memcpy
 // CHECK-NOT:   !annotation
 // CHECK-O0:call void @{{.*}}used{{.*}}%custom)
-// PATTERN-O1:  store i32 -1431655894, ptr {{.*}}, align 4
-// ZERO-O1: store i32 42, ptr {{.*}}, align 4
+// PATTERN-O1:  store i8 42, ptr {{.*}}, align 4
+// PATTERN-O1-NEXT:  %[[I:[^ ]*]] = getelementptr inbounds i8, ptr %custom, 
i64 1
+// PATTERN-O1-NEXT:  store i8 -86, ptr %[[I]], align {{.*}}
+// PATTERN-O1-NEXT:  %[[I:[^ ]*]] = getelementptr inbounds i8, ptr %custom, 
i64 2
+// PATTERN-O1-NEXT:  store i8 -86, ptr %[[I]], align {{.*}}
+// PATTERN-O1-NEXT:  %[[I:[^ ]*]] = getelementptr inbounds i8, ptr %custom, 
i64 3
+// PATTERN-O1-NEXT:  store i8 -86, ptr %[[I]], align {{.*}}

efriedma-quic wrote:

This doesn't look like an improvement... but I guess it's a general limitation 
of IR optimizations at the moment.

https://github.com/llvm/llvm-project/pull/71677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Ensure consistent `mustprogress` attribute emission across all paths (PR #71452)

2023-11-10 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/71452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix linker error for function multiversioning (PR #71706)

2023-11-13 Thread Eli Friedman via cfe-commits


@@ -4098,8 +4098,26 @@ void CodeGenModule::emitMultiVersionFunctions() {
 }
 
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
-if (auto *IFunc = dyn_cast(ResolverConstant))
+if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
+  // In Aarch64, default versions of multiversioned functions are mangled 
to
+  // their 'normal' assembly name. This deviates from other targets which
+  // append a '.default' string. As a result we need to continue appending
+  // .ifunc in Aarch64.
+  // FIXME: Should Aarch64 mangling for 'default' multiversion function and
+  // in turn ifunc function match that of other targets?
+  if (FD->isTargetClonesMultiVersion() &&
+  !getTarget().getTriple().isAArch64()) {
+const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
+llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI);
+std::string MangledName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+auto *Alias = llvm::GlobalAlias::create(
+DeclTy, 0, llvm::Function::WeakODRLinkage, MangledName + ".ifunc",

efriedma-quic wrote:

That sounds right... we don't want to make symbols that are supposed to be 
internal linkage visible through an alias.

https://github.com/llvm/llvm-project/pull/71706
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Emit TBAA info for enums in C (PR #73326)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

The C notion of "compatibility" with regard to enums is a bit weird... clang 
and gcc disagree whether `enum e : int; enum e2: int; enum e x; int x; enum e2 
x;` is valid because 6.2.7 doesn't actually define what's supposed to happen.  
Probably this should be illegal, but the standard isn't really clear here.  
Maybe it should be clarified to have a notion of "redeclaration compatibility" 
which is separate from general type compatibility.

That said, this patch is pretty conservative; it's hard for me to imagine 
treating an enum as the underlying type could cause any issues (unless code is 
assuming an enum has universal aliasing).

I guess this should be compatible with older clang versions, so we don't need 
to rev the version of TBAA data.

https://github.com/llvm/llvm-project/pull/73326
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64] Add soft-float ABI (PR #74460)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I'm a little surprised we don't need any LLVM backend changes, but I guess in 
soft-float mode we basically treat floats as ints anyway, so maybe things just 
work.  I'd like to see appropriate regression tests, though (if they don't 
already exist).

https://github.com/llvm/llvm-project/pull/74460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I don't like the "ExprLValueMap" approach for array bounds checking; it's 
fragile and doesn't handle cases we should be able to handle.  In particular, 
we should be able to handle arbitrary base expressions for array bounds 
checking, I think; there should be a constant offset between a member and its 
corresponding count.  I'd strongly prefer the approach I outlined earlier 
(https://github.com/llvm/llvm-project/pull/73730#discussion_r141039).

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Strict aliasing warning ala GCC [PR50066] (PR #74155)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Making Sema pull the TBAA info out of clang/lib/CodeGen is a layering violation 
(and probably breaks if we aren't actually generating code).  If we need some 
notion of "aliasing" in Sema, we should pull the relevant code into 
clang/lib/AST.

I don't have any experience with this warning, so I'm not sure how effective it 
is at detecting issues; do a significant fraction of issues actually show up at 
a pure syntactic level?  Do you have any idea what false positive rate we 
should expect?

https://github.com/llvm/llvm-project/pull/74155
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

If you do need a map for something, I'd prefer to make it as narrow as 
possible.  For example, I can imagine you could need to specifically look up 
the corresponding allocation for a CompoundLiteralExpr; that might make sense.  
I don't think we should need to look up arbitrary lvalues.  For 
__builtin_dynamic_object_size, we should support a limited set of expressions 
as the base.  (And ideally, the recursive visit should list those expressions 
explicitly, instead aborting on ones we know are bad.)

> But if I placed some code in EmitArraySubscriptExpr, I'm guessing your 
> suggestion is more-or-less this:

Not sure it goes at the end. But to restate more explicitly, if you have 
something like ArraySubscriptExpr(MemberExpr(StructBase), ArrayIndex), you emit 
StructBase, then you emit the addresses of the array member and the counted_by 
member, then you use that to emit a bounds-checked array access.  So you don't 
recurse; you just look for that exact AST structure.

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> > And ideally, the recursive visit should list those expressions explicitly, 
> > instead aborting on ones we know are bad.
> 
> I'm sorry, I don't understand what you're talking about here. The whole point 
> of the recursive visit is to find a suitable base pointer. If we run across 
> any undesirable expressions (e.g. pointer arithmetic) then we return 
> `nullptr` to signify this. What do you mean we should list those expressions 
> explicitly?

I mean, the base case should be "return nullptr", and you should only 
explicitly list out expressions you know we need to handle.  We shouldn't need 
to explicitly mention VisitUnaryPostDec etc.

> > So you don't recurse; you just look for that exact AST structure.
> 
> The information about what LValue was generated for that base pointer is no 
> longer available to us.

No, I mean, you do the check before you emit the lvalue for the base.  So in 
`ArraySubscriptExpr(MemberExpr(StructBase), ArrayIndex)`, instead of calling 
EmitLValue on `MemberExpr(StructBase)` like we normally would, you call 
EmitLValue on StructBase.  So we have the LValue.  Then we do the indexing 
corresponding to the MemberExpr explicitly.  So you don't care what 
`StructBase` refers to, and you don't need a map to look up expressions.

For __builtin_dynamic_object_size, my understanding is that this approach 
doesn't work because the argument isn't actually supposed to be evaluated.  So 
we need a different approach that looks for specific constructs we want to 
allow.  And then we need a mini-codegen that specifically handles those 
constructs (or a mini-verifier that ensures when we call generic codegen, we 
don't have side-effects, but that's harder to get right).  And this is where 
you need the full recursive visit.

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Trying to discuss both __bdos and the array bounds sanitizer changes in the 
same review is making things confusing to discuss.  It seems like they have 
significant differences.

For array bounds sanitizer, take your example:

```
struct s {
  struct s *p;
  int count;
  int array[] __attribute__((count));
};

int foo(struct s *p, int index) {
  return p->p->p->array[index];
}
```

When we visit the ArraySubscriptExpr, without sanitization, we call EmitLValue 
on `p->p->p->array`.  My proposal is that, when we're doing sanitization, we 
don't do that.  Instead, we call EmitPointerWithAlignment on `p->p->p`, then 
use the returned pointer to load `count` and index to `array`.

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-06 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I actually think bdos is more complicated: array bounds checking can handle 
arbitrary base expressions, so it doesn't need to examine the base expression 
at all.  bdos can't do that, so more work is required to handle precisely the 
cases you want to handle.

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-07 Thread Eli Friedman via cfe-commits


@@ -994,31 +1010,55 @@ class MemberExprBaseVisitor
   // }
 
   Expr *Visit(Expr *E) {
-return StmtVisitor::Visit(E);
+return StmtVisitor::Visit(E);
   }
 
-  Expr *VisitCastExpr(CastExpr *E) {
-return IsExpectedRecordDecl(E) ? E : Visit(E->getSubExpr());
-  }
-  Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
-return IsExpectedRecordDecl(E) ? E : nullptr;
-  }
+  // These are the types we expect to return (in order of most to least
+  // likely):
+  //
+  //   1. DeclRefExpr - This is the expression for the base of the structure.
+  //  It's exactly what we want to build an access to the \p counted_by
+  //  field.
+  //   2. MemberExpr - This is the expression that has the same \p RecordDecl
+  //  as the flexble array member's lexical enclosing \p RecordDecl. This
+  //  allows us to catch things like: "p->p->array"
+  //   3. CompoundLiteralExpr - This is for people who create something
+  //  heretical like (struct foo has a flexible array member):
+  //
+  //(struct foo){ 1, 2 }.blah[idx];
   Expr *VisitDeclRefExpr(DeclRefExpr *E) {
 return IsExpectedRecordDecl(E) ? E : nullptr;
   }
   Expr *VisitMemberExpr(MemberExpr *E) {
+if (IsExpectedRecordDecl(E) && E->isArrow())
+  return E;
 Expr *Res = Visit(E->getBase());
 return !Res && IsExpectedRecordDecl(E) ? E : Res;
   }
-  Expr *VisitParenExpr(ParenExpr *E) {
-return IsExpectedRecordDecl(E) ? E : Visit(E->getSubExpr());
+  Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
+return IsExpectedRecordDecl(E) ? E : nullptr;
   }
 
+  // "Pass This On" --The Knife
   Expr *VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
+if (IsExpectedRecordDecl(E))
+  return E;
 return Visit(E->getBase());
   }
-  Expr *VisitImplicitCastExpr(CastExpr *E) { return Visit(E->getSubExpr()); }
-  Expr *VisitUnaryOperator(UnaryOperator *E) { return Visit(E->getSubExpr()); }
+  Expr *VisitCastExpr(CastExpr *E) { return Visit(E->getSubExpr()); }
+  Expr *VisitImplicitCastExpr(ImplicitCastExpr *E) {
+return Visit(E->getSubExpr());
+  }
+  Expr *VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
+  Expr *VisitUnaryAddrOf(UnaryOperator *E) { return Visit(E->getSubExpr()); }
+  Expr *VisitUnaryDeref(UnaryOperator *E) { return Visit(E->getSubExpr()); }
+
+  // Invalid operations. Pointer arithmetic may lead to security violations.
+  Expr *VisitBinaryOperator(BinaryOperator *E) { return nullptr; }
+  Expr *VisitUnaryPostDec(UnaryOperator *E) { return nullptr; }
+  Expr *VisitUnaryPostInc(UnaryOperator *E) { return nullptr; }
+  Expr *VisitUnaryPreDec(UnaryOperator *E) { return nullptr; }
+  Expr *VisitUnaryPreInc(UnaryOperator *E) { return nullptr; }

efriedma-quic wrote:

Can we add a VisitStmt or whatever it's called to change that?

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-07 Thread Eli Friedman via cfe-commits


@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const 
ArraySubscriptExpr *E,
   ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true);
 else
   ArrayLV = EmitLValue(Array);
+
 auto *Idx = EmitIdxAfterBase(/*Promote*/true);
 
+if (SanOpts.has(SanitizerKind::ArrayBounds)) {

efriedma-quic wrote:

It looks like this emits the base twice?  Once to compute ArrayLV, then once to 
compute "Addr".  ArrayLV needs to be computed from Addr instead.

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-07 Thread Eli Friedman via cfe-commits


@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const 
ArraySubscriptExpr *E,
   ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true);
 else
   ArrayLV = EmitLValue(Array);
+
 auto *Idx = EmitIdxAfterBase(/*Promote*/true);
 
+if (SanOpts.has(SanitizerKind::ArrayBounds)) {

efriedma-quic wrote:

If you have `p->p->p->a.b.c.d.e[index]`, the count is something like 
`p->p->p->a.b.c.d.count`.  So you just use `p->p->p->a.b.c.d` as the base, GEP 
from there to "e" and "count".



https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[polly] [llvm] [clang-tools-extra] [clang] Reduction series : Refactor reduction detection code (PR #72343)

2023-12-07 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/72343
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[polly] [llvm] [clang-tools-extra] [clang] Reduction series : Refactor reduction detection code (PR #72343)

2023-12-07 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic closed 
https://github.com/llvm/llvm-project/pull/72343
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-07 Thread Eli Friedman via cfe-commits


@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const 
ArraySubscriptExpr *E,
   ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true);
 else
   ArrayLV = EmitLValue(Array);
+
 auto *Idx = EmitIdxAfterBase(/*Promote*/true);
 
+if (SanOpts.has(SanitizerKind::ArrayBounds)) {

efriedma-quic wrote:

So instead of a GEP from the base to "array", then a GEP from the base to 
"count", you emit a GEP from the base to "array", then a GEP from the "array" 
to the "count"?  That's basically just rearranging the math; instead of "a + 
b", you compute "a + c + (b - c)".  Maybe it saves refactoring some code, 
though.

https://github.com/llvm/llvm-project/pull/73730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Support -fms-volatile as equivalent to /volatile:ms (PR #74790)

2023-12-07 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic created 
https://github.com/llvm/llvm-project/pull/74790

The flag -fms-volatile has existed as a -cc1 flag for a while.  It also 
technically existed as a driver flag, but didn't do anything because it wasn't 
wired up to anything in the driver.

This patch adds -fno-ms-volatile, and makes both -fms-volatile and 
-fno-ms-volatile work the same way as the cl-mode flags. The defaults are 
unchanged (default on for x86 in cl mode, default off otherwise).

>From bd8582278a76bffa4a43be5ba00f0e915b57bbb0 Mon Sep 17 00:00:00 2001
From: Eli Friedman 
Date: Thu, 7 Dec 2023 16:21:53 -0800
Subject: [PATCH] [clang][Driver] Support -fms-volatile as equivalent to
 /volatile:ms

The flag "-fms-volatile" has existed as a -cc1 flag for a while.  It
also technically existed as a driver flag, but didn't do anything
because it wasn't wired up to anything in the driver.

This patch adds -fno-ms-volatile, and makes both -fms-volatile and
-fno-ms-volatile work the same way as the cl-mode flags. The defaults
are unchanged (default on for x86 in cl mode, default off otherwise).
---
 clang/include/clang/Driver/Options.td | 12 +++-
 clang/lib/Driver/ToolChains/Clang.cpp | 16 
 clang/test/Driver/cl-options.c|  6 --
 clang/test/Driver/clang_f_opts.c  |  6 ++
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0eec2b3526376..6274ff76950d9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2869,9 +2869,11 @@ defm asm_blocks : BoolFOption<"asm-blocks",
   LangOpts<"AsmBlocks">, Default,
   PosFlag,
   NegFlag>;
-def fms_volatile : Flag<["-"], "fms-volatile">, Group,
-  Visibility<[ClangOption, CC1Option]>,
-  MarshallingInfoFlag>;
+defm ms_volatile : BoolFOption<"ms-volatile",
+  LangOpts<"MSVolatile">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 def fmsc_version : Joined<["-"], "fmsc-version=">, Group,
   Visibility<[ClangOption, CLOption]>,
   HelpText<"Microsoft compiler version number to report in _MSC_VER (0 = don't 
define it (default))">;
@@ -8184,7 +8186,7 @@ def _SLASH_winsysroot : CLJoinedOrSeparate<"winsysroot">,
   HelpText<"Same as \"/diasdkdir /DIA SDK\" /vctoolsdir 
/VC/Tools/MSVC/ \"/winsdkdir /Windows Kits/10\"">,
   MetaVarName<"">;
 def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>,
-  Group<_SLASH_volatile_Group>, Flags<[NoXarchOption]>, Visibility<[CLOption]>,
+  Visibility<[CLOption]>, Alias,
   HelpText<"Volatile loads and stores have standard semantics">;
 def _SLASH_vmb : CLFlag<"vmb">,
   HelpText<"Use a best-case representation method for member pointers">;
@@ -8199,7 +8201,7 @@ def _SLASH_vmv : CLFlag<"vmv">,
   HelpText<"Set the default most-general representation to "
"virtual inheritance">;
 def _SLASH_volatile_ms  : Option<["/", "-"], "volatile:ms", KIND_FLAG>,
-  Group<_SLASH_volatile_Group>, Flags<[NoXarchOption]>, Visibility<[CLOption]>,
+  Visibility<[CLOption]>, Alias,
   HelpText<"Volatile loads and stores have acquire and release semantics">;
 def _SLASH_clang : CLJoined<"clang:">,
   HelpText<"Pass  to the clang driver">, MetaVarName<"">;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f02f7c841b91f..c6be0750e1c33 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5545,6 +5545,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
options::OPT_fno_auto_import);
   }
 
+  if (Args.hasFlag(options::OPT_fms_volatile, options::OPT_fno_ms_volatile,
+   Triple.isX86() && D.IsCLMode()))
+CmdArgs.push_back("-fms-volatile");
+
   // Non-PIC code defaults to -fdirect-access-external-data while PIC code
   // defaults to -fno-direct-access-external-data. Pass the option if different
   // from the default.
@@ -7877,18 +7881,6 @@ void Clang::AddClangCLArgs(const ArgList &Args, 
types::ID InputType,
 CmdArgs.push_back("-P");
   }
 
-  unsigned VolatileOptionID;
-  if (getToolChain().getTriple().isX86())
-VolatileOptionID = options::OPT__SLASH_volatile_ms;
-  else
-VolatileOptionID = options::OPT__SLASH_volatile_iso;
-
-  if (Arg *A = Args.getLastArg(options::OPT__SLASH_volatile_Group))
-VolatileOptionID = A->getOption().getID();
-
-  if (VolatileOptionID == options::OPT__SLASH_volatile_ms)
-CmdArgs.push_back("-fms-volatile");
-
  if (Args.hasFlag(options::OPT__SLASH_Zc_dllexportInlines_,
   options::OPT__SLASH_Zc_dllexportInlines,
   false)) {
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 6d929b19e7e2e..6bc315b09477a 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -272,10 +272,12 @@
 // RUN: not %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck 
-check-prefix=VMX %s
 // VMX: '/vms'

[clang] [clang][Driver] Support -fms-volatile as equivalent to /volatile:ms (PR #74790)

2023-12-11 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I got a request for this feature from a user that ran into issues porting code 
from cl to clang for a baremetal target.  I expect scenarios like that to 
continue to be relevant for a while.

I don't expect anyone would want to use this for new code because current 
practice has strongly shifted towards using atomic types for synchronization 
since C++11.

Like the commit message notes, this isn't changing any defaults; it's just 
giving users an additional tool for porting code.  It's something we've already 
provided for many years; it just wasn't exposed outside cl-mode.  And it's a 
pretty straightforward extension to support (it just slightly modifies IR 
generation), so I don't think there's much long-term support burden.

https://github.com/llvm/llvm-project/pull/74790
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS-ABI] create unique vftable name for vftable defined with internal alias. (PR #71748)

2023-11-14 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

I see unrelated changes on the branch?  Otherwise LGTM

https://github.com/llvm/llvm-project/pull/71748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS-ABI] create unique vftable name for vftable defined with internal alias. (PR #71748)

2023-11-15 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

The simplest thing to do is rebase and force-push.  You can alternatively try 
to use a merge commit, but I'm not completely sure how github would react to 
that.

https://github.com/llvm/llvm-project/pull/71748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [MS-ABI] create unique vftable name for vftable defined with internal alias. (PR #71748)

2023-11-15 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Looks fine now.  (You might want to change the title before merging.)

https://github.com/llvm/llvm-project/pull/71748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang-tools-extra] Dont alter cold function alignment unless using Os (PR #72387)

2023-11-15 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

This patch appears to do two things:

- Add a "default align" attribute, which instructions the backend to use some 
unspecified "default" alignment for the function in question.
- Tells the frontend to apply this attribute specifically to "cold" functions.

This is basically nonsense.  We already have a way to set alignment: it's the 
"align" attribute.  And there isn't any obvious reason to special-case "cold" 
functions.

> This interferes with code replacement features on our targets

Please take a step back and consider what makes sense to express the 
constraints in general, not what narrowly solves the problem on the current 
version of your codebase.

If there's an ABI constraint that requires a particular function alignment, 
clang should be explicitly marking it.  We already do this if you, for example, 
specify `-falign-functions=16` on the clang command-line.

https://github.com/llvm/llvm-project/pull/72387
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fix: compatible C++ empty record with align UB with gcc (PR #72197)

2023-11-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

The proper fix here is probably to just delete the `return 
ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext()));` from the empty 
struct codepath on aarch64.

Alignment shouldn't affect whether a class is empty.  The issue here is just 
that according to aarch64 AAPCS rules, there isn't supposed to be a special 
case for empty classes; they're supposed to be passed exactly the same way as 
non-empty classes.  If there's no alignment involved, that's the same as an i8; 
if there's alignment, though, that increases the size of the struct, and 
therefore the calling convention.  It looks like whoever wrote it wasn't 
considering that an empty struct can have size greater than one byte if 
alignment is involved.

The code you noted is supposed to handle two cases, neither of which are 
relevant to your testcase:

- Darwin-specific calling convention rules.
- GNU extensions for zero-size structs (which aren't allowed according to 
either C or C++ standards, but GNU invented a bunch of non-standard rules for 
them)

https://github.com/llvm/llvm-project/pull/72197
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen][regression] Add dso_local/hidden/etc. markings to VTT definitions and declarations (PR #72452)

2023-11-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I'd prefer not to call setGVProperties() twice on the same variable; under what 
conditions is the first call not sufficient?

https://github.com/llvm/llvm-project/pull/72452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-11-16 Thread Eli Friedman via cfe-commits


@@ -80,6 +94,139 @@ class Address {
 return Alignment;
   }
 
+  /// Return address with different element type, but same pointer and
+  /// alignment.
+  RawAddress withElementType(llvm::Type *ElemTy) const {
+return RawAddress(getPointer(), ElemTy, getAlignment(), isKnownNonNull());
+  }
+
+  KnownNonNull_t isKnownNonNull() const {
+assert(isValid());
+return (KnownNonNull_t)PointerAndKnownNonNull.getInt();
+  }
+};
+
+/// Like RawAddress, an abstract representation of an aligned address, but the
+/// pointer contained in this class is possibly signed.
+class Address {
+  friend class CGBuilderTy;
+
+  // The boolean flag indicates whether the pointer is known to be non-null.
+  llvm::PointerIntPair Pointer;
+
+  /// The expected IR type of the pointer. When the address is a raw pointer,
+  /// this is currently redundant with the pointer's type, but for signed
+  /// pointers it is useful if the pointer has been offsetted or cast from the
+  /// original type. In the long run, when LLVM adopts opaque pointer types,
+  /// this should become the notional element type of the address.

efriedma-quic wrote:

This comment probably needs to be updated?

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-11-16 Thread Eli Friedman via cfe-commits


@@ -395,27 +395,27 @@ namespace {
 void CodeGenFunction::EmitAnyExprToExn(const Expr *e, Address addr) {
   // Make sure the exception object is cleaned up if there's an
   // exception during initialization.
-  pushFullExprCleanup(EHCleanup, addr.getPointer());
-  EHScopeStack::stable_iterator cleanup = EHStack.stable_begin();
-
-  // __cxa_allocate_exception returns a void*;  we need to cast this
-  // to the appropriate type for the object.
-  llvm::Type *ty = ConvertTypeForMem(e->getType());
-  Address typedAddr = addr.withElementType(ty);
-
-  // FIXME: this isn't quite right!  If there's a final unelided call
-  // to a copy constructor, then according to [except.terminate]p1 we
-  // must call std::terminate() if that constructor throws, because
-  // technically that copy occurs after the exception expression is
-  // evaluated but before the exception is caught.  But the best way
-  // to handle that is to teach EmitAggExpr to do the final copy
-  // differently if it can't be elided.
-  EmitAnyExprToMem(e, typedAddr, e->getType().getQualifiers(),
-   /*IsInit*/ true);
-
-  // Deactivate the cleanup block.
-  DeactivateCleanupBlock(cleanup,
- cast(typedAddr.getPointer()));
+pushFullExprCleanup(EHCleanup, addr.getRawPointer(*this));

efriedma-quic wrote:

The new indentation here doesn't look right?

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

2023-11-16 Thread Eli Friedman via cfe-commits


@@ -232,19 +232,19 @@ static Value *MakeBinaryAtomicValue(
 
 static Value *EmitNontemporalStore(CodeGenFunction &CGF, const CallExpr *E) {
   Value *Val = CGF.EmitScalarExpr(E->getArg(0));
-  Value *Address = CGF.EmitScalarExpr(E->getArg(1));
+  Address Addr = CGF.EmitPointerWithAlignment(E->getArg(1));
 
   Val = CGF.EmitToMemory(Val, E->getArg(0)->getType());
-  LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getArg(0)->getType());
+  LValue LV = CGF.MakeAddrLValue(Addr, E->getArg(0)->getType());
   LV.setNontemporal(true);
   CGF.EmitStoreOfScalar(Val, LV, false);
   return nullptr;
 }
 
 static Value *EmitNontemporalLoad(CodeGenFunction &CGF, const CallExpr *E) {
-  Value *Address = CGF.EmitScalarExpr(E->getArg(0));
+  Address Addr = CGF.EmitPointerWithAlignment(E->getArg(0));
 
-  LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getType());
+  LValue LV = CGF.MakeAddrLValue(Addr, E->getType());

efriedma-quic wrote:

Can we land this separately with appropriate tests?  It looks like it changes 
the behavior (the computed alignment of a pointer can be less than natural 
alignment, I think).

https://github.com/llvm/llvm-project/pull/67454
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)

2023-11-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I'm a little wary of adding these without actually going through any sort of 
standardization process; if other vendors don't support the same interface, we 
just have more variations.  (See also 
https://clang.llvm.org/get_involved.html#criteria )

How consistent are the various scopes across targets?  How likely is it that 
some target will need additional scopes that you haven't specified?

https://github.com/llvm/llvm-project/pull/72280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)

2023-11-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> I figured we can just treat these as clang extensions for the time being. We 
> already have two variants that are more or less redundant for specific 
> use-cases, (OpenCL and HIP), which should be able to be removed after this.

I'm not sure what you mean here.  If you mean that users are expected to use 
the OpenCL/HIP/etc. standard APIs, and you only expect to use these as part of 
language runtimes, then maybe we don't care so much if it's clang-only.

--

It might be worth considering using string literals instead of numbers for the 
different scopes.  It removes any question of whether the list of scopes is 
complete and the order of of numbers on the list.  And it doesn't require 
defining a bunch of new preprocessor macros.

https://github.com/llvm/llvm-project/pull/72280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)

2023-11-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Can you not test this by checking an `__attribute__((swiftcall))` function 
works in C?

https://github.com/llvm/llvm-project/pull/72298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)

2023-11-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

See also #71986

https://github.com/llvm/llvm-project/pull/72298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)

2023-11-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> The underlying implementation is a string literal in the LLVM syncscope 
> argument, but the problem is that this isn't standardized at all and varies 
> between backends potentially

We don't have to use the same set of strings as syncscope if that doesn't make 
sense.

https://github.com/llvm/llvm-project/pull/72280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen][regression] Add dso_local/hidden/etc. markings to VTT definitions and declarations (PR #72452)

2023-11-17 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I mean, looking at the code, as far as I can tell, we always call GetAddrOfVTT 
immediately before EmitVTTDefinition, so setGVProperties() has already run, so 
running it again shouldn't do anything... unless somehow EmitVTTDefinition is 
overwriting the visibility, or setGVProperties() behaves differently for 
declarations vs. definitions.  If something like that is happening, I'd like to 
explicitly document it.

https://github.com/llvm/llvm-project/pull/72452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Ensure minimal alignment of global vars of incomplete type. (PR #72886)

2023-11-20 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

The questions that I came up with while reviewing:

- Does this affect other targets?

It looks like it affects Lanai, but that difference seems fine.  It looks like 
it doesn't affect anything else in-tree; in particular, the overrides just 
return the default for size=0.  Maybe out-of-tree, but we can't really do much 
about that (unless we want to add a separate target hook, but that seems like 
overkill).

- Are there any possible side-effects?

Given the actual usage, this seems safe enough.  I'm a little concerned about 
people doing weird stuff with extern globals and linker scripts, but it looks 
like none of the targets where that would matter are actually impacted by this.

https://github.com/llvm/llvm-project/pull/72886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] Dont alter cold function alignment unless using Os (PR #72387)

2023-11-20 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> Is clang aware of the target's default function alignment?

No?  On x86, the "default" is set by the line 
`setPrefFunctionAlignment(Align(16));`.  Which, as the name suggests, is 
supposed to be a preference, not a mandatory minimum.  And it's subject to 
change in the future if we find that a different number is better on some 
targets, or for certain functions.

> > there isn't any obvious reason to special-case "cold" functions.
> 
> I'd thought that was clear. Cold implies opt-for-size, which implies align(1)

If there's a relevant ABI rule here, we want to mark it on all functions.  So 
if, for example, some optimization decides a function is cold, we get the same 
result.

> If the tweak to the definition of "cold" should be specific to our targets, 
> we can certainly do that.

If there's some relevant ABI rule, clang should compute the required alignment 
explicitly, and explicitly mark functions with the required alignment.  If 
that's target-specific, that's fine.  Ideally, it should be controllable by a 
flag separate from the optimization level.

https://github.com/llvm/llvm-project/pull/72387
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)

2023-11-20 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

We're already assigning names to the different scopes; we're just doing it in 
the __MEMORY_SCOPE_* preprocessor macros.  Replacing `_MEMORY_SCOPE_SYSTEM` in 
the code with `"system"` doesn't really change the nature of how we assign 
names to scopes.

If these are supposed to match the OpenCL enum values, though, I guess that's 
an argument for using numbers.

https://github.com/llvm/llvm-project/pull/72280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen][regression] Add dso_local/hidden/etc. markings to VTT definitions and declarations (PR #72452)

2023-11-20 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Okay.  Please add a comment to the code briefly explaining that.

Otherwise looks fine.

https://github.com/llvm/llvm-project/pull/72452
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   10   >