Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from llvm:master #21

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lldb/packages/Python/lldbsuite/test/lang/cpp/operators/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include <cstdlib>

struct B { int dummy = 2324; };
struct C {
void *operator new(size_t size) { C* r = ::new C; r->custom_new = true; return r; }

bool custom_new = false;
B b;
B* operator->() { return &b; }
int operator->*(int) { return 2; }
Expand Down Expand Up @@ -48,6 +53,11 @@ struct C {

operator int() { return 11; }
operator long() { return 12; }

// Make sure this doesn't collide with
// the real operator int.
int operatorint() { return 13; }
int operatornew() { return 14; }
};

int main(int argc, char **argv) {
Expand Down Expand Up @@ -99,6 +109,10 @@ int main(int argc, char **argv) {

result += static_cast<int>(c);
result += static_cast<long>(c);
result += c.operatorint();
result += c.operatornew();

C *c2 = new C();

//% self.expect("expr c->dummy", endstr=" 2324\n")
//% self.expect("expr c->*2", endstr=" 2\n")
Expand Down Expand Up @@ -141,5 +155,9 @@ int main(int argc, char **argv) {
//% self.expect("expr c[1]", endstr=" 92\n")
//% self.expect("expr static_cast<int>(c)", endstr=" 11\n")
//% self.expect("expr static_cast<long>(c)", endstr=" 12\n")
//% self.expect("expr c.operatorint()", endstr=" 13\n")
//% self.expect("expr c.operatornew()", endstr=" 14\n")
//% self.expect("expr (new C)->custom_new", endstr=" true\n")
delete c2;
return 0;
}
7 changes: 1 addition & 6 deletions llvm/include/llvm/ObjectYAML/ELFYAML.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,7 @@ struct Symbol {
ELF_STB Binding;
llvm::yaml::Hex64 Value;
llvm::yaml::Hex64 Size;
Optional<uint8_t> Other;

// This can be used to set any custom value for the st_other field
// when it is not possible to do so using the "Other" field, which only takes
// specific named constants.
Optional<uint8_t> StOther;
uint8_t Other;
};

struct SectionOrType {
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19552,14 +19552,14 @@ SDValue DAGCombiner::SimplifyVBinOp(SDNode *N) {
TLI.isOperationLegalOrCustomOrPromote(Opcode, NarrowVT)) {
SDLoc DL(N);
unsigned NumOperands = LHS.getNumOperands();
SmallVector<SDValue, 4> Ops;
SmallVector<SDValue, 4> ConcatOps;
for (unsigned i = 0; i != NumOperands; ++i) {
// This constant fold for operands 1 and up.
Ops.push_back(DAG.getNode(Opcode, DL, NarrowVT, LHS.getOperand(i),
RHS.getOperand(i)));
ConcatOps.push_back(DAG.getNode(Opcode, DL, NarrowVT, LHS.getOperand(i),
RHS.getOperand(i)));
}

return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Ops);
return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, ConcatOps);
}
}

Expand Down
7 changes: 1 addition & 6 deletions llvm/lib/ObjectYAML/ELFEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,7 @@ toELFSymbols(NameToIdxMap &SN2I, ArrayRef<ELFYAML::Symbol> Symbols,
}
// else Symbol.st_shndex == SHN_UNDEF (== 0), since it was zero'd earlier.
Symbol.st_value = Sym.Value;

if (Sym.Other)
Symbol.st_other = *Sym.Other;
else if (Sym.StOther)
Symbol.st_other = *Sym.StOther;

Symbol.st_other = Sym.Other;
Symbol.st_size = Sym.Size;
}

Expand Down
50 changes: 18 additions & 32 deletions llvm/lib/ObjectYAML/ELFYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,28 +866,15 @@ void MappingTraits<ELFYAML::ProgramHeader>::mapping(
namespace {

struct NormalizedOther {
NormalizedOther(IO &) {}
NormalizedOther(IO &, Optional<uint8_t> Original) {
if (uint8_t Val = *Original & 0x3)
Visibility = Val;
if (uint8_t Val = *Original & ~0x3)
Other = Val;
}

Optional<uint8_t> denormalize(IO &) {
if (!Visibility && !Other)
return None;
NormalizedOther(IO &)
: Visibility(ELFYAML::ELF_STV(0)), Other(ELFYAML::ELF_STO(0)) {}
NormalizedOther(IO &, uint8_t Original)
: Visibility(Original & 0x3), Other(Original & ~0x3) {}

uint8_t Ret = 0;
if (Visibility)
Ret |= *Visibility;
if (Other)
Ret |= *Other;
return Ret;
}
uint8_t denormalize(IO &) { return Visibility | Other; }

Optional<ELFYAML::ELF_STV> Visibility;
Optional<ELFYAML::ELF_STO> Other;
ELFYAML::ELF_STV Visibility;
ELFYAML::ELF_STO Other;
};

} // end anonymous namespace
Expand All @@ -909,16 +896,17 @@ void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) {
// targets (e.g. MIPS) may use it to specify the named bits to set (e.g.
// STO_MIPS_OPTIONAL). For producing broken objects we want to allow writing
// any value to st_other. To do this we allow one more field called "StOther".
// If it is present in a YAML document, we set st_other to its integer value
// whatever it is.
// obj2yaml should not print 'StOther', it should print 'Visibility' and
// 'Other' fields instead.
assert(!IO.outputting() || !Symbol.StOther.hasValue());
IO.mapOptional("StOther", Symbol.StOther);
MappingNormalization<NormalizedOther, Optional<uint8_t>> Keys(IO,
Symbol.Other);
IO.mapOptional("Visibility", Keys->Visibility);
IO.mapOptional("Other", Keys->Other);
// If it is present in a YAML document, we set st_other to that integer,
// ignoring the other fields.
Optional<llvm::yaml::Hex64> Other;
IO.mapOptional("StOther", Other);
if (Other) {
Symbol.Other = *Other;
} else {
MappingNormalization<NormalizedOther, uint8_t> Keys(IO, Symbol.Other);
IO.mapOptional("Visibility", Keys->Visibility, ELFYAML::ELF_STV(0));
IO.mapOptional("Other", Keys->Other, ELFYAML::ELF_STO(0));
}
}

StringRef MappingTraits<ELFYAML::Symbol>::validate(IO &IO,
Expand All @@ -927,8 +915,6 @@ StringRef MappingTraits<ELFYAML::Symbol>::validate(IO &IO,
return "Index and Section cannot both be specified for Symbol";
if (Symbol.NameIndex && !Symbol.Name.empty())
return "Name and NameIndex cannot both be specified for Symbol";
if (Symbol.StOther && Symbol.Other)
return "StOther cannot be specified for Symbol with either Visibility or Other";
return StringRef();
}

Expand Down
29 changes: 0 additions & 29 deletions llvm/test/tools/yaml2obj/elf-symbol-stother.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,3 @@ Symbols:
StOther: 4
- Name: bar
StOther: 0xff

## Check we can't set StOther for a symbol if Visibility or Other is also specified.

# RUN: not yaml2obj --docnum=5 2>&1 %s | FileCheck %s --check-prefix=ERR2
# RUN: not yaml2obj --docnum=6 2>&1 %s | FileCheck %s --check-prefix=ERR2

# ERR2: error: StOther cannot be specified for Symbol with either Visibility or Other

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Symbols:
- Name: foo
StOther: 0
Other: [ STO_MIPS_OPTIONAL ]

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Symbols:
- Name: foo
StOther: 0
Visibility: STV_DEFAULT