[llvm-branch-commits] [lld] 15bf939 - [ELF][test] Fix ppc64-reloc-pcrel34-overflow.s
Author: Fangrui Song
Date: 2020-08-03T15:39:14+02:00
New Revision: 15bf939137283027fae04e7da8c018346657b254
URL:
https://github.com/llvm/llvm-project/commit/15bf939137283027fae04e7da8c018346657b254
DIFF:
https://github.com/llvm/llvm-project/commit/15bf939137283027fae04e7da8c018346657b254.diff
LOG: [ELF][test] Fix ppc64-reloc-pcrel34-overflow.s
(cherry picked from commit ed7bde0e4b40cbf8a7c833fd8240c957fcda176e)
Added:
Modified:
lld/test/ELF/ppc64-reloc-pcrel34-overflow.s
Removed:
diff --git a/lld/test/ELF/ppc64-reloc-pcrel34-overflow.s
b/lld/test/ELF/ppc64-reloc-pcrel34-overflow.s
index a97160a430dd..ad80ed720b63 100644
--- a/lld/test/ELF/ppc64-reloc-pcrel34-overflow.s
+++ b/lld/test/ELF/ppc64-reloc-pcrel34-overflow.s
@@ -1,21 +1,22 @@
# REQUIRES: ppc
# RUN: echo 'SECTIONS { \
-# RUN: .text_low 0x1001: { *(.text_low) } \
-# RUN: .text_overflow 0x10 : { *(.text_overflow) } \
-# RUN: }' > %t.script
+# RUN: .text 0x1: { *(.text) } \
+# RUN: .data 0x20001 : { *(.data) } \
+# RUN: }' > %t.script
# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
-# RUN: not ld.lld -T %t.script %t.o -o %t
+# RUN: not ld.lld -T %t.script %t.o -o /dev/null 2>&1 | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
-# RUN: not ld.lld -T %t.script %t.o -o %t
+# RUN: not ld.lld -T %t.script %t.o -o /dev/null 2>&1 | FileCheck %s
-.section .text_low, "ax", %progbits
-# CHECK: relocation R_PPC64_PCREL34 out of range
-GlobIntOverflow:
+# CHECK: relocation R_PPC64_PCREL34 out of range: 8589934592 is not in
[-8589934592, 8589934591]
plwa 3, glob_overflow@PCREL(0), 1
- blr
-.section .text_overflow, "ax", %progbits
+
+# CHECK-NOT: relocation
+ plwa 3, .data@PCREL(0), 1
+
+.data
glob_overflow:
.long 0
.size glob_overflow, 4
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] 3ae25b7 - [clangd] findNearbyIdentifier(): fix the word search in the token stream.
Author: Aleksandr Platonov
Date: 2020-08-03T15:43:05+02:00
New Revision: 3ae25b7a09ded12ff63acec0efcf8c7d715114fe
URL:
https://github.com/llvm/llvm-project/commit/3ae25b7a09ded12ff63acec0efcf8c7d715114fe
DIFF:
https://github.com/llvm/llvm-project/commit/3ae25b7a09ded12ff63acec0efcf8c7d715114fe.diff
LOG: [clangd] findNearbyIdentifier(): fix the word search in the token stream.
Without this patch the word occurrence search always returns the first token of
the file.
Despite of that, `findNeardyIdentifier()` returns the correct result (but
inefficently) until there are several matched tokens with the same value
`floor(log2( - ))` (e.g. several matched tokens on the
same line).
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D84912
(cherry picked from commit 05b173466142596b3297ab02e423574cb74b3799)
Added:
Modified:
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Removed:
diff --git a/clang-tools-extra/clangd/XRefs.cpp
b/clang-tools-extra/clangd/XRefs.cpp
index c208e953f2ab..2a82dfd66499 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -518,7 +518,7 @@ const syntax::Token *findNearbyIdentifier(const SpelledWord
&Word,
// Find where the word occurred in the token stream, to search forward &
back.
auto *I = llvm::partition_point(SpelledTokens, [&](const syntax::Token &T) {
assert(SM.getFileID(T.location()) == SM.getFileID(Word.Location));
-return T.location() >= Word.Location; // Comparison OK: same file.
+return T.location() < Word.Location; // Comparison OK: same file.
});
// Search for matches after the cursor.
for (const syntax::Token &Tok : llvm::makeArrayRef(I, SpelledTokens.end()))
diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 0428303f5b0a..0a8f85ed5317 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1197,7 +1197,14 @@ TEST(LocateSymbol, NearbyIdentifier) {
// h^i
)cpp",
- };
+ R"cpp(
+ // prefer nearest occurrence even if several matched tokens
+ // have the same value of `floor(log2( - ))`.
+ int hello;
+ int x = hello, y = hello;
+ int z = [[hello]];
+ // h^ello
+)cpp"};
for (const char *Test : Tests) {
Annotations T(Test);
auto AST = TestTU::withCode(T.code()).build();
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] a45dd85 - [Concepts] Fix a deserialization crash.
Author: Haojian Wu
Date: 2020-08-03T15:46:42+02:00
New Revision: a45dd85fe4ccf721dc5ab01768c79bce73ff3474
URL:
https://github.com/llvm/llvm-project/commit/a45dd85fe4ccf721dc5ab01768c79bce73ff3474
DIFF:
https://github.com/llvm/llvm-project/commit/a45dd85fe4ccf721dc5ab01768c79bce73ff3474.diff
LOG: [Concepts] Fix a deserialization crash.
`TemplateTypeParmDecl::hasTypeConstraint` is not a safe guard for
checking `TemplateTypeParmDecl::getTypeConstraint()` result is null.
in somecases (e.g. implicit deduction guide templates synthesized from the
constructor, immediately-declared constraint is not formed because of an error),
hasTypeConstraint returns false, and getTypeConstraint returns a nullptr.
Fix https://bugs.llvm.org/show_bug.cgi?id=46790
Differential Revision: https://reviews.llvm.org/D84455
(cherry picked from commit 73c12bd8ff1a9cd8375a357ea06f171e127ec1b8)
Added:
clang/test/PCH/cxx2a-constraints-crash.cpp
Modified:
clang/lib/Serialization/ASTReaderDecl.cpp
Removed:
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp
b/clang/lib/Serialization/ASTReaderDecl.cpp
index eef4ab16ec15..117eb598bd5e 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2912,9 +2912,11 @@ static bool isSameTemplateParameter(const NamedDecl *X,
return false;
if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
return false;
-if (TX->hasTypeConstraint()) {
- const TypeConstraint *TXTC = TX->getTypeConstraint();
- const TypeConstraint *TYTC = TY->getTypeConstraint();
+const TypeConstraint *TXTC = TX->getTypeConstraint();
+const TypeConstraint *TYTC = TY->getTypeConstraint();
+if (!TXTC != !TYTC)
+ return false;
+if (TXTC && TYTC) {
if (TXTC->getNamedConcept() != TYTC->getNamedConcept())
return false;
if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())
diff --git a/clang/test/PCH/cxx2a-constraints-crash.cpp
b/clang/test/PCH/cxx2a-constraints-crash.cpp
new file mode 100644
index ..637c55f0c879
--- /dev/null
+++ b/clang/test/PCH/cxx2a-constraints-crash.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
+// RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template
+concept not_same_as = true;
+
+template
+struct subrange {
+ template R>
+ subrange(R) requires(Kind == 0);
+
+ template R>
+ subrange(R) requires(Kind != 0);
+};
+
+template
+subrange(R) -> subrange<42>;
+
+int main() {
+ int c;
+ subrange s(c);
+}
+
+#endif
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 2cf9a07 - Align store conditional address
Author: Brendon Cahoon
Date: 2020-08-03T15:52:15+02:00
New Revision: 2cf9a07fdcf683fdb2dfad6eeb79a78d8d3a8e3a
URL:
https://github.com/llvm/llvm-project/commit/2cf9a07fdcf683fdb2dfad6eeb79a78d8d3a8e3a
DIFF:
https://github.com/llvm/llvm-project/commit/2cf9a07fdcf683fdb2dfad6eeb79a78d8d3a8e3a.diff
LOG: Align store conditional address
In cases where the alignment of the datatype is smaller than
expected by the instruction, the address is aligned. The aligned
address is used for the load, but wasn't used for the store
conditional, which resulted in a run-time alignment exception.
(cherry picked from commit 7b114446c320de542c50c4c02f566e5d18adee33)
Added:
llvm/test/CodeGen/Hexagon/atomic-store-byte.ll
Modified:
llvm/lib/CodeGen/AtomicExpandPass.cpp
Removed:
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp
b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index a5030305435c..c61531c5141a 100644
--- a/llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -1239,7 +1239,8 @@ bool AtomicExpand::expandAtomicCmpXchg(AtomicCmpXchgInst
*CI) {
Value *NewValueInsert =
insertMaskedValue(Builder, LoadedTryStore, CI->getNewValOperand(), PMV);
Value *StoreSuccess =
- TLI->emitStoreConditional(Builder, NewValueInsert, Addr, MemOpOrder);
+ TLI->emitStoreConditional(Builder, NewValueInsert, PMV.AlignedAddr,
+MemOpOrder);
StoreSuccess = Builder.CreateICmpEQ(
StoreSuccess, ConstantInt::get(Type::getInt32Ty(Ctx), 0), "success");
BasicBlock *RetryBB = HasReleasedLoadBB ? ReleasedLoadBB : StartBB;
diff --git a/llvm/test/CodeGen/Hexagon/atomic-store-byte.ll
b/llvm/test/CodeGen/Hexagon/atomic-store-byte.ll
new file mode 100644
index ..e3febe0264ad
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/atomic-store-byte.ll
@@ -0,0 +1,18 @@
+; RUN: llc -mtriple=hexagon < %s | FileCheck %s
+
+; Test that the address for a store conditional for a byte is aligned
+; correctly to use the memw_locked instruction.
+
+; CHECK: [[REG:(r[0-9]+)]] = and(r{{[0-9]+}},#-4)
+; CHECK: = memw_locked([[REG]])
+; CHECK: memw_locked([[REG]],p{{[0-4]}}) =
+
[email protected] = internal global i8 0, align 1
+
+; Function Attrs: nofree norecurse nounwind
+define dso_local void @foo() local_unnamed_addr #0 {
+entry:
+ %0 = cmpxchg volatile i8* @foo.a00, i8 0, i8 1 seq_cst seq_cst
+ ret void
+}
+
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 542a08d - [LAA] Avoid adding pointers to the checks if they are not needed.
Author: Florian Hahn
Date: 2020-08-03T15:55:25+02:00
New Revision: 542a08dcb7a8044c0ba52146d866515603fad122
URL:
https://github.com/llvm/llvm-project/commit/542a08dcb7a8044c0ba52146d866515603fad122
DIFF:
https://github.com/llvm/llvm-project/commit/542a08dcb7a8044c0ba52146d866515603fad122.diff
LOG: [LAA] Avoid adding pointers to the checks if they are not needed.
Currently we skip alias sets with only reads or a single write and no
reads, but still add the pointers to the list of pointers in RtCheck.
This can lead to cases where we try to access a pointer that does not
exist when grouping checks. In most cases, the way we access
PositionMap masked that, as the value would default to index 0.
But in the example in PR46854 it causes a crash.
This patch updates the logic to avoid adding pointers for alias sets
that do not need any checks. It makes things slightly more verbose, by
first checking the numbers of reads/writes and bailing out early if we don't
need checks for the alias set.
I think this makes the logic a bit simpler to follow.
Reviewed By: anemet
Differential Revision: https://reviews.llvm.org/D84608
(cherry picked from commit 2062b3707c1ef698deaa9abc571b937fdd077168)
Added:
llvm/test/Transforms/LoopLoadElim/pr46854-adress-spaces.ll
Modified:
llvm/lib/Analysis/LoopAccessAnalysis.cpp
Removed:
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index ae282a7a1095..f409cd322146 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -393,7 +393,10 @@ void RuntimePointerChecking::groupChecks(
// equivalence class, the iteration order is deterministic.
for (auto MI = DepCands.member_begin(LeaderI), ME = DepCands.member_end();
MI != ME; ++MI) {
- unsigned Pointer = PositionMap[MI->getPointer()];
+ auto PointerI = PositionMap.find(MI->getPointer());
+ assert(PointerI != PositionMap.end() &&
+ "pointer in equivalence class not found in PositionMap");
+ unsigned Pointer = PointerI->second;
bool Merged = false;
// Mark this pointer as seen.
Seen.insert(Pointer);
@@ -726,52 +729,55 @@ bool
AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck,
SmallVector Retries;
+// First, count how many write and read accesses are in the alias set. Also
+// collect MemAccessInfos for later.
+SmallVector AccessInfos;
for (auto A : AS) {
Value *Ptr = A.getValue();
bool IsWrite = Accesses.count(MemAccessInfo(Ptr, true));
- MemAccessInfo Access(Ptr, IsWrite);
if (IsWrite)
++NumWritePtrChecks;
else
++NumReadPtrChecks;
+ AccessInfos.emplace_back(Ptr, IsWrite);
+}
+// We do not need runtime checks for this alias set, if there are no writes
+// or a single write and no reads.
+if (NumWritePtrChecks == 0 ||
+(NumWritePtrChecks == 1 && NumReadPtrChecks == 0)) {
+ assert((AS.size() <= 1 ||
+ all_of(AS,
+ [this](auto AC) {
+ MemAccessInfo AccessWrite(AC.getValue(), true);
+ return DepCands.findValue(AccessWrite) ==
DepCands.end();
+ })) &&
+ "Can only skip updating CanDoRT below, if all entries in AS "
+ "are reads or there is at most 1 entry");
+ continue;
+}
+
+for (auto &Access : AccessInfos) {
if (!createCheckForAccess(RtCheck, Access, StridesMap, DepSetId, TheLoop,
RunningDepId, ASId, ShouldCheckWrap, false)) {
-LLVM_DEBUG(dbgs() << "LAA: Can't find bounds for ptr:" << *Ptr <<
'\n');
+LLVM_DEBUG(dbgs() << "LAA: Can't find bounds for ptr:"
+ << *Access.getPointer() << '\n');
Retries.push_back(Access);
CanDoAliasSetRT = false;
}
}
-// If we have at least two writes or one write and a read then we need to
-// check them. But there is no need to checks if there is only one
-// dependence set for this alias set.
-//
// Note that this function computes CanDoRT and MayNeedRTCheck
// independently. For example CanDoRT=false, MayNeedRTCheck=false means
that
// we have a pointer for which we couldn't find the bounds but we don't
// actually need to emit any checks so it does not matter.
-bool NeedsAliasSetRTCheck = false;
-if (!(IsDepCheckNeeded && CanDoAliasSetRT && RunningDepId == 2)) {
- NeedsAliasSetRTCheck = (NumWritePtrChecks >= 2 ||
- (NumReadPtrChecks >= 1 && NumWritePtrChecks >=
1));
- // For alias sets without at least 2 writes or 1 write and 1 read, there
- // is no need to generate RT checks and CanDoAliasSetRT for this alias
set
- // does not impact whether runtime checks can be generat
[llvm-branch-commits] [llvm] 921838e - [CMake] Pass bugreport URL to standalone clang build
Author: Michał Górny
Date: 2020-08-03T15:59:06+02:00
New Revision: 921838e68fcd379ff779da0a3d9ebb6fc0fb96f8
URL:
https://github.com/llvm/llvm-project/commit/921838e68fcd379ff779da0a3d9ebb6fc0fb96f8
DIFF:
https://github.com/llvm/llvm-project/commit/921838e68fcd379ff779da0a3d9ebb6fc0fb96f8.diff
LOG: [CMake] Pass bugreport URL to standalone clang build
BUG_REPORT_URL is currently used both in LLVM and in Clang but declared
only in the latter. This means that it's missing in standalone clang
builds and the driver ends up outputting:
PLEASE submit a bug report to and include [...]
(note the missing URL)
To fix this, include LLVM_PACKAGE_BUGREPORT in LLVMConfig.cmake
(similarly to how we pass PACKAGE_VERSION) and use it to fill
BUG_REPORT_URL when building clang standalone.
Differential Revision: https://reviews.llvm.org/D84987
(cherry picked from commit 21c165de2a1bcca9dceb452f637d9e8959fba113)
Added:
Modified:
clang/CMakeLists.txt
llvm/cmake/modules/LLVMConfig.cmake.in
Removed:
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 7f8e0718c2eb..2e06c5fd9028 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -121,6 +121,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
include(LLVMDistributionSupport)
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
+ set(BUG_REPORT_URL "${LLVM_PACKAGE_BUGREPORT}" CACHE STRING
+"Default URL where bug reports are to be submitted.")
if (NOT DEFINED LLVM_INCLUDE_TESTS)
set(LLVM_INCLUDE_TESTS ON)
diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in
b/llvm/cmake/modules/LLVMConfig.cmake.in
index e729a839f614..4d8e33711d27 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -7,6 +7,7 @@ set(LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@)
set(LLVM_VERSION_PATCH @LLVM_VERSION_PATCH@)
set(LLVM_VERSION_SUFFIX @LLVM_VERSION_SUFFIX@)
set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@)
+set(LLVM_PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@)
set(LLVM_BUILD_TYPE @CMAKE_BUILD_TYPE@)
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] a9430a1 - AMDGPU: Put inexpensive ops first in AMDGPUAnnotateUniformValues::visitLoadInst
Author: Changpeng Fang
Date: 2020-08-03T16:01:25+02:00
New Revision: a9430a1c9e9c99151361374f0462d751457fa15c
URL:
https://github.com/llvm/llvm-project/commit/a9430a1c9e9c99151361374f0462d751457fa15c
DIFF:
https://github.com/llvm/llvm-project/commit/a9430a1c9e9c99151361374f0462d751457fa15c.diff
LOG: AMDGPU: Put inexpensive ops first in
AMDGPUAnnotateUniformValues::visitLoadInst
Summary:
This is in response to the review of https://reviews.llvm.org/D84873:
The expensive check should be reordered last
Reviewers:
arsenm
Differential Revision:
https://reviews.llvm.org/D84890
(cherry picked from commit 243376cdc7b719d443f42c8c4667e5d96af53dcc)
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
Removed:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
index b09e92c07f9b..45f515c5115e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
@@ -131,10 +131,20 @@ void AMDGPUAnnotateUniformValues::visitLoadInst(LoadInst
&I) {
// We're tracking up to the Function boundaries, and cannot go beyond because
// of FunctionPass restrictions. We can ensure that is memory not clobbered
// for memory operations that are live in to entry points only.
- bool NotClobbered = isEntryFunc && !isClobberedInFunction(&I);
Instruction *PtrI = dyn_cast(Ptr);
- if (!PtrI && NotClobbered && isGlobalLoad(I)) {
-if (isa(Ptr) || isa(Ptr)) {
+
+ if (!isEntryFunc) {
+if (PtrI)
+ setUniformMetadata(PtrI);
+return;
+ }
+
+ bool NotClobbered = false;
+ if (PtrI)
+NotClobbered = !isClobberedInFunction(&I);
+ else if (isa(Ptr) || isa(Ptr)) {
+if (isGlobalLoad(I) && !isClobberedInFunction(&I)) {
+ NotClobbered = true;
// Lookup for the existing GEP
if (noClobberClones.count(Ptr)) {
PtrI = noClobberClones[Ptr];
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] ee5ed9d - Allow lit.util.which() to find executables with extension.
Author: Zachary Turner
Date: 2020-08-03T13:47:27-07:00
New Revision: ee5ed9d11e77f02631ed782f4ed8f6e872047b02
URL:
https://github.com/llvm/llvm-project/commit/ee5ed9d11e77f02631ed782f4ed8f6e872047b02
DIFF:
https://github.com/llvm/llvm-project/commit/ee5ed9d11e77f02631ed782f4ed8f6e872047b02.diff
LOG: Allow lit.util.which() to find executables with extension.
LLVM usually specifies executable names without extension so that
they work portably across platforms. Occasionally, if you're writing
something platform specific, you might want to specify the extension.
For example, you might want to write a test that invokes a batch file.
It's awkward to say foo when the file is really called foo.bat, but
in this case lit.util.which() currently won't find it because it will
construct the filename foo.bat.bat.
Added:
Modified:
llvm/utils/lit/lit/util.py
Removed:
diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py
index d7afbdabcff9..40a16122b4fb 100644
--- a/llvm/utils/lit/lit/util.py
+++ b/llvm/utils/lit/lit/util.py
@@ -232,16 +232,24 @@ def which(command, paths=None):
# Get suffixes to search.
# On Cygwin, 'PATHEXT' may exist but it should not be used.
if os.pathsep == ';':
-pathext = os.environ.get('PATHEXT', '').split(';')
+# Since this branch implies windows, it's safe to convert all
extensions to lowercase.
+assert(sys.platform == 'win32')
+pathext = [x.lower() for x in os.environ.get('PATHEXT', '').split(';')]
+
+# If the path was given to us with an extension already, ignore PATHEXT
+_, current_ext = os.path.splitext(command)
+if current_ext.lower() in pathext:
+pathext = ['']
else:
pathext = ['']
# Search the paths...
for path in paths.split(os.pathsep):
+p = os.path.join(path, command)
for ext in pathext:
-p = os.path.join(path, command + ext)
-if os.path.exists(p) and not os.path.isdir(p):
-return os.path.normcase(os.path.normpath(p))
+p_with_ext = p + ext
+if os.access(p_with_ext, os.X_OK):
+return os.path.normcase(os.path.normpath(p_with_ext))
return None
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] dd18fa1 - [lit] Support running tests on Windows without GnuWin32.
Author: Zachary Turner
Date: 2020-08-03T13:47:27-07:00
New Revision: dd18fa1d7e71e7bc546251a3a68dac114c5c7526
URL:
https://github.com/llvm/llvm-project/commit/dd18fa1d7e71e7bc546251a3a68dac114c5c7526
DIFF:
https://github.com/llvm/llvm-project/commit/dd18fa1d7e71e7bc546251a3a68dac114c5c7526.diff
LOG: [lit] Support running tests on Windows without GnuWin32.
Historically, we have told contributors that GnuWin32 is a pre-requisite
because our tests depend on utilities such as sed, grep, diff, and more.
However, Git on Windows includes versions of these utilities in its
installation. Furthermore, GnuWin32 has not been updated in many years.
For these reasons, it makes sense to have the ability to run llvm tests
in a way that is both:
a) Easier on the user (less stuff to install)
b) More up-to-date (The verions that ship with git are at least as
new, if not newer, than the versions in GnuWin32.
We add support for this here by attempting to detect where Git is
installed using the Windows registry, confirming the existence of
several common Unix tools, and then adding this location to lit's PATH
environment.
Added:
Modified:
llvm/utils/lit/lit/llvm/config.py
Removed:
diff --git a/llvm/utils/lit/lit/llvm/config.py
b/llvm/utils/lit/lit/llvm/config.py
index db557a7b1fef..af79fb5dddb5 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -1,3 +1,4 @@
+import itertools
import os
import platform
import re
@@ -20,13 +21,16 @@ def __init__(self, lit_config, config):
self.use_lit_shell = False
# Tweak PATH for Win32 to decide to use bash.exe or not.
if sys.platform == 'win32':
-# For tests that require Windows to run.
-features.add('system-windows')
-
-# Seek sane tools in directories and set to $PATH.
-path = self.lit_config.getToolsPath(config.lit_tools_dir,
-config.environment['PATH'],
-['cmp.exe', 'grep.exe',
'sed.exe'])
+# Seek necessary tools in directories and set to $PATH.
+path = None
+lit_tools_dir = getattr(config, 'lit_tools_dir', None)
+required_tools = ['cmp.exe', 'grep.exe', 'sed.exe', '
diff .exe', 'echo.exe']
+if lit_tools_dir:
+path = self.lit_config.getToolsPath(lit_tools_dir,
+config.environment['PATH'],
+required_tools)
+if path is None:
+path = self._find_git_windows_unix_tools(required_tools)
if path is not None:
self.with_environment('PATH', path, append_path=True)
# Many tools behave strangely if these environment variables
aren't set.
@@ -115,6 +119,34 @@ def __init__(self, lit_config, config):
self.with_environment(
'DYLD_INSERT_LIBRARIES', gmalloc_path_str)
+def _find_git_windows_unix_tools(self, tools_needed):
+assert(sys.platform == 'win32')
+if sys.version_info.major >= 3:
+import winreg
+else:
+import _winreg as winreg
+
+# Search both the 64-bit hives, as well as HKLM + HKCU
+masks = [0, winreg.KEY_WOW64_64KEY]
+hives = [winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE]
+for mask, hive in itertools.product(masks, hives):
+try:
+with winreg.OpenKey(hive, r"SOFTWARE\GitForWindows",
access=winreg.KEY_READ | mask) as key:
+install_root, _ = winreg.QueryValueEx(key, 'InstallPath')
+
+if not install_root:
+continue
+candidate_path = os.path.join(install_root, 'usr', 'bin')
+if not lit.util.checkToolsPath(candidate_path,
tools_needed):
+continue
+
+# We found it, stop enumerating.
+return candidate_path
+except:
+continue
+
+return None
+
def with_environment(self, variable, value, append_path=False):
if append_path:
# For paths, we should be able to take a list of them and process
all
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
