imaihal updated this revision to Diff 264769.
imaihal added a comment.
Herald added subscribers: lldb-commits, kbarton, hiraditya, nemanjai.
Herald added a project: LLDB.
[mlir][SystemZ] Fix incompatible datalayout in SystemZ
MLIR tests in "mlir/test/mlir-cpu-runner" fails in SystemZ (z14) because
of incompatible datalayout error. This patch fixes it by setting host
CPU name in createTargetMachine()
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80130/new/
https://reviews.llvm.org/D80130
Files:
lldb/docs/man/lldb.rst
lldb/test/Shell/Driver/TestNoUseColor.test
lldb/test/Shell/Driver/TestPositionalArgs.test
lldb/tools/driver/Driver.cpp
llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
llvm/lib/Target/PowerPC/PPCInstrInfo.h
llvm/test/CodeGen/BPF/objdump_dis_all.ll
mlir/lib/ExecutionEngine/ExecutionEngine.cpp
Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===================================================================
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -27,6 +27,7 @@
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/IRBuilder.h"
+#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Host.h"
@@ -119,8 +120,16 @@
errs() << "NO target: " << errorMessage << "\n";
return true;
}
- std::unique_ptr<llvm::TargetMachine> machine(
- target->createTargetMachine(targetTriple, "generic", "", {}, {}));
+ std::string cpu = std::string(llvm::sys::getHostCPUName());
+ llvm::SubtargetFeatures features;
+ llvm::StringMap<bool> hostFeatures;
+
+ if (llvm::sys::getHostCPUFeatures(hostFeatures))
+ for (auto &f : hostFeatures)
+ features.AddFeature(f.first(), f.second);
+
+ std::unique_ptr<llvm::TargetMachine> machine(target->createTargetMachine(
+ targetTriple, cpu, features.getString(), {}, {}));
llvmModule->setDataLayout(machine->createDataLayout());
llvmModule->setTargetTriple(targetTriple);
return false;
Index: llvm/test/CodeGen/BPF/objdump_dis_all.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/BPF/objdump_dis_all.ll
@@ -0,0 +1,26 @@
+; RUN: llc -march=bpfel -filetype=obj -o - %s | llvm-objdump -D - | FileCheck %s
+;
+; Source:
+; /* *(u64 *)(r10 - 16) = r1 */
+; unsigned long long g = 0x00000000fff01a7bULL;
+; /* *(u64 *)(r15 - 16) = r1 */
+; unsigned long long h = 0x00000000fff01f7bULL;
+; int test() {
+; return 0;
+; }
+; Compilation flag:
+; clang -target bpf -O2 -S -emit-llvm t.c
+
+@g = dso_local local_unnamed_addr global i64 4293925499, align 8
+@h = dso_local local_unnamed_addr global i64 4293926779, align 8
+
+; Function Attrs: norecurse nounwind readnone
+define dso_local i32 @test() local_unnamed_addr {
+entry:
+ ret i32 0
+}
+; CHECK-LABEL: section .data
+; CHECK-LABEL: g
+; CHECK: *(u64 *)(r10 - 16) = r1
+; CHECK-LABEL: h
+; CHECK: <unknown>
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.h
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrInfo.h
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.h
@@ -252,6 +252,8 @@
MachineInstr &NewMI1,
MachineInstr &NewMI2) const override;
+ void setSpecialOperandAttr(MachineInstr &MI, uint16_t Flags) const override;
+
bool isCoalescableExtInstr(const MachineInstr &MI,
Register &SrcReg, Register &DstReg,
unsigned &SubIdx) const override;
Index: llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
===================================================================
--- llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
+++ llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
@@ -183,6 +183,14 @@
if (Result == MCDisassembler::Fail) return MCDisassembler::Fail;
+ /* to ensure registers in range */
+ for (unsigned i = 0, e = Instr.getNumOperands(); i != e; ++i) {
+ const MCOperand &MO = Instr.getOperand(i);
+ if (MO.isReg() &&
+ (MO.getReg() <= BPF::NoRegister || MO.getReg() >= BPF::NUM_TARGET_REGS))
+ return MCDisassembler::Fail;
+ }
+
switch (Instr.getOpcode()) {
case BPF::LD_imm64:
case BPF::LD_pseudo: {
Index: lldb/tools/driver/Driver.cpp
===================================================================
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -361,13 +361,8 @@
if (m_option_data.m_process_name.empty() &&
m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID) {
- // If the option data args array is empty that means the file was not
- // specified with -f and we need to get it from the input args.
- if (m_option_data.m_args.empty()) {
- if (auto *arg = args.getLastArgNoClaim(OPT_INPUT)) {
- m_option_data.m_args.push_back(arg->getAsString((args)));
- }
- }
+ for (auto *arg : args.filtered(OPT_INPUT))
+ m_option_data.m_args.push_back(arg->getAsString((args)));
// Any argument following -- is an argument for the inferior.
if (auto *arg = args.getLastArgNoClaim(OPT_REM)) {
@@ -765,10 +760,15 @@
The debugger can be started in several modes.
Passing an executable as a positional argument prepares lldb to debug the
- given executable. Arguments passed after -- are considered arguments to the
- debugged executable.
+ given executable. To disambiguate between arguments passed to lldb and
+ arguments passed to the debugged executable, arguments starting with a - must
+ be passed after --.
+
+ lldb --arch x86_64 /path/to/program program argument -- --arch arvm7
+
+ For convenience, passing the executable after -- is also supported.
- lldb --arch x86_64 /path/to/program -- --arch arvm7
+ lldb --arch x86_64 -- /path/to/program program argument --arch arvm7
Passing one of the attach options causes lldb to immediately attach to the
given process.
Index: lldb/test/Shell/Driver/TestPositionalArgs.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Driver/TestPositionalArgs.test
@@ -0,0 +1,30 @@
+RUN: echo "int main() { return 0; }" | %clang_host -x c - -o %t.foo
+
+RUN: %lldb -x -b %t.foo bar baz quux | FileCheck %s
+RUN: %lldb -x -b -- %t.foo bar baz quux | FileCheck %s
+RUN: %lldb -x -b %t.foo -- bar baz quux | FileCheck %s
+RUN: %lldb -x -b %t.foo bar -- baz quux | FileCheck %s
+RUN: %lldb -x -b %t.foo bar baz -- quux | FileCheck %s
+RUN: %lldb %t.foo -x bar -b baz -- quux | FileCheck %s
+RUN: %lldb -x -b -f %t.foo bar baz quux | FileCheck %s
+RUN: %lldb -x -b -f %t.foo -- bar baz quux | FileCheck %s
+RUN: %lldb -x -b -f %t.foo bar -- baz quux | FileCheck %s
+RUN: %lldb -x -b -f %t.foo bar baz -- quux | FileCheck %s
+
+CHECK: Current executable set to {{.*}}foo
+CHECK: target.run-args "bar" "baz" "quux"
+
+RUN: %lldb -x -b %t.foo -- bar -baz --quux | FileCheck %s --check-prefix DASH
+RUN: %lldb -x -b -- %t.foo bar -baz --quux | FileCheck %s --check-prefix DASH
+RUN: %lldb -x -b -f %t.foo -- bar -baz --quux | FileCheck %s --check-prefix DASH
+
+DASH: Current executable set to {{.*}}foo
+DASH: target.run-args "bar" "-baz" "--quux"
+
+RUN: %lldb -x -b %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix UNKNOWN
+RUN: %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix UNKNOWN
+
+UNKNOWN: warning: ignoring unknown option: -baz
+UNKNOWN: warning: ignoring unknown option: --quux
+UNKNOWN: Current executable set to {{.*}}foo
+UNKNOWN: target.run-args "bar"
Index: lldb/test/Shell/Driver/TestNoUseColor.test
===================================================================
--- lldb/test/Shell/Driver/TestNoUseColor.test
+++ lldb/test/Shell/Driver/TestNoUseColor.test
@@ -1,4 +1,4 @@
-# RUN: %lldb --no-use-color -s %s | FileCheck %s
+# RUN: %lldb --no-use-colors -s %s | FileCheck %s
settings show use-color
# CHECK: use-color (boolean) = false
q
Index: lldb/docs/man/lldb.rst
===================================================================
--- lldb/docs/man/lldb.rst
+++ lldb/docs/man/lldb.rst
@@ -251,11 +251,16 @@
The debugger can be started in several modes.
-Passing an executable as a positional argument prepares :program:`lldb` to
-debug the given executable. Arguments passed after -- are considered arguments
-to the debugged executable.
+Passing an executable as a positional argument prepares lldb to debug the given
+executable. To disambiguate between arguments passed to lldb and arguments
+passed to the debugged executable, arguments starting with a - must be passed
+after --.
- lldb --arch x86_64 /path/to/program -- --arch arvm7
+ lldb --arch x86_64 /path/to/program program argument -- --arch arvm7
+
+For convenience, passing the executable after -- is also supported.
+
+ lldb --arch x86_64 -- /path/to/program program argument --arch arvm7
Passing one of the attach options causes :program:`lldb` to immediately attach
to the given process.
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits