[llvm-branch-commits] [lld] 97319d3 - lld release notes: increased default max page size on arm

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2020-08-18T09:54:38+02:00
New Revision: 97319d39d143810e9b1d3ef1bf11009fd8df6571

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

LOG: lld release notes: increased default max page size on arm

By Tobias Hieta!

Added: 


Modified: 
lld/docs/ReleaseNotes.rst

Removed: 




diff  --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index f0482c2428c4..513ad37e278e 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -28,6 +28,10 @@ ELF Improvements
   chrome://tracing. The file can be specified with ``--time-trace-file``.
   Trace granularity can be specified with ``--time-trace-granularity``.
   (`D71060 `_)
+* For ARM architectures the default max page size was increased to 64k.
+  This increases compatibility with systems where a non standard page
+  size was configured. This also is inline with GNU ld defaults.
+  (`D77330 `_)
 * ...
 
 Breaking changes



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


[llvm-branch-commits] [llvm] da72df4 - [SVE] Fix bug in SVEIntrinsicOpts::optimizePTest

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: David Sherwood
Date: 2020-08-18T10:02:50+02:00
New Revision: da72df44005c909e40af867843168c4c456baa3d

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

LOG: [SVE] Fix bug in SVEIntrinsicOpts::optimizePTest

The code wasn't taking into account that the two operands
passed to ptest could be identical and was trying to erase
them twice.

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

(cherry picked from commit 6c7957c9901714b7ad0a8d2743a8c431b57fd0c9)

Added: 


Modified: 
llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp 
b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
index 74fe0cdd1ea7..0245dd1d611a 100644
--- a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
+++ b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
@@ -160,7 +160,7 @@ bool SVEIntrinsicOpts::optimizePTest(IntrinsicInst *I) {
 I->eraseFromParent();
 if (Op1->use_empty())
   Op1->eraseFromParent();
-if (Op2->use_empty())
+if (Op1 != Op2 && Op2->use_empty())
   Op2->eraseFromParent();
 
 return true;

diff  --git a/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll 
b/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
index 191fddacffd1..9af34676b342 100644
--- a/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
+++ b/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
@@ -44,6 +44,16 @@ define i1 @ptest_first( %a) {
   ret i1 %out
 }
 
+define i1 @ptest_first_same_ops( %a) {
+; OPT-LABEL: ptest_first_same_ops
+; OPT: %[[OUT:.*]] = call i1 @llvm.aarch64.sve.ptest.first.nxv2i1( %a,  %a)
+; OPT-NOT: convert
+; OPT-NEXT: ret i1 %[[OUT]]
+  %1 = tail call  
@llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  %2 = tail call i1 @llvm.aarch64.sve.ptest.first.nxv16i1( 
%1,  %1)
+  ret i1 %2
+}
+
 define i1 @ptest_last( %a) {
 ; OPT-LABEL: ptest_last
 ; OPT: %mask = tail call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 
0)



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


[llvm-branch-commits] [llvm] 8cf2c03 - [PowerPC] Make StartMI ignore COPY like instructions.

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Chen Zheng
Date: 2020-08-18T11:49:37+02:00
New Revision: 8cf2c031632f88a44eea68b48235496cf1c5d6ec

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

LOG: [PowerPC] Make StartMI ignore COPY like instructions.

Reviewed By: lkail

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

(cherry picked from commit 4d52ebb9b9c72b656c1ccb6a1424841f246cd791)

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
llvm/lib/Target/PowerPC/PPCInstrInfo.h
llvm/test/CodeGen/PowerPC/fixup-kill-dead-flag-crash.mir

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index 9a4c57fedac2..e428e7155e5e 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2653,22 +2653,35 @@ const unsigned 
*PPCInstrInfo::getLoadOpcodesForSpillArray() const {
   return LoadSpillOpcodesArray[getSpillTarget()];
 }
 
-void PPCInstrInfo::fixupIsDeadOrKill(MachineInstr &StartMI, MachineInstr 
&EndMI,
+void PPCInstrInfo::fixupIsDeadOrKill(MachineInstr *StartMI, MachineInstr 
*EndMI,
  unsigned RegNo) const {
   // Conservatively clear kill flag for the register if the instructions are in
   // 
diff erent basic blocks and in SSA form, because the kill flag may no longer
   // be right. There is no need to bother with dead flags since defs with no
   // uses will be handled by DCE.
-  MachineRegisterInfo &MRI = StartMI.getParent()->getParent()->getRegInfo();
-  if (MRI.isSSA() && (StartMI.getParent() != EndMI.getParent())) {
+  MachineRegisterInfo &MRI = StartMI->getParent()->getParent()->getRegInfo();
+  if (MRI.isSSA() && (StartMI->getParent() != EndMI->getParent())) {
 MRI.clearKillFlags(RegNo);
 return;
   }
 
   // Instructions between [StartMI, EndMI] should be in same basic block.
-  assert((StartMI.getParent() == EndMI.getParent()) &&
+  assert((StartMI->getParent() == EndMI->getParent()) &&
  "Instructions are not in same basic block");
 
+  // If before RA, StartMI may be def through COPY, we need to adjust it to the
+  // real def. See function getForwardingDefMI.
+  if (MRI.isSSA()) {
+bool Reads, Writes;
+std::tie(Reads, Writes) = StartMI->readsWritesVirtualRegister(RegNo);
+if (!Reads && !Writes) {
+  assert(Register::isVirtualRegister(RegNo) &&
+ "Must be a virtual register");
+  // Get real def and ignore copies.
+  StartMI = MRI.getVRegDef(RegNo);
+}
+  }
+
   bool IsKillSet = false;
 
   auto clearOperandKillInfo = [=] (MachineInstr &MI, unsigned Index) {
@@ -2681,21 +2694,21 @@ void PPCInstrInfo::fixupIsDeadOrKill(MachineInstr 
&StartMI, MachineInstr &EndMI,
   // Set killed flag for EndMI.
   // No need to do anything if EndMI defines RegNo.
   int UseIndex =
-  EndMI.findRegisterUseOperandIdx(RegNo, false, &getRegisterInfo());
+  EndMI->findRegisterUseOperandIdx(RegNo, false, &getRegisterInfo());
   if (UseIndex != -1) {
-EndMI.getOperand(UseIndex).setIsKill(true);
+EndMI->getOperand(UseIndex).setIsKill(true);
 IsKillSet = true;
 // Clear killed flag for other EndMI operands related to RegNo. In some
 // upexpected cases, killed may be set multiple times for same register
 // operand in same MI.
-for (int i = 0, e = EndMI.getNumOperands(); i != e; ++i)
+for (int i = 0, e = EndMI->getNumOperands(); i != e; ++i)
   if (i != UseIndex)
-clearOperandKillInfo(EndMI, i);
+clearOperandKillInfo(*EndMI, i);
   }
 
   // Walking the inst in reverse order (EndMI -> StartMI].
-  MachineBasicBlock::reverse_iterator It = EndMI;
-  MachineBasicBlock::reverse_iterator E = EndMI.getParent()->rend();
+  MachineBasicBlock::reverse_iterator It = *EndMI;
+  MachineBasicBlock::reverse_iterator E = EndMI->getParent()->rend();
   // EndMI has been handled above, skip it here.
   It++;
   MachineOperand *MO = nullptr;
@@ -2721,13 +2734,13 @@ void PPCInstrInfo::fixupIsDeadOrKill(MachineInstr 
&StartMI, MachineInstr &EndMI,
   } else if ((MO = It->findRegisterDefOperand(RegNo, false, true,
   &getRegisterInfo( {
 // No use found, set dead for its def.
-assert(&*It == &StartMI && "No new def between StartMI and EndMI.");
+assert(&*It == StartMI && "No new def between StartMI and EndMI.");
 MO->setIsDead(true);
 break;
   }
 }
 
-if ((&*It) == &StartMI)
+if ((&*It) == StartMI)
   break;
   }
   // Ensure RegMo liveness is killed after EndMI.
@@ -3858,7 +3871,7 @@ bool PPCInstrInfo::simplifyToLI(MachineInstr &MI, 
MachineInstr &DefMI,
 // ForwardingOperandReg = LI imm1
 // y = op2 imm2, ForwardingOperandReg(killed)
 if (Is

[llvm-branch-commits] [flang] 6338655 - [flang] Add -h as a synonym for help

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Richard Barton
Date: 2020-08-18T11:58:47+02:00
New Revision: 633865571bfdd104d84eadfd7ed9dedbdf6027ee

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

LOG: [flang] Add -h as a synonym for help

As expected by user in 
http://lists.llvm.org/pipermail/flang-dev/2020-June/000404.html

Depends on D84856

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

(cherry picked from commit 30e45f339eb0841dc7fe27fad119cc5db0c052f3)

Added: 


Modified: 
flang/test/Driver/help.f90
flang/tools/f18/f18.cpp

Removed: 




diff  --git a/flang/test/Driver/help.f90 b/flang/test/Driver/help.f90
index 66dd14aa5a86..d6162954a872 100644
--- a/flang/test/Driver/help.f90
+++ b/flang/test/Driver/help.f90
@@ -1,3 +1,4 @@
+! RUN: %f18 -h 2>&1 | FileCheck %s
 ! RUN: %f18 -help 2>&1 | FileCheck %s
 ! RUN: %f18 --help 2>&1 | FileCheck %s
 ! RUN: %f18 -? 2>&1 | FileCheck %s

diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 9189f6a46aff..03c0f7afe810 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -600,7 +600,7 @@ int main(int argc, char *const argv[]) {
   driver.getDefinitionArgs = {arguments[0], arguments[1], arguments[2]};
 } else if (arg == "-fget-symbols-sources") {
   driver.getSymbolsSources = true;
-} else if (arg == "-help" || arg == "--help" || arg == "-?") {
+} else if (arg == "-h" || arg == "-help" || arg == "--help" || arg == 
"-?") {
   llvm::errs()
   << "f18: LLVM Fortran compiler\n"
   << "\n"



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


[llvm-branch-commits] [flang] 844f018 - [flang] Version information in flang/f18

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Camille Coti
Date: 2020-08-18T11:58:55+02:00
New Revision: 844f018114b52325b36e1042c8a8fc0ea82d9c17

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

LOG: [flang] Version information in flang/f18

Fixed some version information in flang/f18:

  - fixed the behavior of the -v switch: this flag enables verbosity with used 
with arguments, but just displays the version when used alone (related to this 
bug: https://bugs.llvm.org/show_bug.cgi?id=46017)
 - added __FLANG, __FLANG_MAJOR__, __FLANG_MINOR__ and __FLANG_PATCHLEVEL__ 
(similar to their __F18* counterparts) for compatibility purpose

Reviewed By: sscalpone, AlexisPerry, richard.barton.arm, tskeith

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

(cherry picked from commit 89a9db438f85c6d4c0f11ecd0448bb71e1deac24)

Added: 
flang/test/Preprocessing/compiler_defined_macros.F90
flang/tools/f18/f18_version.h.in

Modified: 
flang/test/Driver/version_test.f90
flang/tools/f18/CMakeLists.txt
flang/tools/f18/f18.cpp

Removed: 




diff  --git a/flang/test/Driver/version_test.f90 
b/flang/test/Driver/version_test.f90
index 08ea35ba49ea..7fe229e2be17 100644
--- a/flang/test/Driver/version_test.f90
+++ b/flang/test/Driver/version_test.f90
@@ -1,7 +1,10 @@
 ! Check that lit configuration works by checking the compiler version
 
-! RUN: %f18 -V 2>&1 | FileCheck  -check-prefix=VERSION %s
 ! VERSION-NOT:{{![[:space:]]}}
 ! VERSION:{{[[:space:]]}}
-! VERSION-SAME:f18 compiler (under development)
+! VERSION-SAME:f18 compiler (under development), version 
{{[1-9][0-9]*.[0-9]*.[0-9]*}}
 ! VERSION-EMPTY:
+
+! RUN: %f18 -V 2>&1 | FileCheck  -check-prefix=VERSION %s
+! RUN: %f18 -v 2>&1 | FileCheck  -check-prefix=VERSION %s
+! RUN: %f18 --version 2>&1 | FileCheck  -check-prefix=VERSION %s

diff  --git a/flang/test/Preprocessing/compiler_defined_macros.F90 
b/flang/test/Preprocessing/compiler_defined_macros.F90
new file mode 100644
index ..80852cfb4472
--- /dev/null
+++ b/flang/test/Preprocessing/compiler_defined_macros.F90
@@ -0,0 +1,12 @@
+! Check that the macros that give the verion number are set properly
+
+!CHECK: flang_major = {{[1-9][0-9]*$}}
+!CHECK: flang_minor = {{[0-9]+$}}
+!CHECK: flang_patchlevel = {{[0-9]+$}}
+!RUN: %f18 -E %s | FileCheck  --ignore-case %s
+
+  
+integer, parameter :: flang_major = __flang_major__
+integer, parameter :: flang_minor = __flang_minor__
+integer, parameter :: flang_patchlevel = __flang_patchlevel__
+

diff  --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 46c38fa43a2e..3dfce3437948 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -64,5 +64,6 @@ file(COPY ${CMAKE_BINARY_DIR}/tools/flang/bin/flang 
DESTINATION ${CMAKE_BINARY_D
 # The flang script to be installed needs a 
diff erent path to the headers.
 set(FLANG_INTRINSIC_MODULES_DIR ${CMAKE_INSTALL_PREFIX}/include/flang)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in 
${FLANG_BINARY_DIR}/bin/flang-install.sh @ONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/f18_version.h.in 
${CMAKE_CURRENT_BINARY_DIR}/f18_version.h @ONLY)
 
 install(PROGRAMS ${FLANG_BINARY_DIR}/bin/flang-install.sh DESTINATION bin 
RENAME flang PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)

diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 03c0f7afe810..23b104ee520c 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -38,6 +38,8 @@
 #include 
 #include 
 
+#include "f18_version.h"
+
 static std::list argList(int argc, char *const argv[]) {
   std::list result;
   for (int j = 0; j < argc; ++j) {
@@ -390,6 +392,13 @@ void Link(std::vector &liblist, 
std::vector &objects,
   }
 }
 
+int printVersion() {
+  llvm::errs() << "\nf18 compiler (under development), version "
+   << __FLANG_MAJOR__ << "." << __FLANG_MINOR__ << "."
+   << __FLANG_PATCHLEVEL__ << "\n";
+  return exitStatus;
+}
+
 int main(int argc, char *const argv[]) {
 
   atexit(CleanUpAtExit);
@@ -411,6 +420,11 @@ int main(int argc, char *const argv[]) {
   options.predefinitions.emplace_back("__F18_MAJOR__", "1");
   options.predefinitions.emplace_back("__F18_MINOR__", "1");
   options.predefinitions.emplace_back("__F18_PATCHLEVEL__", "1");
+  options.predefinitions.emplace_back("__flang__", __FLANG__);
+  options.predefinitions.emplace_back("__flang_major__", __FLANG_MAJOR__);
+  options.predefinitions.emplace_back("__flang_minor__", __FLANG_MINOR__);
+  options.predefinitions.emplace_back(
+  "__flang_patchlevel__", __FLANG_PATCHLEVEL__);
 #if __x86_64__
   options.predefinitions.emplace_back("__x86_64__", "1");
 #endif
@@ -651,13 +665,16 @@ int main(int argc, char *const argv[]) {
   << "Unrecognised options are passed through to the 

[llvm-branch-commits] [flang] 4ad21aa - [flang] Add details to --help screen on default behaviour

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Richard Barton
Date: 2020-08-18T11:58:20+02:00
New Revision: 4ad21aadae561b95cc9d4bb98e91499cb5342367

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

LOG: [flang] Add details to --help screen on default behaviour

Add a usage string and a defaults section that clarifies:
 * If no input files are given, f18 reads from stdin
 * If no input files are given, f18 dumps the parse tree.
 * The default behaviour is to exec F18_FC.
 * The fefault F18_FC setting is 'gfortran'

Adds a simple regression test which tests the top and tail of the help
screen and the exit status.

Depends on D84855

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

(cherry picked from commit b068d19a151d9d3a73b0265df27836d9fd0ad1e3)

Added: 
flang/test/Driver/help.f90

Modified: 
flang/tools/f18/f18.cpp

Removed: 




diff  --git a/flang/test/Driver/help.f90 b/flang/test/Driver/help.f90
new file mode 100644
index ..66dd14aa5a86
--- /dev/null
+++ b/flang/test/Driver/help.f90
@@ -0,0 +1,9 @@
+! RUN: %f18 -help 2>&1 | FileCheck %s
+! RUN: %f18 --help 2>&1 | FileCheck %s
+! RUN: %f18 -? 2>&1 | FileCheck %s
+
+! CHECK: f18: LLVM Fortran compiler
+
+! CHECK:   -helpprint this again
+! CHECK: Unrecognised options are passed through to the external compiler
+! CHECK: set by F18_FC (see defaults).

diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 83db520d8ff9..9189f6a46aff 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -602,6 +602,19 @@ int main(int argc, char *const argv[]) {
   driver.getSymbolsSources = true;
 } else if (arg == "-help" || arg == "--help" || arg == "-?") {
   llvm::errs()
+  << "f18: LLVM Fortran compiler\n"
+  << "\n"
+  << "Usage: f18 [options] \n"
+  << "\n"
+  << "Defaults:\n"
+  << "  When invoked with input files, and no options to tell\n"
+  << "  it otherwise, f18 will unparse its input and pass that on to 
an\n"
+  << "  external compiler to continue the compilation.\n"
+  << "  The external compiler is specified by the F18_FC environment\n"
+  << "  variable. The default is 'gfortran'.\n"
+  << "  If invoked with no input files, f18 reads source code from\n"
+  << "  stdin and runs with -fdebug-measure-parse-tree -funparse.\n"
+  << "\n"
   << "f18 options:\n"
   << "  -Mfixed | -Mfree | -ffixed-form | -ffree-form   force the "
  "source form\n"
@@ -635,7 +648,8 @@ int main(int argc, char *const argv[]) {
   << "  -fget-symbols-sources\n"
   << "  -v -c -o -I -D -Uhave their usual meanings\n"
   << "  -helpprint this again\n"
-  << "Other options are passed through to the compiler.\n";
+  << "Unrecognised options are passed through to the external 
compiler\n"
+  << "set by F18_FC (see defaults).\n";
   return exitStatus;
 } else if (arg == "-V") {
   llvm::errs() << "\nf18 compiler (under development)\n";



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


[llvm-branch-commits] [flang] dfc8459 - [flang] Make interactive behaviour more obvious

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Richard Barton
Date: 2020-08-18T11:58:20+02:00
New Revision: dfc845904b27d5da3b6ae7a389ade01590454331

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

LOG: [flang] Make interactive behaviour more obvious

When flang is invoked with no files it waits for input on stdin. Make it
print a message saying this to prevent the user being surprised.

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

(cherry picked from commit dd5ea5674b86bade4904fab4c66a1156b3df033e)

Added: 
flang/test/Driver/Inputs/hello.f90
flang/test/Driver/no_files.f90

Modified: 
flang/tools/f18/f18.cpp

Removed: 




diff  --git a/flang/test/Driver/Inputs/hello.f90 
b/flang/test/Driver/Inputs/hello.f90
new file mode 100644
index ..d0c7eb94f53c
--- /dev/null
+++ b/flang/test/Driver/Inputs/hello.f90
@@ -0,0 +1,3 @@
+program hello
+  write (*,*), "hello world" 
+end program hello

diff  --git a/flang/test/Driver/no_files.f90 b/flang/test/Driver/no_files.f90
new file mode 100644
index ..718985dce4ca
--- /dev/null
+++ b/flang/test/Driver/no_files.f90
@@ -0,0 +1,10 @@
+! RUN: %f18 < %S/Inputs/hello.f90 | FileCheck %s
+
+
+! CHECK: Enter Fortran source
+! CHECK: Use EOF character (^D) to end file
+
+! CHECK: Parse tree comprises {{.*}} objects and occupies {{.*}} total bytes
+! CHECK: PROGRAM hello
+! CHECK:  WRITE (*, *) "hello world"
+! CHECK: END PROGRAM hello

diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 77af3964bba8..83db520d8ff9 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -683,6 +683,8 @@ int main(int argc, char *const argv[]) {
   if (!anyFiles) {
 driver.measureTree = true;
 driver.dumpUnparse = true;
+llvm::outs() << "Enter Fortran source\n"
+ << "Use EOF character (^D) to end file\n";
 CompileFortran("-", options, driver, defaultKinds);
 return exitStatus;
   }



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


[llvm-branch-commits] [flang] 556e65b - Order of libraries and source files in the f18 frontend

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Camille Coti
Date: 2020-08-18T11:58:19+02:00
New Revision: 556e65b8e9a1ca5d2a62fa397a7fa5eee5b58ac4

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

LOG: Order of libraries and source files in the f18 frontend

When the f18 frontend calls the link editor, put the libraries and object files 
in the correct order.

Fixes the issues reported here 
https://github.com/flang-compiler/flang/issues/897

Reviewed By: sscalpone, AlexisPerry

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

(cherry picked from commit ca0bf440dbf9977340db4a32ba61740930c2be03)

Added: 


Modified: 
flang/tools/f18/f18.cpp

Removed: 




diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 884b21322b73..77af3964bba8 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -368,20 +368,24 @@ std::string CompileOtherLanguage(std::string path, 
DriverOptions &driver) {
   return {};
 }
 
-void Link(std::vector &relocatables, DriverOptions &driver) {
+void Link(std::vector &liblist, std::vector &objects,
+DriverOptions &driver) {
   if (!ParentProcess()) {
 std::vector argv;
 for (size_t j{0}; j < driver.F18_FCArgs.size(); ++j) {
   argv.push_back(driver.F18_FCArgs[j].data());
 }
-for (auto &relo : relocatables) {
-  argv.push_back(relo.data());
+for (auto &obj : objects) {
+  argv.push_back(obj.data());
 }
 if (!driver.outputPath.empty()) {
   char dashO[3] = "-o";
   argv.push_back(dashO);
   argv.push_back(driver.outputPath.data());
 }
+for (auto &lib : liblist) {
+  argv.push_back(lib.data());
+}
 Exec(argv, driver.verbose);
   }
 }
@@ -396,6 +400,7 @@ int main(int argc, char *const argv[]) {
   bool isPGF90{driver.F18_FCArgs.back().rfind("pgf90") != std::string::npos};
 
   std::list args{argList(argc, argv)};
+  std::vector objlist, liblist;
   std::string prefix{args.front()};
   args.pop_front();
   prefix += ": ";
@@ -412,32 +417,37 @@ int main(int argc, char *const argv[]) {
 
   Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;
 
-  std::vector fortranSources, otherSources, relocatables;
+  std::vector fortranSources, otherSources;
   bool anyFiles{false};
 
   while (!args.empty()) {
 std::string arg{std::move(args.front())};
+auto dot{arg.rfind(".")};
+std::string suffix{arg.substr(dot + 1)};
+std::string prefix{arg.substr(0, 2)};
 args.pop_front();
 if (arg.empty()) {
 } else if (arg.at(0) != '-') {
   anyFiles = true;
-  auto dot{arg.rfind(".")};
   if (dot == std::string::npos) {
 driver.F18_FCArgs.push_back(arg);
   } else {
-std::string suffix{arg.substr(dot + 1)};
 if (suffix == "f" || suffix == "F" || suffix == "ff" ||
 suffix == "f90" || suffix == "F90" || suffix == "ff90" ||
 suffix == "f95" || suffix == "F95" || suffix == "ff95" ||
 suffix == "cuf" || suffix == "CUF" || suffix == "f18" ||
 suffix == "F18" || suffix == "ff18") {
   fortranSources.push_back(arg);
-} else if (suffix == "o" || suffix == "a") {
-  relocatables.push_back(arg);
+} else if (suffix == "o" || suffix == "so") {
+  objlist.push_back(arg);
+} else if (suffix == "a") {
+  liblist.push_back(arg);
 } else {
   otherSources.push_back(arg);
 }
   }
+} else if (prefix == "-l" || suffix == "a") {
+  liblist.push_back(arg);
 } else if (arg == "-") {
   fortranSources.push_back("-");
 } else if (arg == "--") {
@@ -679,17 +689,17 @@ int main(int argc, char *const argv[]) {
   for (const auto &path : fortranSources) {
 std::string relo{CompileFortran(path, options, driver, defaultKinds)};
 if (!driver.compileOnly && !relo.empty()) {
-  relocatables.push_back(relo);
+  objlist.push_back(relo);
 }
   }
   for (const auto &path : otherSources) {
 std::string relo{CompileOtherLanguage(path, driver)};
 if (!driver.compileOnly && !relo.empty()) {
-  relocatables.push_back(relo);
+  objlist.push_back(relo);
 }
   }
-  if (!relocatables.empty()) {
-Link(relocatables, driver);
+  if (!objlist.empty()) {
+Link(liblist, objlist, driver);
   }
   return exitStatus;
 }



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


[llvm-branch-commits] [flang] cea0ff3 - [flang] Temp Driver - pass the flag to change the default integer kind through to F18_FC

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: AlexisPerry
Date: 2020-08-18T11:58:19+02:00
New Revision: cea0ff34238d164a5d667898bbedf18f0d3ad11e

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

LOG: [flang] Temp Driver - pass the flag to change the default integer kind 
through to F18_FC

fixes BUG 46307

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

(cherry picked from commit 4a4cafabc9067fced5890a245b03ef5897ad988b)

Added: 


Modified: 
flang/tools/f18/f18.cpp

Removed: 




diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 574a37074e52..884b21322b73 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -544,6 +544,11 @@ int main(int argc, char *const argv[]) {
   defaultKinds.set_defaultIntegerKind(8);
   defaultKinds.set_subscriptIntegerKind(8);
   defaultKinds.set_sizeIntegerKind(8);
+  if (isPGF90) {
+driver.F18_FCArgs.push_back("-i8");
+  } else {
+driver.F18_FCArgs.push_back("-fdefault-integer-8");
+  }
 } else if (arg == "-Mlargearray") {
 } else if (arg == "-Mnolargearray") {
 } else if (arg == "-flarge-sizes") {



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


[llvm-branch-commits] [clang] 529b222 - [Driver] Change -fnostack-clash-protection to -fno-stack-clash-protection

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Dávid Bolvanský
Date: 2020-08-18T12:15:14+02:00
New Revision: 529b2229acb25f005633d43cdb67e0ee093b45e6

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

LOG: [Driver] Change -fnostack-clash-protection to  -fno-stack-clash-protection

Clang command line docs mention `-fno-stack-clash-protection`, and GCC also 
uses  -fno-stack-clash-protection.

Fixes PR47139

Reviewed By: tstellar

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

(cherry picked from commit df3bfaa39071a1382a59a94658ee1a2da30d92fd)

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/stack-clash-protection.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b20b8a288221..f818acb39d51 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1780,7 +1780,7 @@ def fstack_protector_all : Flag<["-"], 
"fstack-protector-all">, Group,
   HelpText<"Enable stack protectors for all functions">;
 def fstack_clash_protection : Flag<["-"], "fstack-clash-protection">, 
Group, Flags<[CC1Option]>,
   HelpText<"Enable stack clash protection">;
-def fnostack_clash_protection : Flag<["-"], "fnostack-clash-protection">, 
Group,
+def fno_stack_clash_protection : Flag<["-"], "fno-stack-clash-protection">, 
Group,
   HelpText<"Disable stack clash protection">;
 def fstack_protector_strong : Flag<["-"], "fstack-protector-strong">, 
Group,
   HelpText<"Enable stack protectors for some functions vulnerable to stack 
smashing. "

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 25fc837e803b..828606bbd0f0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2971,7 +2971,7 @@ static void RenderSCPOptions(const ToolChain &TC, const 
ArgList &Args,
 return;
 
   if (Args.hasFlag(options::OPT_fstack_clash_protection,
-   options::OPT_fnostack_clash_protection, false))
+   options::OPT_fno_stack_clash_protection, false))
 CmdArgs.push_back("-fstack-clash-protection");
 }
 

diff  --git a/clang/test/Driver/stack-clash-protection.c 
b/clang/test/Driver/stack-clash-protection.c
index a2cf3f82a8fd..5217ed26a5b1 100644
--- a/clang/test/Driver/stack-clash-protection.c
+++ b/clang/test/Driver/stack-clash-protection.c
@@ -1,6 +1,6 @@
 // RUN: %clang -target i386-unknown-linux -fstack-clash-protection -### %s 
2>&1 | FileCheck %s -check-prefix=SCP-i386
-// RUN: %clang -target i386-unknown-linux -fnostack-clash-protection 
-fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-i386
-// RUN: %clang -target i386-unknown-linux -fstack-clash-protection 
-fnostack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-i386-NO
+// RUN: %clang -target i386-unknown-linux -fno-stack-clash-protection 
-fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-i386
+// RUN: %clang -target i386-unknown-linux -fstack-clash-protection 
-fno-stack-clash-protection -### %s 2>&1 | FileCheck %s 
-check-prefix=SCP-i386-NO
 // SCP-i386: "-fstack-clash-protection"
 // SCP-i386-NO-NOT: "-fstack-clash-protection"
 



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


[llvm-branch-commits] [llvm] 522eeb6 - [InstCombine] Sanitize undef vector constant to 1 in X*(2^C) with X << C (PR47133)

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-08-18T12:26:01+02:00
New Revision: 522eeb66edfb0d6c4656d3f7a3f635544def30db

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

LOG: [InstCombine] Sanitize undef vector constant to 1 in  X*(2^C) with X << C 
(PR47133)

While x*undef is undef, shift-by-undef is poison,
which we must avoid introducing.

Also log2(iN undef) is *NOT* iN undef, because log2(iN undef) u< N.

See https://bugs.llvm.org/show_bug.cgi?id=47133

(cherry picked from commit 12d93a27e7b78d58dd00817cb737f273d2dba8ae)

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/getelementptr.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index c6233a68847d..2f1325e80d2f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -216,7 +216,11 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
 
 if (match(&I, m_Mul(m_Value(NewOp), m_Constant(C1 {
   // Replace X*(2^C) with X << C, where C is either a scalar or a vector.
-  if (Constant *NewCst = getLogBase2(NewOp->getType(), C1)) {
+  // Note that we need to sanitize undef multipliers to 1,
+  // to avoid introducing poison.
+  Constant *SafeC1 = Constant::replaceUndefsWith(
+  C1, ConstantInt::get(C1->getType()->getScalarType(), 1));
+  if (Constant *NewCst = getLogBase2(NewOp->getType(), SafeC1)) {
 BinaryOperator *Shl = BinaryOperator::CreateShl(NewOp, NewCst);
 
 if (I.hasNoUnsignedWrap())

diff  --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index 0257725d12de..17362b088241 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -216,7 +216,7 @@ define <2 x i1> @test13_vector(<2 x i64> %X, <2 x %S*> %P) 
nounwind {
 define <2 x i1> @test13_vector2(i64 %X, <2 x %S*> %P) nounwind {
 ; CHECK-LABEL: @test13_vector2(
 ; CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <2 x i64> undef, i64 
[[X:%.*]], i32 0
-; CHECK-NEXT:[[TMP1:%.*]] = shl <2 x i64> [[DOTSPLATINSERT]], 
+; CHECK-NEXT:[[TMP1:%.*]] = shl <2 x i64> [[DOTSPLATINSERT]], 
 ; CHECK-NEXT:[[TMP2:%.*]] = icmp eq <2 x i64> [[TMP1]], 
 ; CHECK-NEXT:[[C:%.*]] = shufflevector <2 x i1> [[TMP2]], <2 x i1> undef, 
<2 x i32> zeroinitializer
 ; CHECK-NEXT:ret <2 x i1> [[C]]
@@ -231,7 +231,7 @@ define <2 x i1> @test13_vector2(i64 %X, <2 x %S*> %P) 
nounwind {
 define <2 x i1> @test13_vector3(i64 %X, <2 x %S*> %P) nounwind {
 ; CHECK-LABEL: @test13_vector3(
 ; CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <2 x i64> undef, i64 
[[X:%.*]], i32 0
-; CHECK-NEXT:[[TMP1:%.*]] = shl <2 x i64> [[DOTSPLATINSERT]], 
+; CHECK-NEXT:[[TMP1:%.*]] = shl <2 x i64> [[DOTSPLATINSERT]], 
 ; CHECK-NEXT:[[TMP2:%.*]] = icmp eq <2 x i64> [[TMP1]], 
 ; CHECK-NEXT:[[C:%.*]] = shufflevector <2 x i1> [[TMP2]], <2 x i1> undef, 
<2 x i32> zeroinitializer
 ; CHECK-NEXT:ret <2 x i1> [[C]]



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


[llvm-branch-commits] [clang] d9b3d75 - [WebAssembly] Don't depend on the flags set by handleTargetFeatures in initFeatureMap.

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Craig Topper
Date: 2020-08-18T12:27:57+02:00
New Revision: d9b3d7557a8e98f91cca6f1ce2b1f1f784eaa355

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

LOG: [WebAssembly] Don't depend on the flags set by handleTargetFeatures in 
initFeatureMap.

Properly set "simd128" in the feature map when "unimplemented-simd128"
is requested.

initFeatureMap is used to create the feature vector used by
handleTargetFeatures. There are later calls to initFeatureMap in
CodeGen that were using these flags to recreate the map. But the
original feature vector should be passed to those calls. So that
should be enough to rebuild the map.

The only issue seemed to be that simd128 was not enabled in the
map by the first call to initFeatureMap. Using the SIMDLevel set
by handleTargetFeatures in the later calls allowed simd128 to be
set in the later versions of the map.

To fix this I've added an override of setFeatureEnabled that
will update the map the first time with the correct simd dependency.

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

(cherry picked from commit 2b8ad6b6040833f4f8702721ebaa7749e5c23e60)

Added: 


Modified: 
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 6746768090f5..dcb3d8fd7790 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -96,19 +96,43 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
 }
 
 void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features,
- SIMDEnum Level) {
+ SIMDEnum Level, bool Enabled) {
+  if (Enabled) {
+switch (Level) {
+case UnimplementedSIMD128:
+  Features["unimplemented-simd128"] = true;
+  LLVM_FALLTHROUGH;
+case SIMD128:
+  Features["simd128"] = true;
+  LLVM_FALLTHROUGH;
+case NoSIMD:
+  break;
+}
+return;
+  }
+
   switch (Level) {
-  case UnimplementedSIMD128:
-Features["unimplemented-simd128"] = true;
-LLVM_FALLTHROUGH;
+  case NoSIMD:
   case SIMD128:
-Features["simd128"] = true;
+Features["simd128"] = false;
 LLVM_FALLTHROUGH;
-  case NoSIMD:
+  case UnimplementedSIMD128:
+Features["unimplemented-simd128"] = false;
 break;
   }
 }
 
+void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap &Features,
+  StringRef Name,
+  bool Enabled) const {
+  if (Name == "simd128")
+setSIMDLevel(Features, SIMD128, Enabled);
+  else if (Name == "unimplemented-simd128")
+setSIMDLevel(Features, UnimplementedSIMD128, Enabled);
+  else
+Features[Name] = Enabled;
+}
+
 bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
 const std::vector &FeaturesVec) const {
@@ -119,30 +143,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
 Features["atomics"] = true;
 Features["mutable-globals"] = true;
 Features["tail-call"] = true;
-setSIMDLevel(Features, SIMD128);
+setSIMDLevel(Features, SIMD128, true);
   }
-  // Other targets do not consider user-configured features here, but while we
-  // are actively developing new features it is useful to let user-configured
-  // features control availability of builtins
-  setSIMDLevel(Features, SIMDLevel);
-  if (HasNontrappingFPToInt)
-Features["nontrapping-fptoint"] = true;
-  if (HasSignExt)
-Features["sign-ext"] = true;
-  if (HasExceptionHandling)
-Features["exception-handling"] = true;
-  if (HasBulkMemory)
-Features["bulk-memory"] = true;
-  if (HasAtomics)
-Features["atomics"] = true;
-  if (HasMutableGlobals)
-Features["mutable-globals"] = true;
-  if (HasMultivalue)
-Features["multivalue"] = true;
-  if (HasTailCall)
-Features["tail-call"] = true;
-  if (HasReferenceTypes)
-Features["reference-types"] = true;
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }

diff  --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index 77a2fe9ae117..0068ccb5d71f 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -69,7 +69,8 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public 
TargetInfo {
 MacroBuilder &Builder) const override;
 
 private:
-  static void setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level);
+  static void setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level,
+   bool Enabled);
 
   bool
   initFeatureMap(llvm::StringMap &

[llvm-branch-commits] [clang] 2d01032 - [Target] Cache the command line derived feature map in TargetOptions.

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Craig Topper
Date: 2020-08-18T12:32:20+02:00
New Revision: 2d010325ea233fc97e61c00806b46ab2abab3a94

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

LOG: [Target] Cache the command line derived feature map in TargetOptions.

We can use this to remove some calls to initFeatureMap from Sema
and CodeGen when a function doesn't have a target attribute.

This reduces compile time of the linux kernel where this map
is needed to diagnose some inline assembly constraints based
on whether sse, avx, or avx512 is enabled.

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

(cherry picked from commit 5c1fe4e20f887286baac6989943a0875e12834fe)

Added: 


Modified: 
clang/include/clang/Basic/TargetOptions.h
clang/lib/AST/ASTContext.cpp
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetOptions.h 
b/clang/include/clang/Basic/TargetOptions.h
index bbe86aebb074..4a5d469b8e54 100644
--- a/clang/include/clang/Basic/TargetOptions.h
+++ b/clang/include/clang/Basic/TargetOptions.h
@@ -54,6 +54,10 @@ class TargetOptions {
   /// be a list of strings starting with by '+' or '-'.
   std::vector Features;
 
+  /// The map of which features have been enabled disabled based on the command
+  /// line.
+  llvm::StringMap FeatureMap;
+
   /// Supported OpenCL extensions and optional core features.
   OpenCLOptions SupportedOpenCLOptions;
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 2ba643f12a82..e3798bb46e86 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11147,8 +11147,7 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 std::vector Features(FeaturesTmp.begin(), FeaturesTmp.end());
 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
   } else {
-Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU,
-   Target->getTargetOpts().Features);
+FeatureMap = Target->getTargetOpts().FeatureMap;
   }
 }
 

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 6bbcafa27dfe..206fb9b3f1a2 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -662,14 +662,13 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
 
   // Compute the default target features, we need the target to handle this
   // because features may have dependencies on one another.
-  llvm::StringMap Features;
-  if (!Target->initFeatureMap(Features, Diags, Opts->CPU,
+  if (!Target->initFeatureMap(Opts->FeatureMap, Diags, Opts->CPU,
   Opts->FeaturesAsWritten))
 return nullptr;
 
   // Add the features to the compile options.
   Opts->Features.clear();
-  for (const auto &F : Features)
+  for (const auto &F : Opts->FeatureMap)
 Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
   // Sort here, so we handle the features in a predictable order. (This matters
   // when we're dealing with features that overlap.)

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
index ac6ec742335c..1f79b33772f3 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4956,11 +4956,7 @@ bool 
CGOpenMPRuntimeNVPTX::hasAllocateAttributeForGlobalVar(const VarDecl *VD,
 static CudaArch getCudaArch(CodeGenModule &CGM) {
   if (!CGM.getTarget().hasFeature("ptx"))
 return CudaArch::UNKNOWN;
-  llvm::StringMap Features;
-  CGM.getTarget().initFeatureMap(Features, CGM.getDiags(),
- CGM.getTarget().getTargetOpts().CPU,
- CGM.getTarget().getTargetOpts().Features);
-  for (const auto &Feature : Features) {
+  for (const auto &Feature : CGM.getTarget().getTargetOpts().FeatureMap) {
 if (Feature.getValue()) {
   CudaArch Arch = StringToCudaArch(Feature.getKey());
   if (Arch != CudaArch::UNKNOWN)



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


[llvm-branch-commits] [llvm] 536f65f - [X86] Optimize getImpliedDisabledFeatures & getImpliedEnabledFeatures after D83273

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Fangrui Song
Date: 2020-08-18T12:37:17+02:00
New Revision: 536f65f47fcb314f269355c4001c0f2b4744c0b6

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

LOG: [X86] Optimize getImpliedDisabledFeatures & getImpliedEnabledFeatures 
after D83273

Previously the time complexity is O(|number of paths from the root to an
implied feature| * CPU_FWATURE_MAX) where CPU_FEATURE_MAX is 92.

The number of paths can be large (theoretically exponential).

For an inline asm statement, there is a code path
`clang::Parser::ParseAsmStatement -> clang::Sema::ActOnGCCAsmStmt -> 
ASTContext::getFunctionFeatureMap`
leading to potentially many calls of getImpliedEnabledFeatures (41 for my 
-march=native case).

We should improve the performance a bit in case the number of inline asm
statements is large (Linux kernel builds).

Reviewed By: craig.topper

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

(cherry picked from commit 0c7af8c83bd1acb0ca78f35ddde29b6fde4363a0)

Added: 


Modified: 
llvm/lib/Support/X86TargetParser.cpp

Removed: 




diff  --git a/llvm/lib/Support/X86TargetParser.cpp 
b/llvm/lib/Support/X86TargetParser.cpp
index 572d1203aaf2..c629f872df12 100644
--- a/llvm/lib/Support/X86TargetParser.cpp
+++ b/llvm/lib/Support/X86TargetParser.cpp
@@ -37,6 +37,10 @@ class FeatureBitset {
   set(I);
   }
 
+  bool any() const {
+return llvm::any_of(Bits, [](uint64_t V) { return V != 0; });
+  }
+
   constexpr FeatureBitset &set(unsigned I) {
 // GCC <6.2 crashes if this is written in a single statement.
 uint32_t NewBits = Bits[I / 32] | (uint32_t(1) << (I % 32));
@@ -89,6 +93,13 @@ class FeatureBitset {
   Result.Bits[I] = ~Bits[I];
 return Result;
   }
+
+  constexpr bool operator!=(const FeatureBitset &RHS) const {
+for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I)
+  if (Bits[I] != RHS.Bits[I])
+return true;
+return false;
+  }
 };
 
 struct ProcInfo {
@@ -552,11 +563,17 @@ void llvm::X86::getFeaturesForCPU(StringRef CPU,
 // For each feature that is (transitively) implied by this feature, set it.
 static void getImpliedEnabledFeatures(FeatureBitset &Bits,
   const FeatureBitset &Implies) {
+  // Fast path: Implies is often empty.
+  if (!Implies.any())
+return;
+  FeatureBitset Prev;
   Bits |= Implies;
-  for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i) {
-if (Implies[i])
-  getImpliedEnabledFeatures(Bits, FeatureInfos[i].ImpliedFeatures);
-  }
+  do {
+Prev = Bits;
+for (unsigned i = CPU_FEATURE_MAX; i;)
+  if (Bits[--i])
+Bits |= FeatureInfos[i].ImpliedFeatures;
+  } while (Prev != Bits);
 }
 
 /// Create bit vector of features that are implied disabled if the feature
@@ -564,12 +581,14 @@ static void getImpliedEnabledFeatures(FeatureBitset &Bits,
 static void getImpliedDisabledFeatures(FeatureBitset &Bits, unsigned Value) {
   // Check all features looking for any dependent on this feature. If we find
   // one, mark it and recursively find any feature that depend on it.
-  for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i) {
-if (FeatureInfos[i].ImpliedFeatures[Value]) {
-  Bits.set(i);
-  getImpliedDisabledFeatures(Bits, i);
-}
-  }
+  FeatureBitset Prev;
+  Bits.set(Value);
+  do {
+Prev = Bits;
+for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
+  if ((FeatureInfos[i].ImpliedFeatures & Bits).any())
+Bits.set(i);
+  } while (Prev != Bits);
 }
 
 void llvm::X86::getImpliedFeatures(



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


[llvm-branch-commits] [compiler-rt] a3e8436 - On FreeBSD, add -pthread to ASan dynamic compile flags for tests

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Dimitry Andric
Date: 2020-08-18T12:41:06+02:00
New Revision: a3e8436475242e4d4b8669840f3bf954a538f23f

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

LOG: On FreeBSD, add -pthread to ASan dynamic compile flags for tests

Otherwise, lots of these tests fail with a CHECK error similar to:

==12345==AddressSanitizer CHECK failed: compiler-rt/lib/asan/asan_posix.cpp:120 
"((0)) == ((pthread_key_create(&tsd_key, destructor)))" (0x0, 0x4e)

This is because the default pthread stubs in FreeBSD's libc always
return failures (such as ENOSYS for pthread_key_create) in case the
pthread library is not linked in.

Reviewed By: arichardson

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

(cherry picked from commit 3aecf4bdf3f87e674724ad58d94c4b728feecb2e)

Added: 


Modified: 
compiler-rt/test/asan/lit.cfg.py

Removed: 




diff  --git a/compiler-rt/test/asan/lit.cfg.py 
b/compiler-rt/test/asan/lit.cfg.py
index 9045c6ec8f9c..63c02f7ddeeb 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -91,9 +91,12 @@ def push_dynamic_library_lookup_path(config, new_path):
 asan_dynamic_flags = []
 if config.asan_dynamic:
   asan_dynamic_flags = ["-shared-libasan"]
-  # On Windows, we need to simulate "clang-cl /MD" on the clang driver side.
   if platform.system() == 'Windows':
+# On Windows, we need to simulate "clang-cl /MD" on the clang driver side.
 asan_dynamic_flags += ["-D_MT", "-D_DLL", 
"-Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames"]
+  elif platform.system() == 'FreeBSD':
+# On FreeBSD, we need to add -pthread to ensure pthread functions are 
available.
+asan_dynamic_flags += ['-pthread']
   config.available_features.add("asan-dynamic-runtime")
 else:
   config.available_features.add("asan-static-runtime")



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


[llvm-branch-commits] [clang] c89e9d6 - Change the default target CPU for OpenBSD/i386 to i586

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Brad Smith
Date: 2020-08-18T12:42:42+02:00
New Revision: c89e9d67721ab2bdbb25656bc2da2a52c1116917

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

LOG: Change the default target CPU for OpenBSD/i386 to i586

(cherry picked from commit cd5ab56bc406c3f9a6f593f98c63dafb53547ab1)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 2cc44c09917f..6b82abec6f65 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -93,13 +93,13 @@ const char *x86::getX86TargetCPU(const ArgList &Args,
 return "x86-64";
 
   switch (Triple.getOS()) {
-  case llvm::Triple::FreeBSD:
-return "i686";
   case llvm::Triple::NetBSD:
-  case llvm::Triple::OpenBSD:
 return "i486";
   case llvm::Triple::Haiku:
+  case llvm::Triple::OpenBSD:
 return "i586";
+  case llvm::Triple::FreeBSD:
+return "i686";
   default:
 // Fallback to p4.
 return "pentium4";

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 51a5b4380f45..e17d05dc76da 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -14,6 +14,11 @@
 // CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-nopie" "-o" "a.out" "{{.*}}gcrt0.o" 
"{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" 
"-lcompiler_rt" "{{.*}}crtend.o"
 
+// Check CPU type for i386
+// RUN: %clang -target i386-unknown-openbsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-i386-CPU %s
+// CHECK-i386-CPU: "-target-cpu" "i586"
+
 // Check CPU type for MIPS64
 // RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-MIPS64-CPU %s



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


[llvm-branch-commits] [clang] d09901e - int64_t and intmax_t are always (signed) long long on OpenBSD.

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Brad Smith
Date: 2020-08-18T12:45:09+02:00
New Revision: d09901e2d8aa4ffdf35d50622dd096062d5e6eef

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

LOG: int64_t and intmax_t are always (signed) long long on OpenBSD.

(cherry picked from commit 92e82a2890c38bbb158cbf9dd592328b4c383696)

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index cfa362bef1b1c..a885aa96cc762 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -465,6 +465,8 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public 
OSTargetInfo {
 public:
   OpenBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
+this->IntMaxType = TargetInfo::SignedLongLong;
+this->Int64Type = TargetInfo::SignedLongLong;
 switch (Triple.getArch()) {
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:



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


[llvm-branch-commits] [clang] c2f52e2 - Create strict aligned code for OpenBSD/arm64.

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Brad Smith
Date: 2020-08-18T12:47:26+02:00
New Revision: c2f52e2c1288b00eae528825fb92668b1f3df732

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

LOG: Create strict aligned code for OpenBSD/arm64.

(cherry picked from commit 44613bbec88be9e86b8c52c4f40bb1b1ab48d84c)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/arm-alignment.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 487c50dfc4663..dd4545d6c48fa 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -370,9 +370,11 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
-   options::OPT_munaligned_access))
+   options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))
   Features.push_back("+strict-align");
+  } else if (Triple.isOSOpenBSD())
+Features.push_back("+strict-align");
 
   if (Args.hasArg(options::OPT_ffixed_x1))
 Features.push_back("+reserve-x1");

diff  --git a/clang/test/Driver/arm-alignment.c 
b/clang/test/Driver/arm-alignment.c
index e0b4946d0a4b1..b2bc8a35dfc6f 100644
--- a/clang/test/Driver/arm-alignment.c
+++ b/clang/test/Driver/arm-alignment.c
@@ -80,6 +80,9 @@
 // RUN: %clang -target aarch64-none-gnueabi -mkernel -mno-unaligned-access 
-### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
+// RUN: %clang -target aarch64-unknown-openbsd -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
+
 // CHECK-ALIGNED-ARM: "-target-feature" "+strict-align"
 // CHECK-ALIGNED-AARCH64: "-target-feature" "+strict-align"
 



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


[llvm-branch-commits] [flang] 28a1b6e - Revert "[flang] Version information in flang/f18"

2020-08-18 Thread Richard Barton via llvm-branch-commits

Author: Richard Barton
Date: 2020-08-18T12:17:13+01:00
New Revision: 28a1b6ea4db9e405d563ad36ca4b3bb1916f92ed

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

LOG: Revert "[flang] Version information in flang/f18"

This reverts commit 844f018114b52325b36e1042c8a8fc0ea82d9c17.

Added: 


Modified: 
flang/test/Driver/version_test.f90
flang/tools/f18/CMakeLists.txt
flang/tools/f18/f18.cpp

Removed: 
flang/test/Preprocessing/compiler_defined_macros.F90
flang/tools/f18/f18_version.h.in



diff  --git a/flang/test/Driver/version_test.f90 
b/flang/test/Driver/version_test.f90
index 7fe229e2be17..08ea35ba49ea 100644
--- a/flang/test/Driver/version_test.f90
+++ b/flang/test/Driver/version_test.f90
@@ -1,10 +1,7 @@
 ! Check that lit configuration works by checking the compiler version
 
+! RUN: %f18 -V 2>&1 | FileCheck  -check-prefix=VERSION %s
 ! VERSION-NOT:{{![[:space:]]}}
 ! VERSION:{{[[:space:]]}}
-! VERSION-SAME:f18 compiler (under development), version 
{{[1-9][0-9]*.[0-9]*.[0-9]*}}
+! VERSION-SAME:f18 compiler (under development)
 ! VERSION-EMPTY:
-
-! RUN: %f18 -V 2>&1 | FileCheck  -check-prefix=VERSION %s
-! RUN: %f18 -v 2>&1 | FileCheck  -check-prefix=VERSION %s
-! RUN: %f18 --version 2>&1 | FileCheck  -check-prefix=VERSION %s

diff  --git a/flang/test/Preprocessing/compiler_defined_macros.F90 
b/flang/test/Preprocessing/compiler_defined_macros.F90
deleted file mode 100644
index 80852cfb4472..
--- a/flang/test/Preprocessing/compiler_defined_macros.F90
+++ /dev/null
@@ -1,12 +0,0 @@
-! Check that the macros that give the verion number are set properly
-
-!CHECK: flang_major = {{[1-9][0-9]*$}}
-!CHECK: flang_minor = {{[0-9]+$}}
-!CHECK: flang_patchlevel = {{[0-9]+$}}
-!RUN: %f18 -E %s | FileCheck  --ignore-case %s
-
-  
-integer, parameter :: flang_major = __flang_major__
-integer, parameter :: flang_minor = __flang_minor__
-integer, parameter :: flang_patchlevel = __flang_patchlevel__
-

diff  --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 3dfce3437948..46c38fa43a2e 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -64,6 +64,5 @@ file(COPY ${CMAKE_BINARY_DIR}/tools/flang/bin/flang 
DESTINATION ${CMAKE_BINARY_D
 # The flang script to be installed needs a 
diff erent path to the headers.
 set(FLANG_INTRINSIC_MODULES_DIR ${CMAKE_INSTALL_PREFIX}/include/flang)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in 
${FLANG_BINARY_DIR}/bin/flang-install.sh @ONLY)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/f18_version.h.in 
${CMAKE_CURRENT_BINARY_DIR}/f18_version.h @ONLY)
 
 install(PROGRAMS ${FLANG_BINARY_DIR}/bin/flang-install.sh DESTINATION bin 
RENAME flang PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)

diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 23b104ee520c..03c0f7afe810 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -38,8 +38,6 @@
 #include 
 #include 
 
-#include "f18_version.h"
-
 static std::list argList(int argc, char *const argv[]) {
   std::list result;
   for (int j = 0; j < argc; ++j) {
@@ -392,13 +390,6 @@ void Link(std::vector &liblist, 
std::vector &objects,
   }
 }
 
-int printVersion() {
-  llvm::errs() << "\nf18 compiler (under development), version "
-   << __FLANG_MAJOR__ << "." << __FLANG_MINOR__ << "."
-   << __FLANG_PATCHLEVEL__ << "\n";
-  return exitStatus;
-}
-
 int main(int argc, char *const argv[]) {
 
   atexit(CleanUpAtExit);
@@ -420,11 +411,6 @@ int main(int argc, char *const argv[]) {
   options.predefinitions.emplace_back("__F18_MAJOR__", "1");
   options.predefinitions.emplace_back("__F18_MINOR__", "1");
   options.predefinitions.emplace_back("__F18_PATCHLEVEL__", "1");
-  options.predefinitions.emplace_back("__flang__", __FLANG__);
-  options.predefinitions.emplace_back("__flang_major__", __FLANG_MAJOR__);
-  options.predefinitions.emplace_back("__flang_minor__", __FLANG_MINOR__);
-  options.predefinitions.emplace_back(
-  "__flang_patchlevel__", __FLANG_PATCHLEVEL__);
 #if __x86_64__
   options.predefinitions.emplace_back("__x86_64__", "1");
 #endif
@@ -665,16 +651,13 @@ int main(int argc, char *const argv[]) {
   << "Unrecognised options are passed through to the external 
compiler\n"
   << "set by F18_FC (see defaults).\n";
   return exitStatus;
-} else if (arg == "-V" || arg == "--version") {
-  return printVersion();
+} else if (arg == "-V") {
+  llvm::errs() << "\nf18 compiler (under development)\n";
+  return exitStatus;
 } else {
   driver.F18_FCArgs.push_back(arg);
   if (arg == "-v") {
-if (args.size() > 1) {
-  driver.verbose = true;
-} else {
-  return printVersion();
-}
+  

[llvm-branch-commits] [llvm] 5fc0afe - [X86] Add test case for PR47000. NFC

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Craig Topper
Date: 2020-08-18T16:02:36+02:00
New Revision: 5fc0afee3f09abeceff4064f8ed364c4c6369886

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

LOG: [X86] Add test case for PR47000. NFC

(cherry picked from commit 13796d14238baabff972e15ceddb4ae61b1584b8)

Added: 
llvm/test/CodeGen/X86/pr47000.ll

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/X86/pr47000.ll 
b/llvm/test/CodeGen/X86/pr47000.ll
new file mode 100755
index ..e6ddf3d97c19
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr47000.ll
@@ -0,0 +1,151 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --no_x86_scrub_rip
+; RUN: llc < %s -mcpu=pentium4 -O0 | FileCheck %s
+
+target datalayout = 
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
+target triple = "i386-unknown-linux-unknown"
+
+define <4 x half> @doTheTestMod(<4 x half> %0, <4 x half> %1) nounwind {
+; CHECK-LABEL: doTheTestMod:
+; CHECK:   # %bb.0: # %Entry
+; CHECK-NEXT:pushl %ebp
+; CHECK-NEXT:pushl %ebx
+; CHECK-NEXT:pushl %edi
+; CHECK-NEXT:pushl %esi
+; CHECK-NEXT:subl $124, %esp
+; CHECK-NEXT:movl 144(%esp), %eax
+; CHECK-NEXT:movl %eax, %ecx
+; CHECK-NEXT:movw 176(%esp), %dx
+; CHECK-NEXT:movw 172(%esp), %si
+; CHECK-NEXT:movw 164(%esp), %di
+; CHECK-NEXT:movw 166(%esp), %bx
+; CHECK-NEXT:movw 160(%esp), %bp
+; CHECK-NEXT:movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movw 156(%esp), %ax
+; CHECK-NEXT:movw %ax, {{[-0-9]+}}(%e{{[sb]}}p) # 2-byte Spill
+; CHECK-NEXT:movw 148(%esp), %ax
+; CHECK-NEXT:movw %ax, {{[-0-9]+}}(%e{{[sb]}}p) # 2-byte Spill
+; CHECK-NEXT:movw 150(%esp), %ax
+; CHECK-NEXT:movw %ax, {{[-0-9]+}}(%e{{[sb]}}p) # 2-byte Spill
+; CHECK-NEXT:movw {{[-0-9]+}}(%e{{[sb]}}p), %ax # 2-byte Reload
+; CHECK-NEXT:movw %ax, 112(%esp)
+; CHECK-NEXT:movw {{[-0-9]+}}(%e{{[sb]}}p), %ax # 2-byte Reload
+; CHECK-NEXT:movw %ax, 114(%esp)
+; CHECK-NEXT:movw {{[-0-9]+}}(%e{{[sb]}}p), %ax # 2-byte Reload
+; CHECK-NEXT:movw %ax, 116(%esp)
+; CHECK-NEXT:movw %bp, 118(%esp)
+; CHECK-NEXT:movw %dx, 110(%esp)
+; CHECK-NEXT:movw %si, 108(%esp)
+; CHECK-NEXT:movw %bx, 106(%esp)
+; CHECK-NEXT:movw %di, 104(%esp)
+; CHECK-NEXT:movzwl 118(%esp), %edx
+; CHECK-NEXT:movzwl 116(%esp), %esi
+; CHECK-NEXT:movzwl 114(%esp), %edi
+; CHECK-NEXT:movzwl 112(%esp), %ebx
+; CHECK-NEXT:movzwl 110(%esp), %ebp
+; CHECK-NEXT:movzwl 108(%esp), %eax
+; CHECK-NEXT:movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movzwl 106(%esp), %eax
+; CHECK-NEXT:movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movzwl 104(%esp), %eax
+; CHECK-NEXT:movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movl %esp, %eax
+; CHECK-NEXT:movl %ebx, (%eax)
+; CHECK-NEXT:movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; CHECK-NEXT:calll __gnu_h2f_ieee
+; CHECK-NEXT:movl %esp, %eax
+; CHECK-NEXT:movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
+; CHECK-NEXT:movl %ecx, (%eax)
+; CHECK-NEXT:fstpt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Spill
+; CHECK-NEXT:calll __gnu_h2f_ieee
+; CHECK-NEXT:movl %esp, %eax
+; CHECK-NEXT:fstps 4(%eax)
+; CHECK-NEXT:fldt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Reload
+; CHECK-NEXT:fstps (%eax)
+; CHECK-NEXT:calll fmodf
+; CHECK-NEXT:movl %esp, %eax
+; CHECK-NEXT:fstps (%eax)
+; CHECK-NEXT:calll __gnu_f2h_ieee
+; CHECK-NEXT:movl %esp, %ecx
+; CHECK-NEXT:movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
+; CHECK-NEXT:movl %edx, (%ecx)
+; CHECK-NEXT:movw %ax, {{[-0-9]+}}(%e{{[sb]}}p) # 2-byte Spill
+; CHECK-NEXT:calll __gnu_h2f_ieee
+; CHECK-NEXT:movl %esp, %eax
+; CHECK-NEXT:movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
+; CHECK-NEXT:movl %ecx, (%eax)
+; CHECK-NEXT:fstpt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Spill
+; CHECK-NEXT:calll __gnu_h2f_ieee
+; CHECK-NEXT:movl %esp, %eax
+; CHECK-NEXT:fstps 4(%eax)
+; CHECK-NEXT:fldt {{[-0-9]+}}(%e{{[sb]}}p) # 10-byte Folded Reload
+; CHECK-NEXT:fstps (%eax)
+; CHECK-NEXT:calll fmodf
+; CHECK-NEXT:movl %esp, %eax
+; CHECK-NEXT:fstps (%eax)
+; CHECK-NEXT:calll __gnu_f2h_ieee
+; CHECK-NEXT:movl %esp, %ecx
+; CHECK-NEXT:movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
+; CHECK-

[llvm-branch-commits] [llvm] 6fed1b7 - [X86] Disable copy elision in LowerMemArgument for scalarized vectors when the loc VT is a different size than the original element.

2020-08-18 Thread Hans Wennborg via llvm-branch-commits

Author: Craig Topper
Date: 2020-08-18T16:02:37+02:00
New Revision: 6fed1b7bcb50743d9aad54a08276c9c179d86487

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

LOG: [X86] Disable copy elision in LowerMemArgument for scalarized vectors when 
the loc VT is a different size than the original element.

For example a v4f16 argument is scalarized to 4 i32 values. So
the values are spread out instead of being packed tightly like
in the original vector.

Fixes PR47000.

(cherry picked from commit 08b2d0a963dbbf54317a137d69f430b347d1bfae)

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/pr47000.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 86aa85e965f6..1671917157f4 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3208,13 +3208,23 @@ X86TargetLowering::LowerMemArgument(SDValue Chain, 
CallingConv::ID CallConv,
 return DAG.getFrameIndex(FI, PtrVT);
   }
 
+  EVT ArgVT = Ins[i].ArgVT;
+
+  // If this is a vector that has been split into multiple parts, and the
+  // scalar size of the parts don't match the vector element size, then we 
can't
+  // elide the copy. The parts will have padding between them instead of being
+  // packed like a vector.
+  bool ScalarizedAndExtendedVector =
+  ArgVT.isVector() && !VA.getLocVT().isVector() &&
+  VA.getLocVT().getSizeInBits() != ArgVT.getScalarSizeInBits();
+
   // This is an argument in memory. We might be able to perform copy elision.
   // If the argument is passed directly in memory without any extension, then 
we
   // can perform copy elision. Large vector types, for example, may be passed
   // indirectly by pointer.
   if (Flags.isCopyElisionCandidate() &&
-  VA.getLocInfo() != CCValAssign::Indirect && !ExtendedInMem) {
-EVT ArgVT = Ins[i].ArgVT;
+  VA.getLocInfo() != CCValAssign::Indirect && !ExtendedInMem &&
+  !ScalarizedAndExtendedVector) {
 SDValue PartAddr;
 if (Ins[i].PartOffset == 0) {
   // If this is a one-part value or the first part of a multi-part value,

diff  --git a/llvm/test/CodeGen/X86/pr47000.ll 
b/llvm/test/CodeGen/X86/pr47000.ll
index e6ddf3d97c19..083aa780a07c 100755
--- a/llvm/test/CodeGen/X86/pr47000.ll
+++ b/llvm/test/CodeGen/X86/pr47000.ll
@@ -16,17 +16,15 @@ define <4 x half> @doTheTestMod(<4 x half> %0, <4 x half> 
%1) nounwind {
 ; CHECK-NEXT:movl %eax, %ecx
 ; CHECK-NEXT:movw 176(%esp), %dx
 ; CHECK-NEXT:movw 172(%esp), %si
-; CHECK-NEXT:movw 164(%esp), %di
-; CHECK-NEXT:movw 166(%esp), %bx
+; CHECK-NEXT:movw 168(%esp), %di
+; CHECK-NEXT:movw 164(%esp), %bx
 ; CHECK-NEXT:movw 160(%esp), %bp
 ; CHECK-NEXT:movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
 ; CHECK-NEXT:movw 156(%esp), %ax
 ; CHECK-NEXT:movw %ax, {{[-0-9]+}}(%e{{[sb]}}p) # 2-byte Spill
-; CHECK-NEXT:movw 148(%esp), %ax
-; CHECK-NEXT:movw %ax, {{[-0-9]+}}(%e{{[sb]}}p) # 2-byte Spill
-; CHECK-NEXT:movw 150(%esp), %ax
+; CHECK-NEXT:movw 152(%esp), %ax
 ; CHECK-NEXT:movw %ax, {{[-0-9]+}}(%e{{[sb]}}p) # 2-byte Spill
-; CHECK-NEXT:movw {{[-0-9]+}}(%e{{[sb]}}p), %ax # 2-byte Reload
+; CHECK-NEXT:movw 148(%esp), %ax
 ; CHECK-NEXT:movw %ax, 112(%esp)
 ; CHECK-NEXT:movw {{[-0-9]+}}(%e{{[sb]}}p), %ax # 2-byte Reload
 ; CHECK-NEXT:movw %ax, 114(%esp)
@@ -35,8 +33,8 @@ define <4 x half> @doTheTestMod(<4 x half> %0, <4 x half> %1) 
nounwind {
 ; CHECK-NEXT:movw %bp, 118(%esp)
 ; CHECK-NEXT:movw %dx, 110(%esp)
 ; CHECK-NEXT:movw %si, 108(%esp)
-; CHECK-NEXT:movw %bx, 106(%esp)
-; CHECK-NEXT:movw %di, 104(%esp)
+; CHECK-NEXT:movw %di, 106(%esp)
+; CHECK-NEXT:movw %bx, 104(%esp)
 ; CHECK-NEXT:movzwl 118(%esp), %edx
 ; CHECK-NEXT:movzwl 116(%esp), %esi
 ; CHECK-NEXT:movzwl 114(%esp), %edi



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


[llvm-branch-commits] [llvm] 7e6bf0b - [release][docs] Update contributions to LLVM 11 for SVE.

2020-08-18 Thread Francesco Petrogalli via llvm-branch-commits

Author: Francesco Petrogalli
Date: 2020-08-18T21:13:21Z
New Revision: 7e6bf0bfe6de9e0d0e58764a66f93210f296bbfa

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

LOG: [release][docs] Update contributions to LLVM 11 for SVE.

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

Added: 


Modified: 
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c9ac61d29676..612a5417df95 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -66,7 +66,9 @@ Changes to the LLVM IR
   added to describe the mapping between scalar functions and vector
   functions, to enable vectorization of call sites. The information
   provided by the attribute is interfaced via the API provided by the
-  ``VFDatabase`` class.
+  ``VFDatabase`` class. When scanning through the set of vector
+  functions associated with a scalar call, the loop vectorizer now
+  relies on ``VFDatabase``, instead of ``TargetLibraryInfo``.
 
 * `dereferenceable` attributes and metadata on pointers no longer imply
   anything about the alignment of the pointer in question. Previously, some
@@ -78,6 +80,17 @@ Changes to the LLVM IR
   information. This information is used to represent Fortran modules debug
   info at IR level.
 
+* LLVM IR now supports two distinct ``llvm::FixedVectorType`` and
+  ``llvm::ScalableVectorType`` vector types, both derived from the
+  base class ``llvm::VectorType``. A number of algorithms dealing with
+  IR vector types have been updated to make sure they work for both
+  scalable and fixed vector types. Where possible, the code has been
+  made generic to cover both cases using the base class. Specifically,
+  places that were using the type ``unsigned`` to count the number of
+  lanes of a vector are now using ``llvm::ElementCount``. In places
+  where ``uint64_t`` was used to denote the size in bits of a IR type
+  we have partially migrated the codebase to using ``llvm::TypeSize``.
+
 Changes to building LLVM
 
 
@@ -110,6 +123,55 @@ During this release ...
   default may wish to specify ``-fno-omit-frame-pointer`` to get the old
   behavior. This improves compatibility with GCC.
 
+* Clang adds support for the following macros that enable the
+  C-intrinsics from the `Arm C language extensions for SVE
+  `_ (version
+  ``00bet5``, see section 2.1 for the list of intrinsics associated to
+  each macro):
+
+
+  =  =
+  Preprocessor macro Target feature
+  =  =
+  ``__ARM_FEATURE_SVE``  ``+sve``
+  ``__ARM_FEATURE_SVE_BF16`` ``+sve+bf16``
+  ``__ARM_FEATURE_SVE_MATMUL_FP32``  ``+sve+f32mm``
+  ``__ARM_FEATURE_SVE_MATMUL_FP64``  ``+sve+f64mm``
+  ``__ARM_FEATURE_SVE_MATMUL_INT8``  ``+sve+i8mm``
+  ``__ARM_FEATURE_SVE2`` ``+sve2``
+  ``__ARM_FEATURE_SVE2_AES`` ``+sve2-aes``
+  ``__ARM_FEATURE_SVE2_BITPERM`` ``+sve2-bitperm``
+  ``__ARM_FEATURE_SVE2_SHA3````+sve2-sha3``
+  ``__ARM_FEATURE_SVE2_SM4`` ``+sve2-sm4``
+  =  =
+
+  The macros enable users to write C/C++ `Vector Length Agnostic
+  (VLA)` loops, that can be executed on any CPU that implements the
+  underlying instructions supported by the C intrinsics, independently
+  of the hardware vector register size.
+
+  For example, the ``__ARM_FEATURE_SVE`` macro is enabled when
+  targeting AArch64 code generation by setting ``-march=armv8-a+sve``
+  on the command line.
+
+  .. code-block:: c
+ :caption: Example of VLA addition of two arrays with SVE ACLE.
+
+ // Compile with:
+ // `clang++ -march=armv8a+sve ...` (for c++)
+ // `clang -stc=c11 -march=armv8a+sve ...` (for c)
+ #include 
+
+ void VLA_add_arrays(double *x, double *y, double *out, unsigned N) {
+   for (unsigned i = 0; i < N; i += svcntd()) {
+ svbool_t Pg = svwhilelt_b64(i, N);
+ svfloat64_t vx = svld1(Pg, &x[i]);
+ svfloat64_t vy = svld1(Pg, &y[i]);
+ svfloat64_t vout = svadd_x(Pg, vx, vy);
+ svst1(Pg, &out[i], vout);
+   }
+ }
+
 Changes to the MIPS Target
 --
 



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