[llvm-branch-commits] [llvm] 37e964d - [llvm-rc] Allow specifying language with a leading 0x prefix
Author: Martin Storsjö
Date: 2021-08-06T12:39:15-07:00
New Revision: 37e964d8a623f6ae6a9e3e95bfc2d6503b9586eb
URL:
https://github.com/llvm/llvm-project/commit/37e964d8a623f6ae6a9e3e95bfc2d6503b9586eb
DIFF:
https://github.com/llvm/llvm-project/commit/37e964d8a623f6ae6a9e3e95bfc2d6503b9586eb.diff
LOG: [llvm-rc] Allow specifying language with a leading 0x prefix
This option is always interpreted strictly as a hexadecimal string,
even if it has no prefix that indicates the number format, hence
the existing call to StringRef::getAsInteger(16, ...).
StringRef::getAsInteger(0, ...) consumes a leading "0x" prefix is
present, but when the radix is specified, the radix shouldn't
be included.
Both MS rc.exe and GNU windres accept the language with that
prefix.
Also allow specifying the codepage to llvm-windres with a different
radix, as GNU windres allows that (but MS rc.exe doesn't).
This fixes https://llvm.org/PR51295.
Differential Revision: https://reviews.llvm.org/D107263
(cherry picked from commit 46020f6f0c8aa134002208b2ecf0593b04c46d08)
Added:
Modified:
llvm/test/tools/llvm-rc/codepage.test
llvm/test/tools/llvm-rc/language.test
llvm/tools/llvm-rc/llvm-rc.cpp
Removed:
diff --git a/llvm/test/tools/llvm-rc/codepage.test
b/llvm/test/tools/llvm-rc/codepage.test
index 20639d42ecb82..a55764cd4f76a 100644
--- a/llvm/test/tools/llvm-rc/codepage.test
+++ b/llvm/test/tools/llvm-rc/codepage.test
@@ -4,6 +4,8 @@
; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
; RUN: llvm-windres --no-preprocess --codepage 65001 %p/Inputs/utf8.rc
%t.utf8.res
; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
+; RUN: llvm-windres --no-preprocess --codepage 0xfde9 %p/Inputs/utf8.rc
%t.utf8.res
+; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
; UTF8: Resource type (int): STRINGTABLE (ID 6)
; UTF8-NEXT: Resource name (int): 1
diff --git a/llvm/test/tools/llvm-rc/language.test
b/llvm/test/tools/llvm-rc/language.test
index 9960ae108dfef..539371057414d 100644
--- a/llvm/test/tools/llvm-rc/language.test
+++ b/llvm/test/tools/llvm-rc/language.test
@@ -6,6 +6,8 @@
; RUN: llvm-readobj %t.res | FileCheck %s
; RUN: llvm-windres --no-preprocess --language 40A %p/Inputs/language.rc %t.res
; RUN: llvm-readobj %t.res | FileCheck %s
+; RUN: llvm-windres --no-preprocess -l 0x40A %p/Inputs/language.rc %t.res
+; RUN: llvm-readobj %t.res | FileCheck %s
; CHECK: Resource name (int): 1
; CHECK-NEXT: Data version:
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 0f70e30b2b38f..83925c2ce7725 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -476,13 +476,14 @@ RcOptions parseWindresOptions(ArrayRef
ArgsArr,
Opts.Params.CodePage = CpWin1252; // Different default
if (InputArgs.hasArg(WINDRES_codepage)) {
if (InputArgs.getLastArgValue(WINDRES_codepage)
-.getAsInteger(10, Opts.Params.CodePage))
+.getAsInteger(0, Opts.Params.CodePage))
fatalError("Invalid code page: " +
InputArgs.getLastArgValue(WINDRES_codepage));
}
if (InputArgs.hasArg(WINDRES_language)) {
-if (InputArgs.getLastArgValue(WINDRES_language)
-.getAsInteger(16, Opts.LangId))
+StringRef Val = InputArgs.getLastArgValue(WINDRES_language);
+Val.consume_front_insensitive("0x");
+if (Val.getAsInteger(16, Opts.LangId))
fatalError("Invalid language id: " +
InputArgs.getLastArgValue(WINDRES_language));
}
@@ -565,7 +566,9 @@ RcOptions parseRcOptions(ArrayRef ArgsArr,
}
Opts.AppendNull = InputArgs.hasArg(OPT_add_null);
if (InputArgs.hasArg(OPT_lang_id)) {
-if (InputArgs.getLastArgValue(OPT_lang_id).getAsInteger(16, Opts.LangId))
+StringRef Val = InputArgs.getLastArgValue(OPT_lang_id);
+Val.consume_front_insensitive("0x");
+if (Val.getAsInteger(16, Opts.LangId))
fatalError("Invalid language id: " +
InputArgs.getLastArgValue(OPT_lang_id));
}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 14d0d1f - [InstCombine] Fixed select + masked load fold failure
Author: Dylan Fleming
Date: 2021-08-06T12:41:06-07:00
New Revision: 14d0d1f0985c93cbc830332cbeb99247eaf01f68
URL:
https://github.com/llvm/llvm-project/commit/14d0d1f0985c93cbc830332cbeb99247eaf01f68
DIFF:
https://github.com/llvm/llvm-project/commit/14d0d1f0985c93cbc830332cbeb99247eaf01f68.diff
LOG: [InstCombine] Fixed select + masked load fold failure
Fixed type assertion failure caused by trying to fold a masked load with a
select where the select condition is a scalar value
Reviewed By: sdesmalen, lebedev.ri
Differential Revision: https://reviews.llvm.org/D107372
(cherry picked from commit 3943a74666cbe718b74e06092ce3b4c20e85fde1)
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-masked_load.ll
Removed:
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index ce2b913dba613..5bbc3c87ca4f2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -3230,7 +3230,8 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst
&SI) {
Value *Mask;
if (match(TrueVal, m_Zero()) &&
match(FalseVal, m_MaskedLoad(m_Value(), m_Value(), m_Value(Mask),
- m_CombineOr(m_Undef(), m_Zero() {
+ m_CombineOr(m_Undef(), m_Zero( &&
+ (CondVal->getType() == Mask->getType())) {
// We can remove the select by ensuring the load zeros all lanes the
// select would have. We determine this by proving there is no overlap
// between the load and select masks.
diff --git a/llvm/test/Transforms/InstCombine/select-masked_load.ll
b/llvm/test/Transforms/InstCombine/select-masked_load.ll
index 40f05fb4e68d2..3187a9e5bf655 100644
--- a/llvm/test/Transforms/InstCombine/select-masked_load.ll
+++ b/llvm/test/Transforms/InstCombine/select-masked_load.ll
@@ -94,5 +94,18 @@ define <4 x float> @masked_load_and_zero_inactive_8(<4 x
float>* %ptr, <4 x i1>
ret <4 x float> %masked
}
+define <8 x float> @masked_load_and_scalar_select_cond(<8 x float>* %ptr, <8 x
i1> %mask, i1 %cond) {
+; CHECK-LABEL: @masked_load_and_scalar_select_cond(
+; CHECK-NEXT: entry:
+; CHECK-NEXT:[[TMP0:%.*]] = call <8 x float>
@llvm.masked.load.v8f32.p0v8f32(<8 x float>* [[PTR:%.*]], i32 32, <8 x i1>
[[MASK:%.*]], <8 x float> undef)
+; CHECK-NEXT:[[TMP1:%.*]] = select i1 [[COND:%.*]], <8 x float>
zeroinitializer, <8 x float> [[TMP0]]
+; CHECK-NEXT:ret <8 x float> [[TMP1]]
+entry:
+ %0 = call <8 x float> @llvm.masked.load.v8f32.p0v8f32(<8 x float>* %ptr, i32
32, <8 x i1> %mask, <8 x float> undef)
+ %1 = select i1 %cond, <8 x float> zeroinitializer, <8 x float> %0
+ ret <8 x float> %1
+}
+
+declare <8 x float> @llvm.masked.load.v8f32.p0v8f32(<8 x float>*, i32 immarg,
<8 x i1>, <8 x float>)
declare <4 x i32> @llvm.masked.load.v4i32.p0v4i32(<4 x i32>*, i32 immarg, <4 x
i1>, <4 x i32>)
declare <4 x float> @llvm.masked.load.v4f32.p0v4f32(<4 x float>*, i32 immarg,
<4 x i1>, <4 x float>)
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 8fbd0e2 - [clang] [clang-repl] Fix linking against LLVMLineEditor
Author: Michał Górny
Date: 2021-08-06T12:43:37-07:00
New Revision: 8fbd0e2670f21403c923279e9cabcdb1d4dd8d18
URL:
https://github.com/llvm/llvm-project/commit/8fbd0e2670f21403c923279e9cabcdb1d4dd8d18
DIFF:
https://github.com/llvm/llvm-project/commit/8fbd0e2670f21403c923279e9cabcdb1d4dd8d18.diff
LOG: [clang] [clang-repl] Fix linking against LLVMLineEditor
LLVMLineEditor library is part of the LLVM dylib. Move it into
LLVM_LINK_COMPONENTS to avoid duplicate linking when dylib is being
used. This fixes building standalone clang against installed LLVM
without static libraries.
Differential Revision: https://reviews.llvm.org/D107558
(cherry picked from commit d99e9461b07988914cba573800cd1862f277e155)
Added:
Modified:
clang/tools/clang-repl/CMakeLists.txt
Removed:
diff --git a/clang/tools/clang-repl/CMakeLists.txt
b/clang/tools/clang-repl/CMakeLists.txt
index ae0e4f39be70f..c2576d7c564d9 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -1,6 +1,7 @@
set( LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Core
+ LineEditor
Option
OrcJIT
Support
@@ -14,5 +15,4 @@ clang_target_link_libraries(clang-repl PUBLIC
clangBasic
clangInterpreter
clangTooling
- LLVMLineEditor
)
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 6cdf6e5 - BPF: avoid NE/EQ loop exit condition
Author: Yonghong Song Date: 2021-08-06T12:45:53-07:00 New Revision: 6cdf6e50442cc2c9d19a241ab61db83cde80d416 URL: https://github.com/llvm/llvm-project/commit/6cdf6e50442cc2c9d19a241ab61db83cde80d416 DIFF: https://github.com/llvm/llvm-project/commit/6cdf6e50442cc2c9d19a241ab61db83cde80d416.diff LOG: BPF: avoid NE/EQ loop exit condition Kuniyuki Iwashima reported in [1] that llvm compiler may convert a loop exit condition with "i < bound" to "i != bound", where "i" is the loop index variable and "bound" is the upper bound. In case that "bound" is not a constant, verifier will always have "i != bound" true, which will cause verifier failure since to verifier this is an infinite loop. The fix is to avoid transforming "i < bound" to "i != bound". In llvm, the transformation is done by IndVarSimplify pass. The compiler checks loop condition cost (i = i + 1) and if the cost is lower, it may transform "i < bound" to "i != bound". This patch implemented getArithmeticInstrCost() in BPF TargetTransformInfo class to return a higher cost for such an operation, which will prevent the transformation for the test case added in this patch. [1] https://lore.kernel.org/netdev/[email protected]/ Differential Revision: https://reviews.llvm.org/D107483 (cherry picked from commit e52946b9ababcbf8e6f40b1b15900ae2e795a1c6) Added: llvm/test/CodeGen/BPF/loop-exit-cond.ll Modified: llvm/lib/Target/BPF/BPFTargetTransformInfo.h Removed: diff --git a/llvm/lib/Target/BPF/BPFTargetTransformInfo.h b/llvm/lib/Target/BPF/BPFTargetTransformInfo.h index 3bc5556a62f4d..417e8b6ffec37 100644 --- a/llvm/lib/Target/BPF/BPFTargetTransformInfo.h +++ b/llvm/lib/Target/BPF/BPFTargetTransformInfo.h @@ -54,6 +54,24 @@ class BPFTTIImpl : public BasicTTIImplBase { return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind, I); } + + InstructionCost getArithmeticInstrCost( +unsigned Opcode, Type *Ty, +TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, +TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, +TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, +TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, +TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, +ArrayRef Args = ArrayRef(), +const Instruction *CxtI = nullptr) { + int ISD = TLI->InstructionOpcodeToISD(Opcode); + if (ISD == ISD::ADD && CostKind == TTI::TCK_RecipThroughput) +return SCEVCheapExpansionBudget.getValue() + 1; + + return BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Opd1Info, + Opd2Info, Opd1PropInfo, + Opd2PropInfo); + } }; } // end namespace llvm diff --git a/llvm/test/CodeGen/BPF/loop-exit-cond.ll b/llvm/test/CodeGen/BPF/loop-exit-cond.ll new file mode 100644 index 0..9883367a5b449 --- /dev/null +++ b/llvm/test/CodeGen/BPF/loop-exit-cond.ll @@ -0,0 +1,131 @@ +; RUN: opt -O2 -S -o %t1 < %s +; RUN: llc -march=bpf -mcpu=v3 %t1 -o - | FileCheck %s +; +; Source code: +; typedef unsigned long u64; +; void foo(char *data, int idx, u64 *); +; int test(int len, char *data) { +; if (len < 100) { +; for (int i = 1; i < len; i++) { +; u64 d[1]; +; d[0] = data[0] ?: '0'; +; foo("%c", i, d); +; } +; } +; return 0; +; } +; Compilation flag: +; clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes test.c + +; ModuleID = 'test.c' +source_filename = "test.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" +target triple = "bpf" + [email protected] = private unnamed_addr constant [3 x i8] c"%c\00", align 1 + +; Function Attrs: nounwind +define dso_local i32 @test(i32 %len, i8* %data) #0 { +entry: + %len.addr = alloca i32, align 4 + %data.addr = alloca i8*, align 8 + %i = alloca i32, align 4 + %d = alloca [1 x i64], align 8 + store i32 %len, i32* %len.addr, align 4, !tbaa !3 + store i8* %data, i8** %data.addr, align 8, !tbaa !7 + %0 = load i32, i32* %len.addr, align 4, !tbaa !3 + %cmp = icmp slt i32 %0, 100 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + %1 = bitcast i32* %i to i8* + call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) #3 + store i32 1, i32* %i, align 4, !tbaa !3 + br label %for.cond + +for.cond: ; preds = %for.inc, %if.then + %2 = load i32, i32* %i, align 4, !tbaa !3 + %3 = load i32, i32* %len.addr, align 4, !tbaa !3 + %cmp1 = icmp slt i32 %2, %3 + br i1 %cmp1, label %for.body, label %for.cond.cleanup + +; CHECK: w[[LEN:[0-9]+]] = w1 +; CHECK: w[[IDX:[0-9]+]] += 1 +; CHECK-NEXT: w[[IDX]] s< w[[LEN]] goto + +for.cond.cleanup: ; preds = %for.cond + %4 = bitcast i32* %i to i8* +
[llvm-branch-commits] [llvm] f0bdb5e - [llvm] [lit] Fix inconsistent test order in shtest-keyword-parse-errors
Author: Michał Górny
Date: 2021-08-06T12:50:56-07:00
New Revision: f0bdb5eab7f97d3de17d093418f627cc5ce5fe82
URL:
https://github.com/llvm/llvm-project/commit/f0bdb5eab7f97d3de17d093418f627cc5ce5fe82
DIFF:
https://github.com/llvm/llvm-project/commit/f0bdb5eab7f97d3de17d093418f627cc5ce5fe82.diff
LOG: [llvm] [lit] Fix inconsistent test order in shtest-keyword-parse-errors
Remove test times when running shtest-keyword-parse-errors test,
in order to prevent the previous executions from impacting subtest
order and therefore causing FileCheck to fail.
Differential Revision: https://reviews.llvm.org/D107427
(cherry picked from commit 39fa96a4906934774ba20bcb0cd5f808f619f3a6)
Added:
Modified:
llvm/utils/lit/tests/shtest-keyword-parse-errors.py
Removed:
diff --git a/llvm/utils/lit/tests/shtest-keyword-parse-errors.py
b/llvm/utils/lit/tests/shtest-keyword-parse-errors.py
index fb652bd5964d9..78cbf81a3e6a0 100644
--- a/llvm/utils/lit/tests/shtest-keyword-parse-errors.py
+++ b/llvm/utils/lit/tests/shtest-keyword-parse-errors.py
@@ -1,3 +1,6 @@
+# FIXME: this test depends on order of tests
+# RUN: rm -f %{inputs}/shtest-keyword-parse-errors/.lit_test_times.txt
+
# RUN: not %{lit} -j 1 -vv %{inputs}/shtest-keyword-parse-errors > %t.out
# RUN: FileCheck -input-file %t.out %s
#
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
