[PATCH] D101763: [analyzer][ctu] Avoid parsing invocation list again and again during on-demand parsing of CTU

2021-05-07 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

In D101763#2741629 , @steakhal wrote:

> Okay, so you 'just' want an indication for the given open call. What about 
> using `strace`?
> `strace -e trace=openat %clang_cc1 ... 2>&1 | grep '"invocations.yaml"' | 
> FileCheck %s`

I do not know why the test case always fails on the build server, it runs 
perfectly on my computer. : (
Do any reviewers have any ideas?


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

https://reviews.llvm.org/D101763

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


[PATCH] D102062: [analyzer][ctu] Append ctu-dir to ctu-invocation-list for non-absolute paths

2021-05-07 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

In D102062#2744267 , @steakhal wrote:

> On second thought the current behavior is reasonable.

The behavior of all CTU affairs are related to the `ctu-dir` rather than CWD, 
such as loading the external function map file and looking for the AST dumps 
and source files to be imported.
If a relative path is provided for these files, the `ctu-dir` will be added to 
the path when trying to open the file (see the comments in the code).
Therefore, IMO the behavior of `ctu-invocation-list` and its contents should 
also be relative to the `ctu-dir` unless an absolute path is provided.

> We call clang from a command line, so I think it's fair to expect that 
> relative paths are resolved using the CWD.

I do not know how other people use CSA, but I prefer using CSA via 
`clang-check`.
It works with the relative path to the "directory" option in the compilation 
database of each source file, which could make the CWD not unique.

> AFAIK if one does not supply the `ctu-invocation-list`, then it would be 
> substituted by `ctu-dir/invocations.yaml` anyway.

But we cannot currently distinguish the difference between setting 
`ctu-invocation-list` to `invocations.yaml` and not setting it. As the default 
value of `ctu-invocation-list` is `invocations.yaml` rather than an empty 
string.
Therefore, adding the `ctu-dir` to a relative `ctu-invocation-list` path by 
default seems to be a better choice.




Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:470
   else
 llvm::sys::path::append(IndexFile, IndexName);
 

Loading the external function map.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:516
 Path = CTUDir;
 llvm::sys::path::append(Path, PathStyle, Identifier);
   }

Loading the ASTUnit from external AST dumps or source files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102062

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


[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-07 Thread TaoPan via Phabricator via cfe-commits
TaoPan added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:275-276
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);
 assert(TLI->getSchedulingPreference() == Sched::ILP &&

pengfei wrote:
> Can this be omitted given `createFastDAGScheduler` should make it linked.
For making scheduler fast and linearize visible by clang -pre-RA-sched, yes, 
createDAGLinearizer can be omitted.
Adding both is also for keeping the ability that all schedulers can be selected 
by TargetLowering object in the case of clang -pre-RA-sched=default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

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


[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-07 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

I see. LGTM, but let's wait one or more days to see if others object it.




Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:275-276
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);
 assert(TLI->getSchedulingPreference() == Sched::ILP &&

Can this be omitted given `createFastDAGScheduler` should make it linked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

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


[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-07 Thread TaoPan via Phabricator via cfe-commits
TaoPan added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:273-276
+if (TLI->getSchedulingPreference() == Sched::Fast)
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);

craig.topper wrote:
> craig.topper wrote:
> > TaoPan wrote:
> > > pengfei wrote:
> > > > I saw they are always registered in ScheduleDAGFast.cpp:
> > > > https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp#L36
> > > > Why do we register them again here?
> > > Please also help to have a review of the Summary. It's a little bit of a 
> > > trick. ScheduleDAGFast.cpp is compiled to object file, but the object 
> > > file isn't linked into clang executable file as no symbol is referred by 
> > > outside without this patch.
> > That wasn't very clear from your summary. The "the object file isn't linked 
> > into clang executable file as no symbol is referred by outside without this 
> > patch" in this comment was much more help. Can you put something like that 
> > in summary?
> > 
> > Why are they being stripped from clang but not llc?
> Oh I see, llc uses include/llvm/CodeGen/LinkAllCodegenComponents.h to force 
> these to link in.
Thanks! I modified summary. could you please have a review?
Yes, you are right, llc include LinkAllCodegenComponents.h which refers 
function createFastDAGScheduler of ScheduleDAGFast.cpp.



Comment at: llvm/test/CodeGen/Generic/pre-ra-sched.c:1
+// RUN: clang %s -mllvm -pre-RA-sched=fast -c -o - | FileCheck %s
+// RUN: clang %s -mllvm -pre-RA-sched=linearize -c -o - | FileCheck %s

craig.topper wrote:
> You can't run clang from an llvm test directory. There's no guarantee clang 
> will have been compiled.
Thanks for notifying no guarantee clang in llvm test directory! I moved the 
test back to clang/test/CodeGen/.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

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


[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-07 Thread TaoPan via Phabricator via cfe-commits
TaoPan updated this revision to Diff 343800.
TaoPan added a comment.

Move test back to clang/test/CodeGen/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

Files:
  clang/test/CodeGen/pre-ra-sched.c
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -270,6 +270,10 @@
   return createHybridListDAGScheduler(IS, OptLevel);
 if (TLI->getSchedulingPreference() == Sched::VLIW)
   return createVLIWDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Fast)
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);
 assert(TLI->getSchedulingPreference() == Sched::ILP &&
"Unknown sched type!");
 return createILPListDAGScheduler(IS, OptLevel);
Index: llvm/include/llvm/CodeGen/TargetLowering.h
===
--- llvm/include/llvm/CodeGen/TargetLowering.h
+++ llvm/include/llvm/CodeGen/TargetLowering.h
@@ -94,14 +94,16 @@
 
 namespace Sched {
 
-  enum Preference {
-None, // No preference
-Source,   // Follow source order.
-RegPressure,  // Scheduling for lowest register pressure.
-Hybrid,   // Scheduling for both latency and register pressure.
-ILP,  // Scheduling for ILP in low register pressure mode.
-VLIW  // Scheduling for VLIW targets.
-  };
+enum Preference {
+  None,// No preference
+  Source,  // Follow source order.
+  RegPressure, // Scheduling for lowest register pressure.
+  Hybrid,  // Scheduling for both latency and register pressure.
+  ILP, // Scheduling for ILP in low register pressure mode.
+  VLIW,// Scheduling for VLIW targets.
+  Fast,// Fast suboptimal list scheduling
+  Linearize// Linearize DAG, no scheduling
+};
 
 } // end namespace Sched
 
Index: clang/test/CodeGen/pre-ra-sched.c
===
--- /dev/null
+++ clang/test/CodeGen/pre-ra-sched.c
@@ -0,0 +1,4 @@
+// RUN: %clang %s -mllvm -pre-RA-sched=fast -c -o - | FileCheck %s
+// RUN: %clang %s -mllvm -pre-RA-sched=linearize -c -o - | FileCheck %s
+
+// CHECK-NOT: clang (LLVM option parsing): for the --pre-RA-sched option: 
Cannot find option named


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -270,6 +270,10 @@
   return createHybridListDAGScheduler(IS, OptLevel);
 if (TLI->getSchedulingPreference() == Sched::VLIW)
   return createVLIWDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Fast)
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);
 assert(TLI->getSchedulingPreference() == Sched::ILP &&
"Unknown sched type!");
 return createILPListDAGScheduler(IS, OptLevel);
Index: llvm/include/llvm/CodeGen/TargetLowering.h
===
--- llvm/include/llvm/CodeGen/TargetLowering.h
+++ llvm/include/llvm/CodeGen/TargetLowering.h
@@ -94,14 +94,16 @@
 
 namespace Sched {
 
-  enum Preference {
-None, // No preference
-Source,   // Follow source order.
-RegPressure,  // Scheduling for lowest register pressure.
-Hybrid,   // Scheduling for both latency and register pressure.
-ILP,  // Scheduling for ILP in low register pressure mode.
-VLIW  // Scheduling for VLIW targets.
-  };
+enum Preference {
+  None,// No preference
+  Source,  // Follow source order.
+  RegPressure, // Scheduling for lowest register pressure.
+  Hybrid,  // Scheduling for both latency and register pressure.
+  ILP, // Scheduling for ILP in low register pressure mode.
+  VLIW,// Scheduling for VLIW targets.
+  Fast,// Fast suboptimal list scheduling
+  Linearize// Linearize DAG, no scheduling
+};
 
 } // end namespace Sched
 
Index: clang/test/CodeGen/pre-ra-sched.c
===
--- /dev/null
+++ clang/test/CodeGen/pre-ra-sched.c
@@ -0,0 +1,4 @@
+// RUN: %clang %s -mllvm -pre-RA-sched=fast -c -o - | FileCheck %s
+// RUN: %clang %s -mllvm -pre-RA-sched=linearize -c -o - | FileCheck %s
+
+// CHECK-NOT: clang (LLVM option parsing): for 

[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-07 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 343795.
pzheng added a comment.

Minor update to some comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-usage.c
  clang/test/Driver/stack-usage.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1185,6 +1185,37 @@
   OutStreamer->PopSection();
 }
 
+void AsmPrinter::emitStackUsage(const MachineFunction ) {
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+
+  // OutputFilename empty implies -fstack-usage is not passed.
+  if (OutputFilename.empty())
+return;
+
+  const MachineFrameInfo  = MF.getFrameInfo();
+  uint64_t StackSize = FrameInfo.getStackSize();
+
+  if (StackUsageStream == nullptr) {
+std::error_code EC;
+StackUsageStream =
+std::make_unique(OutputFilename, EC, sys::fs::OF_Text);
+if (EC) {
+  errs() << "Could not open file: " << EC.message();
+  return;
+}
+  }
+
+  *StackUsageStream << MF.getFunction().getParent()->getName();
+  if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
+*StackUsageStream << ":" << DSP->getLine();
+
+  *StackUsageStream << ":" << MF.getName() << "\t" << StackSize << "\t";
+  if (FrameInfo.hasVarSizedObjects())
+*StackUsageStream << "dynamic\n";
+  else
+*StackUsageStream << "static\n";
+}
+
 static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction ) {
   MachineModuleInfo  = MF.getMMI();
   if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
@@ -1469,6 +1500,9 @@
   // Emit section containing stack size metadata.
   emitStackSizeSection(*MF);
 
+  // Emit .su file containing function stack size information.
+  emitStackUsage(*MF);
+
   emitPatchableFunctionEntries();
 
   if (isVerbose())
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -337,6 +337,11 @@
 /// Stack protector guard reg to use, e.g. usually fs or gs in X86.
 std::string StackProtectorGuardReg = "None";
 
+/// Name of the stack usage file (i.e., .su file) if user passes
+/// -fstack-usage. If empty, it can be implied that -fstack-usage is not
+/// passed on the command line.
+std::string StackUsageOutput;
+
 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
 /// on the command line. This setting may either be Default, Soft, or Hard.
 /// Default selects the target's default behavior. Soft selects the ABI for
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -182,6 +182,9 @@
   /// Emit comments in assembly output if this is true.
   bool VerboseAsm;
 
+  /// Output stream for the stack usage file (i.e., .su file).
+  std::unique_ptr StackUsageStream;
+
   static char ID;
 
 protected:
@@ -358,6 +361,8 @@
 
   void emitStackSizeSection(const MachineFunction );
 
+  void emitStackUsage(const MachineFunction );
+
   void emitBBAddrMapSection(const MachineFunction );
 
   void emitPseudoProbe(const MachineInstr );
Index: clang/test/Driver/stack-usage.c
===
--- /dev/null
+++ clang/test/Driver/stack-usage.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-unknown %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ABSENT
+// CHECK-ABSENT-NOT: -fstack-usage
+
+// RUN: %clang -target aarch64-unknown -fstack-usage %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PRESENT
+// CHECK-PRESENT: "-fstack-usage"
+
+int foo() { return 42; }
Index: clang/test/CodeGen/stack-usage.c
===
--- /dev/null
+++ clang/test/CodeGen/stack-usage.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -triple aarch64-unknown -fstack-usage -emit-obj %s -o %t/b.o
+// RUN: FileCheck %s < %t/b.su
+
+// CHECK: stack-usage.c:8:foo	{{[0-9]+}}	static
+int foo() {
+  char a[8];
+
+  return 0;
+}
+
+// CHECK: stack-usage.c:15:bar	{{[0-9]+}}	dynamic
+int bar(int len) {
+  char a[len];
+
+  return 1;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp

[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-07 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng marked 7 inline comments as done.
pzheng added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5474
+  if (Args.hasArg(options::OPT_fstack_usage)) {
+CmdArgs.push_back(Args.MakeArgString("-fstack-usage"));
+

MaskRay wrote:
> CC1 needs two options? 
> 
> If you infer the filename in the driver, CC1 can use "whether 
> StackUsageOutput is empty".
Thanks for the suggestion! Addressed this in the latest update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-05-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: aaron.ballman.
dblaikie added inline comments.



Comment at: clang/test/CodeGen/unique-internal-linkage-names-dwarf.c:34-39
+static int go(a) int a;
+{
+  return glob + a;
+}
+
+

hoy wrote:
> dblaikie wrote:
> > dblaikie wrote:
> > > hoy wrote:
> > > > dblaikie wrote:
> > > > > hoy wrote:
> > > > > > dblaikie wrote:
> > > > > > > hoy wrote:
> > > > > > > > dblaikie wrote:
> > > > > > > > > hoy wrote:
> > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > > > Does this need to be down here? Or would the code 
> > > > > > > > > > > > > > > be a well exercised if it was up next to the go 
> > > > > > > > > > > > > > > declaration above?
> > > > > > > > > > > > > > Yes, it needs to be here. Otherwise it will just 
> > > > > > > > > > > > > > like the function `bar` above that doesn't get a 
> > > > > > > > > > > > > > uniquefied name. I think moving the definition up 
> > > > > > > > > > > > > > to right after the declaration hides the 
> > > > > > > > > > > > > > declaration.
> > > > > > > > > > > > > Not sure I follow - do you mean that if the go 
> > > > > > > > > > > > > declaration and go definition were next to each 
> > > > > > > > > > > > > other, this test would (mechanically speaking) not 
> > > > > > > > > > > > > validate what the patch? Or that it would be less 
> > > > > > > > > > > > > legible, but still mechanically correct?
> > > > > > > > > > > > > 
> > > > > > > > > > > > > I think it would be (assuming it's still mechanically 
> > > > > > > > > > > > > correct) more legible to put the declaration next to 
> > > > > > > > > > > > > the definition - the comment describes why the 
> > > > > > > > > > > > > declaration is significant/why the definition is 
> > > > > > > > > > > > > weird, and seeing all that together would be clearer 
> > > > > > > > > > > > > to me than spreading it out/having to look further 
> > > > > > > > > > > > > away to see what's going on.
> > > > > > > > > > > > When the `go` declaration and `go` definition were next 
> > > > > > > > > > > > to each other, the go function won't get a uniqufied 
> > > > > > > > > > > > name at all. The declaration will be overwritten by the 
> > > > > > > > > > > > definition. Only when the declaration is seen by 
> > > > > > > > > > > > others, such the callsite in `baz`, the declaration 
> > > > > > > > > > > > makes a difference by having the callsite use a 
> > > > > > > > > > > > uniqufied name.
> > > > > > > > > > > > 
> > > > > > > > > > > > 
> > > > > > > > > > > Ah! Interesting, good to know. 
> > > > > > > > > > > 
> > > > > > > > > > > Is that worth supporting, I wonder? I guess it falls out 
> > > > > > > > > > > for free/without significant additional complexity. I 
> > > > > > > > > > > worry about the subtlety of the additional declaration 
> > > > > > > > > > > changing the behavior here... might be a bit 
> > > > > > > > > > > surprising/subtle. But maybe no nice way to avoid it 
> > > > > > > > > > > either.
> > > > > > > > > > It would be ideal if user never writes code like that. 
> > > > > > > > > > Unfortunately it exists with legacy code (such as mysql). I 
> > > > > > > > > > think it's worth supporting it from AutoFDO point of view 
> > > > > > > > > > to avoid a silent mismatch between debug linkage name and 
> > > > > > > > > > real linkage name.
> > > > > > > > > Oh, I agree that we shouldn't mismatch debug info and the 
> > > > > > > > > actual symbol name - what I meant was whether code like this 
> > > > > > > > > should get mangled or not when using unique-internal-linkage 
> > > > > > > > > names.
> > > > > > > > > 
> > > > > > > > > I'm now more curious about this:
> > > > > > > > > 
> > > > > > > > > > When the `go` declaration and `go` definition were next to 
> > > > > > > > > > each other, the go function won't get a uniqufied name at 
> > > > > > > > > > all.
> > > > > > > > > 
> > > > > > > > > This doesn't seem to happen with the 
> > > > > > > > > `__attribute__((overloadable))` attribute, for instance - so 
> > > > > > > > > any idea what's different about uniquification that's working 
> > > > > > > > > differently than overloadable?
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > $ cat test.c
> > > > > > > > > __attribute__((overloadable)) static int go(a) int a; {
> > > > > > > > >   return 3 + a;
> > > > > > > > > }
> > > > > > > > > void baz() {
> > > > > > > > >   go(2);
> > > > > > > > > }
> > > > > > > > > $ clang-tot test.c -emit-llvm -S -o - | grep go
> > > > > > > > >   %call = call i32 @_ZL2goi(i32 2)
> > > > > > > > > define internal i32 @_ZL2goi(i32 %a) #0 {
> > > > > > > > > ```
> > > > > > > > Good question. I'm not sure what's exactly going on but it 
> > > > > > > > looks like with the overloadable attribute, the old-style 
> > > > > > > > 

[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-07 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 343794.
pzheng added a comment.

Addess @MaskRay's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-usage.c
  clang/test/Driver/stack-usage.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1185,6 +1185,36 @@
   OutStreamer->PopSection();
 }
 
+void AsmPrinter::emitStackUsage(const MachineFunction ) {
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+
+  if (OutputFilename.empty())
+return;
+
+  const MachineFrameInfo  = MF.getFrameInfo();
+  uint64_t StackSize = FrameInfo.getStackSize();
+
+  if (StackUsageStream == nullptr) {
+std::error_code EC;
+StackUsageStream =
+std::make_unique(OutputFilename, EC, sys::fs::OF_Text);
+if (EC) {
+  errs() << "Could not open file: " << EC.message();
+  return;
+}
+  }
+
+  *StackUsageStream << MF.getFunction().getParent()->getName();
+  if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
+*StackUsageStream << ":" << DSP->getLine();
+
+  *StackUsageStream << ":" << MF.getName() << "\t" << StackSize << "\t";
+  if (FrameInfo.hasVarSizedObjects())
+*StackUsageStream << "dynamic\n";
+  else
+*StackUsageStream << "static\n";
+}
+
 static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction ) {
   MachineModuleInfo  = MF.getMMI();
   if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
@@ -1469,6 +1499,9 @@
   // Emit section containing stack size metadata.
   emitStackSizeSection(*MF);
 
+  // Emit .su file containing function stack size information.
+  emitStackUsage(*MF);
+
   emitPatchableFunctionEntries();
 
   if (isVerbose())
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -337,6 +337,11 @@
 /// Stack protector guard reg to use, e.g. usually fs or gs in X86.
 std::string StackProtectorGuardReg = "None";
 
+/// Name of the stack usage file (i.e., .su file). If empty, the name of the
+/// source file should be used to name the stack usage file (e.g., foo.su
+/// for foo.c)
+std::string StackUsageOutput;
+
 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
 /// on the command line. This setting may either be Default, Soft, or Hard.
 /// Default selects the target's default behavior. Soft selects the ABI for
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -182,6 +182,9 @@
   /// Emit comments in assembly output if this is true.
   bool VerboseAsm;
 
+  /// Output stream for the stack usage file (i.e., .su file).
+  std::unique_ptr StackUsageStream;
+
   static char ID;
 
 protected:
@@ -358,6 +361,8 @@
 
   void emitStackSizeSection(const MachineFunction );
 
+  void emitStackUsage(const MachineFunction );
+
   void emitBBAddrMapSection(const MachineFunction );
 
   void emitPseudoProbe(const MachineInstr );
Index: clang/test/Driver/stack-usage.c
===
--- /dev/null
+++ clang/test/Driver/stack-usage.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-unknown %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ABSENT
+// CHECK-ABSENT-NOT: -fstack-usage
+
+// RUN: %clang -target aarch64-unknown -fstack-usage %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PRESENT
+// CHECK-PRESENT: "-fstack-usage"
+
+int foo() { return 42; }
Index: clang/test/CodeGen/stack-usage.c
===
--- /dev/null
+++ clang/test/CodeGen/stack-usage.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -triple aarch64-unknown -fstack-usage -emit-obj %s -o %t/b.o
+// RUN: FileCheck %s < %t/b.su
+
+// CHECK: stack-usage.c:8:foo	{{[0-9]+}}	static
+int foo() {
+  char a[8];
+
+  return 0;
+}
+
+// CHECK: stack-usage.c:15:bar	{{[0-9]+}}	dynamic
+int bar(int len) {
+  char a[len];
+
+  return 1;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- 

[PATCH] D101911: [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

2021-05-07 Thread Ethan Stewart via Phabricator via cfe-commits
estewart08 accepted this revision.
estewart08 added a comment.
This revision is now accepted and ready to land.

LGTM as a temporary workaround until SPMD properly assigns team private 
variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101911

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


[PATCH] D101911: [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

2021-05-07 Thread Ethan Stewart via Phabricator via cfe-commits
estewart08 added a comment.

In D101911#2738994 , @ABataev wrote:

> Hi Ethan, try this patch if it fixes the issue.

Tested this on gfx906 and v100, the main reproducer now passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101911

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


[PATCH] D100252: [clang] Fix for "Bug 27113 - MSVC-compat __identifier implementation incomplete"

2021-05-07 Thread Melvin Fox via Phabricator via cfe-commits
super_concat added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100252

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


[PATCH] D101572: Make `hasTypeLoc` matcher support more node types.

2021-05-07 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f65f42dd37a: Make `hasTypeLoc` matcher support more node 
types. (authored by SilensAngelusNex, committed by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D101572?vs=343219=343782#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101572

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Host.h"
 #include "gtest/gtest.h"
@@ -375,15 +376,104 @@
   typedefNameDecl(hasType(asString("foo")), hasName("bar";
 }
 
-TEST(HasTypeLoc, MatchesDeclaratorDecls) {
+TEST(HasTypeLoc, MatchesBlockDecl) {
+  EXPECT_TRUE(matchesConditionally(
+  "auto x = ^int (int a, int b) { return a + b; };",
+  blockDecl(hasTypeLoc(loc(asString("int (int, int)", true,
+  {"-fblocks"}));
+}
+
+TEST(HasTypeLoc, MatchesCXXBaseSpecifierAndCtorInitializer) {
+  llvm::StringRef code = R"cpp(
+  class Foo {};
+  class Bar : public Foo {
+Bar() : Foo() {}
+  };
+  )cpp";
+
+  EXPECT_TRUE(matches(
+  code, cxxRecordDecl(hasAnyBase(hasTypeLoc(loc(asString("class Foo")));
+  EXPECT_TRUE(matches(
+  code, cxxCtorInitializer(hasTypeLoc(loc(asString("class Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXFunctionalCastExpr) {
+  EXPECT_TRUE(matches("auto x = int(3);",
+  cxxFunctionalCastExpr(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesCXXNewExpr) {
+  EXPECT_TRUE(matches("auto* x = new int(3);",
+  cxxNewExpr(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("class Foo{}; auto* x = new Foo();",
+  cxxNewExpr(hasTypeLoc(loc(asString("class Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXTemporaryObjectExpr) {
+  EXPECT_TRUE(
+  matches("struct Foo { Foo(int, int); }; auto x = Foo(1, 2);",
+  cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("struct Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXUnresolvedConstructExpr) {
+  EXPECT_TRUE(
+  matches("template  T make() { return T(); }",
+  cxxUnresolvedConstructExpr(hasTypeLoc(loc(asString("T"));
+}
+
+TEST(HasTypeLoc, MatchesClassTemplateSpecializationDecl) {
+  EXPECT_TRUE(matches(
+  "template  class Foo; template <> class Foo {};",
+  classTemplateSpecializationDecl(hasTypeLoc(loc(asString("Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCompoundLiteralExpr) {
+  EXPECT_TRUE(
+  matches("int* x = (int [2]) { 0, 1 };",
+  compoundLiteralExpr(hasTypeLoc(loc(asString("int [2]"));
+}
+
+TEST(HasTypeLoc, MatchesDeclaratorDecl) {
   EXPECT_TRUE(matches("int x;",
   varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("int x(3);",
+  varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(
+  matches("struct Foo { Foo(int, int); }; Foo x(1, 2);",
+  varDecl(hasName("x"), hasTypeLoc(loc(asString("struct Foo"));
 
   // Make sure we don't crash on implicit constructors.
   EXPECT_TRUE(notMatches("class X {}; X x;",
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(HasTypeLoc, MatchesExplicitCastExpr) {
+  EXPECT_TRUE(matches("auto x = (int) 3;",
+  explicitCastExpr(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("auto x = static_cast(3);",
+  explicitCastExpr(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesObjCPropertyDecl) {
+  EXPECT_TRUE(matchesObjC(R"objc(
+  @interface Foo
+  @property int enabled;
+  @end
+)objc",
+  objcPropertyDecl(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesTemplateArgumentLoc) {
+  EXPECT_TRUE(matches("template  class Foo {}; Foo x;",
+  templateArgumentLoc(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesTypedefNameDecl) {
+  EXPECT_TRUE(matches("typedef int X;",
+  typedefNameDecl(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("using X = int;",
+  typedefNameDecl(hasTypeLoc(loc(asString("int"));
+}
 
 TEST(Callee, 

[clang] 1f65f42 - Make `hasTypeLoc` matcher support more node types.

2021-05-07 Thread Stephen Kelly via cfe-commits

Author: Weston Carvalho
Date: 2021-05-08T00:35:22+01:00
New Revision: 1f65f42dd37ab6a950d3ec110e3efca0ace1b615

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

LOG: Make `hasTypeLoc` matcher support more node types.

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index ab36402e4bca5..6647c4a902950 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -6137,6 +6137,34 @@ AST Traversal Matchers
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html;>BlockDeclhasTypeLocMatcherhttps://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html;>TypeLoc
 Inner
+Matches if the type 
location of a node matches the inner matcher.
+
+Examples:
+  int x;
+declaratorDecl(hasTypeLoc(loc(asString("int"
+  matches int x
+
+auto x = int(3);
+cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"
+  matches int(3)
+
+struct Foo { Foo(int, int); };
+auto x = Foo(1, 2);
+cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"
+  matches Foo(1, 2)
+
+Usable as: Matcherhttps://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html;>BlockDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html;>CXXBaseSpecifier,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html;>CXXCtorInitializer,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html;>CXXFunctionalCastExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html;>CXXNewExpr,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html;>CXXTemporaryObjectExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html;>CXXUnresolvedConstructExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html;>ClassTemplateSpecializationDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html;>CompoundLiteralExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html;>DeclaratorDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html;>ExplicitCastExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html;>ObjCPropertyDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html;>TemplateArgumentLoc,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html;>TypedefNameDecl
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html;>BlockPointerTypepointeeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Type.html;>Type
 Narrows PointerType (and 
similar) matchers to those where the
 pointee matches a given matcher.
@@ -6153,6 +6181,34 @@ AST Traversal Matchers
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html;>CXXBaseSpecifierhasTypeLocMatcherhttps://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html;>TypeLoc
 Inner
+Matches if the type 
location of a node matches the inner matcher.
+
+Examples:
+  int x;
+declaratorDecl(hasTypeLoc(loc(asString("int"
+  matches int x
+
+auto x = int(3);
+cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"
+  matches int(3)
+
+struct Foo { Foo(int, int); };
+auto x = Foo(1, 2);
+cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"
+  matches Foo(1, 2)
+
+Usable as: Matcherhttps://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html;>BlockDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html;>CXXBaseSpecifier,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html;>CXXCtorInitializer,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html;>CXXFunctionalCastExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html;>CXXNewExpr,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html;>CXXTemporaryObjectExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html;>CXXUnresolvedConstructExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html;>ClassTemplateSpecializationDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html;>CompoundLiteralExpr,
+  Matcherhttps://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html;>DeclaratorDecl,
 

[clang] 0ad4948 - NFC: Move TypeList implementation up the file

2021-05-07 Thread Stephen Kelly via cfe-commits

Author: Weston Carvalho
Date: 2021-05-08T00:35:13+01:00
New Revision: 0ad494838b8576de14144776490faa710fa2a099

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

LOG: NFC: Move TypeList implementation up the file

This will make it possible for more code to use it.

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index e8f427bafa257..8d346a6b9315a 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -83,6 +83,37 @@ class BoundNodes;
 
 namespace internal {
 
+/// A type-list implementation.
+///
+/// A "linked list" of types, accessible by using the ::head and ::tail
+/// typedefs.
+template  struct TypeList {}; // Empty sentinel type list.
+
+template  struct TypeList {
+  /// The first type on the list.
+  using head = T1;
+
+  /// A sublist with the tail. ie everything but the head.
+  ///
+  /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the
+  /// end of the list.
+  using tail = TypeList;
+};
+
+/// The empty type list.
+using EmptyTypeList = TypeList<>;
+
+/// Helper meta-function to determine if some type \c T is present or
+///   a parent type in the list.
+template  struct TypeListContainsSuperOf {
+  static const bool value =
+  std::is_base_of::value ||
+  TypeListContainsSuperOf::value;
+};
+template  struct TypeListContainsSuperOf {
+  static const bool value = false;
+};
+
 /// Variadic function object.
 ///
 /// Most of the functions below that use VariadicFunction could be implemented
@@ -1120,39 +1151,6 @@ struct IsBaseType {
 template 
 const bool IsBaseType::value;
 
-/// A type-list implementation.
-///
-/// A "linked list" of types, accessible by using the ::head and ::tail
-/// typedefs.
-template  struct TypeList {}; // Empty sentinel type list.
-
-template  struct TypeList {
-  /// The first type on the list.
-  using head = T1;
-
-  /// A sublist with the tail. ie everything but the head.
-  ///
-  /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the
-  /// end of the list.
-  using tail = TypeList;
-};
-
-/// The empty type list.
-using EmptyTypeList = TypeList<>;
-
-/// Helper meta-function to determine if some type \c T is present or
-///   a parent type in the list.
-template 
-struct TypeListContainsSuperOf {
-  static const bool value =
-  std::is_base_of::value ||
-  TypeListContainsSuperOf::value;
-};
-template 
-struct TypeListContainsSuperOf {
-  static const bool value = false;
-};
-
 /// A "type list" that contains all types.
 ///
 /// Useful for matchers like \c anything and \c unless.



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


[PATCH] D100139: [ifs][elfabi] Merge llvm-ifs/elfabi tools

2021-05-07 Thread Haowei Wu via Phabricator via cfe-commits
haowei updated this revision to Diff 343780.
haowei added a comment.

Rebase the change to resolve presubmit errors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100139

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/test/InterfaceStubs/driver-test.c
  llvm/include/llvm/InterfaceStub/ELFObjHandler.h
  llvm/include/llvm/InterfaceStub/IFSHandler.h
  llvm/include/llvm/InterfaceStub/IFSStub.h
  llvm/lib/InterfaceStub/ELFObjHandler.cpp
  llvm/lib/InterfaceStub/IFSHandler.cpp
  llvm/lib/InterfaceStub/IFSStub.cpp
  llvm/test/CMakeLists.txt
  llvm/test/tools/llvm-ifs/binary-read-add-soname.test
  llvm/test/tools/llvm-ifs/binary-read-arch.test
  llvm/test/tools/llvm-ifs/binary-read-bad-soname.test
  llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
  llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test
  llvm/test/tools/llvm-ifs/binary-read-neededlibs.test
  llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test
  llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test
  llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test
  llvm/test/tools/llvm-ifs/binary-read-replace-soname.test
  llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test
  llvm/test/tools/llvm-ifs/binary-read-soname.test
  llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test
  llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test
  llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
  llvm/test/tools/llvm-ifs/conflict-header-version.ifs
  llvm/test/tools/llvm-ifs/conflict-size.ifs
  llvm/test/tools/llvm-ifs/conflict-type.ifs
  llvm/test/tools/llvm-ifs/conflict-weak.ifs
  llvm/test/tools/llvm-ifs/default-empty.ifs
  llvm/test/tools/llvm-ifs/empty1.ifs
  llvm/test/tools/llvm-ifs/empty2.ifs
  llvm/test/tools/llvm-ifs/fail-file-open.test
  llvm/test/tools/llvm-ifs/fail-file-write-windows.test
  llvm/test/tools/llvm-ifs/fail-file-write.test
  llvm/test/tools/llvm-ifs/func.ifs
  llvm/test/tools/llvm-ifs/ifs-emits-current-version.test
  llvm/test/tools/llvm-ifs/ifs-read-basic.test
  llvm/test/tools/llvm-ifs/ios-tbd.ifs
  llvm/test/tools/llvm-ifs/macos-tbd.ifs
  llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
  llvm/test/tools/llvm-ifs/object.ifs
  llvm/test/tools/llvm-ifs/preserve-dates-stub.test
  llvm/test/tools/llvm-ifs/read-elf-dynsym.test
  llvm/test/tools/llvm-ifs/read-ifs-as-elf.test
  llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test
  llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test
  llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test
  llvm/test/tools/llvm-ifs/read-unsupported-file.test
  llvm/test/tools/llvm-ifs/strong.ifs
  llvm/test/tools/llvm-ifs/tvos-tbd.ifs
  llvm/test/tools/llvm-ifs/version-ok.ifs
  llvm/test/tools/llvm-ifs/watchos-tbd.ifs
  llvm/test/tools/llvm-ifs/weak-mismatch.ifs
  llvm/test/tools/llvm-ifs/weak.ifs
  llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test
  llvm/test/tools/llvm-ifs/write-stub.test
  llvm/tools/llvm-elfabi/CMakeLists.txt
  llvm/tools/llvm-elfabi/ErrorCollector.cpp
  llvm/tools/llvm-elfabi/ErrorCollector.h
  llvm/tools/llvm-elfabi/llvm-elfabi.cpp
  llvm/tools/llvm-ifs/CMakeLists.txt
  llvm/tools/llvm-ifs/ErrorCollector.cpp
  llvm/tools/llvm-ifs/ErrorCollector.h
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
  llvm/utils/gn/secondary/llvm/test/BUILD.gn
  llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn
+++ /dev/null
@@ -1,12 +0,0 @@
-executable("llvm-elfabi") {
-  deps = [
-"//llvm/lib/InterfaceStub",
-"//llvm/lib/Object",
-"//llvm/lib/Support",
-"//llvm/lib/TextAPI",
-  ]
-  sources = [
-"ErrorCollector.cpp",
-"llvm-elfabi.cpp",
-  ]
-}
Index: llvm/utils/gn/secondary/llvm/test/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -239,7 +239,6 @@
 "//llvm/tools/llvm-dis",
 "//llvm/tools/llvm-dwarfdump",
 "//llvm/tools/llvm-dwp",
-"//llvm/tools/llvm-elfabi",
 "//llvm/tools/llvm-exegesis",
 "//llvm/tools/llvm-extract",
 "//llvm/tools/llvm-gsymutil:llvm-gsymutil",
Index: llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
===
--- llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
+++ llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
@@ -17,7 +17,7 @@
 
 using namespace llvm;
 using namespace llvm::ELF;
-using namespace llvm::elfabi;
+using namespace llvm::ifs;
 
 void compareByLine(StringRef LHS, StringRef RHS) {
   StringRef Line1;
Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- 

[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:273-276
+if (TLI->getSchedulingPreference() == Sched::Fast)
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);

craig.topper wrote:
> TaoPan wrote:
> > pengfei wrote:
> > > I saw they are always registered in ScheduleDAGFast.cpp:
> > > https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp#L36
> > > Why do we register them again here?
> > Please also help to have a review of the Summary. It's a little bit of a 
> > trick. ScheduleDAGFast.cpp is compiled to object file, but the object file 
> > isn't linked into clang executable file as no symbol is referred by outside 
> > without this patch.
> That wasn't very clear from your summary. The "the object file isn't linked 
> into clang executable file as no symbol is referred by outside without this 
> patch" in this comment was much more help. Can you put something like that in 
> summary?
> 
> Why are they being stripped from clang but not llc?
Oh I see, llc uses include/llvm/CodeGen/LinkAllCodegenComponents.h to force 
these to link in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

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


[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:273-276
+if (TLI->getSchedulingPreference() == Sched::Fast)
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);

TaoPan wrote:
> pengfei wrote:
> > I saw they are always registered in ScheduleDAGFast.cpp:
> > https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp#L36
> > Why do we register them again here?
> Please also help to have a review of the Summary. It's a little bit of a 
> trick. ScheduleDAGFast.cpp is compiled to object file, but the object file 
> isn't linked into clang executable file as no symbol is referred by outside 
> without this patch.
That wasn't very clear from your summary. The "the object file isn't linked 
into clang executable file as no symbol is referred by outside without this 
patch" in this comment was much more help. Can you put something like that in 
summary?

Why are they being stripped from clang but not llc?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D101030#2745429 , @gregmiller 
wrote:

> Hello, We are maintaining a downstream version of the monorepo based on the 
> LLVM main branch. We have not transitioned to the new PM yet. In a recent 
> attempt to merge the latest upstream commits into our monorepo we came across 
> the following test failures after your commit.
> F16720091: failed_report.txt 
> For below test cases:
>
>   remarks_parallel_in_multiple_target_state_machines.c
>   remarks_parallel_in_target_state_machine.c
>
> Thanks
> greg

Can you add (and if you want upstream) a change that forces the use of the new 
pass manager for those tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D102093: [NewPM] Move analysis invalidation/clearing logging to instrumentation

2021-05-07 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f7131002b6a: [NewPM] Move analysis invalidation/clearing 
logging to instrumentation (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102093

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/CodeGen/MachinePassManager.h
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/CodeGen/PassManagerTest.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -297,7 +297,7 @@
   "end:\n"
   "  ret void\n"
   "}\n")),
-LAM(true), FAM(true), MAM(true) {
+LAM(), FAM(), MAM() {
 // Register our mock analysis.
 LAM.registerPass([&] { return MLAHandle.getAnalysis(); });
 
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -419,11 +419,11 @@
 }
 
 TEST_F(PassManagerTest, Basic) {
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   int FunctionAnalysisRuns = 0;
   FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
 
-  ModuleAnalysisManager MAM(/*DebugLogging*/ true);
+  ModuleAnalysisManager MAM;
   int ModuleAnalysisRuns = 0;
   MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); });
   MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
@@ -704,8 +704,8 @@
 };
 
 TEST_F(PassManagerTest, IndirectAnalysisInvalidation) {
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
-  ModuleAnalysisManager MAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
+  ModuleAnalysisManager MAM;
   int FunctionAnalysisRuns = 0, ModuleAnalysisRuns = 0,
   IndirectAnalysisRuns = 0, DoublyIndirectAnalysisRuns = 0;
   FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
@@ -823,7 +823,7 @@
 "}\n");
 
   auto *F = M->getFunction("foo");
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
@@ -869,7 +869,7 @@
 "}\n");
 
   auto *F = M->getFunction("foo");
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
@@ -934,7 +934,7 @@
 "}\n");
 
   auto *F = M->getFunction("foo");
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -467,7 +467,7 @@
   "}\n")),
 CallbacksHandle(), PB(false, nullptr, PipelineTuningOptions(), None,
   ),
-PM(true), LAM(true), FAM(true), CGAM(true), AM(true) {
+PM(true), LAM(), FAM(), CGAM(), AM() {
 
 EXPECT_TRUE( ==
 PB.getPassInstrumentationCallbacks());
Index: llvm/unittests/CodeGen/PassManagerTest.cpp
===
--- llvm/unittests/CodeGen/PassManagerTest.cpp
+++ llvm/unittests/CodeGen/PassManagerTest.cpp
@@ -208,10 +208,10 @@
   LLVMTargetMachine *LLVMTM = static_cast(TM.get());
   M->setDataLayout(TM->createDataLayout());
 
-  LoopAnalysisManager LAM(/*DebugLogging=*/true);
-  FunctionAnalysisManager FAM(/*DebugLogging=*/true);
-  CGSCCAnalysisManager CGAM(/*DebugLogging=*/true);
-  ModuleAnalysisManager MAM(/*DebugLogging=*/true);
+  LoopAnalysisManager LAM;
+  FunctionAnalysisManager FAM;
+  CGSCCAnalysisManager CGAM;
+  ModuleAnalysisManager MAM;
   PassBuilder 

[clang] 6f71310 - [NewPM] Move analysis invalidation/clearing logging to instrumentation

2021-05-07 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-05-07T15:25:31-07:00
New Revision: 6f7131002b6a821fc9b245ec5179910f171e3358

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

LOG: [NewPM] Move analysis invalidation/clearing logging to instrumentation

We're trying to move DebugLogging into instrumentation, rather than
being part of PassManagers/AnalysisManagers.

Reviewed By: ychen

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/CodeGen/MachinePassManager.h
llvm/include/llvm/IR/PassInstrumentation.h
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/IR/PassManagerImpl.h
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
llvm/tools/opt/NewPMDriver.cpp
llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
llvm/unittests/CodeGen/PassManagerTest.cpp
llvm/unittests/IR/PassBuilderCallbacksTest.cpp
llvm/unittests/IR/PassManagerTest.cpp
llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index fd3ce27bf20d8..31f2c36b2adfd 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1272,10 +1272,10 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
   PTO.Coroutines = LangOpts.Coroutines;
 
-  LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
-  FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
-  CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);
-  ModuleAnalysisManager MAM(CodeGenOpts.DebugPassManager);
+  LoopAnalysisManager LAM;
+  FunctionAnalysisManager FAM;
+  CGSCCAnalysisManager CGAM;
+  ModuleAnalysisManager MAM;
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(CodeGenOpts.DebugPassManager);

diff  --git a/llvm/include/llvm/CodeGen/MachinePassManager.h 
b/llvm/include/llvm/CodeGen/MachinePassManager.h
index 1489177d9668d..a375c47118d1e 100644
--- a/llvm/include/llvm/CodeGen/MachinePassManager.h
+++ b/llvm/include/llvm/CodeGen/MachinePassManager.h
@@ -40,11 +40,10 @@ class MachineFunctionAnalysisManager : public 
AnalysisManager {
 public:
   using Base = AnalysisManager;
 
-  MachineFunctionAnalysisManager() : Base(false), FAM(nullptr), MAM(nullptr) {}
+  MachineFunctionAnalysisManager() : Base(), FAM(nullptr), MAM(nullptr) {}
   MachineFunctionAnalysisManager(FunctionAnalysisManager ,
- ModuleAnalysisManager ,
- bool DebugLogging = false)
-  : Base(DebugLogging), FAM(), MAM() {}
+ ModuleAnalysisManager )
+  : Base(), FAM(), MAM() {}
   MachineFunctionAnalysisManager(MachineFunctionAnalysisManager &&) = default;
   MachineFunctionAnalysisManager &
   operator=(MachineFunctionAnalysisManager &&) = default;

diff  --git a/llvm/include/llvm/IR/PassInstrumentation.h 
b/llvm/include/llvm/IR/PassInstrumentation.h
index 291f324b159aa..b0ae1953361cb 100644
--- a/llvm/include/llvm/IR/PassInstrumentation.h
+++ b/llvm/include/llvm/IR/PassInstrumentation.h
@@ -81,6 +81,8 @@ class PassInstrumentationCallbacks {
   using AfterPassInvalidatedFunc = void(StringRef, const PreservedAnalyses &);
   using BeforeAnalysisFunc = void(StringRef, Any);
   using AfterAnalysisFunc = void(StringRef, Any);
+  using AnalysisInvalidatedFunc = void(StringRef, Any);
+  using AnalysesClearedFunc = void(StringRef);
 
 public:
   PassInstrumentationCallbacks() {}
@@ -123,6 +125,16 @@ class PassInstrumentationCallbacks {
 AfterAnalysisCallbacks.emplace_back(std::move(C));
   }
 
+  template 
+  void registerAnalysisInvalidatedCallback(CallableT C) {
+AnalysisInvalidatedCallbacks.emplace_back(std::move(C));
+  }
+
+  template 
+  void registerAnalysesClearedCallback(CallableT C) {
+AnalysesClearedCallbacks.emplace_back(std::move(C));
+  }
+
   /// Add a class name to pass name mapping for use by pass instrumentation.
   void addClassToPassName(StringRef ClassName, StringRef PassName);
   /// Get the pass name for a given pass class name.
@@ -152,6 +164,12 @@ class PassInstrumentationCallbacks {
   /// These are run on analyses that have been run.
   SmallVector, 4>
   AfterAnalysisCallbacks;
+  /// These are run on analyses that have been invalidated.
+  SmallVector, 4>
+  AnalysisInvalidatedCallbacks;
+  /// These are run on analyses that have been cleared.
+  SmallVector, 4>
+  AnalysesClearedCallbacks;
 
   StringMap ClassToPassName;
 };
@@ -256,6 +274,24 @@ class PassInstrumentation {
 C(Analysis.name(), llvm::Any());
   }
 
+  /// 

[PATCH] D101797: [NewPM] Hide pass manager debug logging behind -debug-pass-manager-verbose

2021-05-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM. Need a test for pass managers debug output.




Comment at: llvm/test/Other/pass-pipeline-parsing.ll:145
 
 ; RUN: opt -disable-output -debug-pass-manager -debug-pass-manager-verbose \
 ; RUN: 
-passes='module(no-op-function,no-op-loop,no-op-cgscc,cgscc(no-op-function,no-op-loop),function(no-op-loop))'
 %s 2>&1 \

Instead of renaming this, could you add a similar test for pass managers? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101797

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


[PATCH] D102094: [AIX][PowerPC] Remove error when specifying mabi=vec-default on AIX

2021-05-07 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: hubert.reinterpretcast, cebowleratibm, sfertile.
Herald added subscribers: shchenz, nemanjai.
ZarkoCA requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The default Altivec ABI was implemented but the clang error for specifying
its use still remains.  Users could get around this but not specifying the
type of Altivec ABI but we need to remove the error.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102094

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/altivec.c
  clang/test/Driver/aix-vec-extabi.c
  clang/test/Preprocessor/aix-vec_extabi.c

Index: clang/test/Preprocessor/aix-vec_extabi.c
===
--- clang/test/Preprocessor/aix-vec_extabi.c
+++ clang/test/Preprocessor/aix-vec_extabi.c
@@ -2,11 +2,11 @@
 // RUN:   | FileCheck %s -check-prefix=EXTABI
 // RUN: %clang  -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-extabi %s -o - 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=EXTABI
-// RUN: not %clang  -target powerpc-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
+// RUN: %clang  -target powerpc-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DFLTABI
-// RUN: not %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DFLTABI
 
 
-// EXTABI:  #define __EXTABI__
-// DFLTABI: The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' for the extended Altivec ABI
+// EXTABI:  #define __EXTABI__
+// DFLTABI-NOT: #define __EXTABI__
Index: clang/test/Driver/aix-vec-extabi.c
===
--- clang/test/Driver/aix-vec-extabi.c
+++ clang/test/Driver/aix-vec-extabi.c
@@ -1,10 +1,11 @@
 // RUN:  %clang -### -target powerpc-unknown-aix -S -maltivec -mabi=vec-extabi %s 2>&1 | \
-// RUN:  FileCheck %s
-
-// CHECK: "-cc1"
-// CHECK-SAME: "-mabi=vec-extabi"
-
+// RUN:  FileCheck %s --check-prefix=EXTABI
 // RUN:  %clang -### -target powerpc-unknown-aix -S -maltivec -mabi=vec-default %s 2>&1 | \
-// RUN:  FileCheck %s --check-prefix=ERROR
+// RUN:  FileCheck %s --check-prefix=DFLTABI
+
+// EXTABI:   "-cc1"
+// EXTABI-SAME:  "-mabi=vec-extabi"
 
-// ERROR: The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' for the extended Altivec ABI
+// DFLTABI:  "-cc1"
+// DFLTABI-SAME: "-mabi=vec-default"
+// DFLTABI-NOT:  "-mabi=vec-default"
Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -4,12 +4,12 @@
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 // RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 -triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 --target=powerpc-unknown-aix %s -o - | FileCheck %s 

[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/CodeGen/Generic/pre-ra-sched.c:1
+// RUN: clang %s -mllvm -pre-RA-sched=fast -c -o - | FileCheck %s
+// RUN: clang %s -mllvm -pre-RA-sched=linearize -c -o - | FileCheck %s

You can't run clang from an llvm test directory. There's no guarantee clang 
will have been compiled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

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


[PATCH] D102093: [NewPM] Move analysis invalidation/clearing logging to instrumentation

2021-05-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102093

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


[PATCH] D102093: [NewPM] Move analysis invalidation/clearing logging to instrumentation

2021-05-07 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks added reviewers: asbirlea, ychen.
Herald added subscribers: dexonsmith, steven_wu, zzheng, hiraditya.
aeubanks requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

We're trying to move DebugLogging into instrumentation, rather than
being part of PassManagers/AnalysisManagers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102093

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/CodeGen/MachinePassManager.h
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/CodeGen/PassManagerTest.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -297,7 +297,7 @@
   "end:\n"
   "  ret void\n"
   "}\n")),
-LAM(true), FAM(true), MAM(true) {
+LAM(), FAM(), MAM() {
 // Register our mock analysis.
 LAM.registerPass([&] { return MLAHandle.getAnalysis(); });
 
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -419,11 +419,11 @@
 }
 
 TEST_F(PassManagerTest, Basic) {
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   int FunctionAnalysisRuns = 0;
   FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
 
-  ModuleAnalysisManager MAM(/*DebugLogging*/ true);
+  ModuleAnalysisManager MAM;
   int ModuleAnalysisRuns = 0;
   MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); });
   MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
@@ -704,8 +704,8 @@
 };
 
 TEST_F(PassManagerTest, IndirectAnalysisInvalidation) {
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
-  ModuleAnalysisManager MAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
+  ModuleAnalysisManager MAM;
   int FunctionAnalysisRuns = 0, ModuleAnalysisRuns = 0,
   IndirectAnalysisRuns = 0, DoublyIndirectAnalysisRuns = 0;
   FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
@@ -823,7 +823,7 @@
 "}\n");
 
   auto *F = M->getFunction("foo");
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
@@ -869,7 +869,7 @@
 "}\n");
 
   auto *F = M->getFunction("foo");
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
@@ -934,7 +934,7 @@
 "}\n");
 
   auto *F = M->getFunction("foo");
-  FunctionAnalysisManager FAM(/*DebugLogging*/ true);
+  FunctionAnalysisManager FAM;
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -467,7 +467,7 @@
   "}\n")),
 CallbacksHandle(), PB(false, nullptr, PipelineTuningOptions(), None,
   ),
-PM(true), LAM(true), FAM(true), CGAM(true), AM(true) {
+PM(true), LAM(), FAM(), CGAM(), AM() {
 
 EXPECT_TRUE( ==
 PB.getPassInstrumentationCallbacks());
Index: llvm/unittests/CodeGen/PassManagerTest.cpp
===
--- llvm/unittests/CodeGen/PassManagerTest.cpp
+++ llvm/unittests/CodeGen/PassManagerTest.cpp
@@ -208,10 +208,10 @@
   LLVMTargetMachine *LLVMTM = static_cast(TM.get());
   M->setDataLayout(TM->createDataLayout());
 
-  LoopAnalysisManager LAM(/*DebugLogging=*/true);
-  FunctionAnalysisManager FAM(/*DebugLogging=*/true);
-  CGSCCAnalysisManager CGAM(/*DebugLogging=*/true);
-  ModuleAnalysisManager MAM(/*DebugLogging=*/true);
+  LoopAnalysisManager LAM;
+  FunctionAnalysisManager FAM;
+  

[clang] 167906c - [BareMetal] Ensure that sysroot always comes after library paths

2021-05-07 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-05-07T14:42:02-07:00
New Revision: 167906c10932f5eda97b480ee084b17746c362e7

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

LOG: [BareMetal] Ensure that sysroot always comes after library paths

This addresses an issue introduced in D91559. We would invoke the
compiler with -Lpath/to/lib --sysroot=path/to/sysroot where both
locations contain libraries with the same name, but we expect linker
to pick up the library in path/to/lib since that version is more
specialized. This was the case before D91559 where the sysroot path
would be ignored, but after that change linker would now pick up the
library from the sysroot which resulted in unexpected behavior.

The sysroot path should always come after any user provided library
paths, followed by compiler runtime paths. We want for libraries in user
provided library paths to always take precedence over sysroot libraries.
This matches the behavior of other toolchains used with other targets.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 69af239dc903d..3d733ca504a07 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -299,13 +299,14 @@ void baremetal::Linker::ConstructJob(Compilation , 
const JobAction ,
 
   CmdArgs.push_back("-Bstatic");
 
-  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
-
-  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
+
+  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
+
   if (TC.ShouldLinkCXXStdlib(Args))
 TC.AddCXXStdlibLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index bca9f7e53f68e..fb760abbb9779 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -11,9 +11,9 @@
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
-// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
 
@@ -35,8 +35,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
-// CHECK-V6M-DEFAULTCXX-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -50,8 +50,8 @@
 // CHECK-V6M-LIBCXX-NOT: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
 // CHECK-V6M-LIBCXX-SAME: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
-// CHECK-V6M-LIBCXX-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
+// CHECK-V6M-LIBCXX-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -65,8 +65,8 @@
 // CHECK-V6M-LIBSTDCXX-NOT: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBSTDCXX-SAME: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: 

[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-07 Thread greg miller via Phabricator via cfe-commits
gregmiller added a comment.

Hello, We are maintaining a downstream version of the monorepo based on the 
LLVM main branch. We have not transitioned to the new PM yet. In a recent 
attempt to merge the latest upstream commits into our monorepo we came across 
the following test failures after your commit.
F16720091: failed_report.txt 
For below test cases:

  remarks_parallel_in_multiple_target_state_machines.c
  remarks_parallel_in_target_state_machine.c

Thanks
greg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:243
+if(${CMAKE_SYSTEM_NAME} MATCHES 
"DragonFly|FreeBSD|Fuchsia|Linux|NetBSD|OpenBSD")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} 
-Wl,-Bsymbolic-functions")
+endif()

phosek wrote:
> MaskRay wrote:
> > phosek wrote:
> > > I'd really like to avoid modifying `CMAKE_SHARED_LINKER_FLAGS`, modifying 
> > > these global variables is an antipattern in modern CMake. We should 
> > > always set these directly on the targets that need them. What's the 
> > > problem with the approach you used in the first patch?
> > With this, we can make libLLVM*.so libclang*.so (-DBUILD_SHARED_LIBS=on) 
> > and other lib*.so faster as well.
> I'd prefer to setting that flag inside `add_llvm_library` and 
> `add_clang_library` when `SHARED` is set. `HandleLLVMOptions` is also used 
> from runtimes where setting this flag is really undesirable (that's why using 
> global variables is really problematic).
`add_llvm_library` and `add_clang_library` may be used by downstream projects 
which don't want -Bsymbolic-functions.

Switched back. I'll just not touch -DBUILD_SHARED_LIBS=on for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 343758.
MaskRay added a comment.

Don't affect -DBUILD_SHARED_LIBS=on


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,6 +50,9 @@
   # Solaris ld does not accept global: *; so there is no way to version 
*all* global symbols
   set(LIB_NAMES 
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
 ${LIB_NAMES})
 endif()
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -305,6 +305,7 @@
 # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
 add_flag_or_print_warning("-fPIC" FPIC)
+add_flag_if_supported("-fno-semantic-interposition" 
FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -48,3 +48,6 @@
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,6 +50,9 @@
   # Solaris ld does not accept global: *; so there is no way to version *all* global symbols
   set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
 endif()
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -305,6 +305,7 @@
 # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
 add_flag_or_print_warning("-fPIC" FPIC)
+add_flag_if_supported("-fno-semantic-interposition" FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -48,3 +48,6 @@
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Petr Hosek via Phabricator via cfe-commits
phosek requested changes to this revision.
phosek added inline comments.
This revision now requires changes to proceed.



Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:243
+if(${CMAKE_SYSTEM_NAME} MATCHES 
"DragonFly|FreeBSD|Fuchsia|Linux|NetBSD|OpenBSD")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} 
-Wl,-Bsymbolic-functions")
+endif()

MaskRay wrote:
> phosek wrote:
> > I'd really like to avoid modifying `CMAKE_SHARED_LINKER_FLAGS`, modifying 
> > these global variables is an antipattern in modern CMake. We should always 
> > set these directly on the targets that need them. What's the problem with 
> > the approach you used in the first patch?
> With this, we can make libLLVM*.so libclang*.so (-DBUILD_SHARED_LIBS=on) and 
> other lib*.so faster as well.
I'd prefer to setting that flag inside `add_llvm_library` and 
`add_clang_library` when `SHARED` is set. `HandleLLVMOptions` is also used from 
runtimes where setting this flag is really undesirable (that's why using global 
variables is really problematic).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:243
+if(${CMAKE_SYSTEM_NAME} MATCHES 
"DragonFly|FreeBSD|Fuchsia|Linux|NetBSD|OpenBSD")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} 
-Wl,-Bsymbolic-functions")
+endif()

phosek wrote:
> I'd really like to avoid modifying `CMAKE_SHARED_LINKER_FLAGS`, modifying 
> these global variables is an antipattern in modern CMake. We should always 
> set these directly on the targets that need them. What's the problem with the 
> approach you used in the first patch?
With this, we can make libLLVM*.so libclang*.so (-DBUILD_SHARED_LIBS=on) and 
other lib*.so faster as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D102090#2745331 , @tstellar wrote:

> Does this change mean that LD_PRELOAD will no longer work?  Are there any 
> other downsides to adding these flags?

The downside is that it will behave more like Windows dll and Mach-O dylib 
using two-level namespace lookup.
No runtime preemption.

LD_PRELOAD will not work. It probably never works properly: replacing a program 
linked with libLLVM-11.so with a different libLLVM-11.so version at runtime?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:243
+if(${CMAKE_SYSTEM_NAME} MATCHES 
"DragonFly|FreeBSD|Fuchsia|Linux|NetBSD|OpenBSD")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} 
-Wl,-Bsymbolic-functions")
+endif()

I'd really like to avoid modifying `CMAKE_SHARED_LINKER_FLAGS`, modifying these 
global variables is an antipattern in modern CMake. We should always set these 
directly on the targets that need them. What's the problem with the approach 
you used in the first patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 343755.
MaskRay added a comment.

Set global CMAKE_SHARED_LINKER_FLAGS instead.

This additional makes -DBUILD_SHARED_LIBS=on builds (dev only; not recommended 
for packagers) faster.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

Files:
  llvm/cmake/modules/HandleLLVMOptions.cmake


Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -237,6 +237,12 @@
   set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,nodelete")
 endif()
 
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+if(${CMAKE_SYSTEM_NAME} MATCHES 
"DragonFly|FreeBSD|Fuchsia|Linux|NetBSD|OpenBSD")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} 
-Wl,-Bsymbolic-functions")
+endif()
+
 
 function(append value)
   foreach(variable ${ARGN})
@@ -305,6 +311,7 @@
 # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
 add_flag_or_print_warning("-fPIC" FPIC)
+add_flag_if_supported("-fno-semantic-interposition" 
FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND


Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -237,6 +237,12 @@
   set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,nodelete")
 endif()
 
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+if(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly|FreeBSD|Fuchsia|Linux|NetBSD|OpenBSD")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
+endif()
+
 
 function(append value)
   foreach(variable ${ARGN})
@@ -305,6 +311,7 @@
 # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
 add_flag_or_print_warning("-fPIC" FPIC)
+add_flag_if_supported("-fno-semantic-interposition" FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90996: [clang-format] Add --staged/--cached option to git-clang-format

2021-05-07 Thread Alexander Lohnau via Phabricator via cfe-commits
alex1701c added a comment.

Any update on this topic? I really like this feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90996

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Does this change mean that LD_PRELOAD will no longer work?  Are there any other 
downsides to adding these flags?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[clang] f97ada2 - Revert "[BareMetal] Ensure that sysroot always comes after library paths"

2021-05-07 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-05-07T13:38:04-07:00
New Revision: f97ada27aaf64207a2ffad937ce3ccf009e81bd8

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

LOG: Revert "[BareMetal] Ensure that sysroot always comes after library paths"

This reverts commit 6b00b34b8a05896f79b18a1963811299b83d5b21.

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal-sysroot.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 3d733ca504a07..69af239dc903d 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -299,14 +299,13 @@ void baremetal::Linker::ConstructJob(Compilation , 
const JobAction ,
 
   CmdArgs.push_back("-Bstatic");
 
+  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
+
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
-  TC.AddFilePathLibArgs(Args, CmdArgs);
-
-  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
-
   if (TC.ShouldLinkCXXStdlib(Args))
 TC.AddCXXStdlibLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {

diff  --git a/clang/test/Driver/baremetal-sysroot.cpp 
b/clang/test/Driver/baremetal-sysroot.cpp
index 9ded043e83ce6..ae174e01417e7 100644
--- a/clang/test/Driver/baremetal-sysroot.cpp
+++ b/clang/test/Driver/baremetal-sysroot.cpp
@@ -1,23 +1,6 @@
 // REQUIRES: shell
 // UNSUPPORTED: system-windows
 
-// Test that --sysroot always comes after any library paths.
-
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target armv6m-none-eabi -fuse-ld=lld \
-// RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: --sysroot=%S/sys-root -L%S/lib \
-// RUN:   | FileCheck --check-prefix=CHECK-V6M -DLIB_DIR=%S/lib %s
-// CHECK-V6M: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none-unknown-eabi"
-// CHECK-V6M-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-V6M-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-V6M-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-SAME: "-L[[LIB_DIR]]"
-// CHECK-V6M-SAME: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK-V6M-SAME: "-L[[RESOURCE_DIR]]{{/|}}lib{{/|}}baremetal"
-// CHECK-V6M-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
-// CHECK-V6M-SAME: "-o" "{{.*}}.o"
-
 // Test that when a --sysroot is not provided, driver picks the default
 // location correctly if available.
 
@@ -28,12 +11,12 @@
 
 // RUN: %T/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### 
-o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
-// RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULT-SYSROOT %s
-// CHECK-V6M-DEFAULT-SYSROOT: "{{.*}}clang{{.*}}" "-cc1" "-triple" 
"thumbv6m-none-unknown-eabi"
-// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
-// CHECk-V6M-DEFAULT-SYSROOT-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
-// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
-// CHECK-V6M-DEFAULT-SYSROOT-NEXT: 
"{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-DEFAULT-SYSROOT-SAME: 
"-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
-// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
-// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-o" "{{.*}}.o"
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
+// CHECK-V6M-C: "{{.*}}clang{{.*}}" "-cc1" "-triple" 
"thumbv6m-none-unknown-eabi"
+// CHECK-V6M-C-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECk-V6M-C-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
+// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
+// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
+// CHECK-V6M-C-SAME: 
"-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"

[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1089
+  LangOpts<"DoubleSquareBracketAttributes">,
+  Default,
   PosFlag, NegFlag,

jansvoboda11 wrote:
> Paul-C-Anagnostopoulos wrote:
> > jansvoboda11 wrote:
> > > Paul-C-Anagnostopoulos wrote:
> > > > jansvoboda11 wrote:
> > > > > Were you planning to refactor this too?
> > > > You can't use the paste operator (#) there because c2x is a defvar. 
> > > > Defvars and undefined identifiers are taken literally by paste, due to 
> > > > its frequent use in forming record and class names.
> > > > 
> > > > This behavior is noted in the Programmer's Reference, but I think I 
> > > > will add a more prominent note. I wonder if we should change the 
> > > > behavior so defvars are treated normally.
> > > I see. In that case, can you please undo the whitespace change?
> > Sure, but don't we try to avoid over-long lines in .td files, too?
> I think that would be nice, but I'm not sure what's LLVM's policy on making 
> whitespace-only changes (it makes `git blame` less useful). If we decide 
> that's fine, let's do it in a purely NFC commit.
Yeah - generally the attitude is to not wholesale reformat files generally, but 
if you're going to make a bunch of changes in a file that's out of conformance 
it can be reasonable/worthwhile to reformat that file before the work - so that 
the autoformatted changes aren't in conflict with the existing format of the 
file. (& yeah, format changes outside the semantic lines being changed in a 
patch is undesirable & should be done separately if it's being done at all)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101766

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


[PATCH] D102027: [SEH] Fix regression with SEH in noexpect functions

2021-05-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I went ahead and implemented my suggested changes and pushed this with 
attribution. Thanks for the fix!




Comment at: clang/lib/CodeGen/CGException.cpp:1966
 
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());

I think passing `GlobalDecl()` here is intentional, there must have been some 
reason to have the helper CGF have a null function. This noexcept thing seems 
like one such example.



Comment at: clang/lib/CodeGen/CGExpr.cpp:4188
 LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field) {
-  assert(cast(CurCodeDecl)->getParent()->isLambda());
-  assert(cast(CurCodeDecl)->getParent() == Field->getParent());
+  assert(IsOutlinedSEHHelper || 
cast(CurCodeDecl)->getParent()->isLambda());
+  assert(IsOutlinedSEHHelper || cast(CurCodeDecl)->getParent() 
== Field->getParent());

Other uses of CurCodeDecl check it for null, so I think it makes sense to go 
ahead and do the same here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102027

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


[PATCH] D102027: [SEH] Fix regression with SEH in noexpect functions

2021-05-07 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4adc49a1c98: [SEH] Fix regression with SEH in noexpect 
functions (authored by ogoffart, committed by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D102027?vs=343502=343753#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102027

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGenCXX/exceptions-seh.cpp


Index: clang/test/CodeGenCXX/exceptions-seh.cpp
===
--- clang/test/CodeGenCXX/exceptions-seh.cpp
+++ clang/test/CodeGenCXX/exceptions-seh.cpp
@@ -164,3 +164,5 @@
 // CHECK: store i32 1234, i32* @my_unique_global
 
 // CHECK: attributes #[[NOINLINE]] = { {{.*noinline.*}} }
+
+void seh_in_noexcept() noexcept { __try {} __finally {} }
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4185,8 +4185,10 @@
 /// Given that we are currently emitting a lambda, emit an l-value for
 /// one of its members.
 LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field) {
-  assert(cast(CurCodeDecl)->getParent()->isLambda());
-  assert(cast(CurCodeDecl)->getParent() == Field->getParent());
+  if (CurCodeDecl) {
+assert(cast(CurCodeDecl)->getParent()->isLambda());
+assert(cast(CurCodeDecl)->getParent() == 
Field->getParent());
+  }
   QualType LambdaTagType =
 getContext().getTagDeclType(Field->getParent());
   LValue LambdaLV = MakeNaturalAlignAddrLValue(CXXABIThisValue, LambdaTagType);
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -1966,7 +1966,6 @@
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());
   CurSEHParent = ParentCGF.CurSEHParent;
-  CurCodeDecl = ParentCGF.CurCodeDecl;
 
   CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);


Index: clang/test/CodeGenCXX/exceptions-seh.cpp
===
--- clang/test/CodeGenCXX/exceptions-seh.cpp
+++ clang/test/CodeGenCXX/exceptions-seh.cpp
@@ -164,3 +164,5 @@
 // CHECK: store i32 1234, i32* @my_unique_global
 
 // CHECK: attributes #[[NOINLINE]] = { {{.*noinline.*}} }
+
+void seh_in_noexcept() noexcept { __try {} __finally {} }
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4185,8 +4185,10 @@
 /// Given that we are currently emitting a lambda, emit an l-value for
 /// one of its members.
 LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field) {
-  assert(cast(CurCodeDecl)->getParent()->isLambda());
-  assert(cast(CurCodeDecl)->getParent() == Field->getParent());
+  if (CurCodeDecl) {
+assert(cast(CurCodeDecl)->getParent()->isLambda());
+assert(cast(CurCodeDecl)->getParent() == Field->getParent());
+  }
   QualType LambdaTagType =
 getContext().getTagDeclType(Field->getParent());
   LValue LambdaLV = MakeNaturalAlignAddrLValue(CXXABIThisValue, LambdaTagType);
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -1966,7 +1966,6 @@
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());
   CurSEHParent = ParentCGF.CurSEHParent;
-  CurCodeDecl = ParentCGF.CurCodeDecl;
 
   CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c4adc49 - [SEH] Fix regression with SEH in noexpect functions

2021-05-07 Thread Reid Kleckner via cfe-commits

Author: Olivier Goffart
Date: 2021-05-07T13:27:59-07:00
New Revision: c4adc49a1c988e6ea8a340b6245525ef5599812c

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

LOG: [SEH] Fix regression with SEH in noexpect functions

Commit 5baea0560160a693b19022c5d0ba637b6b46b2d8 set the CurCodeDecl
because it was needed to pass the assert in 
CodeGenFunction::EmitLValueForLambdaField,
But this was not right to do as CodeGenFunction::FinishFunction passes it to 
EmitEndEHSpec
and cause corruption of the EHStack.

Revert the part of the commit that changes the CurCodeDecl, and instead
adjust the assert to check for a null CurCodeDecl.

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

Added: 


Modified: 
clang/lib/CodeGen/CGException.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGenCXX/exceptions-seh.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index 078c60c6c4cf4..aa6fe303ff659 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1966,7 +1966,6 @@ void 
CodeGenFunction::startOutlinedSEHHelper(CodeGenFunction ,
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());
   CurSEHParent = ParentCGF.CurSEHParent;
-  CurCodeDecl = ParentCGF.CurCodeDecl;
 
   CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 2a272bf29e04e..3e6e25dc3d2f5 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4185,8 +4185,10 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr 
*E) {
 /// Given that we are currently emitting a lambda, emit an l-value for
 /// one of its members.
 LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field) {
-  assert(cast(CurCodeDecl)->getParent()->isLambda());
-  assert(cast(CurCodeDecl)->getParent() == Field->getParent());
+  if (CurCodeDecl) {
+assert(cast(CurCodeDecl)->getParent()->isLambda());
+assert(cast(CurCodeDecl)->getParent() == 
Field->getParent());
+  }
   QualType LambdaTagType =
 getContext().getTagDeclType(Field->getParent());
   LValue LambdaLV = MakeNaturalAlignAddrLValue(CXXABIThisValue, LambdaTagType);

diff  --git a/clang/test/CodeGenCXX/exceptions-seh.cpp 
b/clang/test/CodeGenCXX/exceptions-seh.cpp
index a922daac1c0b6..42b76b1dcc5a9 100644
--- a/clang/test/CodeGenCXX/exceptions-seh.cpp
+++ b/clang/test/CodeGenCXX/exceptions-seh.cpp
@@ -164,3 +164,5 @@ void use_inline() {
 // CHECK: store i32 1234, i32* @my_unique_global
 
 // CHECK: attributes #[[NOINLINE]] = { {{.*noinline.*}} }
+
+void seh_in_noexcept() noexcept { __try {} __finally {} }



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


[PATCH] D102049: [BareMetal] Ensure that sysroot always comes after library paths

2021-05-07 Thread Petr Hosek via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b00b34b8a05: [BareMetal] Ensure that sysroot always comes 
after library paths (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102049

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal-sysroot.cpp


Index: clang/test/Driver/baremetal-sysroot.cpp
===
--- clang/test/Driver/baremetal-sysroot.cpp
+++ clang/test/Driver/baremetal-sysroot.cpp
@@ -1,6 +1,23 @@
 // REQUIRES: shell
 // UNSUPPORTED: system-windows
 
+// Test that --sysroot always comes after any library paths.
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi -fuse-ld=lld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/sys-root -L%S/lib \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M -DLIB_DIR=%S/lib %s
+// CHECK-V6M: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none-unknown-eabi"
+// CHECK-V6M-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-V6M-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
+// CHECK-V6M-SAME: "-L[[LIB_DIR]]"
+// CHECK-V6M-SAME: "-L[[SYSROOT]]{{/|}}lib"
+// CHECK-V6M-SAME: "-L[[RESOURCE_DIR]]{{/|}}lib{{/|}}baremetal"
+// CHECK-V6M-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+// CHECK-V6M-SAME: "-o" "{{.*}}.o"
+
 // Test that when a --sysroot is not provided, driver picks the default
 // location correctly if available.
 
@@ -11,12 +28,12 @@
 
 // RUN: %T/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### 
-o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
-// RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
-// CHECK-V6M-C: "{{.*}}clang{{.*}}" "-cc1" "-triple" 
"thumbv6m-none-unknown-eabi"
-// CHECK-V6M-C-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
-// CHECk-V6M-C-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
-// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
-// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: 
"-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
-// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULT-SYSROOT %s
+// CHECK-V6M-DEFAULT-SYSROOT: "{{.*}}clang{{.*}}" "-cc1" "-triple" 
"thumbv6m-none-unknown-eabi"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECk-V6M-DEFAULT-SYSROOT-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
+// CHECK-V6M-DEFAULT-SYSROOT-NEXT: 
"{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: 
"-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-o" "{{.*}}.o"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -299,13 +299,14 @@
 
   CmdArgs.push_back("-Bstatic");
 
-  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
-
-  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
+
+  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
+
   if (TC.ShouldLinkCXXStdlib(Args))
 TC.AddCXXStdlibLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {


Index: clang/test/Driver/baremetal-sysroot.cpp
===
--- clang/test/Driver/baremetal-sysroot.cpp
+++ 

[clang] 6b00b34 - [BareMetal] Ensure that sysroot always comes after library paths

2021-05-07 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-05-07T13:21:07-07:00
New Revision: 6b00b34b8a05896f79b18a1963811299b83d5b21

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

LOG: [BareMetal] Ensure that sysroot always comes after library paths

This addresses an issue introduced in D91559. We would invoke the
compiler with -Lpath/to/lib --sysroot=path/to/sysroot where both
locations contain libraries with the same name, but we expect linker
to pick up the library in path/to/lib since that version is more
specialized. This was the case before D91559 where the sysroot path
would be ignored, but after that change linker would now pick up the
library from the sysroot which resulted in unexpected behavior.

The sysroot path should always come after any user provided library
paths, followed by compiler runtime paths. We want for libraries in user
provided library paths to always take precedence over sysroot libraries.
This matches the behavior of other toolchains used with other targets.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal-sysroot.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 69af239dc903d..3d733ca504a07 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -299,13 +299,14 @@ void baremetal::Linker::ConstructJob(Compilation , 
const JobAction ,
 
   CmdArgs.push_back("-Bstatic");
 
-  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
-
-  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
+
+  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
+
   if (TC.ShouldLinkCXXStdlib(Args))
 TC.AddCXXStdlibLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {

diff  --git a/clang/test/Driver/baremetal-sysroot.cpp 
b/clang/test/Driver/baremetal-sysroot.cpp
index ae174e01417e7..9ded043e83ce6 100644
--- a/clang/test/Driver/baremetal-sysroot.cpp
+++ b/clang/test/Driver/baremetal-sysroot.cpp
@@ -1,6 +1,23 @@
 // REQUIRES: shell
 // UNSUPPORTED: system-windows
 
+// Test that --sysroot always comes after any library paths.
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi -fuse-ld=lld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/sys-root -L%S/lib \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M -DLIB_DIR=%S/lib %s
+// CHECK-V6M: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none-unknown-eabi"
+// CHECK-V6M-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-V6M-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
+// CHECK-V6M-SAME: "-L[[LIB_DIR]]"
+// CHECK-V6M-SAME: "-L[[SYSROOT]]{{/|}}lib"
+// CHECK-V6M-SAME: "-L[[RESOURCE_DIR]]{{/|}}lib{{/|}}baremetal"
+// CHECK-V6M-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+// CHECK-V6M-SAME: "-o" "{{.*}}.o"
+
 // Test that when a --sysroot is not provided, driver picks the default
 // location correctly if available.
 
@@ -11,12 +28,12 @@
 
 // RUN: %T/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### 
-o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
-// RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
-// CHECK-V6M-C: "{{.*}}clang{{.*}}" "-cc1" "-triple" 
"thumbv6m-none-unknown-eabi"
-// CHECK-V6M-C-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
-// CHECk-V6M-C-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
-// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
-// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: 
"-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
-// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULT-SYSROOT %s
+// CHECK-V6M-DEFAULT-SYSROOT: "{{.*}}clang{{.*}}" "-cc1" "-triple" 
"thumbv6m-none-unknown-eabi"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-internal-isystem" 

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-05-07 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 343750.
ASDenysPetrov added a comment.

Minor comment fix.


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

https://reviews.llvm.org/D99797

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -61,6 +61,9 @@
   static constexpr BaseType getMax() {
 return std::numeric_limits::max();
   }
+  // MID is a value in the middle of the range
+  // which unary minus does not affect on,
+  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   static constexpr BaseType getMid() {
 return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
   }
@@ -160,7 +163,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -168,6 +171,29 @@
  RawExpected);
   }
 
+  template 
+  void checkUniteImpl(RangeSet LHS, RHSType RHS, RangeSet Expected) {
+RangeSet Result = F.unite(LHS, RHS);
+EXPECT_EQ(Result, Expected)
+<< "while uniting " << toString(LHS) << " and " << toString(RHS);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRange RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRangeSet RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, BaseType RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS,
+ RawExpected);
+  }
+
   void checkDeleteImpl(const llvm::APSInt , RangeSet From,
RangeSet Expected) {
 RangeSet Result = F.deletePoint(From, Point);
@@ -195,9 +221,6 @@
 
   constexpr TypeParam MIN = TestFixture::getMin();
   constexpr TypeParam MAX = TestFixture::getMax();
-  // MID is a value in the middle of the range
-  // which unary minus does not affect on,
-  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   constexpr TypeParam MID = TestFixture::getMid();
   constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
   constexpr TypeParam B = MID - TestFixture::fromInt(42);
@@ -347,3 +370,201 @@
   // Check that delete of the point not from the range set works as expected.
   this->checkDelete(10, {{0, 5}, {20, 30}}, {{0, 5}, {20, 30}});
 }
+
+TYPED_TEST(RangeSetTest, RangeSetUniteTest) {
+
+  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
+  constexpr TypeParam MIN = TestFixture::getMin();
+  constexpr TypeParam MAX = TestFixture::getMax();
+  constexpr TypeParam MID = TestFixture::getMid();
+  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
+  constexpr TypeParam B = MID - TestFixture::fromInt(42);
+  constexpr TypeParam C = -B;
+  constexpr TypeParam D = -A;
+
+  // LHS and RHS is empty.
+  // RHS =>
+  // LHS => =
+  //___   ___
+  this->checkUnite({}, {}, {});
+
+  // RHS is empty.
+  // RHS =>
+  // LHS =>_=_
+  //__/_\__   __/_\__
+  this->checkUnite({{A, B}}, {}, {{A, B}});
+  this->checkUnite({{A, B}, {C, D}}, {}, {{A, B}, {C, D}});
+
+  // LHS is empty.
+  // RHS => ___
+  // LHS =>/   \=_
+  //__/_\__   __/_\__
+  this->checkUnite({}, B, {{B, B}});
+  this->checkUnite({}, {B, C}, {{B, C}});
+  this->checkUnite({}, {{MIN, B}, {C, MAX}}, {{MIN, B}, {C, MAX}});
+
+  // RHS is detached from LHS.
+  // RHS => ___
+  // LHS =>___ /   \=___ _
+  //__/___\___/_\__   __/___\___/_\__
+  this->checkUnite({{A, C}}, D, {{A, C}, {D, D}});
+  this->checkUnite({{MID, C}, {D, MAX}}, A, {{A, A}, {MID, C}, {D, MAX}});
+  this->checkUnite({{A, B}}, {MID, D}, {{A, B}, {MID, D}});
+  this->checkUnite({{MIN, A}, {D, MAX}}, {B, C}, {{MIN, A}, {B, C}, {D, MAX}});
+  this->checkUnite({{B, MID}, {D, MAX}}, {{MIN, A}, {C, C}},
+   {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkUnite({{MIN, A}, {C, C}}, {{B, MID}, {D, MAX}},
+   {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkUnite({{MAX, MAX}}, {A, B}, {{A, B}, {MAX, MAX}});
+  this->checkUnite({{MIN, MIN}}, {A, B}, {{MIN, MIN}, {A, B}});
+
+  // RHS is inside LHS.
+  // RHS => ___
+  // LHS => ___/___\___ = ___
+  //

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-05-07 Thread Fred Grim via Phabricator via cfe-commits
feg208 added a comment.

Missed a request in the release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-05-07 Thread Fred Grim via Phabricator via cfe-commits
feg208 updated this revision to Diff 343748.
feg208 marked an inline comment as done.
feg208 added a comment.

Oops missed a request


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15,6 +15,8 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
+#include 
+
 #define DEBUG_TYPE "format-test"
 
 using clang::tooling::ReplacementTest;
@@ -16347,6 +16349,147 @@
getLLVMStyle());
 }
 
+template 
+auto createStylesImpl(
+const std::array ,
+const std::array ) {
+  std::array Styles;
+  auto StyleIter = Styles.begin();
+  for (const auto  : ACSValues) {
+for (const auto  : ACSValues) {
+  for (const auto  : Limits) {
+auto  = *(StyleIter);
+StyleValue = getLLVMStyle();
+StyleValue.AlignArrayOfStructures = true;
+StyleValue.AlignConsecutiveAssignments = OuterACS;
+StyleValue.AlignConsecutiveDeclarations = InnerACS;
+StyleValue.ColumnLimit = LimitValue;
+++StyleIter;
+  }
+}
+  }
+  return Styles;
+}
+
+auto createStyles() {
+  constexpr static auto N = 5;
+  std::array ACSValues{
+  {FormatStyle::AlignConsecutiveStyle::ACS_None,
+   FormatStyle::AlignConsecutiveStyle::ACS_Consecutive,
+   FormatStyle::AlignConsecutiveStyle::ACS_AcrossEmptyLines,
+   FormatStyle::AlignConsecutiveStyle::ACS_AcrossComments,
+   FormatStyle::AlignConsecutiveStyle::ACS_AcrossEmptyLinesAndComments}};
+  std::array LimitValues{{0, 80}};
+  return createStylesImpl(ACSValues, LimitValues);
+}
+
+TEST_F(FormatTest, CatchAlignArrayOfStructures) {
+  const static auto Styles = createStyles();
+  for (const auto  : Styles) {
+verifyFormat("struct test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"}\n"
+ "};\n",
+ Style);
+verifyFormat("struct test demo[3] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"}\n"
+ "};\n",
+ Style);
+verifyFormat("struct test demo[3] = {\n"
+ "{int{56}, 23,\"hello\" },\n"
+ "{int{-1}, 93463, \"world\" },\n"
+ "{int{7},  5, \"!!\"}\n"
+ "};\n",
+ Style);
+verifyFormat("struct test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"},\n"
+ "};\n",
+ Style);
+verifyFormat("test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"},\n"
+ "};\n",
+ Style);
+verifyFormat("demo = std::array{\n"
+ "test{56, 23,\"hello\" },\n"
+ "test{-1, 93463, \"world\" },\n"
+ "test{7,  5, \"!!\"},\n"
+ "};\n",
+ Style);
+verifyFormat("test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "#if X\n"
+ "{-1, 93463, \"world\" },\n"
+ "#endif\n"
+ "{7,  5, \"!!\"}\n"
+ "};\n",
+ Style);
+  }
+  auto Style = getLLVMStyle();
+  Style.AlignArrayOfStructures = true;
+  verifyFormat(
+  "test demo[] = {\n"
+  "{56, 23,\"hello world i am a very long line that really, in any "
+  "\"\n"
+  "\"just world, ought to be split over multiple lines\" "
+  "},\n"
+  "{-1, 93463, \"world\" "
+  "},\n"
+  "{7,  5, \"!!\""
+  "},\n"
+  "};\n",
+  Style);
+  Style.ColumnLimit = 0;
+  EXPECT_EQ(
+  "test demo[] = {\n"
+  "{56, 23,\"hello world i am a very long line that really, in any "
+  "just world, ought to be split over multiple lines\" },\n"
+  "{-1, 93463, \"world\"   "
+  "},\n"
+  "{7,  5, \"!!\"  "
+  " 

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-05-07 Thread Fred Grim via Phabricator via cfe-commits
feg208 updated this revision to Diff 343747.
feg208 added a comment.

Added more tests and addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15,6 +15,8 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
+#include 
+
 #define DEBUG_TYPE "format-test"
 
 using clang::tooling::ReplacementTest;
@@ -16347,6 +16349,147 @@
getLLVMStyle());
 }
 
+template 
+auto createStylesImpl(
+const std::array ,
+const std::array ) {
+  std::array Styles;
+  auto StyleIter = Styles.begin();
+  for (const auto  : ACSValues) {
+for (const auto  : ACSValues) {
+  for (const auto  : Limits) {
+auto  = *(StyleIter);
+StyleValue = getLLVMStyle();
+StyleValue.AlignArrayOfStructures = true;
+StyleValue.AlignConsecutiveAssignments = OuterACS;
+StyleValue.AlignConsecutiveDeclarations = InnerACS;
+StyleValue.ColumnLimit = LimitValue;
+++StyleIter;
+  }
+}
+  }
+  return Styles;
+}
+
+auto createStyles() {
+  constexpr static auto N = 5;
+  std::array ACSValues{
+  {FormatStyle::AlignConsecutiveStyle::ACS_None,
+   FormatStyle::AlignConsecutiveStyle::ACS_Consecutive,
+   FormatStyle::AlignConsecutiveStyle::ACS_AcrossEmptyLines,
+   FormatStyle::AlignConsecutiveStyle::ACS_AcrossComments,
+   FormatStyle::AlignConsecutiveStyle::ACS_AcrossEmptyLinesAndComments}};
+  std::array LimitValues{{0, 80}};
+  return createStylesImpl(ACSValues, LimitValues);
+}
+
+TEST_F(FormatTest, CatchAlignArrayOfStructures) {
+  const static auto Styles = createStyles();
+  for (const auto  : Styles) {
+verifyFormat("struct test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"}\n"
+ "};\n",
+ Style);
+verifyFormat("struct test demo[3] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"}\n"
+ "};\n",
+ Style);
+verifyFormat("struct test demo[3] = {\n"
+ "{int{56}, 23,\"hello\" },\n"
+ "{int{-1}, 93463, \"world\" },\n"
+ "{int{7},  5, \"!!\"}\n"
+ "};\n",
+ Style);
+verifyFormat("struct test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"},\n"
+ "};\n",
+ Style);
+verifyFormat("test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "{-1, 93463, \"world\" },\n"
+ "{7,  5, \"!!\"},\n"
+ "};\n",
+ Style);
+verifyFormat("demo = std::array{\n"
+ "test{56, 23,\"hello\" },\n"
+ "test{-1, 93463, \"world\" },\n"
+ "test{7,  5, \"!!\"},\n"
+ "};\n",
+ Style);
+verifyFormat("test demo[] = {\n"
+ "{56, 23,\"hello\" },\n"
+ "#if X\n"
+ "{-1, 93463, \"world\" },\n"
+ "#endif\n"
+ "{7,  5, \"!!\"}\n"
+ "};\n",
+ Style);
+  }
+  auto Style = getLLVMStyle();
+  Style.AlignArrayOfStructures = true;
+  verifyFormat(
+  "test demo[] = {\n"
+  "{56, 23,\"hello world i am a very long line that really, in any "
+  "\"\n"
+  "\"just world, ought to be split over multiple lines\" "
+  "},\n"
+  "{-1, 93463, \"world\" "
+  "},\n"
+  "{7,  5, \"!!\""
+  "},\n"
+  "};\n",
+  Style);
+  Style.ColumnLimit = 0;
+  EXPECT_EQ(
+  "test demo[] = {\n"
+  "{56, 23,\"hello world i am a very long line that really, in any "
+  "just world, ought to be split over multiple lines\" },\n"
+  "{-1, 93463, \"world\"   "
+  "},\n"
+  "{7,  5, \"!!\"  "
+  " 

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-05-07 Thread Fred Grim via Phabricator via cfe-commits
feg208 marked 4 inline comments as done.
feg208 added a comment.

I think I have all the tests and requested review comments rolled up




Comment at: clang/unittests/Format/FormatTest.cpp:16352
 
+template 
+auto createStylesImpl(

curdeius wrote:
> HazardyKnusperkeks wrote:
> > This is a nice approach!
> > 
> > Could it be made constexpr? I'm not sure about C++14.
> Personally, I'm not really fond of testing all the combinations of styles. It 
> adds little value to those tests.
> I find it interesting to find problematic edge cases (which then should be 
> added to the test suite "manually").
> Also, when a test like this fails, it would be hard to see with which style 
> it failed.
I think it could be constexpr (thats the direction I originally started which 
lead to much moaning about the lack of fold expressions) however getLLVMStyle() 
is not constexpr and it felt inappropriate for this commit to change the 
interface to that function even if the change were relatively harmless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D102051: [RISCV] Consider scalar types for required extensions.

2021-05-07 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc04c66d705b4: [RISCV] Consider scalar types for required 
extensions. (authored by HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102051

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -107,6 +107,9 @@
   bool isFloatVector(unsigned Width) const {
 return isVector() && isFloat() && ElementBitwidth == Width;
   }
+  bool isFloat(unsigned Width) const {
+return isFloat() && ElementBitwidth == Width;
+  }
 
 private:
   // Verify RVV vector type and set Valid.
@@ -765,11 +768,11 @@
   }
   // Init RISC-V extensions
   for (const auto  : OutInTypes) {
-if (T->isFloatVector(16))
+if (T->isFloatVector(16) || T->isFloat(16))
   RISCVExtensions |= RISCVExtension::Zfh;
-else if (T->isFloatVector(32))
+else if (T->isFloatVector(32) || T->isFloat(32))
   RISCVExtensions |= RISCVExtension::F;
-else if (T->isFloatVector(64))
+else if (T->isFloatVector(64) || T->isFloat(64))
   RISCVExtensions |= RISCVExtension::D;
   }
   if (RequiredExtension == "Zvamo")


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -107,6 +107,9 @@
   bool isFloatVector(unsigned Width) const {
 return isVector() && isFloat() && ElementBitwidth == Width;
   }
+  bool isFloat(unsigned Width) const {
+return isFloat() && ElementBitwidth == Width;
+  }
 
 private:
   // Verify RVV vector type and set Valid.
@@ -765,11 +768,11 @@
   }
   // Init RISC-V extensions
   for (const auto  : OutInTypes) {
-if (T->isFloatVector(16))
+if (T->isFloatVector(16) || T->isFloat(16))
   RISCVExtensions |= RISCVExtension::Zfh;
-else if (T->isFloatVector(32))
+else if (T->isFloatVector(32) || T->isFloat(32))
   RISCVExtensions |= RISCVExtension::F;
-else if (T->isFloatVector(64))
+else if (T->isFloatVector(64) || T->isFloat(64))
   RISCVExtensions |= RISCVExtension::D;
   }
   if (RequiredExtension == "Zvamo")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c04c66d - [RISCV] Consider scalar types for required extensions.

2021-05-07 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-05-08T04:06:45+08:00
New Revision: c04c66d705b4f6e95a6325ef6d6c647ebc622165

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

LOG: [RISCV] Consider scalar types for required extensions.

We have vector operations on double vector and float scalar. For
example, vfwadd.wf is such a instruction.

vfloat64m1_t vfwadd_wf(vfloat64m1_t op0, float op1, size_t op2);

We should specify F and D extensions for it.

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

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 423e5477fbbae..467a8b2f52ac6 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -107,6 +107,9 @@ class RVVType {
   bool isFloatVector(unsigned Width) const {
 return isVector() && isFloat() && ElementBitwidth == Width;
   }
+  bool isFloat(unsigned Width) const {
+return isFloat() && ElementBitwidth == Width;
+  }
 
 private:
   // Verify RVV vector type and set Valid.
@@ -765,11 +768,11 @@ RVVIntrinsic::RVVIntrinsic(StringRef NewName, StringRef 
Suffix,
   }
   // Init RISC-V extensions
   for (const auto  : OutInTypes) {
-if (T->isFloatVector(16))
+if (T->isFloatVector(16) || T->isFloat(16))
   RISCVExtensions |= RISCVExtension::Zfh;
-else if (T->isFloatVector(32))
+else if (T->isFloatVector(32) || T->isFloat(32))
   RISCVExtensions |= RISCVExtension::F;
-else if (T->isFloatVector(64))
+else if (T->isFloatVector(64) || T->isFloat(64))
   RISCVExtensions |= RISCVExtension::D;
   }
   if (RequiredExtension == "Zvamo")



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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
Herald added subscribers: pengfei, mgorny.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

In an ELF shared object, a default visibility defined symbol is preemptible by 
default.
This creates some missed optimization opportunities. 
-fno-semantic-interposition can

- in Clang: avoid GOT/PLT cost for variable access/function calls to external 
linkage definition in the same TU
- in GCC: enable interprocedural optimizations (including inlining) and avoid 
PLT

-Bsymbolic-functions can

- avoid PLT for cross-TU function calls && reduce dynamic symbol lookup
- reduce dynamic symbol lookup for taking function addresses and optimize out 
GOT/TOC on x86-64/ppc64

With both options, the libLLVM.so and libclang-cpp.so performance should
be closer to PIE binary linking against `libLLVM*.a` and `libclang*.a`

(In a -DLLVM_TARGETS_TO_BUILD=X86 build, the number of JUMP_SLOT decreases from 
12716 to 1628, and the number of GLOB_DAT decreases from 1918 to 1313)

The two options should be safe since they bring the behavior closer to
Mach-O dylib (without `-flat_namespace` or `-U symbol` => no interposition)
and Windows dll.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102090

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,6 +50,8 @@
   # Solaris ld does not accept global: *; so there is no way to version 
*all* global symbols
   set(LIB_NAMES 
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
 ${LIB_NAMES})
 endif()
+# Optimize function calls and global variable access for default 
visibility definitions to avoid GOT/PLT.
+target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -305,6 +305,7 @@
 # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
 add_flag_or_print_warning("-fPIC" FPIC)
+add_flag_if_supported("-fno-semantic-interposition" 
FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -48,3 +48,5 @@
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+# Optimize function calls and global variable access for default visibility 
definitions to avoid GOT/PLT.
+target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,6 +50,8 @@
   # Solaris ld does not accept global: *; so there is no way to version *all* global symbols
   set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
 endif()
+# Optimize function calls and global variable access for default visibility definitions to avoid GOT/PLT.
+target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -305,6 +305,7 @@
 # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
 add_flag_or_print_warning("-fPIC" FPIC)
+add_flag_if_supported("-fno-semantic-interposition" FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -48,3 +48,5 @@
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+# Optimize function calls and global variable access for default visibility definitions to avoid GOT/PLT.
+target_link_options(clang-cpp 

[PATCH] D102070: [AIX][TLS] Diagnose use of unimplemented TLS models

2021-05-07 Thread Victor Huang via Phabricator via cfe-commits
NeHuang updated this revision to Diff 343743.
NeHuang added a comment.

Addressed review comment for the diagnostic message and update the test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102070

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-tls-model.cpp
  clang/test/Sema/aix-attr-tls_model.c

Index: clang/test/Sema/aix-attr-tls_model.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-tls_model.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-cpu pwr8 -verify -fsyntax-only %s
+
+#if !__has_attribute(tls_model)
+#error "Should support tls_model attribute"
+#endif
+
+static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
+static __thread int y __attribute((tls_model("local-dynamic"))); // expected-error {{TLS model local-dynamic is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("initial-exec"))); // expected-error {{TLS model initial-exec is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("local-exec"))); // expected-error {{TLS model local-exec is not yet supported on AIX}}
Index: clang/test/CodeGen/aix-tls-model.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-tls-model.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LE-ERROR
+
+int z1 = 0;
+int z2;
+int __thread x;
+int f() {
+  static int __thread y;
+  return y++;
+}
+
+// CHECK-GD: @z1 ={{.*}} global i32 0
+// CHECK-GD: @z2 ={{.*}} global i32 0
+// CHECK-GD: @x ={{.*}} thread_local global i32 0
+// CHECK-GD: @_ZZ1fvE1y = internal thread_local global i32 0
+// CHECK-GD-ERROR:  error in backend: thread local storage not yet implemented on AIX
+// CHECK-LD-ERROR:  error: TLS model local-dynamic is not yet supported on AIX
+// CHECK-IE-ERROR:  error: TLS model initial-exec is not yet supported on AIX
+// CHECK-LE-ERROR:  error: TLS model local-exec is not yet supported on AIX
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1935,6 +1935,12 @@
 return;
   }
 
+  if (S.Context.getTargetInfo().getTriple().isOSAIX() &&
+  Model != "global-dynamic") {
+S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model;
+return;
+  }
+
   D->addAttr(::new (S.Context) TLSModelAttr(S.Context, AL, Model));
 }
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1808,6 +1808,14 @@
 Opts.ExplicitEmulatedTLS = true;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
+if (T.isOSAIX()) {
+  StringRef Name = A->getValue();
+  if (Name != "global-dynamic")
+Diags.Report(diag::err_aix_unsupported_tls_model) << Name;
+}
+  }
+
   if (Arg *A = Args.getLastArg(OPT_fdenormal_fp_math_EQ)) {
 StringRef Val = A->getValue();
 Opts.FPDenormalMode = llvm::parseDenormalFPAttribute(Val);
Index: 

[PATCH] D97680: [OpenMP] Simplify GPU memory globalization

2021-05-07 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

Is it better to split the patch? For example, the new alloc/free shared can be 
in a separate patch, and the globalization can be in another one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97680

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


[PATCH] D101192: Add support for #elifdef and #elifndef

2021-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 343731.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Now, with ever-so-slightly better formatting (the rest of the formatting issues 
are either matching existing style or a fight between my clang-format and CI's 
clang-format).


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

https://reviews.llvm.org/D101192

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/PPConditionalDirectiveRecord.h
  clang/include/clang/Lex/PreprocessingRecord.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPConditionalDirectiveRecord.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PreprocessingRecord.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/Index/complete-preprocessor.m
  clang/test/Preprocessor/elifdef.c
  clang/test/Preprocessor/if_warning.c
  clang/test/Preprocessor/ifdef-recover.c
  clang/test/Preprocessor/macro_misc.c
  clang/test/Preprocessor/macro_vaopt_check.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -53,6 +53,8 @@
"#if A\n"
"#ifdef A\n"
"#ifndef A\n"
+   "#elifdef A\n"
+   "#elifndef A\n"
"#elif A\n"
"#else\n"
"#include \n"
@@ -70,18 +72,20 @@
   EXPECT_EQ(pp_if, Tokens[3].K);
   EXPECT_EQ(pp_ifdef, Tokens[4].K);
   EXPECT_EQ(pp_ifndef, Tokens[5].K);
-  EXPECT_EQ(pp_elif, Tokens[6].K);
-  EXPECT_EQ(pp_else, Tokens[7].K);
-  EXPECT_EQ(pp_include, Tokens[8].K);
-  EXPECT_EQ(pp_include_next, Tokens[9].K);
-  EXPECT_EQ(pp___include_macros, Tokens[10].K);
-  EXPECT_EQ(pp_import, Tokens[11].K);
-  EXPECT_EQ(decl_at_import, Tokens[12].K);
-  EXPECT_EQ(pp_pragma_import, Tokens[13].K);
-  EXPECT_EQ(cxx_export_decl, Tokens[14].K);
-  EXPECT_EQ(cxx_module_decl, Tokens[15].K);
-  EXPECT_EQ(cxx_import_decl, Tokens[16].K);
-  EXPECT_EQ(pp_eof, Tokens[17].K);
+  EXPECT_EQ(pp_elifdef, Tokens[6].K);
+  EXPECT_EQ(pp_elifndef, Tokens[7].K);
+  EXPECT_EQ(pp_elif, Tokens[8].K);
+  EXPECT_EQ(pp_else, Tokens[9].K);
+  EXPECT_EQ(pp_include, Tokens[10].K);
+  EXPECT_EQ(pp_include_next, Tokens[11].K);
+  EXPECT_EQ(pp___include_macros, Tokens[12].K);
+  EXPECT_EQ(pp_import, Tokens[13].K);
+  EXPECT_EQ(decl_at_import, Tokens[14].K);
+  EXPECT_EQ(pp_pragma_import, Tokens[15].K);
+  EXPECT_EQ(cxx_export_decl, Tokens[16].K);
+  EXPECT_EQ(cxx_module_decl, Tokens[17].K);
+  EXPECT_EQ(cxx_import_decl, Tokens[18].K);
+  EXPECT_EQ(pp_eof, Tokens[19].K);
 }
 
 TEST(MinimizeSourceToDependencyDirectivesTest, Define) {
@@ -324,6 +328,44 @@
Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, Elifdef) {
+  SmallVector Out;
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef C\n"
+"#define D\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef C\n"
+   "#define D\n"
+   "#endif\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef B\n"
+"#define C\n"
+"#elifndef C\n"
+"#define D\n"
+"#else\n"
+"#define E\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef B\n"
+   "#define C\n"
+ 

[PATCH] D102018: [WebAssembly] Use functions instead of macros for const SIMD intrinsics

2021-05-07 Thread Thomas Lively via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e9c39a3f982: [WebAssembly] Use functions instead of macros 
for const SIMD intrinsics (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102018

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -420,7 +420,7 @@
 
 // CHECK-LABEL: @test_f32x4_const_splat(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:ret <4 x i32> 
+// CHECK-NEXT:ret <4 x i32> 
 //
 v128_t test_f32x4_const_splat() {
   return wasm_f32x4_const_splat(42);
@@ -428,7 +428,7 @@
 
 // CHECK-LABEL: @test_f64x2_const_splat(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:ret <4 x i32> 
+// CHECK-NEXT:ret <4 x i32> 
 //
 v128_t test_f64x2_const_splat() {
   return wasm_f64x2_const_splat(42);
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -48,8 +48,9 @@
   __attribute__((__always_inline__, __nodebug__, __target__("simd128"),\
  __min_vector_width__(128)))
 
-#define __REQUIRE_CONSTANT(e)  \
-  _Static_assert(__builtin_constant_p(e), "Expected constant")
+#define __REQUIRE_CONSTANT(c)  \
+  __attribute__((__diagnose_if__(!__builtin_constant_p(c), \
+ #c " must be constant", "error")))
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load(const void *__mem) {
   // UB-free unaligned access copied from xmmintrin.h
@@ -246,88 +247,90 @@
   return (v128_t)(__f64x2){__c0, __c1};
 }
 
-#define wasm_i8x16_const(__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7, __c8, \
- __c9, __c10, __c11, __c12, __c13, __c14, __c15)   \
-  __extension__({  \
-__REQUIRE_CONSTANT(__c0);  \
-__REQUIRE_CONSTANT(__c1);  \
-__REQUIRE_CONSTANT(__c2);  \
-__REQUIRE_CONSTANT(__c3);  \
-__REQUIRE_CONSTANT(__c4);  \
-__REQUIRE_CONSTANT(__c5);  \
-__REQUIRE_CONSTANT(__c6);  \
-__REQUIRE_CONSTANT(__c7);  \
-__REQUIRE_CONSTANT(__c8);  \
-__REQUIRE_CONSTANT(__c9);  \
-__REQUIRE_CONSTANT(__c10); \
-__REQUIRE_CONSTANT(__c11); \
-__REQUIRE_CONSTANT(__c12); \
-__REQUIRE_CONSTANT(__c13); \
-__REQUIRE_CONSTANT(__c14); \
-__REQUIRE_CONSTANT(__c15); \
-(v128_t)(__i8x16){__c0, __c1, __c2,  __c3,  __c4,  __c5,  __c6,  __c7, \
-  __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15};   \
-  })
-
-#define wasm_i16x8_const(__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7)   \
-  __extension__({  \
-__REQUIRE_CONSTANT(__c0);  \
-__REQUIRE_CONSTANT(__c1);  \
-__REQUIRE_CONSTANT(__c2);  \
-__REQUIRE_CONSTANT(__c3);  \
-__REQUIRE_CONSTANT(__c4);  \
-__REQUIRE_CONSTANT(__c5);  \
-__REQUIRE_CONSTANT(__c6);  \
-__REQUIRE_CONSTANT(__c7);  \
-(v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; \
-  })
-
-#define wasm_i32x4_const(__c0, __c1, __c2, __c3)   \
-  __extension__({  \
-__REQUIRE_CONSTANT(__c0);  \
-__REQUIRE_CONSTANT(__c1);  \
-

[clang] 1e9c39a - [WebAssembly] Use functions instead of macros for const SIMD intrinsics

2021-05-07 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-05-07T11:50:19-07:00
New Revision: 1e9c39a3f982fe2f50cd19c74be8b64dfba4baad

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

LOG: [WebAssembly] Use functions instead of macros for const SIMD intrinsics

To improve hygiene, consistency, and usability, it would be good to replace all
the macro intrinsics in wasm_simd128.h with functions. The reason for using
macros in the first place was to enforce the use of constants for some arguments
using `_Static_assert` with `__builtin_constant_p`. This commit switches to
using functions and uses the `__diagnose_if__` attribute rather than
`_Static_assert` to enforce constantness.

The remaining macro intrinsics cannot be made into functions until the builtin
functions they are implemented with can be replaced with normal code patterns
because the builtin functions themselves require that their arguments are
constants.

This commit also fixes a bug with the const_splat intrinsics in which the f32x4
and f64x2 variants were incorrectly producing integer vectors.

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

Added: 


Modified: 
clang/lib/Headers/wasm_simd128.h
clang/test/Headers/wasm.c

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index cd11f096dd956..fe087d2442a16 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -48,8 +48,9 @@ typedef unsigned int __u32x2
   __attribute__((__always_inline__, __nodebug__, __target__("simd128"),
\
  __min_vector_width__(128)))
 
-#define __REQUIRE_CONSTANT(e)  
\
-  _Static_assert(__builtin_constant_p(e), "Expected constant")
+#define __REQUIRE_CONSTANT(c)  
\
+  __attribute__((__diagnose_if__(!__builtin_constant_p(c), 
\
+ #c " must be constant", "error")))
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load(const void *__mem) {
   // UB-free unaligned access copied from xmmintrin.h
@@ -246,88 +247,90 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_f64x2_make(double __c0,
   return (v128_t)(__f64x2){__c0, __c1};
 }
 
-#define wasm_i8x16_const(__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7, __c8, 
\
- __c9, __c10, __c11, __c12, __c13, __c14, __c15)   
\
-  __extension__({  
\
-__REQUIRE_CONSTANT(__c0);  
\
-__REQUIRE_CONSTANT(__c1);  
\
-__REQUIRE_CONSTANT(__c2);  
\
-__REQUIRE_CONSTANT(__c3);  
\
-__REQUIRE_CONSTANT(__c4);  
\
-__REQUIRE_CONSTANT(__c5);  
\
-__REQUIRE_CONSTANT(__c6);  
\
-__REQUIRE_CONSTANT(__c7);  
\
-__REQUIRE_CONSTANT(__c8);  
\
-__REQUIRE_CONSTANT(__c9);  
\
-__REQUIRE_CONSTANT(__c10); 
\
-__REQUIRE_CONSTANT(__c11); 
\
-__REQUIRE_CONSTANT(__c12); 
\
-__REQUIRE_CONSTANT(__c13); 
\
-__REQUIRE_CONSTANT(__c14); 
\
-__REQUIRE_CONSTANT(__c15); 
\
-(v128_t)(__i8x16){__c0, __c1, __c2,  __c3,  __c4,  __c5,  __c6,  __c7, 
\
-  __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15};   
\
-  })
-
-#define wasm_i16x8_const(__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7)   
\
-  __extension__({  
\
-__REQUIRE_CONSTANT(__c0);  
\
-__REQUIRE_CONSTANT(__c1);  
\
-__REQUIRE_CONSTANT(__c2);  
\
-__REQUIRE_CONSTANT(__c3);  
\
-__REQUIRE_CONSTANT(__c4);  
\
-__REQUIRE_CONSTANT(__c5);  
\
-__REQUIRE_CONSTANT(__c6);  
\
-

[PATCH] D102086: [RISCV] Validate the SEW and LMUL operands to __builtin_rvv_vsetvli(max)

2021-05-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: evandro, HsiangKai, arcbbb, frasercrmck, 
rogfer01, khchen.
Herald added subscribers: StephenFan, vkmr, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, 
niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

These are required to be constants, this patch makes sure they
are in the accepted range of values.

These are usually created by wrappers in the riscv_vector.h header
which should always be correct. This patch protects against a user
using the builtin directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102086

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvv_errors.c


Index: clang/test/CodeGen/RISCV/rvv_errors.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv_errors.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +experimental-v 
-fsyntax-only -verify
+
+void test() {
+  __builtin_rvv_vsetvli(1, 7, 0); // expected-error {{argument value 7 is 
outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvlimax(-1, 0); // expected-error {{argument value 
18446744073709551615 is outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvli(1, 0, 4); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvlimax(0, 4); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvli(1, 0, 8); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvlimax(0, -1); // expected-error {{LMUL argument must be 
in the range [0,3] or [5,7]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3417,6 +3417,26 @@
   return false;
 }
 
+bool Sema::CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum) {
+  llvm::APSInt Result;
+
+  // We can't check the value of a dependent argument.
+  Expr *Arg = TheCall->getArg(ArgNum);
+  if (Arg->isTypeDependent() || Arg->isValueDependent())
+return false;
+
+  // Check constant-ness first.
+  if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
+return true;
+
+  int64_t Val = Result.getSExtValue();
+  if ((Val >= 0 && Val <= 3) || (Val >= 5 && Val <= 7))
+return false;
+
+  return Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_invalid_lmul)
+ << Arg->getSourceRange();
+}
+
 bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo ,
  unsigned BuiltinID,
  CallExpr *TheCall) {
@@ -3448,7 +3468,19 @@
 << TheCall->getSourceRange() << StringRef(FeatureStr);
   }
 
-  return FeatureMissing;
+  if (FeatureMissing)
+return true;
+
+  switch (BuiltinID) {
+  case RISCV::BI__builtin_rvv_vsetvli:
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, 3) ||
+   CheckRISCVLMUL(TheCall, 2);
+  case RISCV::BI__builtin_rvv_vsetvlimax:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3) ||
+   CheckRISCVLMUL(TheCall, 1);
+  }
+
+  return false;
 }
 
 bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID,
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -12539,6 +12539,7 @@
   bool CheckPPCBuiltinFunctionCall(const TargetInfo , unsigned BuiltinID,
CallExpr *TheCall);
   bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum);
   bool CheckRISCVBuiltinFunctionCall(const TargetInfo , unsigned BuiltinID,
  CallExpr *TheCall);
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11267,4 +11267,6 @@
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
   "builtin requires '%0' extension support to be enabled">;
+def err_riscv_builtin_invalid_lmul : Error<
+  "LMUL argument must be in the range [0,3] or [5,7]">;
 } // end of sema component.


Index: clang/test/CodeGen/RISCV/rvv_errors.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv_errors.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +experimental-v -fsyntax-only 

[PATCH] D102018: [WebAssembly] Use functions instead of macros for const SIMD intrinsics

2021-05-07 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

In D102018#2743818 , @aheejin wrote:

> So what prevented us from using functions when we were using `_Static_assert` 
> and why is it now possible to use functions?

From inside a function, the parameter never looks like a constant because the 
function body does not know how the function will be used. Since the 
static_asserts would have been statements on the function body, they would not 
have been able to assert that the arguments to the function were constant. We 
were using macros to copy the static_asserts to each call site so they could 
see the actual arguments. In contrast, it looks like the diagnose_if attribute 
is evaluated separately for each call site and is able to see the actual 
arguments.

>> The remaining macro intrinsics cannot be made into functions until the 
>> builtin
>> functions they are implemented with can be replaced with normal code patterns
>> because the builtin functions themselves require that their arguments are
>> constants.
>
> Why can't we also use `__REQUIRE_CONSTANT` there? Can't we call 
> `__REQUIRE_CONSTANT` before we call builtins within intrinsic functions?

The new __REQUIRE_CONSTANT would be able to enforce that the intrinsic is only 
called with constant arguments, but that information is not propagated to the 
builtin call in the intrinsic's body. From the builtin's point of view inside 
the function body, its arguments are function parameters, so they may not be 
constant. One fix for this would have been to remove the part of the builtin 
definitions that requires the arguments to be constants, but that seemed more 
hacky than just keeping the original macros for a little bit longer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102018

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


[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-05-07 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10006
   "use of %select{type|declaration}0 %1 requires %2 support">;
+def ext_opencl_double_without_pragma : Extension<
+  "Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is 
supported">;

Anastasia wrote:
> azabaznov wrote:
> > nit: this can be extended to use arbitrary type and extension for other 
> > patches which will eliminate pragmas for types
> Well, actually I am not sure we should use it elsewhere because I don't think 
> it really applies universally.
> The situation for `doubles` seems to be that the older specs were intructing 
> to use the pragma explicitly.
> 
> For the future work we should just avoid adding or using pragma at all unless 
> it brings beneficial functionality.  
> Well, actually I am not sure we should use it elsewhere because I don't think 
> it really applies universally.
> The situation for doubles seems to be that the older specs were intructing to 
> use the pragma explicitly.

The same applies for atomic types, for example 
(https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#_footnoteref_55):

//If the device address space is 64-bits, the data types atomic_intptr_t, 
atomic_uintptr_t, atomic_size_t and atomic_ptrdiff_t are supported if the 
cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics **extensions are 
supported and have been enabled**.//

It seems for me that simplifying the implementation in a way that enabling 
pragma is not necessary is fine if such warning is diagnosed for atomic types 
and half type as well. Alternatively, maybe the spec should be fixed by adding 
`__opencl_c_fp16` and etc. as optional core features?


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

https://reviews.llvm.org/D100980

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


[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2021-05-07 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

@Tyker in case you didn't see my previous message, I'm curious if you'd be 
willing to take a look at the bug. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70638

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


[PATCH] D101960: [openmp] Drop requirement on library path environment variables

2021-05-07 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:648
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,

protze.joachim wrote:
> JonChesterfield wrote:
> > lebedev.ri wrote:
> > > JonChesterfield wrote:
> > > > Similar to other functions in this file, derived from aomp (by deleting 
> > > > some stuff for finding a debug version of the library)
> > > > 
> > > > I can make my peace with runpath instead if people are keen to override 
> > > > this with LD_LIBRARY_PATH. The rest of clang's toolchains wire things 
> > > > up with rpath but that doesn't mean we have to make the same choice 
> > > > here.
> > > I think it would be a shame if this would be the only thing
> > > that *doesn't* support being overriden with `LD_LIBRARY_PATH`.
> > > I'm not sure about `libomptarget`, but it i think it would be good to 
> > > keep such possibility for `libomp`.
> > The search order is 'rpath' then 'LD_LIBRARY_PATH' then 'runpath'. 
> > Presently we set no default at all and require the user to set 
> > LD_LIBRARY_PATH or manually link the right library. So using runpath here 
> > is backwards compatible, in that all the scripts out there that use 
> > LD_LIBRARY_PATH will continue to work. That may force our hand here.
> Especially for debugging, I like the ability to exchange the OpenMP runtimes 
> by adding the debugging build of the runtimes to LD_LIBRARY_PATH without 
> needing to relink the application, so I'd also prefer runpath.
> 
> 
> In the manpage of ld I found: 
> > For a native ELF linker, the directories in "DT_RUNPATH" or "DT_RPATH" of a 
> > shared library are searched for shared libraries needed by it. The 
> > "DT_RPATH" entries are ignored if "DT_RUNPATH" entries exist.
> 
> Does this mean, that adding a runpath here will lead to ignoring the other 
> rpath entries? Or does this only affect linking shared libraries and not 
> linking an application?
> 
The internet also claims rpath is now deprecated, which I suppose is consistent 
with ignoring rpath when both are present. So it seems likely that setting 
runpath here will clobber any (possibly deprecated) rpath that is added 
elsewhere.

I'm not sure what the right path is from there. People might set rpath on 
openmp executables, and we shouldn't clobber that if they do. There may be a 
linker flag along the lines of 'set runpath unless there is already an rpath 
requested'.

I think it's a bug in the linker to ignore one when the other is present but 
backwards compatibility will render that a feature.

There is a halfway step where we set rpath (or runpath) on libomp.so so that it 
can find libomptarget, as we own the libomp.so that is being built at the time, 
but that doesn't really solve the problem.

I'd note that compiler-rt is always statically linked, which seems a good idea 
for a compiler runtime, but would totally thwart the desire to replace it with 
some other runtime without relinking.

We could embed rpath, which gets definitely working out of the box behaviour, 
with a compiler flag to leave that off for development builds that want dynamic 
control over the pieces. Where I see that rpath is 'deprecated', but also that 
the runpath behaviour of clobbering an unrelated rpath makes it unusable in 
this context.



Comment at: openmp/libomptarget/test/lit.cfg:182
+
+if config.cuda_path and config.cuda_path != 'CUDA_TOOLKIT_ROOT_DIR-NOTFOUND':
   config.substitutions.append(("%cuda_flags", "--cuda-path=" + 
config.cuda_path))

protze.joachim wrote:
> This would completely avoid the --cuda-path flag for non-nvptx tests
Yes. That seems like a good thing. Is there a reason we want to pass 
`--cuda-path=CUDA_TOOLKIT_ROOT_DIR-NOTFOUND` to all the non-nvptx tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101960

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


[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-05-07 Thread Georgy Komarov via Phabricator via cfe-commits
jubnzv added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp:7
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+

dyung wrote:
> jubnzv wrote:
> > probinson wrote:
> > > probinson wrote:
> > > > TWeaver wrote:
> > > > > njames93 wrote:
> > > > > > TWeaver wrote:
> > > > > > > Is the missing FileCheck call here on purpose? it seems to me 
> > > > > > > that the CHECK-MESSAGES aren't actually being verified by this 
> > > > > > > test?
> > > > > > > 
> > > > > > > unless I'm missing something.
> > > > > > > 
> > > > > > > TIA
> > > > > > `check_clang_tidy` invokes FileCheck. Does something else make you 
> > > > > > think these labels are being tested?? 
> > > > > whilst investigating an unrelated issue on our internal branch, I 
> > > > > tried editting the check lines in this test and wasn't able to create 
> > > > > a failure. but if I add
> > > > > 
> > > > > '| FileCheck %s -check-prefix=CHECK-MESSAGES' to the run line and 
> > > > > then edit the checks, I can induce an error.
> > > > > 
> > > > > This could be an issue on our internal branch though... :shrug: 
> > > > > thanks for the speedy reply.
> > > > I'm suspicious that our downstream problem is because the test is 
> > > > assuming that the target is Windows, just because the host is.  That's 
> > > > not true for us (or anyone with a Windows-hosted cross-compiler).  Does 
> > > > clang-tidy accept a target triple?
> > > Or possibly the test could be set up to require a Windows target, rather 
> > > than a Windows host.
> > I'm not sure that there is a way to pass a target triple to `clang-tidy`.
> > 
> > But `llvm-lit` should not run this test on non-Windows host because of 
> > `REQUIRES: system-windows`. For example, when I trying to run it on my 
> > Debian machine (`llvm-lit 
> > clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
> >  -v`) I got the following result:
> > 
> > ```
> > -- Testing: 1 tests, 1 workers --
> > UNSUPPORTED: Clang Tools :: 
> > clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp (1 of 1)
> > 
> > Testing Time: 0.01s
> >   Unsupported: 1
> > ```
> Our problem is the opposite, we are running a cross compiler hosted on 
> Windows, but targeting a non-Windows platform (PS4 in our case).
Well, maybe it's a good idea to add the option to set target triple to 
//clang-tidy//?

I think this makes sense because //clang-tidy// can be used to check sources 
for a project built using a cross-toolchain. In the case, when the platform is 
set incorrectly, the tool can works incorrectly, because now we have 
platform-dependent checks.
This also will also help to get rid of similar problems if other 
platform-dependent tests are added.

I will prepare a patch that adds the `-target` option within a few days. If 
anyone has any other ideas on how to work around this problem, I'm open to 
suggestions.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101259

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


[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-05-07 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:136
+
+RangeSet RangeSet::Factory::unite(RangeSet LHS, RangeSet RHS) {
+  if (LHS.isEmpty())

vsavchenko wrote:
> I'd prefer `merge`
There are common namings of operations with sets and `union` is one of them. 
IMO this is most appropriate one.


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

https://reviews.llvm.org/D99797

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


[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-05-07 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 343714.
ASDenysPetrov added a comment.

Updated the patch due to comments. Added more tests. Simplified and improved 
solution.


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

https://reviews.llvm.org/D99797

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -61,6 +61,9 @@
   static constexpr BaseType getMax() {
 return std::numeric_limits::max();
   }
+  // MID is a value in the middle of the range
+  // which unary minus does not affect on,
+  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   static constexpr BaseType getMid() {
 return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
   }
@@ -160,7 +163,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -168,6 +171,29 @@
  RawExpected);
   }
 
+  template 
+  void checkUniteImpl(RangeSet LHS, RHSType RHS, RangeSet Expected) {
+RangeSet Result = F.unite(LHS, RHS);
+EXPECT_EQ(Result, Expected)
+<< "while uniting " << toString(LHS) << " and " << toString(RHS);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRange RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRangeSet RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, BaseType RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS,
+ RawExpected);
+  }
+
   void checkDeleteImpl(const llvm::APSInt , RangeSet From,
RangeSet Expected) {
 RangeSet Result = F.deletePoint(From, Point);
@@ -195,9 +221,6 @@
 
   constexpr TypeParam MIN = TestFixture::getMin();
   constexpr TypeParam MAX = TestFixture::getMax();
-  // MID is a value in the middle of the range
-  // which unary minus does not affect on,
-  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   constexpr TypeParam MID = TestFixture::getMid();
   constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
   constexpr TypeParam B = MID - TestFixture::fromInt(42);
@@ -347,3 +370,201 @@
   // Check that delete of the point not from the range set works as expected.
   this->checkDelete(10, {{0, 5}, {20, 30}}, {{0, 5}, {20, 30}});
 }
+
+TYPED_TEST(RangeSetTest, RangeSetUniteTest) {
+
+  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
+  constexpr TypeParam MIN = TestFixture::getMin();
+  constexpr TypeParam MAX = TestFixture::getMax();
+  constexpr TypeParam MID = TestFixture::getMid();
+  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
+  constexpr TypeParam B = MID - TestFixture::fromInt(42);
+  constexpr TypeParam C = -B;
+  constexpr TypeParam D = -A;
+
+  // LHS and RHS is empty.
+  // RHS =>
+  // LHS => =
+  //___   ___
+  this->checkUnite({}, {}, {});
+
+  // RHS is empty.
+  // RHS =>
+  // LHS =>_=_
+  //__/_\__   __/_\__
+  this->checkUnite({{A, B}}, {}, {{A, B}});
+  this->checkUnite({{A, B}, {C, D}}, {}, {{A, B}, {C, D}});
+
+  // LHS is empty.
+  // RHS => ___
+  // LHS =>/   \=_
+  //__/_\__   __/_\__
+  this->checkUnite({}, B, {{B, B}});
+  this->checkUnite({}, {B, C}, {{B, C}});
+  this->checkUnite({}, {{MIN, B}, {C, MAX}}, {{MIN, B}, {C, MAX}});
+
+  // RHS is detached from LHS.
+  // RHS => ___
+  // LHS =>___ /   \=___ _
+  //__/___\___/_\__   __/___\___/_\__
+  this->checkUnite({{A, C}}, D, {{A, C}, {D, D}});
+  this->checkUnite({{MID, C}, {D, MAX}}, A, {{A, A}, {MID, C}, {D, MAX}});
+  this->checkUnite({{A, B}}, {MID, D}, {{A, B}, {MID, D}});
+  this->checkUnite({{MIN, A}, {D, MAX}}, {B, C}, {{MIN, A}, {B, C}, {D, MAX}});
+  this->checkUnite({{B, MID}, {D, MAX}}, {{MIN, A}, {C, C}},
+   {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkUnite({{MIN, A}, {C, C}}, {{B, MID}, {D, MAX}},
+   {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkUnite({{MAX, MAX}}, {A, B}, {{A, B}, {MAX, MAX}});
+  this->checkUnite({{MIN, MIN}}, {A, B}, {{MIN, MIN}, {A, B}});
+
+  // RHS is inside LHS.
+  // RHS => ___
+ 

[PATCH] D101960: [openmp] Drop requirement on library path environment variables

2021-05-07 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:648
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain ,
+  const ArgList ,

JonChesterfield wrote:
> lebedev.ri wrote:
> > JonChesterfield wrote:
> > > Similar to other functions in this file, derived from aomp (by deleting 
> > > some stuff for finding a debug version of the library)
> > > 
> > > I can make my peace with runpath instead if people are keen to override 
> > > this with LD_LIBRARY_PATH. The rest of clang's toolchains wire things up 
> > > with rpath but that doesn't mean we have to make the same choice here.
> > I think it would be a shame if this would be the only thing
> > that *doesn't* support being overriden with `LD_LIBRARY_PATH`.
> > I'm not sure about `libomptarget`, but it i think it would be good to keep 
> > such possibility for `libomp`.
> The search order is 'rpath' then 'LD_LIBRARY_PATH' then 'runpath'. Presently 
> we set no default at all and require the user to set LD_LIBRARY_PATH or 
> manually link the right library. So using runpath here is backwards 
> compatible, in that all the scripts out there that use LD_LIBRARY_PATH will 
> continue to work. That may force our hand here.
Especially for debugging, I like the ability to exchange the OpenMP runtimes by 
adding the debugging build of the runtimes to LD_LIBRARY_PATH without needing 
to relink the application, so I'd also prefer runpath.


In the manpage of ld I found: 
> For a native ELF linker, the directories in "DT_RUNPATH" or "DT_RPATH" of a 
> shared library are searched for shared libraries needed by it. The "DT_RPATH" 
> entries are ignored if "DT_RUNPATH" entries exist.

Does this mean, that adding a runpath here will lead to ignoring the other 
rpath entries? Or does this only affect linking shared libraries and not 
linking an application?




Comment at: openmp/libomptarget/test/lit.cfg:182
+
+if config.cuda_path and config.cuda_path != 'CUDA_TOOLKIT_ROOT_DIR-NOTFOUND':
   config.substitutions.append(("%cuda_flags", "--cuda-path=" + 
config.cuda_path))

This would completely avoid the --cuda-path flag for non-nvptx tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101960

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


[PATCH] D102051: [RISCV] Consider scalar types for required extensions.

2021-05-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

LGTM too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102051

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


[PATCH] D101572: Make `hasTypeLoc` matcher support more node types.

2021-05-07 Thread Weston Carvalho via Phabricator via cfe-commits
SilensAngelusNex added a comment.

I don't have commit access; you can go ahead and submit it.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101572

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


[PATCH] D101873: [clang] Support clang -fpic -fno-semantic-interposition for AArch64

2021-05-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D101873#2743987 , @peter.smith 
wrote:

> Thanks for the update.
>
> With the clarification that this isn't breaking aarch64 long range thunks 
> now, and we are not considering Arm then I'm happy for this to happen if the 
> user opts in with -fno-semantic-interposition. I think the longer term 
> question, outside of the scope of this review, about whether 
> -fno-semantic-interposition should be the default is probably one for 
> llvm-dev.
>
> In D101873#2742660 , @MaskRay wrote:
>
>> In D101873#2741903 , @peter.smith 
>> wrote:
>>
>>> In D101873#2741299 , @MaskRay 
>>> wrote:
>>>
 https://gist.github.com/MaskRay/2d4dfcfc897341163f734afb59f689c6 has more 
 information about -fno-semantic-interposition.

> Can Clang default to -fno-semantic-interposition?

 I think we can probably make non-x86 default to 
 -fno-semantic-interposition (dso_local inference, given D72197 
 . x86 may find default 
 -fno-semantic-interposition too aggressive.
>>>
>>> Thanks for the link, and the explanation that -fno-semantic-interposition 
>>> is not the default.
>>>
>>> I'm not (yet) convinced that we could make -fno-semantic-interposition the 
>>> default, primarily due to data and not functions, I agree that 
>>> interpositioning functions is rarely used. For data the classic example for 
>>> symbol-interposition was errno, a shared library can't know if any other 
>>> library or executable will define it so it must define, but it must use 
>>> only one value for the definition. I'm not sure if that still holds in 
>>> today's environment with shared C libraries used by practically everything 
>>> but I think the principle still applies.
>>
>> errno needs to be thread-local. C11 7.5.2 says "and errno which expands to a 
>> modifiable lvalue that has type int and thread local storage duration, the 
>> value of which is set to a positive error number by several library 
>> functions."
>> Do you mean that in some environment it may be defined in more than one 
>> shared object?
>
> In the general case it is multiple shared libraries include the same static 
> library that has a global variable, in the normal rules only one of these 
> globals will be used, wheras with -fno-semantic-interposition they will all 
> use individual copies. I don't think that this is common as it is not 
> considered good design, it is just an example of how some programs could be 
> broken in subtle ways if the default were changed.

I had been aware that there could be data preemption though I could not find an 
example.
Being aware of potentially such programs I don't intend to flip the default for 
any target without a wider discussion.

Does this patch look good since no default is flipped?

>>> Looking at the gist I've got one concern for AArch64 and Arm. The ABI 
>>> relies on thunks which are only defined for symbols of type STT_FUNC. 
>>> Changing branches to STT_FUNC to STT_SECTION will break long range thunks 
>>> on AArch64 and interworking for Arm (there is a possibility that the bottom 
>>> bit for STT_FUNC may get used in the future for AArch64 as well). This is 
>>> solvable by keeping the local label and setting STT_FUNC on it.
>>
>> I'll unlikely touch 32-bit arm.
>>
>> For aarch64, aaelf64/aaelf64.rst says
>>
>>   A linker may use a veneer (a sequence of instructions) to implement a 
>> relocated branch if the relocation is either
>>   
>>   ``R__CALL26``, ``R__JUMP26`` or ``R__PLT32`` and:
>>   
>>   - The target symbol has type ``STT_FUNC``.
>>   
>>   - Or, the target symbol and relocated place are in separate sections input 
>> to the linker.
>>   
>>   - Or, the target symbol is undefined (external to the link unit).
>>
>> If `bl .Lhigh_target$local` and `.Lhigh_target$local` are in the same 
>> section, the fixup is resolved at assembly time;
>> otherwise, they are in separate sections and satisfy the ABI requirement.
>>
>> I just changed `bl high_target` in `test/lld/ELF/aarch64-thunk-script.s` and 
>> noticed that both GNU ld and ld.lld can produce a thunk, regardless of the 
>> symbol type.
>
> OK, so it looks like the "Or, the target symbol and relocated place are in 
> separate sections input to the linker." can cover AArch64.
>
> An area I didn't want to mention earlier as there is no guarantee it will be 
> part of the architecture, or the ABI is Morello. This introduces capabilities 
> into AArch64 
> https://github.com/ARM-software/abi-aa/blob/main/aaelf64-morello/aaelf64-morello.rst#414symbol-values
>  with an eye to the future where this might be significant. I realise that we 
> can't be hostage to a future that might not come to pass and there can always 
> be "turn fno-semantic-interposition off when Morello is selected" but my 
> instinct is to 

[PATCH] D101630: [HIP] Fix device-only compilation

2021-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D101630#2733761 , @tra wrote:

> In D101630#2730273 , @yaxunl wrote:
>
>> How about an option -fhip-bundle-device-output. If it is on, device output 
>> is bundled no matter how many GPU arch there are. By default it is on.
>
> +1 to the option, but I can't say I'm particularly happy about the default. 
> I'd still prefer the default to be a no-bundling + an error in cases when 
> we'd nominally produce multiple outputs.
> We could use a third opinion here.
>
> @jdoerfert : Do you have any thoughts on what would be a sensible default 
> when a user uses `-S -o foo.s` for compilations that may produce multiple 
> results? I think OpenMP may have to deal with similar issues.
>
> On one hand it would be convenient for ccache to just work with the CUDA/HIP 
> compilation out of the box. Compiler always produces one output file, 
> regardless of what it does under the hood and ccache may not care what's in 
> it.
>
> On the other, this behavior breaks user expectations. I.e. `clang -S` is 
> supposed to produce the assembly, not an opaque binary bundle blob.
> Using an `-S` with multiple sub-compilations is also likely an error on the 
> user's end and should be explicitly diagnosed and that's how it currently 
> work.
> Using `-fno-hip-bundle-device-output` to restore the expected behavior puts 
> the burden on the wrong side, IMO.  I believe, it should be ccache which 
> should be using `-fhip-bundle-device-output` to deal with the CUDA/HIP 
> compilations.

I choose to emit the bundled output by default since it is the convention for 
compiler to have one output. The compilation is like a pipeline. If we break it 
into stages, users would expect to use the output from one stage as input for 
the next stage. This is possible only if there is one output. This happens with 
host compilations and combined device/host compilations. I would see it is a 
surprise that this is not true for device compilation.

Also, when users do not want the output to be bundled, it is usually for 
debugging or special purposes. Users need to know the naming convention of the 
multiple outputs. I think it is justifiable to enable this by an option.


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

https://reviews.llvm.org/D101630

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


[PATCH] D102064: Parse vector bool when stdbool.h and altivec.h are included

2021-05-07 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/test/Parser/altivec-bool.c:11
+// RUN:-target-feature +altivec -fsyntax-only %s
+
+__vector bool char bc;

nemanjai wrote:
> Do we not want the test case to provide a similar define to what `stdbool.h` 
> does?
Is using eg adding cases such as: `__vector _Bool char bc;` what you meant? 
Added those in just now. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102064

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


[PATCH] D99683: [HIP] Support ThinLTO

2021-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 343696.
yaxunl marked an inline comment as done.
yaxunl added a comment.

revised by Teresa's comments


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

https://reviews.llvm.org/D99683

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-options.hip
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
  llvm/test/Transforms/FunctionImport/adjustable_threshold.ll
  llvm/test/Transforms/FunctionImport/funcimport.ll
  llvm/test/Transforms/FunctionImport/noinline.ll

Index: llvm/test/Transforms/FunctionImport/noinline.ll
===
--- /dev/null
+++ llvm/test/Transforms/FunctionImport/noinline.ll
@@ -0,0 +1,23 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.main.bc
+; RUN: opt -module-summary %p/Inputs/noinline.ll -o %t.inputs.noinline.bc
+; RUN: llvm-lto -thinlto -o %t.summary %t.main.bc %t.inputs.noinline.bc
+
+; Attempt the import now, ensure below that file containing noinline
+; is not imported by default but imported with -force-import-all.
+
+; RUN: opt -function-import -summary-file %t.summary.thinlto.bc %t.main.bc -S 2>&1 \
+; RUN:   | FileCheck -check-prefix=NOIMPORT %s
+; RUN: opt -function-import -force-import-all -summary-file %t.summary.thinlto.bc \
+; RUN:   %t.main.bc -S 2>&1 | FileCheck -check-prefix=IMPORT %s
+
+define i32 @main() #0 {
+entry:
+  %f = alloca i64, align 8
+  call void @foo(i64* %f)
+  ret i32 0
+}
+
+; NOIMPORT: declare void @foo(i64*)
+; IMPORT: define available_externally void @foo
+declare void @foo(i64*) #1
Index: llvm/test/Transforms/FunctionImport/funcimport.ll
===
--- llvm/test/Transforms/FunctionImport/funcimport.ll
+++ llvm/test/Transforms/FunctionImport/funcimport.ll
@@ -15,7 +15,11 @@
 ; RUN: opt -function-import -enable-import-metadata  -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
 ; INSTLIM5-NOT: @staticfunc.llvm.
 
+; Test force import all
+; RUN: opt -function-import -force-import-all -summary-file %t3.thinlto.bc %t.bc -S 2>&1 \
+; RUN:  | FileCheck %s --check-prefix=IMPORTALL
 
+; IMPORTALL-DAG: Error importing module: Failed to import functions to {{.*}}funcimport.ll.tmp.bc: weakalias, weakfunc, linkoncefunc2, __gxx_personality_v0, staticfunc2.llvm.0
 define i32 @main() #0 {
 entry:
   call void (...) @weakalias()
Index: llvm/test/Transforms/FunctionImport/adjustable_threshold.ll
===
--- llvm/test/Transforms/FunctionImport/adjustable_threshold.ll
+++ llvm/test/Transforms/FunctionImport/adjustable_threshold.ll
@@ -11,7 +11,15 @@
 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=10 -import-instr-evolution-factor=0.5 -S | FileCheck %s --check-prefix=INSTLIM-PROGRESSIVE
 ; INSTLIM-PROGRESSIVE-NOT: call void @staticfunc
 
-
+; Test force import all
+; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc \
+; RUN:  -import-instr-limit=1 -force-import-all -S \
+; RUN:  | FileCheck %s --check-prefix=IMPORTALL
+; IMPORTALL-DAG: define available_externally void @globalfunc1()
+; IMPORTALL-DAG: define available_externally void @trampoline()
+; IMPORTALL-DAG: define available_externally void @largefunction()
+; IMPORTALL-DAG: define available_externally hidden void @staticfunc2.llvm.0()
+; IMPORTALL-DAG: define available_externally void @globalfunc2()
 
 declare void @globalfunc1()
 declare void @globalfunc2()
Index: llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
===
--- /dev/null
+++ llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
@@ -0,0 +1,8 @@
+define void @foo(i64* %v) #0 {
+entry:
+  %v.addr = alloca i64*, align 8
+  store i64* %v, i64** %v.addr, align 8
+  ret void
+}
+
+attributes #0 = { noinline }
\ No newline at end of file
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -84,6 +84,10 @@
 "import-cutoff", cl::init(-1), cl::Hidden, cl::value_desc("N"),
 cl::desc("Only import first N functions if N>=0 (default -1)"));
 
+static cl::opt
+ForceImportAll("force-import-all", cl::init(false), cl::Hidden,
+   cl::desc("Import functions with noinline attribute"));
+
 static cl::opt
 ImportInstrFactor("import-instr-evolution-factor", cl::init(0.7),
   cl::Hidden, cl::value_desc("x"),
@@ -227,7 +231,7 @@
 }
 
 if ((Summary->instCount() > 

[PATCH] D99683: [HIP] Support ThinLTO

2021-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

In D99683#2683308 , @tejohnson wrote:

> To do what I suggested in the prior comment, you'd probably want to add a new 
> index-wide flag (since we don't read IR in the thin link). See for example 
> how EnableSplitLTOUnit is set and used. You could add a flag like 
> ForceImportAll or something like that. Then you don't necessarily even need 
> to bump up the importing threshold or add the new import-noinline flag. Just 
> key off of that in the importer to try to force import everything. If 
> something cannot be imported, fail with a clear error.

will do




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4421
+// Only AMDGPU supports device-side LTO
+if (IsUsingLTO && (!IsDeviceOffloadAction || Triple.isAMDGPU())) {
   Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);

tejohnson wrote:
> Should there be an error (or is there one already) emitted somewhere if LTO 
> is requested along with device offloading and this isn't AMDGPU?
yes. will do


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

https://reviews.llvm.org/D99683

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


[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-07 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 343695.
pmatos added a comment.

Making the linter happy...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+%extern = type opaque
+%externref = type %extern addrspace(10)*
+
+define void 

[PATCH] D102070: [AIX][TLS] Diagnose use of unimplemented TLS models

2021-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:548
 
+def err_aix_unsupported_tls_model : Error<"The tls model %0 is not yet 
supported on AIX">;
+

This neatly avoids the problem of diagnostics not starting with a capital 
letter (it looks like we have other diagnostics to update, but that's not your 
problem to deal with).



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3154
 
+def err_aix_attr_unsupported_tls_model : Error<"The tls model %0 is not yet 
supported on AIX">;
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102070

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: hubert.reinterpretcast.
aaron.ballman added a subscriber: hubert.reinterpretcast.
aaron.ballman added a comment.

I think the changes look good to me, but I'm not a floating-point expert either.

Adding @hubert.reinterpretcast for his floating-point expertise.




Comment at: clang/test/CodeGen/fp-floatcontrol-pragma.cpp:240
+
+float mySub(float x, float y) {
+  // CHECK: define {{.*}}float {{.*}}mySub{{.*}}

mibintc wrote:
> aaron.ballman wrote:
> > Can we also get some tests that show how this behaves with the less common 
> > floating-point types like float16, bfloat16, float128, half?
> I added tests __fp16 and __float128. I don't know if the other type names are 
> supported in Intel, _Float16 isn't supported. I didn't see a typename half 
> nor bfloat16 being used in any of the CodeGen tests, is this sufficient? if 
> the predicate IsFloatingType is true and if the expression comes into 
> UsualUnaryConversions then this new code should take effect 
I think this is fine (I picked the floating point names from Types.h when 
looking to see what other floating-point types exist) -- thanks for adding the 
new tests!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

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


[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-07 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 343685.
pmatos added a comment.

- Simplifies some of code in the middle-end.
- Removes setComdat and adds setWeak

Small improvements to address comments in review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s 

[PATCH] D101192: Add support for #elifdef and #elifndef

2021-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 2 inline comments as done.
aaron.ballman added inline comments.



Comment at: clang/lib/Lex/PPDirectives.cpp:3254-3265
+  Token MacroNameTok;
+  ReadMacroName(MacroNameTok);
+
+  // Error reading macro name?  If so, diagnostic already issued.
+  if (MacroNameTok.is(tok::eod)) {
+// Skip code until we get to #endif.  This helps with recovery by not
+// emitting an error when the #endif is reached.

rsmith wrote:
> Hm, is the strict checking here appropriate? I'd expect skipping to start as 
> soon as we hit the `#elifdef` directive, so the restriction on the form of 
> the directive should be relaxed and we should just skip to the end of the 
> line. ("When in a group that is skipped (15.2), the directive syntax is 
> relaxed to allow any sequence of preprocessing tokens to occur between the 
> directive name and the following new-line character."). For example, given:
> 
> ```
> #if 1
> #elif
> #endif
> ```
> 
> ... we don't diagnose, even though the `#elif` line doesn't match the usual 
> form for the directive (a //constant-expression// would require at least one 
> token between `elif` and //new-line//), and I'd expect `#elifdef` to behave 
> the same way.
> 
> With this fixed, the handling of `#elif`, `#elifdef`, and `#elifndef` (when 
> not skipping) should be identical other than which callback is invoked; can 
> the implementations be combined?
Good point! I think this means we'd need a second set of callbacks though -- we 
want the macro information when we process a `#elifdef` or a `#elifndef` that 
is taken (same as with `#ifdef`), so we'd need the interface that takes a 
`MacroDefinition`, but if we skip reading that because we're skipping the 
entire conditional block, we'd need a callback that takes the condition range.

I went that route with the updated patch. LMK if that works for you.


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

https://reviews.llvm.org/D101192

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


[PATCH] D102070: [AIX][TLS] Diagnose use of unimplemented TLS models

2021-05-07 Thread Victor Huang via Phabricator via cfe-commits
NeHuang updated this revision to Diff 343683.
NeHuang added a comment.

Update the test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102070

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-tls-model.cpp
  clang/test/Sema/aix-attr-tls_model.c

Index: clang/test/Sema/aix-attr-tls_model.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-tls_model.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-cpu pwr8 -verify -fsyntax-only %s
+
+#if !__has_attribute(tls_model)
+#error "Should support tls_model attribute"
+#endif
+
+static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
+static __thread int y __attribute((tls_model("local-dynamic"))); // expected-error {{The tls model local-dynamic is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("initial-exec"))); // expected-error {{The tls model initial-exec is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("local-exec"))); // expected-error {{The tls model local-exec is not yet supported on AIX}}
Index: clang/test/CodeGen/aix-tls-model.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-tls-model.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LE-ERROR
+
+int z1 = 0;
+int z2;
+int __thread x;
+int f() {
+  static int __thread y;
+  return y++;
+}
+
+// CHECK-GD: @z1 ={{.*}} global i32 0
+// CHECK-GD: @z2 ={{.*}} global i32 0
+// CHECK-GD: @x ={{.*}} thread_local global i32 0
+// CHECK-GD: @_ZZ1fvE1y = internal thread_local global i32 0
+// CHECK-GD-ERROR:  error in backend: thread local storage not yet implemented on AIX
+// CHECK-LD-ERROR:  error: The tls model local-dynamic is not yet supported on AIX
+// CHECK-IE-ERROR:  error: The tls model initial-exec is not yet supported on AIX
+// CHECK-LE-ERROR:  error: The tls model local-exec is not yet supported on AIX
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1935,6 +1935,12 @@
 return;
   }
 
+  if (S.Context.getTargetInfo().getTriple().isOSAIX() &&
+  Model != "global-dynamic") {
+S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model;
+return;
+  }
+
   D->addAttr(::new (S.Context) TLSModelAttr(S.Context, AL, Model));
 }
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1808,6 +1808,14 @@
 Opts.ExplicitEmulatedTLS = true;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
+if (T.isOSAIX()) {
+  StringRef Name = A->getValue();
+  if (Name != "global-dynamic")
+Diags.Report(diag::err_aix_unsupported_tls_model) << Name;
+}
+  }
+
   if (Arg *A = Args.getLastArg(OPT_fdenormal_fp_math_EQ)) {
 StringRef Val = A->getValue();
 Opts.FPDenormalMode = llvm::parseDenormalFPAttribute(Val);
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D101192: Add support for #elifdef and #elifndef

2021-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 343680.
aaron.ballman added a comment.

Updated based on review feedback.


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

https://reviews.llvm.org/D101192

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/PPConditionalDirectiveRecord.h
  clang/include/clang/Lex/PreprocessingRecord.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPConditionalDirectiveRecord.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PreprocessingRecord.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/Index/complete-preprocessor.m
  clang/test/Preprocessor/elifdef.c
  clang/test/Preprocessor/if_warning.c
  clang/test/Preprocessor/ifdef-recover.c
  clang/test/Preprocessor/macro_misc.c
  clang/test/Preprocessor/macro_vaopt_check.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -53,6 +53,8 @@
"#if A\n"
"#ifdef A\n"
"#ifndef A\n"
+   "#elifdef A\n"
+   "#elifndef A\n"
"#elif A\n"
"#else\n"
"#include \n"
@@ -70,18 +72,20 @@
   EXPECT_EQ(pp_if, Tokens[3].K);
   EXPECT_EQ(pp_ifdef, Tokens[4].K);
   EXPECT_EQ(pp_ifndef, Tokens[5].K);
-  EXPECT_EQ(pp_elif, Tokens[6].K);
-  EXPECT_EQ(pp_else, Tokens[7].K);
-  EXPECT_EQ(pp_include, Tokens[8].K);
-  EXPECT_EQ(pp_include_next, Tokens[9].K);
-  EXPECT_EQ(pp___include_macros, Tokens[10].K);
-  EXPECT_EQ(pp_import, Tokens[11].K);
-  EXPECT_EQ(decl_at_import, Tokens[12].K);
-  EXPECT_EQ(pp_pragma_import, Tokens[13].K);
-  EXPECT_EQ(cxx_export_decl, Tokens[14].K);
-  EXPECT_EQ(cxx_module_decl, Tokens[15].K);
-  EXPECT_EQ(cxx_import_decl, Tokens[16].K);
-  EXPECT_EQ(pp_eof, Tokens[17].K);
+  EXPECT_EQ(pp_elifdef, Tokens[6].K);
+  EXPECT_EQ(pp_elifndef, Tokens[7].K);
+  EXPECT_EQ(pp_elif, Tokens[8].K);
+  EXPECT_EQ(pp_else, Tokens[9].K);
+  EXPECT_EQ(pp_include, Tokens[10].K);
+  EXPECT_EQ(pp_include_next, Tokens[11].K);
+  EXPECT_EQ(pp___include_macros, Tokens[12].K);
+  EXPECT_EQ(pp_import, Tokens[13].K);
+  EXPECT_EQ(decl_at_import, Tokens[14].K);
+  EXPECT_EQ(pp_pragma_import, Tokens[15].K);
+  EXPECT_EQ(cxx_export_decl, Tokens[16].K);
+  EXPECT_EQ(cxx_module_decl, Tokens[17].K);
+  EXPECT_EQ(cxx_import_decl, Tokens[18].K);
+  EXPECT_EQ(pp_eof, Tokens[19].K);
 }
 
 TEST(MinimizeSourceToDependencyDirectivesTest, Define) {
@@ -324,6 +328,44 @@
Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, Elifdef) {
+  SmallVector Out;
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef C\n"
+"#define D\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef C\n"
+   "#define D\n"
+   "#endif\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef B\n"
+"#define C\n"
+"#elifndef C\n"
+"#define D\n"
+"#else\n"
+"#define E\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef B\n"
+   "#define C\n"
+   "#elifndef C\n"
+   "#define D\n"
+   "#else\n"
+   "#define E\n"
+   "#endif\n",
+   Out.data());
+}
+
 

[PATCH] D102067: [amdgpu-arch] Guard hsa.h with __has_include

2021-05-07 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

A thought - we need to keep return 0 for success, but could return a different 
integer for each failure mode. That would be useful when guessing why it 
failed. Orthogonal to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102067

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


[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-05-07 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 7 inline comments as done.
pmatos added inline comments.



Comment at: llvm/lib/CodeGen/MachineOperand.cpp:1174
+  } else
+OS << ", opaque ";
   if (getAlign() != getBaseAlign())

tlively wrote:
> Is there a test that demonstrates this printing? Also, I'm not sure 
> specifically calling out zero-sized operands in the text dump is that useful. 
> Can zero-sized operands still be given an alignment? If so, it might even be 
> good to continue printing the alignment for them.
The reason I changed this here is due to the call of getSize() crashing for 
zeroSized arguments. I have not added test for the printing. I don't think 
zero-sized operands can still be given an alignment. We are actually setting 
the alignment to



Comment at: llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp:132-134
+// Setting Comdat ensure only one table is left after linking when multiple
+// modules define the table.
+Sym->setComdat(true);

sbc100 wrote:
> tlively wrote:
> > Is this necessary given that the symbol is set to be undefined? Perhaps it 
> > would be better to make it defined here and also set comdat so that the 
> > linker doesn't need to do anything special to make sure it exists in the 
> > final binary. (Or possibly I'm misunderstanding what these settings mean!) 
> > @sbc100 wdyt?
> I think don't want this here.  Firstly I think this will mark the symbol as 
> being a comdat group symbol .. which is not the same thing as being part of a 
> comdat group ( which I think is that is indented here).Secondly, I don't 
> think it makes sense for an undefined symbol to be part of a comdat group.  I 
> think what you want here, if the symbol was defined is `setWeak()`.Given 
> that is not defined I dont think you even want that.
It seems I was mistaken - I thought that by setting it as Comdat, the linker 
would merge symbols from different compilation units if they existed. Maybe 
what I need is `Weak` then.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h:59-61
+  // AS 2 : is an integral address space for globals of externref values
+  // AS 3 : is an non-integral address space for funcref values
+  // AS 4 : is an integral address spaces for globals of funcref values

tlively wrote:
> Why are the address spaces for globals integral? It doesn't make sense to do 
> arithmetic on the "address" of a global afaict. Does using getelementptr to 
> index tables in the global address space require the address space to be 
> integral? If so, that might be a good reason to make the address space 
> integral, but it might also be a good reason to put tables and globals in 
> different address spaces instead. Also, IMO it would be better to use just a 
> single address space for all globals; that way we could support globals with 
> other types like i32, i64, etc. without even more address spaces.
Current set of patches should have addressed your concerns here.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td:15
 multiclass TABLE {
+  let mayLoad = 1 in
   defm TABLE_GET_#rt : I<(outs rt:$res), (ins table32_op:$table),

tlively wrote:
> wingo wrote:
> > I think you may need `hasSideEffects = 0` for these annotations to have an 
> > effect.
> I would be surprised if this were true!
Why would this be the case? If I remember correctly, I added `mayLoad` and 
`mayStore` here so that lowering includes a chain. And this works without the 
need for `hasSideEffects`. Unless you think this is required for other reaons, 
but `mayLoad` works with it.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td:19
  [],
  "table.get\t$res, $table",
  "table.get\t$table",

tlively wrote:
> wingo wrote:
> > Not something for this patch, but this is certainly bogus: surely we mean 
> > `table.get\t$table, $i` and we have an i32 index argument?
> Agree about the i32 index argument, but it is correct to have the result as 
> part of the string for the register-based output format.
Not sure I understand why this should be `$i` instead of `$table`. Isn't 
`$table` represented as an index anyway? A `table32_op` is defined as 
`Operand` so I don't quite understand what we gain by changing this.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:129
+TT.isArch64Bit()
+? (hasReferenceTypes(FS)
+   ? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:3"

tlively wrote:
> This check should incorporate the CPU as well using `getSubtargetImpl(CPU, 
> FS)->hasReferenceTypes()`.
What exactly do you mean here? Not sure what is the difference here. You mean 
adding something like : `hasReferenceTypes(FS) || 

[PATCH] D102067: [amdgpu-arch] Guard hsa.h with __has_include

2021-05-07 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

LGTM, thanks. I think this leaves us totally sure the clang build will succeed 
with a best effort chance of having a working amdgpu ident tool afterwards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102067

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


[PATCH] D101843: [OpenCL] Add clang extension for bitfields

2021-05-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCL/unsupported.cl:11
+#ifndef BITFIELDS_EXT
+// expected-error@-2 {{bit-fields are not supported in OpenCL}}
+#endif

svenvh wrote:
> The extension has "bitfields" in the name but most diagnostics (including 
> this one) spell it as "bit-fields".  I wonder what the least surprising name 
> would be?  It seems Clang tends to use the hyphenated form in diagnostics and 
> the non-hyphenated form in e.g. option names (e.g. `fsigned-bitfields`), so 
> using the non-hyphenated form in the extension name is probably fine.
Hyphenated words are often split so we could also go for 
`__cl_clang_bit_fields`? But I think this might be more confusing...


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

https://reviews.llvm.org/D101843

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


[clang] 25bbff6 - [PowerPC] Provide MMA builtins for compatibility

2021-05-07 Thread Ahsan Saghir via cfe-commits

Author: Ahsan Saghir
Date: 2021-05-07T09:10:16-05:00
New Revision: 25bbff632d018d178272a61c0732203d53d3a2e3

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

LOG: [PowerPC] Provide MMA builtins for compatibility

Vector pair intrinsics and builtins were renamed in
https://reviews.llvm.org/D91974 to replace the _mma_ prefix by _vsx_.
However, some projects used the _mma_ version, so this patch adds
these intrinsics to provide compatibility.

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

Reviewed By: nemanjai, amyk

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-pair-mma.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 7b083a9333e2..f47c9b097ae3 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -20,11 +20,15 @@
 // MMA builtins that are using their own format documented below.
 
 #if defined(BUILTIN) && !defined(CUSTOM_BUILTIN)
-#   define CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_##ID, "i.", 
"t")
+#   define CUSTOM_BUILTIN(ID, INTR, TYPES, ACCUMULATE) \
+  BUILTIN(__builtin_##ID, "i.", "t")
 #elif defined(CUSTOM_BUILTIN) && !defined(BUILTIN)
 #   define BUILTIN(ID, TYPES, ATTRS)
 #endif
 
+#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) \
+   CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE)
+
 BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n")
 
 // This is just a placeholder, the types and attributes are wrong.
@@ -674,90 +678,103 @@ BUILTIN(__builtin_dcbf, "vvC*", "")
 // Because these built-ins rely on target-dependent types and to avoid 
pervasive
 // change, they are type checked manually in Sema using custom type 
descriptors.
 // The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
-// with its prefix, the second argument specifies the type of the function
+// with its prefix, the second argument is the name of the intrinsic this
+// built-in generates, the third argument specifies the type of the function
 // (result value, then each argument) as follows:
 //  i -> Unsigned integer followed by the greatest possible value for that
 //   argument or 0 if no constraint on the value.
 //   (e.g. i15 for a 4-bits value)
-//  V -> Vector type used with MMA builtins (vector unsigned char)
+//  V -> Vector type used with MMA built-ins (vector unsigned char)
 //  W -> PPC Vector type followed by the size of the vector type.
 //   (e.g. W512 for __vector_quad)
 //  any other descriptor -> Fall back to generic type descriptor decoding.
 // The 'C' suffix can be used as a suffix to specify the const type.
 // The '*' suffix can be used as a suffix to specify a pointer to a type.
-// The third argument is set to true if the builtin accumulates its result into
+// The fourth argument is set to true if the built-in accumulates its result 
into
 // its given accumulator.
 
-CUSTOM_BUILTIN(vsx_lxvp, "W256SLLiW256C*", false)
-CUSTOM_BUILTIN(vsx_stxvp, "vW256SLLiW256C*", false)
-CUSTOM_BUILTIN(vsx_assemble_pair, "vW256*VV", false)
-CUSTOM_BUILTIN(vsx_disassemble_pair, "vv*W256*", false)
-
-CUSTOM_BUILTIN(mma_assemble_acc, "vW512*", false)
-CUSTOM_BUILTIN(mma_disassemble_acc, "vv*W512*", false)
-CUSTOM_BUILTIN(mma_xxmtacc, "vW512*", true)
-CUSTOM_BUILTIN(mma_xxmfacc, "vW512*", true)
-CUSTOM_BUILTIN(mma_xxsetaccz, "vW512*", false)
-CUSTOM_BUILTIN(mma_xvi4ger8, "vW512*VV", false)
-CUSTOM_BUILTIN(mma_xvi8ger4, "vW512*VV", false)
-CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", false)
-CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false)
-CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false)
-CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false)
-CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false)
-CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false)
-CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false)
-CUSTOM_BUILTIN(mma_pmxvi16ger2, "vW512*VVi15i15i3", false)
-CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false)
-CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false)
-CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false)
-CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false)
-CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true)
-CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true)
-CUSTOM_BUILTIN(mma_xvi8ger4spp, "vW512*VV", true)
-CUSTOM_BUILTIN(mma_xvi16ger2pp, "vW512*VV", true)
-CUSTOM_BUILTIN(mma_xvi16ger2spp, "vW512*VV", true)
-CUSTOM_BUILTIN(mma_pmxvi4ger8pp, "vW512*VVi15i15i255", true)
-CUSTOM_BUILTIN(mma_pmxvi8ger4pp, "vW512*VVi15i15i15", true)
-CUSTOM_BUILTIN(mma_pmxvi8ger4spp, "vW512*VVi15i15i15", true)

[PATCH] D100482: [PowerPC] Provide MMA builtins for compatibility

2021-05-07 Thread Ahsan Saghir via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG25bbff632d01: [PowerPC] Provide MMA builtins for 
compatibility (authored by saghir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100482

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-pair-mma.c

Index: clang/test/CodeGen/builtins-ppc-pair-mma.c
===
--- clang/test/CodeGen/builtins-ppc-pair-mma.c
+++ clang/test/CodeGen/builtins-ppc-pair-mma.c
@@ -5,7 +5,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.assemble.acc(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]], <16 x i8> [[VC]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa [[TBAA2:![0-9]+]]
 // CHECK-NEXT:ret void
 //
 void test1(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -46,7 +46,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <256 x i1>*
-// CHECK-NEXT:store <256 x i1> [[TMP0]], <256 x i1>* [[TMP1]], align 32, !tbaa !6
+// CHECK-NEXT:store <256 x i1> [[TMP0]], <256 x i1>* [[TMP1]], align 32, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-NEXT:ret void
 //
 void test3(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -78,10 +78,10 @@
 // CHECK-LABEL: @test5(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[VQP:%.*]] to <512 x i1>*
-// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa !2
+// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:[[TMP2:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xxmtacc(<512 x i1> [[TMP1]])
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test5(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -94,10 +94,10 @@
 // CHECK-LABEL: @test6(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[VQP:%.*]] to <512 x i1>*
-// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa !2
+// CHECK-NEXT:[[TMP1:%.*]] = load <512 x i1>, <512 x i1>* [[TMP0]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:[[TMP2:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xxmfacc(<512 x i1> [[TMP1]])
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP2]], <512 x i1>* [[TMP3]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test6(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -111,7 +111,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xxsetaccz()
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test7(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -125,7 +125,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xvi4ger8(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa [[TBAA2]]
 // CHECK-NEXT:ret void
 //
 void test8(unsigned char *vqp, unsigned char *vpp, vector unsigned char vc, unsigned char *resp) {
@@ -139,7 +139,7 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <512 x i1> @llvm.ppc.mma.xvi8ger4(<16 x i8> [[VC:%.*]], <16 x i8> [[VC]])
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast i8* [[RESP:%.*]] to <512 x i1>*
-// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], align 64, !tbaa !2
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[TMP1]], 

[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

2021-05-07 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added inline comments.



Comment at: clang/test/Parser/opencl-atomics-cl20.cl:34
   atomic_ptrdiff_t pd;
-// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier
-// are not supported by OpenCL.
-  _Atomic int i; // expected-error {{use of undeclared identifier '_Atomic'}}
-}
-#ifndef CL20
-// expected-error@-16 {{use of undeclared identifier 'atomic_int'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uint'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_long'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ulong'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_float'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_double'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_flag'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_size_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ptrdiff_t'}}
-#elif !EXT
-// expected-error@-26 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-27 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_extended_atomics support}}
-#if __LP64__
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-32 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
+#if !defined(LANG_VER_OK) || !defined(cl_khr_int64_base_atomics)
+// expected-error@-8 {{use of undeclared identifier 'atomic_long'}}

Anastasia wrote:
> Anastasia wrote:
> > mantognini wrote:
> > > Shouldn't that be 
> > > ```
> > > !(defined(cl_khr_int64_extended_atomics) && 
> > > defined(cl_khr_int64_base_atomics))
> > > ```
> > > for atomic_long and atomic_ulong, and covering double for atomic_double?
> > > 
> > > Alternatively, if the goal isn't to have 100% coverage in this test of 
> > > all these variations (which would be fine I believe), then a comment 
> > > could clarify the intent.
> > I think for the purpose of this test it is enough that at least one 
> > extension is not enabled. So we could add another run line and check for 
> > `cl_khr_int64_extended_atomics` too and also another run line with both 
> > although I am not sure it adds a lot into testing at the moment.
> > 
> > We can add a comment, so something like:
> > 
> > ```
> > Optional type identifiers are not added in earlier version or if at least 
> > one of the extensions is not supported. Here we check with 
> > `cl_khr_int64_base_atomics` only.
> > ```
> Does it make sense?
Yes, I think it does.


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

https://reviews.llvm.org/D100976

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 9 inline comments as done.
mibintc added inline comments.



Comment at: clang/include/clang/Lex/Preprocessor.h:181
   IdentifierInfo *Ident__is_target_environment;// __is_target_environment
+  IdentifierInfo *Ident__FLT_EVAL_METHOD__;// __FLT_EVAL_METHOD__
 

aaron.ballman wrote:
> Otherwise, when `LexExpandSpecialBuiltins` is `false`, I think this winds up 
> being an uninitialized pointer value.
thanks for catching this!



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1714
   });
-  } else if (II == Ident__has_cpp_attribute ||
- II == Ident__has_c_attribute) {
+  } else if (II == Ident__has_cpp_attribute || II == Ident__has_c_attribute) {
 bool IsCXX = II == Ident__has_cpp_attribute;

aaron.ballman wrote:
> It looks like some unrelated formatting changes snuck in.
clang-format really wants to fix this file



Comment at: clang/lib/Sema/Sema.cpp:216
+// Use setting from TargetInfo.
+PP.setCurrentFltEvalMethod(static_cast(
+ctxt.getTargetInfo().getFloatEvalMethod()));

aaron.ballman wrote:
> I don't think this cast is needed, is it? (It might make sense for the 
> `getFloatEvalMethod()` return type to be `int` rather than `unisnged` though, 
> given that we support negative values for implementation-defined semantics?)
You are so right. i changed the type and modified the identifier like you 
suggested to make things more easily understandable



Comment at: clang/test/CodeGen/fp-floatcontrol-pragma.cpp:240
+
+float mySub(float x, float y) {
+  // CHECK: define {{.*}}float {{.*}}mySub{{.*}}

aaron.ballman wrote:
> Can we also get some tests that show how this behaves with the less common 
> floating-point types like float16, bfloat16, float128, half?
I added tests __fp16 and __float128. I don't know if the other type names are 
supported in Intel, _Float16 isn't supported. I didn't see a typename half nor 
bfloat16 being used in any of the CodeGen tests, is this sufficient? if the 
predicate IsFloatingType is true and if the expression comes into 
UsualUnaryConversions then this new code should take effect 



Comment at: clang/test/Preprocessor/predefined-flteval-macro.c:1
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s

Since __FLT_EVAL_METHOD__ is no longer a typical predefined macro, I removed 
all the tests from clang/test/Preprocessor/init.c (see above) and created this 
to test all the combinations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

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


[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

2021-05-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/Parser/opencl-atomics-cl20.cl:34
   atomic_ptrdiff_t pd;
-// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier
-// are not supported by OpenCL.
-  _Atomic int i; // expected-error {{use of undeclared identifier '_Atomic'}}
-}
-#ifndef CL20
-// expected-error@-16 {{use of undeclared identifier 'atomic_int'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uint'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_long'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ulong'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_float'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_double'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_flag'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_size_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ptrdiff_t'}}
-#elif !EXT
-// expected-error@-26 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-27 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_extended_atomics support}}
-#if __LP64__
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-32 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
+#if !defined(LANG_VER_OK) || !defined(cl_khr_int64_base_atomics)
+// expected-error@-8 {{use of undeclared identifier 'atomic_long'}}

Anastasia wrote:
> mantognini wrote:
> > Shouldn't that be 
> > ```
> > !(defined(cl_khr_int64_extended_atomics) && 
> > defined(cl_khr_int64_base_atomics))
> > ```
> > for atomic_long and atomic_ulong, and covering double for atomic_double?
> > 
> > Alternatively, if the goal isn't to have 100% coverage in this test of all 
> > these variations (which would be fine I believe), then a comment could 
> > clarify the intent.
> I think for the purpose of this test it is enough that at least one extension 
> is not enabled. So we could add another run line and check for 
> `cl_khr_int64_extended_atomics` too and also another run line with both 
> although I am not sure it adds a lot into testing at the moment.
> 
> We can add a comment, so something like:
> 
> ```
> Optional type identifiers are not added in earlier version or if at least one 
> of the extensions is not supported. Here we check with 
> `cl_khr_int64_base_atomics` only.
> ```
Does it make sense?


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

https://reviews.llvm.org/D100976

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


[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

2021-05-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/Parser/opencl-atomics-cl20.cl:34
   atomic_ptrdiff_t pd;
-// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier
-// are not supported by OpenCL.
-  _Atomic int i; // expected-error {{use of undeclared identifier '_Atomic'}}
-}
-#ifndef CL20
-// expected-error@-16 {{use of undeclared identifier 'atomic_int'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uint'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_long'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ulong'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_float'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_double'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_flag'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_size_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ptrdiff_t'}}
-#elif !EXT
-// expected-error@-26 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-27 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_extended_atomics support}}
-#if __LP64__
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-32 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
+#if !defined(LANG_VER_OK) || !defined(cl_khr_int64_base_atomics)
+// expected-error@-8 {{use of undeclared identifier 'atomic_long'}}

mantognini wrote:
> Shouldn't that be 
> ```
> !(defined(cl_khr_int64_extended_atomics) && 
> defined(cl_khr_int64_base_atomics))
> ```
> for atomic_long and atomic_ulong, and covering double for atomic_double?
> 
> Alternatively, if the goal isn't to have 100% coverage in this test of all 
> these variations (which would be fine I believe), then a comment could 
> clarify the intent.
I think for the purpose of this test it is enough that at least one extension 
is not enabled. So we could add another run line and check for 
`cl_khr_int64_extended_atomics` too and also another run line with both 
although I am not sure it adds a lot into testing at the moment.

We can add a comment, so something like:

```
Optional type identifiers are not added in earlier version or if at least one 
of the extensions is not supported. Here we check with 
`cl_khr_int64_base_atomics` only.
```


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

https://reviews.llvm.org/D100976

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


[PATCH] D102067: [amdgpu-arch] Guard hsa.h with __has_include

2021-05-07 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 343668.
pdhaliwal added a comment.

Added fallback in case __has_include is not defined or header is not found 
anywhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102067

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp


Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,7 +11,24 @@
 //
 
//===--===//
 
-#include 
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
 #include 
 #include 
 
@@ -57,3 +74,5 @@
   hsa_shut_down();
   return 0;
 }
+
+#endif


Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,7 +11,24 @@
 //
 //===--===//
 
-#include 
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
 #include 
 #include 
 
@@ -57,3 +74,5 @@
   hsa_shut_down();
   return 0;
 }
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102070: [AIX][TLS] Diagnose use of unimplemented TLS models

2021-05-07 Thread Victor Huang via Phabricator via cfe-commits
NeHuang created this revision.
Herald added a reviewer: aaron.ballman.
NeHuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add front end diagnostics to report error for unimplemented TLS models set by

- compiler option `-ftls-model`
- attributes like `__thread int __attribute__((tls_model("local-exec"))) 
var_name;`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102070

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-tls-model.cpp
  clang/test/Sema/aix-attr-tls_model.c

Index: clang/test/Sema/aix-attr-tls_model.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-tls_model.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-cpu pwr8 -verify -fsyntax-only %s
+
+#if !__has_attribute(tls_model)
+#error "Should support tls_model attribute"
+#endif
+
+static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
+static __thread int y __attribute((tls_model("local-dynamic"))); // expected-error {{The tls model local-dynamic is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("initial-exec"))); // expected-error {{The tls model initial-exec is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("local-exec"))); // expected-error {{The tls model local-exec is not yet supported on AIX}}
Index: clang/test/CodeGen/aix-tls-model.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-tls-model.cpp
@@ -0,0 +1,36 @@
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-GD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-GD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LE-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-GD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-GD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
+// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LE-ERROR
+
+
+int z1 = 0;
+int z2;
+int __thread x;
+int f() {
+  static int __thread y;
+  return y++;
+}
+int __thread z;
+
+struct S {
+  S();
+  ~S();
+};
+struct T {
+  ~T();
+};
+
+struct S thread_local s1;
+struct T thread_local t1;
+
+// CHECK-GD-ERROR:  error in backend: thread local storage not yet implemented on AIX
+// CHECK-LD-ERROR:  error: The tls model local-dynamic is not yet supported on AIX
+// CHECK-IE-ERROR:  error: The tls model initial-exec is not yet supported on AIX
+// CHECK-LE-ERROR:  error: The tls model local-exec is not yet supported on AIX
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1935,6 +1935,12 @@
 return;
   }
 
+  if (S.Context.getTargetInfo().getTriple().isOSAIX() &&
+  Model != "global-dynamic") {
+S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model;
+return;
+  }
+
   D->addAttr(::new (S.Context) TLSModelAttr(S.Context, AL, Model));
 }
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1808,6 +1808,14 @@
 Opts.ExplicitEmulatedTLS = true;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
+if (T.isOSAIX()) {
+  StringRef Name = A->getValue();
+  if (Name != "global-dynamic")
+Diags.Report(diag::err_aix_unsupported_tls_model) << Name;
+}
+  }
+
   if (Arg *A = 

[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 343666.
mibintc added a comment.

Respond to @aaron.ballman 's review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/PragmaKinds.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init-arm.c
  clang/test/Preprocessor/init-mips.c
  clang/test/Preprocessor/init-ppc.c
  clang/test/Preprocessor/init-ppc64.c
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-v7k-compat.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c
  clang/test/Preprocessor/predefined-flteval-macro.c

Index: clang/test/Preprocessor/predefined-flteval-macro.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-flteval-macro.c
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=arm64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64_be -xc  -fsyntax-only %s
+// RUN: %clang_cc1  -triple=arm64 -xc++  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-apple-ios7.0 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=small -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=tiny -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=large -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv7-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1  -x c++ -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple arm-none-none -target-abi apcs-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armeb-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv6-unknown-cloudabi-eabihf -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabi -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-elf -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7 -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armebv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbebv8 -fsyntax-only %s
+// RUN: %clang_cc1 

[PATCH] D100604: [PowerPC] Improve codegen for int-to-fp conversion of subword vector extract

2021-05-07 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D100604

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


[PATCH] D102069: [clang][PreProcessor] Cutoff parsing after hitting completion point

2021-05-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a crash caused by Lexers being invalidated at code
completion points in
https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/PPLexerChange.cpp#L520.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102069

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/CodeCompletion/crash-if-directive.cpp


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,3 @@
+#define FOO(X) X + 1
+#if FOO(
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s | FileCheck %s 
--allow-empty
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -3023,6 +3023,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while evulating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,3 @@
+#define FOO(X) X + 1
+#if FOO(
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s | FileCheck %s --allow-empty
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -3023,6 +3023,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while evulating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102067: [amdgpu-arch] Guard hsa.h with __has_include

2021-05-07 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Logic doesn't look quite right to me. If the compiler supports has_include, but 
neither of those headers exist, we fall through to main() which won't compile.

How about:

  #if defined(__has_include)
#if __has_include("hsa.h")
  #define HSA_FOUND 1 // name tbd
  #include "hsa.h"
#elif __has_include("hsa/hsa.h")
  #define HSA_FOUND 1
  #include "hsa/hsa.h"
#else
  #define HSA_FOUND 0
#endif
  #else
#define HSA_FOUND 0
  #endif
  
  
  #if !HSA_FOUND
  int main() { return 1; }
  #else
  // all the current stuff
  #endif

That takes the approach that missing __has_include is a bad sign and 
immediately gives up. As far as I can tell it was introduced ~ 10 years ago, 
and was more recently added to c++17 
(https://en.cppreference.com/w/cpp/preprocessor/include, which uses a similar 
pattern to the above in terms of booleans). Seems to be present in gcc, clang, 
msvc and we have a safe fallback if it isn't.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102067

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


[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S

2021-05-07 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Ah, yes. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102065

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


[PATCH] D102064: Parse vector bool when stdbool.h and altivec.h are included

2021-05-07 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 343656.
ZarkoCA added a comment.

- update test cases to contain `_Bool` as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102064

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-bool.c

Index: clang/test/Parser/altivec-bool.c
===
--- /dev/null
+++ clang/test/Parser/altivec-bool.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only %s
+
+__vector bool char bc;
+__vector bool short bsh;
+__vector bool short int bshi;
+__vector bool int bi;
+__vector _Bool char bc;
+__vector _Bool short bsh;
+__vector _Bool short int bshi;
+__vector _Bool int bi;
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -503,6 +503,7 @@
 
   Ident_vector = nullptr;
   Ident_bool = nullptr;
+  Ident_Bool = nullptr;
   Ident_pixel = nullptr;
   if (getLangOpts().AltiVec || getLangOpts().ZVector) {
 Ident_vector = ().get("vector");
@@ -511,6 +512,9 @@
   if (getLangOpts().AltiVec)
 Ident_pixel = ().get("pixel");
 
+  if (getLangOpts().AltiVec)
+Ident_Bool = ().get("_Bool");
+
   Ident_introduced = nullptr;
   Ident_deprecated = nullptr;
   Ident_obsoleted = nullptr;
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -7318,6 +7318,7 @@
   case tok::kw_float:
   case tok::kw_double:
   case tok::kw_bool:
+  case tok::kw__Bool:
   case tok::kw___bool:
   case tok::kw___pixel:
 Tok.setKind(tok::kw___vector);
@@ -7327,7 +7328,8 @@
   Tok.setKind(tok::kw___vector);
   return true;
 }
-if (Next.getIdentifierInfo() == Ident_bool) {
+if ((Next.getIdentifierInfo() == Ident_bool) ||
+Next.getIdentifierInfo() == Ident_Bool) {
   Tok.setKind(tok::kw___vector);
   return true;
 }
@@ -7352,6 +7354,7 @@
 case tok::kw_float:
 case tok::kw_double:
 case tok::kw_bool:
+case tok::kw__Bool:
 case tok::kw___bool:
 case tok::kw___pixel:
   isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
@@ -7361,8 +7364,10 @@
 isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
 return true;
   }
-  if (Next.getIdentifierInfo() == Ident_bool) {
-isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
+  if (Next.getIdentifierInfo() == Ident_bool ||
+  Next.getIdentifierInfo() == Ident_Bool) {
+isInvalid =
+DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
 return true;
   }
   break;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -118,10 +118,12 @@
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
   IdentifierInfo *Ident_super;
-  /// Ident_vector, Ident_bool - cached IdentifierInfos for "vector" and
-  /// "bool" fast comparison.  Only present if AltiVec or ZVector are enabled.
+  /// Ident_vector, Ident_bool, Ident_Bool - cached IdentifierInfos for "vector"
+  /// and "bool" fast comparison.  Only present if AltiVec or ZVector are
+  /// enabled.
   IdentifierInfo *Ident_vector;
   IdentifierInfo *Ident_bool;
+  IdentifierInfo *Ident_Bool;
   /// Ident_pixel - cached IdentifierInfos for "pixel" fast comparison.
   /// Only present if AltiVec enabled.
   IdentifierInfo *Ident_pixel;
@@ -879,6 +881,7 @@
 
 if (Tok.getIdentifierInfo() != Ident_vector &&
 Tok.getIdentifierInfo() != Ident_bool &&
+Tok.getIdentifierInfo() != Ident_Bool &&
 (!getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
   return false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >