r357127 - Revert "[WebAssembly] Don't use default GetLinkerPath"
Author: dschuff Date: Wed Mar 27 15:22:18 2019 New Revision: 357127 URL: http://llvm.org/viewvc/llvm-project?rev=357127&view=rev Log: Revert "[WebAssembly] Don't use default GetLinkerPath" This reverts commit 4dcf3acce6d7455fd079d8e57441906ca2bad254. (reverts LLVM SVN r356953) Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp cfe/trunk/lib/Driver/ToolChains/WebAssembly.h cfe/trunk/test/Driver/wasm-toolchain.c cfe/trunk/test/Driver/wasm-toolchain.cpp Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=357127&r1=357126&r2=357127&view=diff == --- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Wed Mar 27 15:22:18 2019 @@ -12,8 +12,6 @@ #include "clang/Driver/Driver.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/Path.h" #include "llvm/Option/ArgList.h" using namespace clang::driver; @@ -38,25 +36,6 @@ bool wasm::Linker::isLinkJob() const { r bool wasm::Linker::hasIntegratedCPP() const { return false; } -std::string wasm::Linker::getLinkerPath(const ArgList &Args) const { - const ToolChain &ToolChain = getToolChain(); - if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) { -StringRef UseLinker = A->getValue(); -if (!UseLinker.empty()) { - if (llvm::sys::path::is_absolute(UseLinker) && - llvm::sys::fs::can_execute(UseLinker)) -return UseLinker; - - // Accept 'lld', and 'ld' as aliases for the default linker - if (UseLinker != "lld" && UseLinker != "ld") -ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name) -<< A->getAsString(Args); -} - } - - return ToolChain.getDefaultLinker(); -} - void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, @@ -64,7 +43,7 @@ void wasm::Linker::ConstructJob(Compilat const char *LinkingOutput) const { const ToolChain &ToolChain = getToolChain(); - const char *Linker = Args.MakeArgString(getLinkerPath(Args)); + const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath()); ArgStringList CmdArgs; if (Args.hasArg(options::OPT_s)) Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=357127&r1=357126&r2=357127&view=diff == --- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original) +++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Wed Mar 27 15:22:18 2019 @@ -23,7 +23,6 @@ public: explicit Linker(const ToolChain &TC); bool isLinkJob() const override; bool hasIntegratedCPP() const override; - std::string getLinkerPath(const llvm::opt::ArgList &Args) const; void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, Modified: cfe/trunk/test/Driver/wasm-toolchain.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=357127&r1=357126&r2=357127&view=diff == --- cfe/trunk/test/Driver/wasm-toolchain.c (original) +++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Mar 27 15:22:18 2019 @@ -12,25 +12,25 @@ // A basic C link command-line with unknown OS. -// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s +// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" // A basic C link command-line with optimization with unknown OS. -// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s +// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" // A basic C link command-line with known OS. -// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s +// RUN
[llvm] [compiler-rt] [lldb] [mlir] [libc] [libcxx] [openmp] [clang] [flang] [lld] [polly] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
@@ -0,0 +1,125 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -O0 | FileCheck %s dschuff wrote: Is there a test that covers this behavior for DAG ISel? Maybe it would make sense to add test expectations for both here? https://github.com/llvm/llvm-project/pull/77281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[polly] [flang] [mlir] [openmp] [libc] [compiler-rt] [lld] [llvm] [lldb] [clang] [libcxx] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
https://github.com/dschuff approved this pull request. Thanks for the fix! https://github.com/llvm/llvm-project/pull/77281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [llvm] [clang] [lld] [libcxx] [libc] [mlir] [compiler-rt] [openmp] [polly] [flang] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
@@ -839,9 +839,11 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) { unsigned Reg; -if (Attrs.hasParamAttr(I, Attribute::SExt)) +if (Attrs.hasParamAttr(I, Attribute::SExt) || +(IsDirect && Func->hasParamAttribute(I, Attribute::SExt))) dschuff wrote: Pointers are (on their way to being) opaque; I forget whether function pointers ever had these parameters attached, but in any case they soon won't, so for indirect calls I think it should just be the instruction. https://github.com/llvm/llvm-project/pull/77281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lld] [compiler-rt] [openmp] [flang] [lldb] [libcxx] [libc] [mlir] [llvm] [clang] [polly] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
dschuff wrote: Yeah, sorry I missed Alex's suggestion there. There's no hurry. https://github.com/llvm/llvm-project/pull/77281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [llvm] [CodeGen] Mark mem intrinsic loads and stores as dereferenceable (PR #80184)
https://github.com/dschuff updated https://github.com/llvm/llvm-project/pull/80184 >From 8fce40a38370f92926f1dabbc00c29e2d48b46e7 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Tue, 30 Jan 2024 17:39:00 -0800 Subject: [PATCH 1/6] Use getObjectPtrOffset to generate constant offsets for memcpy/memset --- .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 19 ++- llvm/lib/IR/Function.cpp | 1 + .../WebAssembly/mem-intrinsics-offsets.ll | 14 ++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 llvm/test/CodeGen/WebAssembly/mem-intrinsics-offsets.ll diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 3c1343836187a9..45ce8b75cb1e6f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -7571,17 +7571,21 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, const SDLoc &dl, SrcMMOFlags |= MachineMemOperand::MODereferenceable; if (isConstant) SrcMMOFlags |= MachineMemOperand::MOInvariant; - +llvm::errs() << "isDereferenceable " << isDereferenceable<<'\n'; Value = DAG.getExtLoad( ISD::EXTLOAD, dl, NVT, Chain, - DAG.getMemBasePlusOffset(Src, TypeSize::getFixed(SrcOff), dl), + isDereferenceable ? DAG.getObjectPtrOffset(dl, Src, TypeSize::getFixed(SrcOff)) : +DAG.getMemBasePlusOffset(Src, TypeSize::getFixed(SrcOff), dl), SrcPtrInfo.getWithOffset(SrcOff), VT, commonAlignment(*SrcAlign, SrcOff), SrcMMOFlags, NewAAInfo); OutLoadChains.push_back(Value.getValue(1)); + isDereferenceable = +DstPtrInfo.getWithOffset(DstOff).isDereferenceable(VTSize, C, DL); Store = DAG.getTruncStore( Chain, dl, Value, - DAG.getMemBasePlusOffset(Dst, TypeSize::getFixed(DstOff), dl), + isDereferenceable ? DAG.getObjectPtrOffset(dl, Dst, TypeSize::getFixed(DstOff)) : +DAG.getMemBasePlusOffset(Dst, TypeSize::getFixed(DstOff), dl), DstPtrInfo.getWithOffset(DstOff), VT, Alignment, MMOFlags, NewAAInfo); OutStoreChains.push_back(Store); } @@ -7715,7 +7719,7 @@ static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, const SDLoc &dl, MachineMemOperand::Flags SrcMMOFlags = MMOFlags; if (isDereferenceable) SrcMMOFlags |= MachineMemOperand::MODereferenceable; - +// TODO: Fix memmove too. Value = DAG.getLoad( VT, dl, Chain, DAG.getMemBasePlusOffset(Src, TypeSize::getFixed(SrcOff), dl), @@ -7863,9 +7867,13 @@ static SDValue getMemsetStores(SelectionDAG &DAG, const SDLoc &dl, Value = getMemsetValue(Src, VT, DAG, dl); } assert(Value.getValueType() == VT && "Value with wrong type."); +bool Dereferenceable = DstPtrInfo.isDereferenceable(DstOff, *DAG.getContext(), DAG.getDataLayout()); +llvm::errs() << llvm::format(" calling, dstoff %d deref is %d", DstOff, Dereferenceable)<<"\n"; + SDValue Store = DAG.getStore( Chain, dl, Value, -DAG.getMemBasePlusOffset(Dst, TypeSize::getFixed(DstOff), dl), +Dereferenceable ? DAG.getObjectPtrOffset(dl, Dst, TypeSize::getFixed(DstOff)) : + DAG.getMemBasePlusOffset(Dst, TypeSize::getFixed(DstOff), dl), DstPtrInfo.getWithOffset(DstOff), Alignment, isVol ? MachineMemOperand::MOVolatile : MachineMemOperand::MONone, NewAAInfo); @@ -8112,6 +8120,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, // For cases within the target-specified limits, this is the best choice. ConstantSDNode *ConstantSize = dyn_cast(Size); if (ConstantSize) { +llvm::errs() << "Constant size\n"; // Memset with size zero? Just return the original chain. if (ConstantSize->isZero()) return Chain; diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 22e2455462bf44..2ae3cc3081165a 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -242,6 +242,7 @@ Type *Argument::getParamInAllocaType() const { uint64_t Argument::getDereferenceableBytes() const { assert(getType()->isPointerTy() && "Only pointers have dereferenceable bytes"); + this->dump(); return getParent()->getParamDereferenceableBytes(getArgNo()); } diff --git a/llvm/test/CodeGen/WebAssembly/mem-intrinsics-offsets.ll b/llvm/test/CodeGen/WebAssembly/mem-intrinsics-offsets.ll new file mode 100644 index 00..9890a0383ed30e --- /dev/null +++ b/llvm/test/CodeGen/WebAssembly/mem-intrinsics-offsets.ll @@ -0,0 +1,14 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mcpu=mvp -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -tail-dup-placement=0 | FileCheck % + +target triple = "wasm32-unknown-unknown" + +define void @call_memset(ptr dereferenceable(16)) #0
[clang] [llvm] [clang-tools-extra] [CodeGen] Mark mem intrinsic loads and stores as dereferenceable (PR #80184)
dschuff wrote: I am getting one local test failure here, in `/test/CodeGen/BPF/undef.ll`: The test has a bunch of [stores](https://github.com/llvm/llvm-project/blob/cdd9221489ec4ed6afc0e5146c2fae4daa8ab260/llvm/test/CodeGen/BPF/undef.ll#L44-L54) into an alloca, which i think are supposed to get converted to a single memset, so the test calls for ``` ; EL: r1 = 11033905661445 ll ; CHECK: *(u64 *)(r10 - 8) = r1 ``` (where 11033905661445 is 0xA0908070605, i.e. the stored values). With this change the output is ``` r1 = 2569 *(u16 *)(r10 - 4) = r1 r1 = 134678021 *(u32 *)(r10 - 8) = r1 ``` i.e. the 0x0A09 has been split out from the 0x8070605. I have no idea yet why this change would do that. Also, there is actually a memset on the next line, which seem to be zeroing the memory *after* the alloca'd pointer (which I think is UB?). Removing it doesn't seem to affect the output, but maybe something weird is going on. https://github.com/llvm/llvm-project/pull/80184 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lld] [clang-tools-extra] [llvm] [clang] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)
https://github.com/dschuff created https://github.com/llvm/llvm-project/pull/79235 This change allows a WasmObjectFile to be created from a wasm file even if it uses typed funcrefs and GC types. It does not significantly change how lib/Object models its various internal types (e.g. WasmSignature, WasmElemSegment), so LLVM does not really "support" or understand such files, but it is sufficient to parse the type, global and element sections, discarding types that are not understood. This is useful for low-level binary tools such as nm and objcopy, which use only limited aspects of the binary (such as function definitions) or deal with sections as opaque blobs. This is done by allowing `WasmValType` to have a value of `OTHERREF` (representing any unmodeled reference type), and adding a field to `WasmSignature` indicating it's a placeholder for an unmodeled reference type (since there is a 1:1 correspondence between WasmSignature objects and types in the type section). Then the object file parsers for the type and element sections are expanded to parse encoded reference types and discard any unmodeled fields. >From 976c98f631e5ed48bb18accbe59c9babd354a924 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 3 Jan 2024 09:06:37 -0800 Subject: [PATCH 01/11] parse types --- llvm/include/llvm/BinaryFormat/Wasm.h | 8 +++ llvm/lib/Object/WasmObjectFile.cpp| 83 +++ 2 files changed, 91 insertions(+) diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h index c7658cc7b7432b3..89499a61b76c8c3 100644 --- a/llvm/include/llvm/BinaryFormat/Wasm.h +++ b/llvm/include/llvm/BinaryFormat/Wasm.h @@ -265,7 +265,13 @@ enum : unsigned { WASM_TYPE_V128 = 0x7B, WASM_TYPE_FUNCREF = 0x70, WASM_TYPE_EXTERNREF = 0x6F, + WASM_TYPE_NULLABLE = 0x63, WASM_TYPE_FUNC = 0x60, + WASM_TYPE_ARRAY = 0x5E, // Composite types, not used for codegen + WASM_TYPE_STRUCT = 0x5F, + WASM_TYPE_SUB = 0x50, + WASM_TYPE_SUB_FINAL = 0x4F, + WASM_TYPE_REC = 0x4E, WASM_TYPE_NORESULT = 0x40, // for blocks with no result values }; @@ -431,11 +437,13 @@ enum class ValType { V128 = WASM_TYPE_V128, FUNCREF = WASM_TYPE_FUNCREF, EXTERNREF = WASM_TYPE_EXTERNREF, + OTHERREF, }; struct WasmSignature { SmallVector Returns; SmallVector Params; + enum {Function, Other} Kind = Function; // Support empty and tombstone instances, needed by DenseMap. enum { Plain, Empty, Tombstone } State = Plain; diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 94cd96968ff2010..3d2b06342481aa0 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -21,6 +21,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Format.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/TargetParser/SubtargetFeature.h" @@ -29,6 +30,7 @@ #include #include #include +#include #define DEBUG_TYPE "wasm-object" @@ -1104,26 +1106,107 @@ Error WasmObjectFile::parseCustomSection(WasmSection &Sec, ReadContext &Ctx) { } Error WasmObjectFile::parseTypeSection(ReadContext &Ctx) { + auto parseFieldDef = [&]() { +int32_t TypeCode = readVarint32((Ctx)); +uint32_t Mutability = readVaruint32(Ctx); + }; + auto parseRecType = [&]() { +uint8_t Form = readUint8(Ctx); +if (Form == wasm::WASM_TYPE_REC) { + uint32_t Size = readVaruint32(Ctx); + assert(Size > 0); // TODO real errors here and below + Form = readVaruint32(Ctx); +} +if (Form == wasm::WASM_TYPE_SUB || Form == wasm::WASM_TYPE_SUB_FINAL) { + uint32_t Supers = readVaruint32(Ctx); + if (Supers > 0) { +assert(Supers == 1); +uint32_t SuperIndex = readVaruint32(Ctx); + } + Form = readVaruint32(Ctx); +} +if (Form == wasm::WASM_TYPE_STRUCT) { + uint32_t NumFields = readVaruint32(Ctx); + for (size_t i = 0; i < NumFields; i++) { +parseFieldDef(); + } +} else if (Form == wasm::WASM_TYPE_ARRAY) { + parseFieldDef(); +} + + }; + auto parseParamType = [&](uint32_t code) -> wasm::ValType { +switch(code) { + case wasm::WASM_TYPE_I32: + case wasm::WASM_TYPE_I64: + case wasm::WASM_TYPE_F32: + case wasm::WASM_TYPE_F64: + case wasm::WASM_TYPE_V128: + case wasm::WASM_TYPE_FUNCREF: + case wasm::WASM_TYPE_EXTERNREF: +return wasm::ValType(code); +} + }; uint32_t Count = readVaruint32(Ctx); Signatures.reserve(Count); while (Count--) { wasm::WasmSignature Sig; uint8_t Form = readUint8(Ctx); +llvm::errs() << llvm::format("Top Count %d form %x", Count, Form) << '\n'; +if (Form == wasm::WASM_TYPE_REC) { + uint32_t Size = readVaruint32(Ctx); + assert(Size > 0); // TODO real errors here and below + Form = readVaruint32(Ctx); + wasm::
[lld] [clang] [llvm] [clang-tools-extra] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)
@@ -259,10 +259,13 @@ class InputFunction : public InputChunk { file->codeSection->Content.slice(inputSectionOffset, function->Size); debugName = function->DebugName; comdat = function->Comdat; +assert(s.Kind != WasmSignature::Placeholder); dschuff wrote: My guess with the assert was that we should never get here, because we would never expect to see a file with a symbol table that also had GC. But yeah, also enforcing it on entry to the linker makes sense. I wonder if a more specific or meaningful error message would make sense (I guess in this case if you tried to link something that just happened to have some unrelated GC types, the link error would be the same as if there were no linking section). https://github.com/llvm/llvm-project/pull/79235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [lld] [clang] [clang-tools-extra] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)
https://github.com/dschuff updated https://github.com/llvm/llvm-project/pull/79235 >From 976c98f631e5ed48bb18accbe59c9babd354a924 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 3 Jan 2024 09:06:37 -0800 Subject: [PATCH 01/12] parse types --- llvm/include/llvm/BinaryFormat/Wasm.h | 8 +++ llvm/lib/Object/WasmObjectFile.cpp| 83 +++ 2 files changed, 91 insertions(+) diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h index c7658cc7b7432b3..89499a61b76c8c3 100644 --- a/llvm/include/llvm/BinaryFormat/Wasm.h +++ b/llvm/include/llvm/BinaryFormat/Wasm.h @@ -265,7 +265,13 @@ enum : unsigned { WASM_TYPE_V128 = 0x7B, WASM_TYPE_FUNCREF = 0x70, WASM_TYPE_EXTERNREF = 0x6F, + WASM_TYPE_NULLABLE = 0x63, WASM_TYPE_FUNC = 0x60, + WASM_TYPE_ARRAY = 0x5E, // Composite types, not used for codegen + WASM_TYPE_STRUCT = 0x5F, + WASM_TYPE_SUB = 0x50, + WASM_TYPE_SUB_FINAL = 0x4F, + WASM_TYPE_REC = 0x4E, WASM_TYPE_NORESULT = 0x40, // for blocks with no result values }; @@ -431,11 +437,13 @@ enum class ValType { V128 = WASM_TYPE_V128, FUNCREF = WASM_TYPE_FUNCREF, EXTERNREF = WASM_TYPE_EXTERNREF, + OTHERREF, }; struct WasmSignature { SmallVector Returns; SmallVector Params; + enum {Function, Other} Kind = Function; // Support empty and tombstone instances, needed by DenseMap. enum { Plain, Empty, Tombstone } State = Plain; diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 94cd96968ff2010..3d2b06342481aa0 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -21,6 +21,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Format.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/TargetParser/SubtargetFeature.h" @@ -29,6 +30,7 @@ #include #include #include +#include #define DEBUG_TYPE "wasm-object" @@ -1104,26 +1106,107 @@ Error WasmObjectFile::parseCustomSection(WasmSection &Sec, ReadContext &Ctx) { } Error WasmObjectFile::parseTypeSection(ReadContext &Ctx) { + auto parseFieldDef = [&]() { +int32_t TypeCode = readVarint32((Ctx)); +uint32_t Mutability = readVaruint32(Ctx); + }; + auto parseRecType = [&]() { +uint8_t Form = readUint8(Ctx); +if (Form == wasm::WASM_TYPE_REC) { + uint32_t Size = readVaruint32(Ctx); + assert(Size > 0); // TODO real errors here and below + Form = readVaruint32(Ctx); +} +if (Form == wasm::WASM_TYPE_SUB || Form == wasm::WASM_TYPE_SUB_FINAL) { + uint32_t Supers = readVaruint32(Ctx); + if (Supers > 0) { +assert(Supers == 1); +uint32_t SuperIndex = readVaruint32(Ctx); + } + Form = readVaruint32(Ctx); +} +if (Form == wasm::WASM_TYPE_STRUCT) { + uint32_t NumFields = readVaruint32(Ctx); + for (size_t i = 0; i < NumFields; i++) { +parseFieldDef(); + } +} else if (Form == wasm::WASM_TYPE_ARRAY) { + parseFieldDef(); +} + + }; + auto parseParamType = [&](uint32_t code) -> wasm::ValType { +switch(code) { + case wasm::WASM_TYPE_I32: + case wasm::WASM_TYPE_I64: + case wasm::WASM_TYPE_F32: + case wasm::WASM_TYPE_F64: + case wasm::WASM_TYPE_V128: + case wasm::WASM_TYPE_FUNCREF: + case wasm::WASM_TYPE_EXTERNREF: +return wasm::ValType(code); +} + }; uint32_t Count = readVaruint32(Ctx); Signatures.reserve(Count); while (Count--) { wasm::WasmSignature Sig; uint8_t Form = readUint8(Ctx); +llvm::errs() << llvm::format("Top Count %d form %x", Count, Form) << '\n'; +if (Form == wasm::WASM_TYPE_REC) { + uint32_t Size = readVaruint32(Ctx); + assert(Size > 0); // TODO real errors here and below + Form = readVaruint32(Ctx); + wasm::WasmSignature s; s.Kind = s.Other; + Signatures.push_back(s); + Count--; + llvm::errs() << llvm::format(" Rec size %d form %x", Size, Form) << '\n'; +} if (Form != wasm::WASM_TYPE_FUNC) { + wasm::WasmSignature s; s.Kind = s.Other; + if (Form == wasm::WASM_TYPE_SUB || Form == wasm::WASM_TYPE_SUB_FINAL) { +uint32_t Supers = readVaruint32(Ctx); +if (Supers > 0) { + assert(Supers == 1); + uint32_t SuperIndex = readVaruint32(Ctx); +} +Form = readVaruint32(Ctx); +llvm::errs() << llvm::format(" Sub Supers %d form %x", Supers, Form) << '\n'; + } + if (Form == wasm::WASM_TYPE_STRUCT) { +uint32_t NumFields = readVaruint32(Ctx); +for (size_t i = 0; i < NumFields; i++) { + parseFieldDef(); +} +llvm::errs() << llvm::format(" Struct size %d", NumFields) << '\n'; + } else if (Form == wasm::WASM_TYPE_ARRAY) { +parseFieldDef(); +llvm::errs() << llvm::format("arr form %x", Form) << '\n'; +
[llvm] [lld] [clang] [clang-tools-extra] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)
@@ -259,10 +259,13 @@ class InputFunction : public InputChunk { file->codeSection->Content.slice(inputSectionOffset, function->Size); debugName = function->DebugName; comdat = function->Comdat; +assert(s.Kind != WasmSignature::Placeholder); dschuff wrote: I added a more explicit check in `createObjectFile`. I don't have test because I haven't yet successfully created a file with both GC types and a linking section that wasn't also rejected by the object file parser. But a little redundancy in the checks seems fine. https://github.com/llvm/llvm-project/pull/79235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lld] [llvm] [clang] [clang-tools-extra] [Object][Wasm] Allow parsing of GC types in type and table sections (PR #79235)
https://github.com/dschuff closed https://github.com/llvm/llvm-project/pull/79235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0ff28fa - Support dwarf fission for wasm object files
Author: Derek Schuff Date: 2020-09-17T14:42:41-07:00 New Revision: 0ff28fa6a75617d61b1aeea77463d6a1684c3c89 URL: https://github.com/llvm/llvm-project/commit/0ff28fa6a75617d61b1aeea77463d6a1684c3c89 DIFF: https://github.com/llvm/llvm-project/commit/0ff28fa6a75617d61b1aeea77463d6a1684c3c89.diff LOG: Support dwarf fission for wasm object files Initial support for dwarf fission sections (-gsplit-dwarf) on wasm. The most interesting change is support for writing 2 files (.o and .dwo) in the wasm object writer. My approach moves object-writing logic into its own function and calls it twice, swapping out the endian::Writer (W) in between calls. It also splits the import-preparation step into its own function (and skips it when writing a dwo). Differential Revision: https://reviews.llvm.org/D85685 Added: llvm/test/DebugInfo/WebAssembly/fission-cu.ll llvm/test/DebugInfo/WebAssembly/fission-sections.ll Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/split-debug.c llvm/include/llvm/MC/MCWasmObjectWriter.h llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/MC/MCAsmBackend.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/MC/WasmObjectWriter.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index e13ffe67af89..67c17ee2cbb4 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4805,7 +4805,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Add the split debug info name to the command lines here so we // can propagate it to the backend. bool SplitDWARF = (DwarfFission != DwarfFissionKind::None) && -TC.getTriple().isOSBinFormatELF() && +(TC.getTriple().isOSBinFormatELF() || + TC.getTriple().isOSBinFormatWasm()) && (isa(JA) || isa(JA) || isa(JA)); if (SplitDWARF) { diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index d40207d5ae3b..b6ebbaa2036e 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -10,6 +10,11 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=split -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s +// RUN: %clang -target wasm32-unknown-unknown -gsplit-dwarf -c -### %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s +// RUN: %clang -target wasm32-unknown-unknown -gsplit-dwarf=split -c -### %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s + // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=single -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-ACTIONS-SINGLE-SPLIT < %t %s // diff --git a/llvm/include/llvm/MC/MCWasmObjectWriter.h b/llvm/include/llvm/MC/MCWasmObjectWriter.h index 382818ad6867..00da632bbcc6 100644 --- a/llvm/include/llvm/MC/MCWasmObjectWriter.h +++ b/llvm/include/llvm/MC/MCWasmObjectWriter.h @@ -52,6 +52,10 @@ std::unique_ptr createWasmObjectWriter(std::unique_ptr MOTW, raw_pwrite_stream &OS); +std::unique_ptr +createWasmDwoObjectWriter(std::unique_ptr MOTW, + raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS); + } // namespace llvm #endif diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 4f8c206d66d6..68386a555fda 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -422,7 +422,10 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) { // FIXME: duplicated from Target/WebAssembly/WebAssembly.h // don't want to depend on target specific headers in this code? const unsigned TI_GLOBAL_RELOC = 3; - if (FrameBase.Location.WasmLoc.Kind == TI_GLOBAL_RELOC) { + // FIXME: when writing dwo, we need to avoid relocations. Probably + // the "right" solution is to treat globals the way func and data symbols + // are (with entries in .debug_addr). + if (FrameBase.Location.WasmLoc.Kind == TI_GLOBAL_RELOC && !isDwoUnit()) { // These need to be relocatable. assert(FrameBase.Location.WasmLoc.Index == 0); // Only SP so far. auto SPSym = cast( diff --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp index cf110345df3d..0d32e71c2d8f 100644 --- a/llvm/lib/MC/MCAsmBackend.cpp +++ b/llvm/lib/MC/MCAsmBackend.cpp @@ -54,10 +54,17 @@ std::unique_ptr MCAsmBackend::createDwoObjectWriter(raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS) const { auto TW = createObjectTargetWriter(); - if (TW->getFormat() != Triple::ELF) -report_fatal_error("dwo only supported with ELF"); - return createELFDwoObjectWriter(cast(std::move(TW)), -
[clang] bcb8a11 - [WebAssembly] Add support for DWARF type units
Author: Derek Schuff Date: 2020-10-27T17:13:41-07:00 New Revision: bcb8a119df210753c5f1a3ac346d49597fef0f51 URL: https://github.com/llvm/llvm-project/commit/bcb8a119df210753c5f1a3ac346d49597fef0f51 DIFF: https://github.com/llvm/llvm-project/commit/bcb8a119df210753c5f1a3ac346d49597fef0f51.diff LOG: [WebAssembly] Add support for DWARF type units Since Wasm comdat sections work similarly to ELF, we can use that mechanism to eliminate duplicate dwarf type information in the same way. Differential Revision: https://reviews.llvm.org/D88603 Added: llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/debug-options.c llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/MC/WasmObjectWriter.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 61e367bd835d..59cf34749bb4 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3989,7 +3989,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, if (Args.hasFlag(options::OPT_fdebug_types_section, options::OPT_fno_debug_types_section, false)) { -if (!T.isOSBinFormatELF()) { +if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) { D.Diag(diag::err_drv_unsupported_opt_for_target) << Args.getLastArg(options::OPT_fdebug_types_section) ->getAsString(Args) diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 1be976d9743a..bedc9d044a2c 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -214,6 +214,9 @@ // RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOFDTS %s // +// RUN: %clang -### -fdebug-types-section -target wasm32-unknown-unknown %s 2>&1 \ +// RUN:| FileCheck -check-prefix=FDTS %s +// // RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ // RUN:| FileCheck -check-prefix=FDTSE %s // diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index e460402e7941..859956e6c3a5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -394,8 +394,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) UseSectionsAsReferences = DwarfSectionsAsReferences == Enable; // Don't generate type units for unsupported object file formats. - GenerateTypeUnits = - A->TM.getTargetTriple().isOSBinFormatELF() && GenerateDwarfTypeUnits; + GenerateTypeUnits = (A->TM.getTargetTriple().isOSBinFormatELF() || + A->TM.getTargetTriple().isOSBinFormatWasm()) && + GenerateDwarfTypeUnits; TheAccelTableKind = computeAccelTableKind( DwarfVersion, GenerateTypeUnits, DebuggerTuning, A->TM.getTargetTriple()); diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index d8ea0a879f2b..fcae22c8ce2e 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -963,9 +963,11 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name, case Triple::ELF: return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0, utostr(Hash)); + case Triple::Wasm: +return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash), + MCContext::GenericSectionID); case Triple::MachO: case Triple::COFF: - case Triple::Wasm: case Triple::GOFF: case Triple::XCOFF: case Triple::UnknownObjectFormat: diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index f81a83d1651c..2f1277eb8110 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1378,9 +1378,6 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm, MCSymbol *Begin = Sec.getBeginSymbol(); if (Begin) { WasmIndices[cast(Begin)] = CustomSections.size(); -if (SectionName != Begin->getName()) - report_fatal_error("section name and begin symbol should match: " + - Twine(SectionName)); } // Separate out the producers and target features sections diff --git a/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll b/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll new file mode 100644 index ..a35bbca2cd21 --- /dev/null +++ b/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll @@ -0,0 +1,116 @@ +; RUN: llc -dwarf-version=4 -generate-type-units \ +; RUN: -filetype=obj -O0 -mtriple=wasm32-unknown-unknown < %s \ +; RUN: | llvm-dwarfdump -v - | FileCheck %s --check-pref
[clang] 44eea0b - Revert "[WebAssembly] Add support for DWARF type units"
Author: Derek Schuff Date: 2020-10-27T17:57:32-07:00 New Revision: 44eea0b1a7301de4c284afed1c023014c391372f URL: https://github.com/llvm/llvm-project/commit/44eea0b1a7301de4c284afed1c023014c391372f DIFF: https://github.com/llvm/llvm-project/commit/44eea0b1a7301de4c284afed1c023014c391372f.diff LOG: Revert "[WebAssembly] Add support for DWARF type units" This reverts commit bcb8a119df210753c5f1a3ac346d49597fef0f51. Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/debug-options.c llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/MC/WasmObjectWriter.cpp Removed: llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 59cf34749bb4..61e367bd835d 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3989,7 +3989,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, if (Args.hasFlag(options::OPT_fdebug_types_section, options::OPT_fno_debug_types_section, false)) { -if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) { +if (!T.isOSBinFormatELF()) { D.Diag(diag::err_drv_unsupported_opt_for_target) << Args.getLastArg(options::OPT_fdebug_types_section) ->getAsString(Args) diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index bedc9d044a2c..1be976d9743a 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -214,9 +214,6 @@ // RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOFDTS %s // -// RUN: %clang -### -fdebug-types-section -target wasm32-unknown-unknown %s 2>&1 \ -// RUN:| FileCheck -check-prefix=FDTS %s -// // RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ // RUN:| FileCheck -check-prefix=FDTSE %s // diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 859956e6c3a5..e460402e7941 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -394,9 +394,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) UseSectionsAsReferences = DwarfSectionsAsReferences == Enable; // Don't generate type units for unsupported object file formats. - GenerateTypeUnits = (A->TM.getTargetTriple().isOSBinFormatELF() || - A->TM.getTargetTriple().isOSBinFormatWasm()) && - GenerateDwarfTypeUnits; + GenerateTypeUnits = + A->TM.getTargetTriple().isOSBinFormatELF() && GenerateDwarfTypeUnits; TheAccelTableKind = computeAccelTableKind( DwarfVersion, GenerateTypeUnits, DebuggerTuning, A->TM.getTargetTriple()); diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index fcae22c8ce2e..d8ea0a879f2b 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -963,11 +963,9 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name, case Triple::ELF: return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0, utostr(Hash)); - case Triple::Wasm: -return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash), - MCContext::GenericSectionID); case Triple::MachO: case Triple::COFF: + case Triple::Wasm: case Triple::GOFF: case Triple::XCOFF: case Triple::UnknownObjectFormat: diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 2f1277eb8110..f81a83d1651c 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1378,6 +1378,9 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm, MCSymbol *Begin = Sec.getBeginSymbol(); if (Begin) { WasmIndices[cast(Begin)] = CustomSections.size(); +if (SectionName != Begin->getName()) + report_fatal_error("section name and begin symbol should match: " + + Twine(SectionName)); } // Separate out the producers and target features sections diff --git a/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll b/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll deleted file mode 100644 index a35bbca2cd21.. --- a/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll +++ /dev/null @@ -1,116 +0,0 @@ -; RUN: llc -dwarf-version=4 -generate-type-units \ -; RUN: -filetype=obj -O0 -mtriple=wasm32-unknown-unknown < %s \ -; RUN: | llvm-dwarfdump -v - | FileCheck %s --check-prefix=SINGLE-4 - -; RUN: llc -split-dwarf-file=foo.dwo -split-dwarf-output=%t.dwo \ -; RUN: -dwarf-version=4 -generate-
[clang] 77973f8 - [WebAssembly] Add support for DWARF type units
Author: Derek Schuff Date: 2020-10-28T17:41:22-07:00 New Revision: 77973f8dee6d4d6f1b7c2a026249c1f7068f267b URL: https://github.com/llvm/llvm-project/commit/77973f8dee6d4d6f1b7c2a026249c1f7068f267b DIFF: https://github.com/llvm/llvm-project/commit/77973f8dee6d4d6f1b7c2a026249c1f7068f267b.diff LOG: [WebAssembly] Add support for DWARF type units Since Wasm comdat sections work similarly to ELF, we can use that mechanism to eliminate duplicate dwarf type information in the same way. Differential Revision: https://reviews.llvm.org/D88603 Added: llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/debug-options.c llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/MC/WasmObjectWriter.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index dde4e8de531c..a15067b081b7 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3989,7 +3989,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, if (Args.hasFlag(options::OPT_fdebug_types_section, options::OPT_fno_debug_types_section, false)) { -if (!T.isOSBinFormatELF()) { +if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) { D.Diag(diag::err_drv_unsupported_opt_for_target) << Args.getLastArg(options::OPT_fdebug_types_section) ->getAsString(Args) diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 1be976d9743a..bedc9d044a2c 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -214,6 +214,9 @@ // RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOFDTS %s // +// RUN: %clang -### -fdebug-types-section -target wasm32-unknown-unknown %s 2>&1 \ +// RUN:| FileCheck -check-prefix=FDTS %s +// // RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ // RUN:| FileCheck -check-prefix=FDTSE %s // diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index e460402e7941..859956e6c3a5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -394,8 +394,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) UseSectionsAsReferences = DwarfSectionsAsReferences == Enable; // Don't generate type units for unsupported object file formats. - GenerateTypeUnits = - A->TM.getTargetTriple().isOSBinFormatELF() && GenerateDwarfTypeUnits; + GenerateTypeUnits = (A->TM.getTargetTriple().isOSBinFormatELF() || + A->TM.getTargetTriple().isOSBinFormatWasm()) && + GenerateDwarfTypeUnits; TheAccelTableKind = computeAccelTableKind( DwarfVersion, GenerateTypeUnits, DebuggerTuning, A->TM.getTargetTriple()); diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index d8ea0a879f2b..1349494c5436 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -963,9 +963,14 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name, case Triple::ELF: return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0, utostr(Hash)); + case Triple::Wasm: +// FIXME: When using dwarf 5, the .debug_info section is used for type units +// but that section already exists, so attempting to get it as a comdate +// section triggers an assert. +return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash), + MCContext::GenericSectionID); case Triple::MachO: case Triple::COFF: - case Triple::Wasm: case Triple::GOFF: case Triple::XCOFF: case Triple::UnknownObjectFormat: diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index f81a83d1651c..2f1277eb8110 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1378,9 +1378,6 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm, MCSymbol *Begin = Sec.getBeginSymbol(); if (Begin) { WasmIndices[cast(Begin)] = CustomSections.size(); -if (SectionName != Begin->getName()) - report_fatal_error("section name and begin symbol should match: " + - Twine(SectionName)); } // Separate out the producers and target features sections diff --git a/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll b/llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll new file mode 100644 index ..fa244d99735d --- /dev/null +++ b/llvm/test/DebugInfo/WebAssembly/dwar
[clang] ac02baa - WebAssembly: Update datalayout to match fp128 ABI change
Author: Derek Schuff Date: 2021-07-09T16:51:36-07:00 New Revision: ac02baab48c2ff512e40140e2fe6845d2b6a636f URL: https://github.com/llvm/llvm-project/commit/ac02baab48c2ff512e40140e2fe6845d2b6a636f DIFF: https://github.com/llvm/llvm-project/commit/ac02baab48c2ff512e40140e2fe6845d2b6a636f.diff LOG: WebAssembly: Update datalayout to match fp128 ABI change This fix goes along with d1a96e906cc03a95cfd41a1f22bdda92651250c7 and makes the fp128 alignment match clang's long double alignment. Differential Revision: https://reviews.llvm.org/D105749 Added: Modified: clang/lib/Basic/Targets/WebAssembly.h llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp llvm/test/CodeGen/WebAssembly/varargs.ll Removed: diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h index c3e5d7e572c3..a43e770eb1e8 100644 --- a/clang/lib/Basic/Targets/WebAssembly.h +++ b/clang/lib/Basic/Targets/WebAssembly.h @@ -149,7 +149,10 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo explicit WebAssembly32TargetInfo(const llvm::Triple &T, const TargetOptions &Opts) : WebAssemblyTargetInfo(T, Opts) { -resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"); +if (T.isOSEmscripten()) + resetDataLayout("e-m:e-p:32:32-i64:64-f128:64-n32:64-S128-ni:1"); +else + resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"); } protected: @@ -168,7 +171,10 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo SizeType = UnsignedLong; PtrDiffType = SignedLong; IntPtrType = SignedLong; -resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"); +if (T.isOSEmscripten()) + resetDataLayout("e-m:e-p:64:64-i64:64-f128:64-n32:64-S128-ni:1"); +else + resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"); } protected: diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index a0c7c778767c..6a37903da4f5 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -120,12 +120,17 @@ WebAssemblyTargetMachine::WebAssemblyTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, Optional CM, CodeGenOpt::Level OL, bool JIT) -: LLVMTargetMachine(T, -TT.isArch64Bit() -? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1" -: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1", -TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT), -getEffectiveCodeModel(CM, CodeModel::Large), OL), +: LLVMTargetMachine( + T, + TT.isArch64Bit() + ? (TT.isOSEmscripten() + ? "e-m:e-p:64:64-i64:64-f128:64-n32:64-S128-ni:1" + : "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1") + : (TT.isOSEmscripten() + ? "e-m:e-p:32:32-i64:64-f128:64-n32:64-S128-ni:1" + : "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"), + TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT), + getEffectiveCodeModel(CM, CodeModel::Large), OL), TLOF(new WebAssemblyTargetObjectFile()) { // WebAssembly type-checks instructions, but a noreturn function with a return // type that doesn't match the context will cause a check failure. So we lower diff --git a/llvm/test/CodeGen/WebAssembly/varargs.ll b/llvm/test/CodeGen/WebAssembly/varargs.ll index c36912854c0c..7a9f0b08c1f4 100644 --- a/llvm/test/CodeGen/WebAssembly/varargs.ll +++ b/llvm/test/CodeGen/WebAssembly/varargs.ll @@ -2,8 +2,7 @@ ; Test varargs constructs. -target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32-unknown-unknown" +target triple = "wasm32-unknown-emscripten" ; Test va_start. @@ -167,21 +166,19 @@ define void @nonlegal_fixed(fp128 %x, ...) nounwind { ; within a vararg buffer. ; CHECK-LABEL: call_fp128_alignment: -; CHECK: global.get $push7=, __stack_pointer -; CHECK-NEXT: i32.const $push8=, 32 -; CHECK-NEXT: i32.sub $push12=, $pop7, $pop8 -; CHECK-NEXT: local.tee $push11=, $1=, $pop12 -; CHECK-NEXT: global.set __stack_pointer, $pop11 -; CHECK-NEXT: i32.const $push0=, 24 +; CHECK: global.get $push5=, __stack_pointer +; CHECK-NEXT: i32.const $push6=, 32 +; CHECK-NEXT: i32.sub $push10=, $pop5, $pop6 +; CHECK-NEXT: local.tee $push9=, $1=, $pop10 +; CHECK-NEXT: global.set __stack_pointer, $pop9 +; CHECK-NEXT: i32.const $push0=, 16 ; CHECK-NEXT: i32.add $push1=, $1, $pop0 ; CHECK-NEXT: i64.const $push2=, -9223372036854775808 ; CHECK-NEXT: i64.store 0($pop1), $pop2 -; CHECK-N
[clang] c6a33ff - [clang][CodeGen] Emit annotations for function declarations.
Author: Brendan Dahl Date: 2023-09-12T13:07:55-07:00 New Revision: c6a33ff49dfb3498dae15c718820ea3d9c19f3cb URL: https://github.com/llvm/llvm-project/commit/c6a33ff49dfb3498dae15c718820ea3d9c19f3cb DIFF: https://github.com/llvm/llvm-project/commit/c6a33ff49dfb3498dae15c718820ea3d9c19f3cb.diff LOG: [clang][CodeGen] Emit annotations for function declarations. Previously, annotations were only emitted for function definitions. With this change annotations are also emitted for declarations. Also, emitting function annotations is now deferred until the end so that the most up to date declaration is used which will have any inherited annotations. Differential Revision: https://reviews.llvm.org/D156172/new/ Added: clang/test/CodeGen/annotations-decl-use-decl.c clang/test/CodeGen/annotations-decl-use-define.c clang/test/CodeGen/annotations-declaration.c clang/test/CodeGenCXX/attr-annotate-destructor.cpp Modified: clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/test/CodeGen/annotations-global.c clang/test/CodeGenCXX/attr-annotate.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8b0c9340775cbe9..0ee9c4a9e0be4c9 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -697,6 +697,7 @@ void CodeGenModule::checkAliases() { void CodeGenModule::clear() { DeferredDeclsToEmit.clear(); EmittedDeferredDecls.clear(); + DeferredAnnotations.clear(); if (OpenMPRuntime) OpenMPRuntime->clear(); } @@ -3093,6 +3094,10 @@ void CodeGenModule::EmitVTablesOpportunistically() { } void CodeGenModule::EmitGlobalAnnotations() { + for (const auto& [MangledName, VD] : DeferredAnnotations) +AddGlobalAnnotations(VD, GetGlobalValue(MangledName)); + DeferredAnnotations.clear(); + if (Annotations.empty()) return; @@ -3597,6 +3602,14 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { // Ignore declarations, they will be emitted on their first use. if (const auto *FD = dyn_cast(Global)) { +// Update deferred annotations with the latest declaration if the function +// function was already used or defined. +if (FD->hasAttr()) { + StringRef MangledName = getMangledName(GD); + if (GetGlobalValue(MangledName)) +DeferredAnnotations[MangledName] = FD; +} + // Forward declarations are emitted lazily on first use. if (!FD->doesThisDeclarationHaveABody()) { if (!FD->doesDeclarationForceExternallyVisibleDefinition()) @@ -4370,6 +4383,11 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction( llvm::Function::Create(FTy, llvm::Function::ExternalLinkage, Entry ? StringRef() : MangledName, &getModule()); + // Store the declaration associated with this function so it is potentially + // updated by further declarations or definitions and emitted at the end. + if (D && D->hasAttr()) +DeferredAnnotations[MangledName] = cast(D); + // If we already created a function with the same mangled name (but diff erent // type) before, take its name and add it to the list of functions to be // replaced with F at the end of CodeGen. @@ -5664,8 +5682,6 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, AddGlobalCtor(Fn, CA->getPriority()); if (const DestructorAttr *DA = D->getAttr()) AddGlobalDtor(Fn, DA->getPriority(), true); - if (D->hasAttr()) -AddGlobalAnnotations(D, Fn); if (getLangOpts().OpenMP && D->hasAttr()) getOpenMPRuntime().emitDeclareTargetFunction(D, GV); } diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 073b471c6e3cc11..8b0d68afbd0ecd2 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -431,6 +431,10 @@ class CodeGenModule : public CodeGenTypeCache { /// Global annotations. std::vector Annotations; + // Store deferred function annotations so they can be emitted at the end with + // most up to date ValueDecl that will have all the inherited annotations. + llvm::DenseMap DeferredAnnotations; + /// Map used to get unique annotation strings. llvm::StringMap AnnotationStrings; diff --git a/clang/test/CodeGen/annotations-decl-use-decl.c b/clang/test/CodeGen/annotations-decl-use-decl.c new file mode 100644 index 000..f43ba91a34d876f --- /dev/null +++ b/clang/test/CodeGen/annotations-decl-use-decl.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s + +// Test annotation attributes are still emitted when the function is used before +// it is defined with annotations. + +void foo(void); +void *xxx = (void*)foo; +void __attribute__((annotate("bar"))) foo(); + +// CHECK: target triple +// CHECK-DAG: private unnamed_addr constant [4 x i8] c"bar\00", section "llvm.metadata" + +// CHECK: @llvm.glo
[clang] c5bd3d0 - Support Swift calling convention for WebAssembly targets
Author: Yuta Saito Date: 2020-01-24T10:30:46-08:00 New Revision: c5bd3d07262ffda5b21576b9e1e2d2dd2e51fb4b URL: https://github.com/llvm/llvm-project/commit/c5bd3d07262ffda5b21576b9e1e2d2dd2e51fb4b DIFF: https://github.com/llvm/llvm-project/commit/c5bd3d07262ffda5b21576b9e1e2d2dd2e51fb4b.diff LOG: Support Swift calling convention for WebAssembly targets This adds basic support for the Swift calling convention with WebAssembly targets. Reviewed By: dschuff Differential Revision: https://reviews.llvm.org/D71823 Added: Modified: clang/lib/Basic/Targets/WebAssembly.h llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Removed: diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h index 9665156b143f..55d90db267e1 100644 --- a/clang/lib/Basic/Targets/WebAssembly.h +++ b/clang/lib/Basic/Targets/WebAssembly.h @@ -114,6 +114,16 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo { ? (IsSigned ? SignedLongLong : UnsignedLongLong) : TargetInfo::getLeastIntTypeByWidth(BitWidth, IsSigned); } + + CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { +switch (CC) { +case CC_C: +case CC_Swift: + return CCCR_OK; +default: + return CCCR_Warning; +} + } }; class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo : public WebAssemblyTargetInfo { diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index e91a9ea03767..12fad047759f 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -672,7 +672,8 @@ static bool callingConvSupported(CallingConv::ID CallConv) { CallConv == CallingConv::PreserveMost || CallConv == CallingConv::PreserveAll || CallConv == CallingConv::CXX_FAST_TLS || - CallConv == CallingConv::WASM_EmscriptenInvoke; + CallConv == CallingConv::WASM_EmscriptenInvoke || + CallConv == CallingConv::Swift; } SDValue ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24134: [WebAssembly] Change wasm SizeType to match asmjs
dschuff added a comment. test comment https://reviews.llvm.org/D24134 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24134: [WebAssembly] Change wasm SizeType to match asmjs
dschuff accepted this revision. dschuff added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D24134 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280420 - [WebAssembly] Change wasm SizeType to match asmjs
Author: dschuff Date: Thu Sep 1 17:38:37 2016 New Revision: 280420 URL: http://llvm.org/viewvc/llvm-project?rev=280420&view=rev Log: [WebAssembly] Change wasm SizeType to match asmjs Summary: We want wasm and asmjs to have matching ABIs, and right now asmjs uses unsigned int for its size_t. This causes exported symbols in libcxx to not match and can cause weird breakage where libcxx doesn't get linked as a result. Long-term we probably want wasm32, wasm64, and asmjs to all use unsigned long, but that would cause unnecessary ABI churn for asmjs so defer that until we can make all the ABI changes at once. Patch by Jacob Gravelle Differential Revision: https://reviews.llvm.org/D24134 Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=280420&r1=280419&r2=280420&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Thu Sep 1 17:38:37 2016 @@ -7840,6 +7840,9 @@ public: SigAtomicType = SignedLong; LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::IEEEquad; +SizeType = UnsignedInt; +PtrDiffType = SignedInt; +IntPtrType = SignedInt; } protected: @@ -7958,6 +7961,9 @@ public: LongAlign = LongWidth = 64; PointerAlign = PointerWidth = 64; MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; +SizeType = UnsignedLong; +PtrDiffType = SignedLong; +IntPtrType = SignedLong; resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128"); } Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=280420&r1=280419&r2=280420&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Thu Sep 1 17:38:37 2016 @@ -8560,10 +8560,10 @@ // WEBASSEMBLY32-NEXT:#define __INTMAX_MAX__ 9223372036854775807LL // WEBASSEMBLY32-NEXT:#define __INTMAX_TYPE__ long long int // WEBASSEMBLY32-NEXT:#define __INTMAX_WIDTH__ 64 -// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTd__ "ld" -// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTi__ "li" -// WEBASSEMBLY32-NEXT:#define __INTPTR_MAX__ 2147483647L -// WEBASSEMBLY32-NEXT:#define __INTPTR_TYPE__ long int +// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTd__ "d" +// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTi__ "i" +// WEBASSEMBLY32-NEXT:#define __INTPTR_MAX__ 2147483647 +// WEBASSEMBLY32-NEXT:#define __INTPTR_TYPE__ int // WEBASSEMBLY32-NEXT:#define __INTPTR_WIDTH__ 32 // WEBASSEMBLY32-NEXT:#define __INT_FAST16_FMTd__ "hd" // WEBASSEMBLY32-NEXT:#define __INT_FAST16_FMTi__ "hi" @@ -8622,10 +8622,10 @@ // WEBASSEMBLY32-NEXT:#define __ORDER_PDP_ENDIAN__ 3412 // WEBASSEMBLY32-NEXT:#define __POINTER_WIDTH__ 32 // WEBASSEMBLY32-NEXT:#define __PRAGMA_REDEFINE_EXTNAME 1 -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTd__ "ld" -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTi__ "li" -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_MAX__ 2147483647L -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_TYPE__ long int +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTd__ "d" +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTi__ "i" +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_MAX__ 2147483647 +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_TYPE__ int // WEBASSEMBLY32-NEXT:#define __PTRDIFF_WIDTH__ 32 // WEBASSEMBLY32-NOT:#define __REGISTER_PREFIX__ // WEBASSEMBLY32-NEXT:#define __SCHAR_MAX__ 127 @@ -8645,12 +8645,12 @@ // WEBASSEMBLY32-NEXT:#define __SIZEOF_SIZE_T__ 4 // WEBASSEMBLY32-NEXT:#define __SIZEOF_WCHAR_T__ 4 // WEBASSEMBLY32-NEXT:#define __SIZEOF_WINT_T__ 4 -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTX__ "lX" -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTo__ "lo" -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTu__ "lu" -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTx__ "lx" -// WEBASSEMBLY32-NEXT:#define __SIZE_MAX__ 4294967295UL -// WEBASSEMBLY32-NEXT:#define __SIZE_TYPE__ long unsigned int +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTX__ "X" +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTo__ "o" +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTu__ "u" +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTx__ "x" +// WEBASSEMBLY32-NEXT:#define __SIZE_MAX__ 4294967295U +// WEBASSEMBLY32-NEXT:#define __SIZE_TYPE__ unsigned int // WEBASSEMBLY32-NEXT:#define __SIZE_WIDTH__ 32 // WEBASSEMBLY32-NEXT:#define __STDC_HOSTED__ 0 // WEBASSEMBLY32-NOT:#define __STDC_MB_MIGHT_NEQ_WC__ @@ -8698,12 +8698,12 @@ // WEBASSEMBLY32-NEXT:#define __UINTMAX_MAX__ 18446744073709551615ULL // WEBASSEMBLY32-NEXT:#define __UINTMAX_TYPE__ long long unsigned int // WEBASSEMBLY32-NEXT:#define __UINTMAX_WIDTH__ 64 -// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTX__ "lX" -// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTo__ "lo" -// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTu__ "lu" -// WEBASSEMBLY32-NEXT:
Re: [PATCH] D24134: [WebAssembly] Change wasm SizeType to match asmjs
This revision was automatically updated to reflect the committed changes. Closed by commit rL280420: [WebAssembly] Change wasm SizeType to match asmjs (authored by dschuff). Changed prior to commit: https://reviews.llvm.org/D24134?vs=70008&id=70082#toc Repository: rL LLVM https://reviews.llvm.org/D24134 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/init.c Index: cfe/trunk/test/Preprocessor/init.c === --- cfe/trunk/test/Preprocessor/init.c +++ cfe/trunk/test/Preprocessor/init.c @@ -8560,10 +8560,10 @@ // WEBASSEMBLY32-NEXT:#define __INTMAX_MAX__ 9223372036854775807LL // WEBASSEMBLY32-NEXT:#define __INTMAX_TYPE__ long long int // WEBASSEMBLY32-NEXT:#define __INTMAX_WIDTH__ 64 -// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTd__ "ld" -// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTi__ "li" -// WEBASSEMBLY32-NEXT:#define __INTPTR_MAX__ 2147483647L -// WEBASSEMBLY32-NEXT:#define __INTPTR_TYPE__ long int +// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTd__ "d" +// WEBASSEMBLY32-NEXT:#define __INTPTR_FMTi__ "i" +// WEBASSEMBLY32-NEXT:#define __INTPTR_MAX__ 2147483647 +// WEBASSEMBLY32-NEXT:#define __INTPTR_TYPE__ int // WEBASSEMBLY32-NEXT:#define __INTPTR_WIDTH__ 32 // WEBASSEMBLY32-NEXT:#define __INT_FAST16_FMTd__ "hd" // WEBASSEMBLY32-NEXT:#define __INT_FAST16_FMTi__ "hi" @@ -8622,10 +8622,10 @@ // WEBASSEMBLY32-NEXT:#define __ORDER_PDP_ENDIAN__ 3412 // WEBASSEMBLY32-NEXT:#define __POINTER_WIDTH__ 32 // WEBASSEMBLY32-NEXT:#define __PRAGMA_REDEFINE_EXTNAME 1 -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTd__ "ld" -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTi__ "li" -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_MAX__ 2147483647L -// WEBASSEMBLY32-NEXT:#define __PTRDIFF_TYPE__ long int +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTd__ "d" +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_FMTi__ "i" +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_MAX__ 2147483647 +// WEBASSEMBLY32-NEXT:#define __PTRDIFF_TYPE__ int // WEBASSEMBLY32-NEXT:#define __PTRDIFF_WIDTH__ 32 // WEBASSEMBLY32-NOT:#define __REGISTER_PREFIX__ // WEBASSEMBLY32-NEXT:#define __SCHAR_MAX__ 127 @@ -8645,12 +8645,12 @@ // WEBASSEMBLY32-NEXT:#define __SIZEOF_SIZE_T__ 4 // WEBASSEMBLY32-NEXT:#define __SIZEOF_WCHAR_T__ 4 // WEBASSEMBLY32-NEXT:#define __SIZEOF_WINT_T__ 4 -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTX__ "lX" -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTo__ "lo" -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTu__ "lu" -// WEBASSEMBLY32-NEXT:#define __SIZE_FMTx__ "lx" -// WEBASSEMBLY32-NEXT:#define __SIZE_MAX__ 4294967295UL -// WEBASSEMBLY32-NEXT:#define __SIZE_TYPE__ long unsigned int +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTX__ "X" +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTo__ "o" +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTu__ "u" +// WEBASSEMBLY32-NEXT:#define __SIZE_FMTx__ "x" +// WEBASSEMBLY32-NEXT:#define __SIZE_MAX__ 4294967295U +// WEBASSEMBLY32-NEXT:#define __SIZE_TYPE__ unsigned int // WEBASSEMBLY32-NEXT:#define __SIZE_WIDTH__ 32 // WEBASSEMBLY32-NEXT:#define __STDC_HOSTED__ 0 // WEBASSEMBLY32-NOT:#define __STDC_MB_MIGHT_NEQ_WC__ @@ -8698,12 +8698,12 @@ // WEBASSEMBLY32-NEXT:#define __UINTMAX_MAX__ 18446744073709551615ULL // WEBASSEMBLY32-NEXT:#define __UINTMAX_TYPE__ long long unsigned int // WEBASSEMBLY32-NEXT:#define __UINTMAX_WIDTH__ 64 -// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTX__ "lX" -// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTo__ "lo" -// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTu__ "lu" -// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTx__ "lx" -// WEBASSEMBLY32-NEXT:#define __UINTPTR_MAX__ 4294967295UL -// WEBASSEMBLY32-NEXT:#define __UINTPTR_TYPE__ long unsigned int +// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTX__ "X" +// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTo__ "o" +// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTu__ "u" +// WEBASSEMBLY32-NEXT:#define __UINTPTR_FMTx__ "x" +// WEBASSEMBLY32-NEXT:#define __UINTPTR_MAX__ 4294967295U +// WEBASSEMBLY32-NEXT:#define __UINTPTR_TYPE__ unsigned int // WEBASSEMBLY32-NEXT:#define __UINTPTR_WIDTH__ 32 // WEBASSEMBLY32-NEXT:#define __UINT_FAST16_FMTX__ "hX" // WEBASSEMBLY32-NEXT:#define __UINT_FAST16_FMTo__ "ho" Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -7840,6 +7840,9 @@ SigAtomicType = SignedLong; LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::IEEEquad; +SizeType = UnsignedInt; +PtrDiffType = SignedInt; +IntPtrType = SignedInt; } protected: @@ -7958,6 +7961,9 @@ LongAlign = LongWidth = 64; PointerAlign = PointerWidth = 64; MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; +SizeType = UnsignedLong; +PtrDiffType = SignedLong; +IntPtrType = SignedLong; resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128"); } Index: cfe/trunk/test/Preprocessor/init.c ==
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
dschuff accepted this revision. dschuff added a comment. This revision is now accepted and ready to land. Also it matches asm.js @sunfish is planning on unifying the triples, and this will be part of that (and there may be more defines that we want to add and/or subtract), but for now it makes more of the emscripten test suite pass, so LGTM https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
dschuff added a comment. Yeah, I don't mean for this to be the final word; mostly this just matches asm.js. I do agree with you that the unixy stuff goes with the emscripten environment rather than wasm per se. I had thought we might define emscripten as an "OS" (i.e. the third or maybe even 4th part of the triple) in LLVM, because currently it affects not just defines but also things like emscripten exception handling (which we currently use a backend flag for). https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D11921: Add NaCl (a target where long double = double) to long double ABI test
dschuff created this revision. dschuff added reviewers: rnk, chh, majnemer, echristo. dschuff added a subscriber: cfe-commits. Herald added subscribers: srhines, danalbert, tberghammer, jfb. A test was recently (r244468) added to cover long double calling convention codegen, distinguishing between Android and GNU conventions (where long doubles are fp128 and x86_fp80, respectively). Native Client is a target where long doubles are the same as doubles. This change augments the test to cover that case. http://reviews.llvm.org/D11921 Files: test/CodeGen/x86_64-fp128.c Index: test/CodeGen/x86_64-fp128.c === --- test/CodeGen/x86_64-fp128.c +++ test/CodeGen/x86_64-fp128.c @@ -4,6 +4,9 @@ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK // RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK +// NaCl is an example of a target for which long double is the same as double. +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=NACL --check-prefix=CHECK // Android uses fp128 for long double but other x86_64 targets use x86_fp80. @@ -19,12 +22,14 @@ return x * x; // ANDROID: define fp128 @TestLD(fp128 %x) // GNU: define x86_fp80 @TestLD(x86_fp80 %x) +// NACL: define double @TestLD(double %x) } long double _Complex TestLDC(long double _Complex x) { return x * x; // ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x) // GNU: define { x86_fp80, x86_fp80 } @TestLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) +// NACL: define { double, double } @TestLDC(double %x{{.*}}, double %x{{.*}}) } typedef __builtin_va_list va_list; @@ -51,14 +56,18 @@ long double TestGetVarLD(va_list ap) { return __builtin_va_arg(ap, long double); -// fp128 can be passed in memory or in register, but x86_fp80 is in memory. +// fp128 and double can be passed in memory or in register, but x86_fp80 is in +// memory. // ANDROID: define fp128 @TestGetVarLD( // GNU: define x86_fp80 @TestGetVarLD( +// NACL: define double @TestGetVarLD( // ANDROID: br // GNU-NOT: br +// NACL: br // CHECK: load {{.*}} %overflow_arg_area_p // ANDROID: = phi // GNU-NOT: = phi +// NACL: = phi // ANDROID: ret fp128 // GNU: ret x86_fp80 } @@ -68,11 +77,18 @@ // Pair of fp128 or x86_fp80 are passed as struct in memory. // ANDROID: define void @TestGetVarLDC({ fp128, fp128 }* {{.*}}, %struct.__va_list_tag* // GNU: define { x86_fp80, x86_fp80 } @TestGetVarLDC( -// CHECK-NOT: br +// Pair of double can go in SSE registers or memory +// NACL: define { double, double } @TestGetVarLDC( +// ANDROID-NOT: br +// GNU-NOT: br +// NACL: br // CHECK: load {{.*}} %overflow_arg_area_p -// CHECK-NOT: phi +// ANDROID-NOT: phi +// GNU-NOT: phi +// NACL: phi // ANDROID: ret void // GNU: ret { x86_fp80, x86_fp80 } +// NACL: ret { double, double } } void TestVarArg(const char *s, ...); @@ -101,6 +117,8 @@ // ANDROID: call {{.*}} @TestVarArg(i8* {{.*}}, fp128 %x // GNU: define void @TestPassVarLD(x86_fp80 %x) // GNU: call {{.*}} @TestVarArg(i8* {{.*}}, x86_fp80 %x +// NACL: define void @TestPassVarLD(double %x) +// NACL: call {{.*}} @TestVarArg(i8* {{.*}}, double %x } void TestPassVarLDC(long double _Complex x) { @@ -112,5 +130,7 @@ // GNU: define void @TestPassVarLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) // GNU: store x86_fp80 %x.{{.*}}, x86_fp80* % // GNU-NEXT: store x86_fp80 %x.{{.*}}, x86_fp80* % -// GNGNU-NEXT: call {{.*}} @TestVarArg(i8* {{.*}}, { x86_fp80, x86_fp80 }* {{.*}} % +// GNU-NEXT: call {{.*}} @TestVarArg(i8* {{.*}}, { x86_fp80, x86_fp80 }* {{.*}} % +// NACL: define void @TestPassVarLDC(double %x{{.*}}, double %x{{.*}}) +// NACL: call {{.*}} @TestVarArg(i8* {{.*}}, double %x{{.*}}, double %x{{.*}}) } Index: test/CodeGen/x86_64-fp128.c === --- test/CodeGen/x86_64-fp128.c +++ test/CodeGen/x86_64-fp128.c @@ -4,6 +4,9 @@ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK // RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK +// NaCl is an example of a target for which long double is the same as double. +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=NACL --check-prefix=CHECK // Android uses fp128 for long double but other x86_64 targets use x86_fp80. @@ -19,12 +22,14 @@ return x * x; // ANDROID: define fp128 @TestLD(fp128 %x) // GNU: define x86_fp80 @TestLD(x86_fp80 %x) +// NACL: define double @TestLD(double %x) } long double _Complex TestLDC(long double _Complex x) { return x * x; // ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x) // GNU: define { x86_fp80, x86_
Re: [PATCH] D11921: Add NaCl (a target where long double = double) to long double ABI test
dschuff added a comment. Should this test be renamed to x86_longdouble.c or some such instead of fp128? http://reviews.llvm.org/D11921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11921: Add NaCl (a target where long double = double) to long double ABI test
dschuff updated this revision to Diff 31741. dschuff added a comment. Herald added a subscriber: dschuff. - rename to x86_64-longdouble.c http://reviews.llvm.org/D11921 Files: test/CodeGen/x86_64-fp128.c test/CodeGen/x86_64-longdouble.c Index: test/CodeGen/x86_64-longdouble.c === --- test/CodeGen/x86_64-longdouble.c +++ test/CodeGen/x86_64-longdouble.c @@ -4,6 +4,9 @@ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK // RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK +// NaCl is an example of a target for which long double is the same as double. +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=NACL --check-prefix=CHECK // Android uses fp128 for long double but other x86_64 targets use x86_fp80. @@ -19,12 +22,14 @@ return x * x; // ANDROID: define fp128 @TestLD(fp128 %x) // GNU: define x86_fp80 @TestLD(x86_fp80 %x) +// NACL: define double @TestLD(double %x) } long double _Complex TestLDC(long double _Complex x) { return x * x; // ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x) // GNU: define { x86_fp80, x86_fp80 } @TestLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) +// NACL: define { double, double } @TestLDC(double %x{{.*}}, double %x{{.*}}) } typedef __builtin_va_list va_list; @@ -51,14 +56,18 @@ long double TestGetVarLD(va_list ap) { return __builtin_va_arg(ap, long double); -// fp128 can be passed in memory or in register, but x86_fp80 is in memory. +// fp128 and double can be passed in memory or in register, but x86_fp80 is in +// memory. // ANDROID: define fp128 @TestGetVarLD( // GNU: define x86_fp80 @TestGetVarLD( +// NACL: define double @TestGetVarLD( // ANDROID: br // GNU-NOT: br +// NACL: br // CHECK: load {{.*}} %overflow_arg_area_p // ANDROID: = phi // GNU-NOT: = phi +// NACL: = phi // ANDROID: ret fp128 // GNU: ret x86_fp80 } @@ -68,11 +77,18 @@ // Pair of fp128 or x86_fp80 are passed as struct in memory. // ANDROID: define void @TestGetVarLDC({ fp128, fp128 }* {{.*}}, %struct.__va_list_tag* // GNU: define { x86_fp80, x86_fp80 } @TestGetVarLDC( -// CHECK-NOT: br +// Pair of double can go in SSE registers or memory +// NACL: define { double, double } @TestGetVarLDC( +// ANDROID-NOT: br +// GNU-NOT: br +// NACL: br // CHECK: load {{.*}} %overflow_arg_area_p -// CHECK-NOT: phi +// ANDROID-NOT: phi +// GNU-NOT: phi +// NACL: phi // ANDROID: ret void // GNU: ret { x86_fp80, x86_fp80 } +// NACL: ret { double, double } } void TestVarArg(const char *s, ...); @@ -101,6 +117,8 @@ // ANDROID: call {{.*}} @TestVarArg(i8* {{.*}}, fp128 %x // GNU: define void @TestPassVarLD(x86_fp80 %x) // GNU: call {{.*}} @TestVarArg(i8* {{.*}}, x86_fp80 %x +// NACL: define void @TestPassVarLD(double %x) +// NACL: call {{.*}} @TestVarArg(i8* {{.*}}, double %x } void TestPassVarLDC(long double _Complex x) { @@ -112,5 +130,7 @@ // GNU: define void @TestPassVarLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) // GNU: store x86_fp80 %x.{{.*}}, x86_fp80* % // GNU-NEXT: store x86_fp80 %x.{{.*}}, x86_fp80* % -// GNGNU-NEXT: call {{.*}} @TestVarArg(i8* {{.*}}, { x86_fp80, x86_fp80 }* {{.*}} % +// GNU-NEXT: call {{.*}} @TestVarArg(i8* {{.*}}, { x86_fp80, x86_fp80 }* {{.*}} % +// NACL: define void @TestPassVarLDC(double %x{{.*}}, double %x{{.*}}) +// NACL: call {{.*}} @TestVarArg(i8* {{.*}}, double %x{{.*}}, double %x{{.*}}) } Index: test/CodeGen/x86_64-longdouble.c === --- test/CodeGen/x86_64-longdouble.c +++ test/CodeGen/x86_64-longdouble.c @@ -4,6 +4,9 @@ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK // RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \ // RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK +// NaCl is an example of a target for which long double is the same as double. +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=NACL --check-prefix=CHECK // Android uses fp128 for long double but other x86_64 targets use x86_fp80. @@ -19,12 +22,14 @@ return x * x; // ANDROID: define fp128 @TestLD(fp128 %x) // GNU: define x86_fp80 @TestLD(x86_fp80 %x) +// NACL: define double @TestLD(double %x) } long double _Complex TestLDC(long double _Complex x) { return x * x; // ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x) // GNU: define { x86_fp80, x86_fp80 } @TestLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) +// NACL: define { double, double } @TestLDC(double %x{{.*}}, double %x{{.*}}) } typedef __builtin_va_list va_list; @@ -51,14 +56,18 @@ long double TestGetVarLD(va_list ap) { return __builtin_va_arg(ap, long double); -// fp128 can be passed
r244524 - Add NaCl (a target where long double = double) to long double ABI test
Author: dschuff Date: Mon Aug 10 18:02:37 2015 New Revision: 244524 URL: http://llvm.org/viewvc/llvm-project?rev=244524&view=rev Log: Add NaCl (a target where long double = double) to long double ABI test A test was recently (r244468) added to cover long double calling convention codegen, distinguishing between Android and GNU conventions (where long doubles are fp128 and x86_fp80, respectively). Native Client is a target where long doubles are the same as doubles. This change augments the test to cover that case. Also rename the test to test/codeGen/X86_64-longdouble.c Differential Revision: http://reviews.llvm.org/D11921 Added: cfe/trunk/test/CodeGen/x86_64-longdouble.c - copied, changed from r244517, cfe/trunk/test/CodeGen/x86_64-fp128.c Removed: cfe/trunk/test/CodeGen/x86_64-fp128.c Removed: cfe/trunk/test/CodeGen/x86_64-fp128.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-fp128.c?rev=244523&view=auto == --- cfe/trunk/test/CodeGen/x86_64-fp128.c (original) +++ cfe/trunk/test/CodeGen/x86_64-fp128.c (removed) @@ -1,115 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-linux-android -emit-llvm -O -o - %s \ -// RUN:| FileCheck %s --check-prefix=ANDROID --check-prefix=CHECK -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -O -o - %s \ -// RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK -// RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \ -// RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK - -// Android uses fp128 for long double but other x86_64 targets use x86_fp80. - -long double dataLD = 1.0L; -// ANDROID: @dataLD = global fp128 0xL3FFF, align 16 -// GNU: @dataLD = global x86_fp80 0xK3FFF8000, align 16 - -long double _Complex dataLDC = {1.0L, 1.0L}; -// ANDROID: @dataLDC = global { fp128, fp128 } { fp128 0xL3FFF, fp128 0xL3FFF }, align 16 -// GNU: @dataLDC = global { x86_fp80, x86_fp80 } { x86_fp80 0xK3FFF8000, x86_fp80 0xK3FFF8000 }, align 16 - -long double TestLD(long double x) { - return x * x; -// ANDROID: define fp128 @TestLD(fp128 %x) -// GNU: define x86_fp80 @TestLD(x86_fp80 %x) -} - -long double _Complex TestLDC(long double _Complex x) { - return x * x; -// ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x) -// GNU: define { x86_fp80, x86_fp80 } @TestLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) -} - -typedef __builtin_va_list va_list; - -int TestGetVarInt(va_list ap) { - return __builtin_va_arg(ap, int); -// Since int can be passed in memory or register there are two branches. -// CHECK: define i32 @TestGetVarInt( -// CHECK: br label -// CHECK: br label -// CHECK: = phi -// CHECK: ret i32 -} - -double TestGetVarDouble(va_list ap) { - return __builtin_va_arg(ap, double); -// Since double can be passed in memory or register there are two branches. -// CHECK: define double @TestGetVarDouble( -// CHECK: br label -// CHECK: br label -// CHECK: = phi -// CHECK: ret double -} - -long double TestGetVarLD(va_list ap) { - return __builtin_va_arg(ap, long double); -// fp128 can be passed in memory or in register, but x86_fp80 is in memory. -// ANDROID: define fp128 @TestGetVarLD( -// GNU: define x86_fp80 @TestGetVarLD( -// ANDROID: br label -// ANDROID: br label -// ANDROID: = phi -// GNU-NOT: br -// GNU-NOT: = phi -// ANDROID: ret fp128 -// GNU: ret x86_fp80 -} - -long double _Complex TestGetVarLDC(va_list ap) { - return __builtin_va_arg(ap, long double _Complex); -// Pair of fp128 or x86_fp80 are passed as struct in memory. -// ANDROID: define void @TestGetVarLDC({ fp128, fp128 }* {{.*}}, %struct.__va_list_tag* -// GNU: define { x86_fp80, x86_fp80 } @TestGetVarLDC( -// CHECK-NOT: br -// CHECK-NOT: phi -// ANDROID: ret void -// GNU: ret { x86_fp80, x86_fp80 } -} - -void TestVarArg(const char *s, ...); - -void TestPassVarInt(int x) { - TestVarArg("A", x); -// CHECK: define void @TestPassVarInt(i32 %x) -// CHECK: call {{.*}} @TestVarArg(i8* {{.*}}, i32 %x) -} - -void TestPassVarFloat(float x) { - TestVarArg("A", x); -// CHECK: define void @TestPassVarFloat(float %x) -// CHECK: call {{.*}} @TestVarArg(i8* {{.*}}, double % -} - -void TestPassVarDouble(double x) { - TestVarArg("A", x); -// CHECK: define void @TestPassVarDouble(double %x) -// CHECK: call {{.*}} @TestVarArg(i8* {{.*}}, double %x -} - -void TestPassVarLD(long double x) { - TestVarArg("A", x); -// ANDROID: define void @TestPassVarLD(fp128 %x) -// ANDROID: call {{.*}} @TestVarArg(i8* {{.*}}, fp128 %x -// GNU: define void @TestPassVarLD(x86_fp80 %x) -// GNU: call {{.*}} @TestVarArg(i8* {{.*}}, x86_fp80 %x -} - -void TestPassVarLDC(long double _Complex x) { - TestVarArg("A", x); -// ANDROID: define void @TestPassVarLDC({ fp128, fp128 }* {{.*}} %x) -// ANDROID: store fp128 %{{
Re: [PATCH] D11921: Add NaCl (a target where long double = double) to long double ABI test
This revision was automatically updated to reflect the committed changes. Closed by commit rL244524: Add NaCl (a target where long double = double) to long double ABI test (authored by dschuff). Changed prior to commit: http://reviews.llvm.org/D11921?vs=31741&id=31743#toc Repository: rL LLVM http://reviews.llvm.org/D11921 Files: cfe/trunk/test/CodeGen/x86_64-fp128.c cfe/trunk/test/CodeGen/x86_64-longdouble.c Index: cfe/trunk/test/CodeGen/x86_64-longdouble.c === --- cfe/trunk/test/CodeGen/x86_64-longdouble.c +++ cfe/trunk/test/CodeGen/x86_64-longdouble.c @@ -0,0 +1,135 @@ +// RUN: %clang_cc1 -triple x86_64-linux-android -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=ANDROID --check-prefix=CHECK +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK +// RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=GNU --check-prefix=CHECK +// NaCl is an example of a target for which long double is the same as double. +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -O -o - %s \ +// RUN:| FileCheck %s --check-prefix=NACL --check-prefix=CHECK + +// Android uses fp128 for long double but other x86_64 targets use x86_fp80. + +long double dataLD = 1.0L; +// ANDROID: @dataLD = global fp128 0xL3FFF, align 16 +// GNU: @dataLD = global x86_fp80 0xK3FFF8000, align 16 + +long double _Complex dataLDC = {1.0L, 1.0L}; +// ANDROID: @dataLDC = global { fp128, fp128 } { fp128 0xL3FFF, fp128 0xL3FFF }, align 16 +// GNU: @dataLDC = global { x86_fp80, x86_fp80 } { x86_fp80 0xK3FFF8000, x86_fp80 0xK3FFF8000 }, align 16 + +long double TestLD(long double x) { + return x * x; +// ANDROID: define fp128 @TestLD(fp128 %x) +// GNU: define x86_fp80 @TestLD(x86_fp80 %x) +// NACL: define double @TestLD(double %x) +} + +long double _Complex TestLDC(long double _Complex x) { + return x * x; +// ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x) +// GNU: define { x86_fp80, x86_fp80 } @TestLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) +// NACL: define { double, double } @TestLDC(double %x{{.*}}, double %x{{.*}}) +} + +typedef __builtin_va_list va_list; + +int TestGetVarInt(va_list ap) { + return __builtin_va_arg(ap, int); +// Since int can be passed in memory or register there are two branches. +// CHECK: define i32 @TestGetVarInt( +// CHECK: br label +// CHECK: br label +// CHECK: = phi +// CHECK: ret i32 +} + +double TestGetVarDouble(va_list ap) { + return __builtin_va_arg(ap, double); +// Since double can be passed in memory or register there are two branches. +// CHECK: define double @TestGetVarDouble( +// CHECK: br label +// CHECK: br label +// CHECK: = phi +// CHECK: ret double +} + +long double TestGetVarLD(va_list ap) { + return __builtin_va_arg(ap, long double); +// fp128 and double can be passed in memory or in register, but x86_fp80 is in +// memory. +// ANDROID: define fp128 @TestGetVarLD( +// GNU: define x86_fp80 @TestGetVarLD( +// NACL: define double @TestGetVarLD( +// ANDROID: br label +// ANDROID: br label +// NACL: br +// ANDROID: = phi +// GNU-NOT: br +// GNU-NOT: = phi +// NACL: = phi +// ANDROID: ret fp128 +// GNU: ret x86_fp80 +} + +long double _Complex TestGetVarLDC(va_list ap) { + return __builtin_va_arg(ap, long double _Complex); +// Pair of fp128 or x86_fp80 are passed as struct in memory. +// ANDROID: define void @TestGetVarLDC({ fp128, fp128 }* {{.*}}, %struct.__va_list_tag* +// GNU: define { x86_fp80, x86_fp80 } @TestGetVarLDC( +// Pair of double can go in SSE registers or memory +// NACL: define { double, double } @TestGetVarLDC( +// ANDROID-NOT: br +// GNU-NOT: br +// NACL: br +// ANDROID-NOT: phi +// GNU-NOT: phi +// NACL: phi +// ANDROID: ret void +// GNU: ret { x86_fp80, x86_fp80 } +// NACL: ret { double, double } +} + +void TestVarArg(const char *s, ...); + +void TestPassVarInt(int x) { + TestVarArg("A", x); +// CHECK: define void @TestPassVarInt(i32 %x) +// CHECK: call {{.*}} @TestVarArg(i8* {{.*}}, i32 %x) +} + +void TestPassVarFloat(float x) { + TestVarArg("A", x); +// CHECK: define void @TestPassVarFloat(float %x) +// CHECK: call {{.*}} @TestVarArg(i8* {{.*}}, double % +} + +void TestPassVarDouble(double x) { + TestVarArg("A", x); +// CHECK: define void @TestPassVarDouble(double %x) +// CHECK: call {{.*}} @TestVarArg(i8* {{.*}}, double %x +} + +void TestPassVarLD(long double x) { + TestVarArg("A", x); +// ANDROID: define void @TestPassVarLD(fp128 %x) +// ANDROID: call {{.*}} @TestVarArg(i8* {{.*}}, fp128 %x +// GNU: define void @TestPassVarLD(x86_fp80 %x) +// GNU: call {{.*}} @TestVarArg(i8* {{.*}}, x86_fp80 %x +// NACL: define void @TestPassVarLD(double %x) +// NACL: call {{.*
Re: [PATCH] D11921: Add NaCl (a target where long double = double) to long double ABI test
dschuff added a comment. In http://reviews.llvm.org/D11921#221172, @chh wrote: > Please rebase the change to r244502 or newer, to run with -Asserts builds. Did that; Not sure it's reflected on Phabricator, but I did check the diff. Thanks! Repository: rL LLVM http://reviews.llvm.org/D11921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D11922: Add NaCl to long double/fp128 mangling test
dschuff created this revision. dschuff added reviewers: rnk, chh. dschuff added a subscriber: cfe-commits. Herald added subscribers: dschuff, jfb. NaCl is a platform where long double is the same as double. Its mangling is spelled with "long double" but its ABI lowering is the same as double. http://reviews.llvm.org/D11922 Files: test/CodeGen/long_double_fp128.cpp Index: test/CodeGen/long_double_fp128.cpp === --- test/CodeGen/long_double_fp128.cpp +++ test/CodeGen/long_double_fp128.cpp @@ -10,6 +10,8 @@ // RUN:| FileCheck %s --check-prefix=G32 // RUN: %clang_cc1 -triple powerpc-linux-gnu -emit-llvm -o - %s \ // RUN:| FileCheck %s --check-prefix=P32 +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -o - %s \ +// RUN:| FileCheck %s --check-prefix=N64 // Check mangled name of long double. // Android's gcc and llvm use fp128 for long double. @@ -20,3 +22,4 @@ // A32: define void @_Z4testlfdeCe(i32, float, double, double, { double, double }* // G32: define void @_Z4testlfdeCe(i32, float, double, x86_fp80, { x86_fp80, x86_fp80 }* // P32: define void @_Z4testlfdgCg(i32, float, double, ppc_fp128, { ppc_fp128, ppc_fp128 }* +// N64: define void @_Z4testlfdeCe(i32, float, double, double, double {{.*}}, double Index: test/CodeGen/long_double_fp128.cpp === --- test/CodeGen/long_double_fp128.cpp +++ test/CodeGen/long_double_fp128.cpp @@ -10,6 +10,8 @@ // RUN:| FileCheck %s --check-prefix=G32 // RUN: %clang_cc1 -triple powerpc-linux-gnu -emit-llvm -o - %s \ // RUN:| FileCheck %s --check-prefix=P32 +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -o - %s \ +// RUN:| FileCheck %s --check-prefix=N64 // Check mangled name of long double. // Android's gcc and llvm use fp128 for long double. @@ -20,3 +22,4 @@ // A32: define void @_Z4testlfdeCe(i32, float, double, double, { double, double }* // G32: define void @_Z4testlfdeCe(i32, float, double, x86_fp80, { x86_fp80, x86_fp80 }* // P32: define void @_Z4testlfdgCg(i32, float, double, ppc_fp128, { ppc_fp128, ppc_fp128 }* +// N64: define void @_Z4testlfdeCe(i32, float, double, double, double {{.*}}, double ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11922: Add NaCl to long double/fp128 mangling test
dschuff added a comment. I'm not an expert in mangling, and I'm not 100% sure if this is right. The Itanium ABI's spec lists "long double" as the same as __float80. Should we use "double" in mangling instead? http://reviews.llvm.org/D11922 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11922: Add NaCl to long double/fp128 mangling test
dschuff added a comment. Looks like all the other unix targets that use IEEEDouble as their format do this too, including all the NaCl compilers. http://reviews.llvm.org/D11922 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11922: Add NaCl to long double/fp128 mangling test
This revision was automatically updated to reflect the committed changes. Closed by commit rL244541: Add NaCl to long double/fp128 mangling test (authored by dschuff). Changed prior to commit: http://reviews.llvm.org/D11922?vs=31744&id=31747#toc Repository: rL LLVM http://reviews.llvm.org/D11922 Files: cfe/trunk/test/CodeGen/long_double_fp128.cpp Index: cfe/trunk/test/CodeGen/long_double_fp128.cpp === --- cfe/trunk/test/CodeGen/long_double_fp128.cpp +++ cfe/trunk/test/CodeGen/long_double_fp128.cpp @@ -10,6 +10,8 @@ // RUN:| FileCheck %s --check-prefix=G32 // RUN: %clang_cc1 -triple powerpc-linux-gnu -emit-llvm -o - %s \ // RUN:| FileCheck %s --check-prefix=P32 +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -o - %s \ +// RUN:| FileCheck %s --check-prefix=N64 // Check mangled name of long double. // Android's gcc and llvm use fp128 for long double. @@ -20,3 +22,4 @@ // A32: define void @_Z4testlfdeCe(i32, float, double, double, { double, double }* // G32: define void @_Z4testlfdeCe(i32, float, double, x86_fp80, { x86_fp80, x86_fp80 }* // P32: define void @_Z4testlfdgCg(i32, float, double, ppc_fp128, { ppc_fp128, ppc_fp128 }* +// N64: define void @_Z4testlfdeCe(i32, float, double, double, double {{.*}}, double Index: cfe/trunk/test/CodeGen/long_double_fp128.cpp === --- cfe/trunk/test/CodeGen/long_double_fp128.cpp +++ cfe/trunk/test/CodeGen/long_double_fp128.cpp @@ -10,6 +10,8 @@ // RUN:| FileCheck %s --check-prefix=G32 // RUN: %clang_cc1 -triple powerpc-linux-gnu -emit-llvm -o - %s \ // RUN:| FileCheck %s --check-prefix=P32 +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -o - %s \ +// RUN:| FileCheck %s --check-prefix=N64 // Check mangled name of long double. // Android's gcc and llvm use fp128 for long double. @@ -20,3 +22,4 @@ // A32: define void @_Z4testlfdeCe(i32, float, double, double, { double, double }* // G32: define void @_Z4testlfdeCe(i32, float, double, x86_fp80, { x86_fp80, x86_fp80 }* // P32: define void @_Z4testlfdgCg(i32, float, double, ppc_fp128, { ppc_fp128, ppc_fp128 }* +// N64: define void @_Z4testlfdeCe(i32, float, double, double, double {{.*}}, double ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r244542 - add comment
Author: dschuff Date: Mon Aug 10 19:19:54 2015 New Revision: 244542 URL: http://llvm.org/viewvc/llvm-project?rev=244542&view=rev Log: add comment Modified: cfe/trunk/test/CodeGen/long_double_fp128.cpp Modified: cfe/trunk/test/CodeGen/long_double_fp128.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/long_double_fp128.cpp?rev=244542&r1=244541&r2=244542&view=diff == --- cfe/trunk/test/CodeGen/long_double_fp128.cpp (original) +++ cfe/trunk/test/CodeGen/long_double_fp128.cpp Mon Aug 10 19:19:54 2015 @@ -15,6 +15,7 @@ // Check mangled name of long double. // Android's gcc and llvm use fp128 for long double. +// NaCl uses double format for long double, but still has separate overloads. void test(long, float, double, long double, long double _Complex) { } // A64: define void @_Z4testlfdgCg(i64, float, double, fp128, { fp128, fp128 }* // G64: define void @_Z4testlfdeCe(i64, float, double, x86_fp80, { x86_fp80, x86_fp80 }* ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r244541 - Add NaCl to long double/fp128 mangling test
Author: dschuff Date: Mon Aug 10 19:19:53 2015 New Revision: 244541 URL: http://llvm.org/viewvc/llvm-project?rev=244541&view=rev Log: Add NaCl to long double/fp128 mangling test Summary: NaCl is a platform where long double is the same as double. Its mangling is spelled with "long double" but its ABI lowering is the same as double. Reviewers: rnk, chh Subscribers: jfb, cfe-commits, dschuff Differential Revision: http://reviews.llvm.org/D11922 Modified: cfe/trunk/test/CodeGen/long_double_fp128.cpp Modified: cfe/trunk/test/CodeGen/long_double_fp128.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/long_double_fp128.cpp?rev=244541&r1=244540&r2=244541&view=diff == --- cfe/trunk/test/CodeGen/long_double_fp128.cpp (original) +++ cfe/trunk/test/CodeGen/long_double_fp128.cpp Mon Aug 10 19:19:53 2015 @@ -10,6 +10,8 @@ // RUN:| FileCheck %s --check-prefix=G32 // RUN: %clang_cc1 -triple powerpc-linux-gnu -emit-llvm -o - %s \ // RUN:| FileCheck %s --check-prefix=P32 +// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -o - %s \ +// RUN:| FileCheck %s --check-prefix=N64 // Check mangled name of long double. // Android's gcc and llvm use fp128 for long double. @@ -20,3 +22,4 @@ void test(long, float, double, long doub // A32: define void @_Z4testlfdeCe(i32, float, double, double, { double, double }* // G32: define void @_Z4testlfdeCe(i32, float, double, x86_fp80, { x86_fp80, x86_fp80 }* // P32: define void @_Z4testlfdgCg(i32, float, double, ppc_fp128, { ppc_fp128, ppc_fp128 }* +// N64: define void @_Z4testlfdeCe(i32, float, double, double, double {{.*}}, double ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r245908 - Use GetLinkerPath utility function to find linker for NaCl toolchain
Author: dschuff Date: Mon Aug 24 18:53:25 2015 New Revision: 245908 URL: http://llvm.org/viewvc/llvm-project?rev=245908&view=rev Log: Use GetLinkerPath utility function to find linker for NaCl toolchain Summary: This is more consistent with other targets and also makes the -fuse-ld flag work. Reviewers: jvoung Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10697 Modified: cfe/trunk/lib/Driver/ToolChains.cpp Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=245908&r1=245907&r2=245908&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Aug 24 18:53:25 2015 @@ -2359,7 +2359,7 @@ NaClToolChain::NaClToolChain(const Drive } // Use provided linker, not system linker - Linker = GetProgramPath("ld"); + Linker = GetLinkerPath(); NaClArmMacrosPath = GetFilePath("nacl-arm-macros.s"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r245909 - broken test. uses system ld.gold
Author: dschuff Date: Mon Aug 24 18:53:28 2015 New Revision: 245909 URL: http://llvm.org/viewvc/llvm-project?rev=245909&view=rev Log: broken test. uses system ld.gold Added: cfe/trunk/test/Driver/Inputs/basic_nacl_tree/ cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld.gold Modified: cfe/trunk/test/Driver/fuse-ld.c Added: cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld?rev=245909&view=auto == (empty) Added: cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld.gold URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld.gold?rev=245909&view=auto == (empty) Modified: cfe/trunk/test/Driver/fuse-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuse-ld.c?rev=245909&r1=245908&r2=245909&view=diff == --- cfe/trunk/test/Driver/fuse-ld.c (original) +++ cfe/trunk/test/Driver/fuse-ld.c Mon Aug 24 18:53:28 2015 @@ -61,3 +61,9 @@ // RUN: -gcc-toolchain %S/Inputs/basic_android_tree 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-ANDROID-ARM-GOLD-TC // CHECK-ANDROID-ARM-GOLD-TC: Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin{{/|\\+}}ld.gold + +// RUN: %clang %s -### -fuse-ld=gold \ +// RUN: -target i686-unknown-nacl \ +// RUN: -B%S/Inputs/basic_nacl_tree/bin 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-NACL-GOLD-TC +// CHECK-NACL-GOLD-TC: ld.gold ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r245910 - Revert "broken test. uses system ld.gold"
Author: dschuff Date: Mon Aug 24 18:53:30 2015 New Revision: 245910 URL: http://llvm.org/viewvc/llvm-project?rev=245910&view=rev Log: Revert "broken test. uses system ld.gold" We should check in a basic_nacl_tree that works and also fix --sysroot Removed: cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld.gold Modified: cfe/trunk/test/Driver/fuse-ld.c Removed: cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld?rev=245909&view=auto == (empty) Removed: cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld.gold URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_nacl_tree/bin/ld.gold?rev=245909&view=auto == (empty) Modified: cfe/trunk/test/Driver/fuse-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuse-ld.c?rev=245910&r1=245909&r2=245910&view=diff == --- cfe/trunk/test/Driver/fuse-ld.c (original) +++ cfe/trunk/test/Driver/fuse-ld.c Mon Aug 24 18:53:30 2015 @@ -61,9 +61,3 @@ // RUN: -gcc-toolchain %S/Inputs/basic_android_tree 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-ANDROID-ARM-GOLD-TC // CHECK-ANDROID-ARM-GOLD-TC: Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin{{/|\\+}}ld.gold - -// RUN: %clang %s -### -fuse-ld=gold \ -// RUN: -target i686-unknown-nacl \ -// RUN: -B%S/Inputs/basic_nacl_tree/bin 2>&1 \ -// RUN: | FileCheck %s -check-prefix=CHECK-NACL-GOLD-TC -// CHECK-NACL-GOLD-TC: ld.gold ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r246040 - Change Native Client x86 usr include and link path to match SDK expectations
Author: dschuff Date: Wed Aug 26 12:14:08 2015 New Revision: 246040 URL: http://llvm.org/viewvc/llvm-project?rev=246040&view=rev Log: Change Native Client x86 usr include and link path to match SDK expectations GNU multilib style uses x86_64-nacl/include and x86_64-nacl/usr/include but the SDK expects i686-nacl/usr/include for its files. Change the driver to use this. Fixes https://code.google.com/p/nativeclient/issues/detail?id=4108 Differential Revision: http://reviews.llvm.org/D11271 Modified: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/test/Driver/nacl-direct.c Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=246040&r1=246039&r2=246040&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Aug 26 12:14:08 2015 @@ -2328,7 +2328,7 @@ NaClToolChain::NaClToolChain(const Drive switch (Triple.getArch()) { case llvm::Triple::x86: { file_paths.push_back(FilePath + "x86_64-nacl/lib32"); -file_paths.push_back(FilePath + "x86_64-nacl/usr/lib32"); +file_paths.push_back(FilePath + "i686-nacl/usr/lib"); prog_paths.push_back(ProgPath + "x86_64-nacl/bin"); file_paths.push_back(ToolPath + "i686-nacl"); break; @@ -2380,12 +2380,21 @@ void NaClToolChain::AddClangSystemInclud SmallString<128> P(D.Dir + "/../"); switch (getTriple().getArch()) { + case llvm::Triple::x86: +// x86 is special because multilib style uses x86_64-nacl/include for libc +// headers but the SDK wants i686-nacl/usr/include. The other architectures +// have the same substring. +llvm::sys::path::append(P, "i686-nacl/usr/include"); +addSystemInclude(DriverArgs, CC1Args, P.str()); +llvm::sys::path::remove_filename(P); +llvm::sys::path::remove_filename(P); +llvm::sys::path::remove_filename(P); +llvm::sys::path::append(P, "x86_64-nacl/include"); +addSystemInclude(DriverArgs, CC1Args, P.str()); +return; case llvm::Triple::arm: llvm::sys::path::append(P, "arm-nacl/usr/include"); break; - case llvm::Triple::x86: -llvm::sys::path::append(P, "x86_64-nacl/usr/include"); -break; case llvm::Triple::x86_64: llvm::sys::path::append(P, "x86_64-nacl/usr/include"); break; Modified: cfe/trunk/test/Driver/nacl-direct.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nacl-direct.c?rev=246040&r1=246039&r2=246040&view=diff == --- cfe/trunk/test/Driver/nacl-direct.c (original) +++ cfe/trunk/test/Driver/nacl-direct.c Wed Aug 26 12:14:08 2015 @@ -9,7 +9,7 @@ // CHECK-I686: "-target-cpu" "pentium4" // CHECK-I686: "-resource-dir" "foo" // CHECK-I686: "-internal-isystem" "foo{{/|}}include" -// CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}include" +// CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include" // CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}include" // CHECK-I686: as{{(.exe)?}}" "--32" // CHECK-I686: ld{{(.exe)?}}" @@ -17,7 +17,7 @@ // CHECK-I686: "-m" "elf_i386_nacl" // CHECK-I686: "-static" // CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}lib32" -// CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}lib32" +// CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}lib" // CHECK-I686: "-Lfoo{{/|}}lib{{/|}}i686-nacl" // CHECK-I686-NOT: -lpthread // @@ -118,7 +118,7 @@ // CHECK-I686-CXX: "-resource-dir" "foo" // CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}include{{/|}}c++{{/|}}v1" // CHECK-I686-CXX: "-internal-isystem" "foo{{/|}}include" -// CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}include" +// CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include" // CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}include" // CHECK-I686-CXX: "-lpthread" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11271: Change Native Client x86 usr include and link path to match SDK expectations
This revision was automatically updated to reflect the committed changes. Closed by commit rL246040: Change Native Client x86 usr include and link path to match SDK expectations (authored by dschuff). Changed prior to commit: http://reviews.llvm.org/D11271?vs=29924&id=33216#toc Repository: rL LLVM http://reviews.llvm.org/D11271 Files: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/test/Driver/nacl-direct.c Index: cfe/trunk/test/Driver/nacl-direct.c === --- cfe/trunk/test/Driver/nacl-direct.c +++ cfe/trunk/test/Driver/nacl-direct.c @@ -9,15 +9,15 @@ // CHECK-I686: "-target-cpu" "pentium4" // CHECK-I686: "-resource-dir" "foo" // CHECK-I686: "-internal-isystem" "foo{{/|}}include" -// CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}include" +// CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include" // CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}include" // CHECK-I686: as{{(.exe)?}}" "--32" // CHECK-I686: ld{{(.exe)?}}" // CHECK-I686: "--build-id" // CHECK-I686: "-m" "elf_i386_nacl" // CHECK-I686: "-static" // CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}lib32" -// CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}lib32" +// CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}lib" // CHECK-I686: "-Lfoo{{/|}}lib{{/|}}i686-nacl" // CHECK-I686-NOT: -lpthread // @@ -118,7 +118,7 @@ // CHECK-I686-CXX: "-resource-dir" "foo" // CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}include{{/|}}c++{{/|}}v1" // CHECK-I686-CXX: "-internal-isystem" "foo{{/|}}include" -// CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}include" +// CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include" // CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}include" // CHECK-I686-CXX: "-lpthread" Index: cfe/trunk/lib/Driver/ToolChains.cpp === --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -2328,7 +2328,7 @@ switch (Triple.getArch()) { case llvm::Triple::x86: { file_paths.push_back(FilePath + "x86_64-nacl/lib32"); -file_paths.push_back(FilePath + "x86_64-nacl/usr/lib32"); +file_paths.push_back(FilePath + "i686-nacl/usr/lib"); prog_paths.push_back(ProgPath + "x86_64-nacl/bin"); file_paths.push_back(ToolPath + "i686-nacl"); break; @@ -2380,12 +2380,21 @@ SmallString<128> P(D.Dir + "/../"); switch (getTriple().getArch()) { + case llvm::Triple::x86: +// x86 is special because multilib style uses x86_64-nacl/include for libc +// headers but the SDK wants i686-nacl/usr/include. The other architectures +// have the same substring. +llvm::sys::path::append(P, "i686-nacl/usr/include"); +addSystemInclude(DriverArgs, CC1Args, P.str()); +llvm::sys::path::remove_filename(P); +llvm::sys::path::remove_filename(P); +llvm::sys::path::remove_filename(P); +llvm::sys::path::append(P, "x86_64-nacl/include"); +addSystemInclude(DriverArgs, CC1Args, P.str()); +return; case llvm::Triple::arm: llvm::sys::path::append(P, "arm-nacl/usr/include"); break; - case llvm::Triple::x86: -llvm::sys::path::append(P, "x86_64-nacl/usr/include"); -break; case llvm::Triple::x86_64: llvm::sys::path::append(P, "x86_64-nacl/usr/include"); break; Index: cfe/trunk/test/Driver/nacl-direct.c === --- cfe/trunk/test/Driver/nacl-direct.c +++ cfe/trunk/test/Driver/nacl-direct.c @@ -9,15 +9,15 @@ // CHECK-I686: "-target-cpu" "pentium4" // CHECK-I686: "-resource-dir" "foo" // CHECK-I686: "-internal-isystem" "foo{{/|}}include" -// CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}include" +// CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include" // CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}include" // CHECK-I686: as{{(.exe)?}}" "--32" // CHECK-I686: ld{{(.exe)?}}" // CHECK-I686: "--build-id" // CHECK-I686: "-m" "elf_i386_nacl" // CHECK-I686: "-static" // CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}lib32" -// CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}x86_64-nacl{{/|}}usr{{/|}}lib32" +// CHECK-I686: "-L{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}lib" // CHECK-I686: "-Lfoo{{/|}}lib{{/|}}i686-nacl" // CHECK-I686-NOT: -lpthread // @@ -118,7 +118,7 @@ // CHECK-I686-CXX: "-resource-dir" "foo" // CHECK-I686-CXX: "-internal-isystem"
r278051 - [Driver] Enable CFI for WebAssembly
Author: dschuff Date: Mon Aug 8 16:14:15 2016 New Revision: 278051 URL: http://llvm.org/viewvc/llvm-project?rev=278051&view=rev Log: [Driver] Enable CFI for WebAssembly Since CFI support has landed in the WebAssembly backend, enable it in the frontend driver. Patch by Dominic Chen Differential Revision: https://reviews.llvm.org/D23244 Modified: cfe/trunk/lib/Driver/ToolChain.cpp Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=278051&r1=278050&r2=278051&view=diff == --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Aug 8 16:14:15 2016 @@ -697,7 +697,9 @@ SanitizerMask ToolChain::getSupportedSan SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) | CFICastStrict | UnsignedIntegerOverflow | LocalBounds; if (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64) + getTriple().getArch() == llvm::Triple::x86_64 || + getTriple().getArch() == llvm::Triple::wasm32 || + getTriple().getArch() == llvm::Triple::wasm64) Res |= CFIICall; return Res; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23244: [Driver] Enable CFI for WebAssembly
This revision was automatically updated to reflect the committed changes. Closed by commit rL278051: [Driver] Enable CFI for WebAssembly (authored by dschuff). Changed prior to commit: https://reviews.llvm.org/D23244?vs=67090&id=67226#toc Repository: rL LLVM https://reviews.llvm.org/D23244 Files: cfe/trunk/lib/Driver/ToolChain.cpp Index: cfe/trunk/lib/Driver/ToolChain.cpp === --- cfe/trunk/lib/Driver/ToolChain.cpp +++ cfe/trunk/lib/Driver/ToolChain.cpp @@ -697,7 +697,9 @@ SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) | CFICastStrict | UnsignedIntegerOverflow | LocalBounds; if (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64) + getTriple().getArch() == llvm::Triple::x86_64 || + getTriple().getArch() == llvm::Triple::wasm32 || + getTriple().getArch() == llvm::Triple::wasm64) Res |= CFIICall; return Res; } Index: cfe/trunk/lib/Driver/ToolChain.cpp === --- cfe/trunk/lib/Driver/ToolChain.cpp +++ cfe/trunk/lib/Driver/ToolChain.cpp @@ -697,7 +697,9 @@ SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) | CFICastStrict | UnsignedIntegerOverflow | LocalBounds; if (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64) + getTriple().getArch() == llvm::Triple::x86_64 || + getTriple().getArch() == llvm::Triple::wasm32 || + getTriple().getArch() == llvm::Triple::wasm64) Res |= CFIICall; return Res; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16154: Default vaarg lowering should support indirect struct types.
dschuff added a comment. This LGTM for PNaCl and WebAssembly. It's possible that for wasm we may still end up doing our own thing for varargs instead of using the default, but this still looks like strictly an improvement, (and it makes bootstrapping a backend simpler). http://reviews.llvm.org/D16154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r268256 - [WebAssembly] Rename memory_size intrinsic to current_memory
Author: dschuff Date: Mon May 2 12:26:19 2016 New Revision: 268256 URL: http://llvm.org/viewvc/llvm-project?rev=268256&view=rev Log: [WebAssembly] Rename memory_size intrinsic to current_memory This follows the recent change in the wasm spec. Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/builtins-wasm.c Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=268256&r1=268255&r2=268256&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Mon May 2 12:26:19 2016 @@ -16,9 +16,9 @@ // The format of this database matches clang/Basic/Builtins.def. -// Note that memory_size is not "c" (readnone) because it must be sequenced with +// Note that current_memory is not "c" (readnone) because it must be sequenced with // respect to grow_memory calls. -BUILTIN(__builtin_wasm_memory_size, "z", "n") +BUILTIN(__builtin_wasm_current_memory, "z", "n") BUILTIN(__builtin_wasm_grow_memory, "vz", "n") #undef BUILTIN Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=268256&r1=268255&r2=268256&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May 2 12:26:19 2016 @@ -7441,9 +7441,9 @@ Value *CodeGenFunction::EmitNVPTXBuiltin Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { switch (BuiltinID) { - case WebAssembly::BI__builtin_wasm_memory_size: { + case WebAssembly::BI__builtin_wasm_current_memory: { llvm::Type *ResultType = ConvertType(E->getType()); -Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_size, ResultType); +Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_current_memory, ResultType); return Builder.CreateCall(Callee); } case WebAssembly::BI__builtin_wasm_grow_memory: { Modified: cfe/trunk/test/CodeGen/builtins-wasm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=268256&r1=268255&r2=268256&view=diff == --- cfe/trunk/test/CodeGen/builtins-wasm.c (original) +++ cfe/trunk/test/CodeGen/builtins-wasm.c Mon May 2 12:26:19 2016 @@ -4,9 +4,9 @@ // RUN: | FileCheck %s -check-prefix=WEBASSEMBLY64 __SIZE_TYPE__ f1(void) { - return __builtin_wasm_memory_size(); -// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32() -// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64() + return __builtin_wasm_current_memory(); +// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.current.memory.i32() +// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64() } void f2(long delta) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff added a comment. Thanks for the feedback, PTAL http://reviews.llvm.org/D19275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff updated this revision to Diff 56218. dschuff added a comment. - Introduce CGCXXABI::canCallMismatchedFunctionType http://reviews.llvm.org/D19275 Files: lib/CodeGen/CGCXXABI.h lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/ItaniumCXXABI.cpp test/CodeGenCXX/static-destructor.cpp Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=ARM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// ARM destructors return this, but can be registered directly with __cxa_atexit +// because the calling conventions tolerate the mismatch. +// ARM: define internal void @__cxx_global_var_init() +// ARM-NEXT: entry: +// ARM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (%class.Foo* (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// Wasm destructors return this, and use a wrapper function, which is registered +// with __cxa_atexit. +// WASM: define internal void @__cxx_global_var_init() +// WASM-NEXT: entry: +// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) + +// WASM: define internal void @__cxx_global_array_dtor(i8*) +// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global) Index: lib/CodeGen/ItaniumCXXABI.cpp === --- lib/CodeGen/ItaniumCXXABI.cpp +++ lib/CodeGen/ItaniumCXXABI.cpp @@ -443,6 +443,7 @@ (isa(GD.getDecl()) && GD.getDtorType() != Dtor_Deleting); } + bool canCallMismatchedFunctionType() const override { return false; } }; } Index: lib/CodeGen/CGDeclCXX.cpp === --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -86,13 +86,21 @@ llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, where there's a function - // with the right signature that we can just call. - const CXXRecordDecl *record = nullptr; - if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl())) { -assert(!record->hasTrivialDestructor()); -CXXDestructorDecl *dtor = record->getDestructor(); + // Special-case non-array C++ destructors, if they have the right signature. + // Under some ABIs, destructors return this instead of void, and cannot be + // passed directly to __cxa_atexit if the target does not allow this mismatch. + const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); + bool CanRegisterDestructor = + Record && (!CGM.getCXXABI().HasThisReturn( + GlobalDecl(Record->getDestructor(), Dtor_Complete)) || + CGM.getCXXABI().canCallMismatchedFunctionType()); + // If __cxa_atexit is disabled via a flag, a different helper function is + // generated elsewhere which uses atexit instead, and it takes the destructor + // directly. + bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit; + if (Record && (CanRegisterDestructor || UsingExternalHelper)) { +assert(!Record->hasTrivialDestructor()); +CXXDestructorDecl *dtor = Record->getDestructor(); function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete); argument = llvm::ConstantExpr::getBitCast( Index: lib/CodeGen/CGCXXABI.h === --- lib/CodeGen/CGCXXABI.h +++ lib/CodeGen/CGCXXABI.h @@ -106,6 +106,16 @@ virtual bool hasMostDerivedReturn(GlobalDecl GD) const { return false; } + /// Returns true if the target allows calling a function through a pointer + /// with a different signature than the actual function (or equivalently, + /// bitcasting a function or function pointer to a different function type). + /// In principle in the most general case this could depend on the target, the + /// calling convention, and the actual types of the arguments and return + /// value. Here it just means whether the
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff added a comment. Ping? http://reviews.llvm.org/D19275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269087 - Clarify condition, remove redundant check
Author: dschuff Date: Tue May 10 12:44:50 2016 New Revision: 269087 URL: http://llvm.org/viewvc/llvm-project?rev=269087&view=rev Log: Clarify condition, remove redundant check Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=269087&r1=269086&r2=269087&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue May 10 12:44:50 2016 @@ -87,15 +87,17 @@ static void EmitDeclDestroy(CodeGenFunct llvm::Constant *argument; // Special-case non-array C++ destructors, if they have the right signature - // that can be directly registered with __cxa_atexit. If __cxa_atexit is - // disabled via a flag, a different helper function is generated anyway. + // that can be directly registered with __cxa_atexit. const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); bool CanRegisterDestructor = Record && !CGM.getCXXABI().HasThisReturn(GlobalDecl( Record->getDestructor(), Dtor_Complete)); - - if (dtorKind == QualType::DK_cxx_destructor && Record && - (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) { + // If __cxa_atexit is disabled via a flag, a different helper function is + // generated elsewhere which uses atexit instead, and it takes the destructor + // directly. + bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit; + if (Record && + (CanRegisterDestructor || UsingExternalHelper)) { assert(!Record->hasTrivialDestructor()); CXXDestructorDecl *dtor = Record->getDestructor(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269086 - Clean up condition, add ARM to test
Author: dschuff Date: Tue May 10 12:44:48 2016 New Revision: 269086 URL: http://llvm.org/viewvc/llvm-project?rev=269086&view=rev Log: Clean up condition, add ARM to test Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/test/CodeGenCXX/static-destructor.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=269086&r1=269085&r2=269086&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue May 10 12:44:48 2016 @@ -89,14 +89,15 @@ static void EmitDeclDestroy(CodeGenFunct // Special-case non-array C++ destructors, if they have the right signature // that can be directly registered with __cxa_atexit. If __cxa_atexit is // disabled via a flag, a different helper function is generated anyway. - const CXXRecordDecl *record = nullptr; - if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl()) && - (!CGM.getCXXABI().HasThisReturn( - GlobalDecl(record->getDestructor(), Dtor_Complete)) || - !CGM.getCodeGenOpts().CXAAtExit)) { -assert(!record->hasTrivialDestructor()); -CXXDestructorDecl *dtor = record->getDestructor(); + const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); + bool CanRegisterDestructor = Record && + !CGM.getCXXABI().HasThisReturn(GlobalDecl( + Record->getDestructor(), Dtor_Complete)); + + if (dtorKind == QualType::DK_cxx_destructor && Record && + (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) { +assert(!Record->hasTrivialDestructor()); +CXXDestructorDecl *dtor = Record->getDestructor(); function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete); argument = llvm::ConstantExpr::getBitCast( Modified: cfe/trunk/test/CodeGenCXX/static-destructor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-destructor.cpp?rev=269086&r1=269085&r2=269086&view=diff == --- cfe/trunk/test/CodeGenCXX/static-destructor.cpp (original) +++ cfe/trunk/test/CodeGenCXX/static-destructor.cpp Tue May 10 12:44:48 2016 @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s // RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s // Test that destructors are not passed directly to __cxa_atexit when their // signatures do not match the type of its first argument. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269085 - Do not register incompatible C++ destructors with __cxa_atexit
Author: dschuff Date: Tue May 10 12:44:46 2016 New Revision: 269085 URL: http://llvm.org/viewvc/llvm-project?rev=269085&view=rev Log: Do not register incompatible C++ destructors with __cxa_atexit Summary: For a static object with a nontrivial destructor, clang generates an initializer function (__cxx_global_var_init) which registers that object's destructor using __cxa_atexit. However some ABIs (ARM, WebAssembly) use destructors that return 'this' instead of having void return (which does not match the signature of function pointers passed to __cxa_atexit). This results in undefined behavior when the destructors are called. All the calling conventions I know of on ARM can tolerate this, but WebAssembly requires the signatures of indirect calls to match the called function. This patch disables that direct registration of destructors for ABIs that have this-returning destructors. Subscribers: aemerson, jfb, cfe-commits, dschuff Differential Revision: http://reviews.llvm.org/D19275 Added: cfe/trunk/test/CodeGenCXX/static-destructor.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/test/CodeGenCXX/runtimecc.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=269085&r1=269084&r2=269085&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue May 10 12:44:46 2016 @@ -86,11 +86,15 @@ static void EmitDeclDestroy(CodeGenFunct llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, where there's a function - // with the right signature that we can just call. + // Special-case non-array C++ destructors, if they have the right signature + // that can be directly registered with __cxa_atexit. If __cxa_atexit is + // disabled via a flag, a different helper function is generated anyway. const CXXRecordDecl *record = nullptr; if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl())) { + (record = type->getAsCXXRecordDecl()) && + (!CGM.getCXXABI().HasThisReturn( + GlobalDecl(record->getDestructor(), Dtor_Complete)) || + !CGM.getCodeGenOpts().CXAAtExit)) { assert(!record->hasTrivialDestructor()); CXXDestructorDecl *dtor = record->getDestructor(); Modified: cfe/trunk/test/CodeGenCXX/runtimecc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/runtimecc.cpp?rev=269085&r1=269084&r2=269085&view=diff == --- cfe/trunk/test/CodeGenCXX/runtimecc.cpp (original) +++ cfe/trunk/test/CodeGenCXX/runtimecc.cpp Tue May 10 12:44:46 2016 @@ -22,8 +22,13 @@ namespace test0 { A global; // CHECK-LABEL:define internal void @__cxx_global_var_init() // CHECK: call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* @_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] +// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] // CHECK-NEXT: ret void + +// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*) +// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE) +// CHECK-NEXT: ret void + } // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]] Added: cfe/trunk/test/CodeGenCXX/static-destructor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-destructor.cpp?rev=269085&view=auto == --- cfe/trunk/test/CodeGenCXX/static-destructor.cpp (added) +++ cfe/trunk/test/CodeGenCXX/static-destructor.cpp Tue May 10 12:44:46 2016 @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// Wasm destructors return this, and use a wrapper function, which is registered +// with __cxa_atexit. +// WASM: define internal void @__cxx_global_var_i
r269088 - more cleanup
Author: dschuff Date: Tue May 10 12:44:52 2016 New Revision: 269088 URL: http://llvm.org/viewvc/llvm-project?rev=269088&view=rev Log: more cleanup Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=269088&r1=269087&r2=269088&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue May 10 12:44:52 2016 @@ -86,8 +86,9 @@ static void EmitDeclDestroy(CodeGenFunct llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, if they have the right signature - // that can be directly registered with __cxa_atexit. + // Special-case non-array C++ destructors, if they have the right signature. + // Under some ABIs, destructors return this instead of void, and cannot be + // passed directly to __cxa_atexit. const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); bool CanRegisterDestructor = Record && !CGM.getCXXABI().HasThisReturn(GlobalDecl( @@ -96,8 +97,7 @@ static void EmitDeclDestroy(CodeGenFunct // generated elsewhere which uses atexit instead, and it takes the destructor // directly. bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit; - if (Record && - (CanRegisterDestructor || UsingExternalHelper)) { + if (Record && (CanRegisterDestructor || UsingExternalHelper)) { assert(!Record->hasTrivialDestructor()); CXXDestructorDecl *dtor = Record->getDestructor(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269089 - Introduce CGCXXABI::canCallMismatchedFunctionType
Author: dschuff Date: Tue May 10 12:44:55 2016 New Revision: 269089 URL: http://llvm.org/viewvc/llvm-project?rev=269089&view=rev Log: Introduce CGCXXABI::canCallMismatchedFunctionType Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/test/CodeGenCXX/runtimecc.cpp cfe/trunk/test/CodeGenCXX/static-destructor.cpp Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=269089&r1=269088&r2=269089&view=diff == --- cfe/trunk/lib/CodeGen/CGCXXABI.h (original) +++ cfe/trunk/lib/CodeGen/CGCXXABI.h Tue May 10 12:44:55 2016 @@ -106,6 +106,16 @@ public: virtual bool hasMostDerivedReturn(GlobalDecl GD) const { return false; } + /// Returns true if the target allows calling a function through a pointer + /// with a different signature than the actual function (or equivalently, + /// bitcasting a function or function pointer to a different function type). + /// In principle in the most general case this could depend on the target, the + /// calling convention, and the actual types of the arguments and return + /// value. Here it just means whether the signature mismatch could *ever* be + /// allowed; in other words, does the target do strict checking of signatures + /// for all calls. + virtual bool canCallMismatchedFunctionType() const { return true; } + /// If the C++ ABI requires the given type be returned in a particular way, /// this method sets RetAI and returns true. virtual bool classifyReturnType(CGFunctionInfo &FI) const = 0; Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=269089&r1=269088&r2=269089&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue May 10 12:44:55 2016 @@ -88,11 +88,12 @@ static void EmitDeclDestroy(CodeGenFunct // Special-case non-array C++ destructors, if they have the right signature. // Under some ABIs, destructors return this instead of void, and cannot be - // passed directly to __cxa_atexit. + // passed directly to __cxa_atexit if the target does not allow this mismatch. const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); - bool CanRegisterDestructor = Record && - !CGM.getCXXABI().HasThisReturn(GlobalDecl( - Record->getDestructor(), Dtor_Complete)); + bool CanRegisterDestructor = + Record && (!CGM.getCXXABI().HasThisReturn( + GlobalDecl(Record->getDestructor(), Dtor_Complete)) || + CGM.getCXXABI().canCallMismatchedFunctionType()); // If __cxa_atexit is disabled via a flag, a different helper function is // generated elsewhere which uses atexit instead, and it takes the destructor // directly. Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=269089&r1=269088&r2=269089&view=diff == --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue May 10 12:44:55 2016 @@ -443,6 +443,7 @@ private: (isa(GD.getDecl()) && GD.getDtorType() != Dtor_Deleting); } + bool canCallMismatchedFunctionType() const override { return false; } }; } Modified: cfe/trunk/test/CodeGenCXX/runtimecc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/runtimecc.cpp?rev=269089&r1=269088&r2=269089&view=diff == --- cfe/trunk/test/CodeGenCXX/runtimecc.cpp (original) +++ cfe/trunk/test/CodeGenCXX/runtimecc.cpp Tue May 10 12:44:55 2016 @@ -22,13 +22,8 @@ namespace test0 { A global; // CHECK-LABEL:define internal void @__cxx_global_var_init() // CHECK: call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] +// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* @_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] // CHECK-NEXT: ret void - -// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*) -// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: ret void - } // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]] Modified: cfe/trunk/test/CodeGenCXX/static-destructor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-destructor.cpp?rev=269089&r1=269088&r2=269089&view=di
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
This revision was automatically updated to reflect the committed changes. Closed by commit rL269085: Do not register incompatible C++ destructors with __cxa_atexit (authored by dschuff). Changed prior to commit: http://reviews.llvm.org/D19275?vs=56218&id=56751#toc Repository: rL LLVM http://reviews.llvm.org/D19275 Files: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/test/CodeGenCXX/runtimecc.cpp cfe/trunk/test/CodeGenCXX/static-destructor.cpp Index: cfe/trunk/test/CodeGenCXX/static-destructor.cpp === --- cfe/trunk/test/CodeGenCXX/static-destructor.cpp +++ cfe/trunk/test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// Wasm destructors return this, and use a wrapper function, which is registered +// with __cxa_atexit. +// WASM: define internal void @__cxx_global_var_init() +// WASM-NEXT: entry: +// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) + +// WASM: define internal void @__cxx_global_array_dtor(i8*) +// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global) Index: cfe/trunk/test/CodeGenCXX/runtimecc.cpp === --- cfe/trunk/test/CodeGenCXX/runtimecc.cpp +++ cfe/trunk/test/CodeGenCXX/runtimecc.cpp @@ -22,8 +22,13 @@ A global; // CHECK-LABEL:define internal void @__cxx_global_var_init() // CHECK: call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* @_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] +// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] // CHECK-NEXT: ret void + +// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*) +// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE) +// CHECK-NEXT: ret void + } // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]] Index: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp === --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp @@ -86,11 +86,15 @@ llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, where there's a function - // with the right signature that we can just call. + // Special-case non-array C++ destructors, if they have the right signature + // that can be directly registered with __cxa_atexit. If __cxa_atexit is + // disabled via a flag, a different helper function is generated anyway. const CXXRecordDecl *record = nullptr; if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl())) { + (record = type->getAsCXXRecordDecl()) && + (!CGM.getCXXABI().HasThisReturn( + GlobalDecl(record->getDestructor(), Dtor_Complete)) || + !CGM.getCodeGenOpts().CXAAtExit)) { assert(!record->hasTrivialDestructor()); CXXDestructorDecl *dtor = record->getDestructor(); Index: cfe/trunk/test/CodeGenCXX/static-destructor.cpp === --- cfe/trunk/test/CodeGenCXX/static-destructor.cpp +++ cfe/trunk/test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to v
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff added a comment. Well, I forgot to squash my local commits before landing, so this is r269085 thru r269089 :( Repository: rL LLVM http://reviews.llvm.org/D19275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269099 - [WebAssembly] Reduce strictness of static destructor test
Author: dschuff Date: Tue May 10 13:35:31 2016 New Revision: 269099 URL: http://llvm.org/viewvc/llvm-project?rev=269099&view=rev Log: [WebAssembly] Reduce strictness of static destructor test It didn't work on non-asserts builds Modified: cfe/trunk/test/CodeGenCXX/static-destructor.cpp Modified: cfe/trunk/test/CodeGenCXX/static-destructor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-destructor.cpp?rev=269099&r1=269098&r2=269099&view=diff == --- cfe/trunk/test/CodeGenCXX/static-destructor.cpp (original) +++ cfe/trunk/test/CodeGenCXX/static-destructor.cpp Tue May 10 13:35:31 2016 @@ -17,20 +17,17 @@ Foo global; // X86 destructors have void return, and are registered directly with __cxa_atexit. // X86: define internal void @__cxx_global_var_init() -// X86-NEXT: entry: -// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) +// X86: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) // ARM destructors return this, but can be registered directly with __cxa_atexit // because the calling conventions tolerate the mismatch. // ARM: define internal void @__cxx_global_var_init() -// ARM-NEXT: entry: -// ARM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (%class.Foo* (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) +// ARM: call i32 @__cxa_atexit(void (i8*)* bitcast (%class.Foo* (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) // Wasm destructors return this, and use a wrapper function, which is registered // with __cxa_atexit. // WASM: define internal void @__cxx_global_var_init() -// WASM-NEXT: entry: -// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) +// WASM: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) // WASM: define internal void @__cxx_global_array_dtor(i8*) // WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff created this revision. dschuff added a subscriber: cfe-commits. Herald added subscribers: dschuff, jfb, aemerson. For a static object with a nontrivial destructor, clang generates an initializer function (__cxx_global_var_init) which registers that object's destructor using __cxa_atexit. However some ABIs (ARM, WebAssembly) use destructors that return 'this' instead of having void return (which does not match the signature of function pointers passed to __cxa_atexit). This results in undefined behavior when the destructors are called. All the calling conventions I know of on ARM can tolerate this, but WebAssembly requires the signatures of indirect calls to match the called function. This patch disables that direct registration of destructors for ABIs that have this-returning destructors. http://reviews.llvm.org/D19275 Files: lib/CodeGen/CGDeclCXX.cpp test/CodeGenCXX/runtimecc.cpp test/CodeGenCXX/static-destructor.cpp Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// Wasm destructors return this, and use a wrapper function, which is registered +// with __cxa_atexit. +// WASM: define internal void @__cxx_global_var_init() +// WASM-NEXT: entry: +// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) + +// WASM: define internal void @__cxx_global_array_dtor(i8*) +// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global) Index: test/CodeGenCXX/runtimecc.cpp === --- test/CodeGenCXX/runtimecc.cpp +++ test/CodeGenCXX/runtimecc.cpp @@ -22,8 +22,13 @@ A global; // CHECK-LABEL:define internal void @__cxx_global_var_init() // CHECK: call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* @_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] +// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] // CHECK-NEXT: ret void + +// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*) +// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE) +// CHECK-NEXT: ret void + } // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]] Index: lib/CodeGen/CGDeclCXX.cpp === --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -86,11 +86,15 @@ llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, where there's a function - // with the right signature that we can just call. + // Special-case non-array C++ destructors, if they have the right signature + // that can be directly registered with __cxa_atexit. If __cxa_atexit is + // disabled via a flag, a different helper function is generated anyway. const CXXRecordDecl *record = nullptr; if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl())) { + (record = type->getAsCXXRecordDecl()) && + (!CGM.getCXXABI().HasThisReturn( + GlobalDecl(record->getDestructor(), Dtor_Complete)) || + !CGM.getCodeGenOpts().CXAAtExit)) { assert(!record->hasTrivialDestructor()); CXXDestructorDecl *dtor = record->getDestructor(); Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo {
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff added a reviewer: sunfish. dschuff added a comment. Will want a reviewer who's involved with ARM too, still looking. http://reviews.llvm.org/D19275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff updated this revision to Diff 54260. dschuff marked 3 inline comments as done. dschuff added a comment. - Clean up condition, add ARM to test http://reviews.llvm.org/D19275 Files: lib/CodeGen/CGDeclCXX.cpp test/CodeGenCXX/runtimecc.cpp test/CodeGenCXX/static-destructor.cpp Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// Wasm destructors return this, and use a wrapper function, which is registered +// with __cxa_atexit. +// WASM: define internal void @__cxx_global_var_init() +// WASM-NEXT: entry: +// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) + +// WASM: define internal void @__cxx_global_array_dtor(i8*) +// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global) Index: test/CodeGenCXX/runtimecc.cpp === --- test/CodeGenCXX/runtimecc.cpp +++ test/CodeGenCXX/runtimecc.cpp @@ -22,8 +22,13 @@ A global; // CHECK-LABEL:define internal void @__cxx_global_var_init() // CHECK: call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* @_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] +// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] // CHECK-NEXT: ret void + +// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*) +// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE) +// CHECK-NEXT: ret void + } // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]] Index: lib/CodeGen/CGDeclCXX.cpp === --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -86,13 +86,18 @@ llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, where there's a function - // with the right signature that we can just call. - const CXXRecordDecl *record = nullptr; - if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl())) { -assert(!record->hasTrivialDestructor()); -CXXDestructorDecl *dtor = record->getDestructor(); + // Special-case non-array C++ destructors, if they have the right signature + // that can be directly registered with __cxa_atexit. If __cxa_atexit is + // disabled via a flag, a different helper function is generated anyway. + const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); + bool CanRegisterDestructor = Record && + !CGM.getCXXABI().HasThisReturn(GlobalDecl( + Record->getDestructor(), Dtor_Complete)); + + if (dtorKind == QualType::DK_cxx_destructor && Record && + (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) { +assert(!Record->hasTrivialDestructor()); +CXXDestructorDecl *dtor = Record->getDestructor(); function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete); argument = llvm::ConstantExpr::getBitCast( Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo glo
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff updated this revision to Diff 54264. dschuff added a comment. - Clarify condition, remove redundant check http://reviews.llvm.org/D19275 Files: lib/CodeGen/CGDeclCXX.cpp test/CodeGenCXX/runtimecc.cpp test/CodeGenCXX/static-destructor.cpp Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// Wasm destructors return this, and use a wrapper function, which is registered +// with __cxa_atexit. +// WASM: define internal void @__cxx_global_var_init() +// WASM-NEXT: entry: +// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) + +// WASM: define internal void @__cxx_global_array_dtor(i8*) +// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global) Index: test/CodeGenCXX/runtimecc.cpp === --- test/CodeGenCXX/runtimecc.cpp +++ test/CodeGenCXX/runtimecc.cpp @@ -22,8 +22,13 @@ A global; // CHECK-LABEL:define internal void @__cxx_global_var_init() // CHECK: call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* @_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] +// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] // CHECK-NEXT: ret void + +// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*) +// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE) +// CHECK-NEXT: ret void + } // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]] Index: lib/CodeGen/CGDeclCXX.cpp === --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -86,13 +86,20 @@ llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, where there's a function - // with the right signature that we can just call. - const CXXRecordDecl *record = nullptr; - if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl())) { -assert(!record->hasTrivialDestructor()); -CXXDestructorDecl *dtor = record->getDestructor(); + // Special-case non-array C++ destructors, if they have the right signature + // that can be directly registered with __cxa_atexit. + const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); + bool CanRegisterDestructor = Record && + !CGM.getCXXABI().HasThisReturn(GlobalDecl( + Record->getDestructor(), Dtor_Complete)); + // If __cxa_atexit is disabled via a flag, a different helper function is + // generated elsewhere which uses atexit instead, and it takes the destructor + // directly. + bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit; + if (Record && + (CanRegisterDestructor || UsingExternalHelper)) { +assert(!Record->hasTrivialDestructor()); +CXXDestructorDecl *dtor = Record->getDestructor(); function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete); argument = llvm::ConstantExpr::getBitCast( Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +clas
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff added inline comments. Comment at: lib/CodeGen/CGDeclCXX.cpp:92 @@ +91,3 @@ + // disabled via a flag, a different helper function is generated anyway. + const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); + bool CanRegisterDestructor = Record && jfb wrote: > Can you do that unconditionally? Or do you have to test for `dtorKind == > QualType::DK_cxx_destructor` first? It looks like the function already does a > `dyncast_or_null` so the previous code was doing a check it didn't need to. Yes, that's why I made it unconditional. And actually I just noticed that the switch statement above returns from the function if `dtorKind != DK_cxx_destructor` anyway, so I removed the check here too. Comment at: lib/CodeGen/CGDeclCXX.cpp:95 @@ +94,3 @@ + !CGM.getCXXABI().HasThisReturn(GlobalDecl( + Record->getDestructor(), Dtor_Complete)); + jfb wrote: > Comment on why you can't register dtor when has this return (ABI mismatch). Doesn't the new text in the comment right above on line 98 cover that? Comment at: lib/CodeGen/CGDeclCXX.cpp:97 @@ +96,3 @@ + + if (dtorKind == QualType::DK_cxx_destructor && Record && + (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) { jfb wrote: > Do you need to check `Record` here? Doesn't it also imply `dtorKind == > QualType::DK_cxx_destructor`? Yes, there can be a case where `Record` is nullptr and `CGM.getCodeGenOpts().CXAAtExit` is false. Comment at: lib/CodeGen/CGDeclCXX.cpp:98 @@ +97,3 @@ + if (dtorKind == QualType::DK_cxx_destructor && Record && + (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) { +assert(!Record->hasTrivialDestructor()); jfb wrote: > ` || !CGM.getCodeGenOpts().CXAAtExit` seems wrong here. Shouldn't the > condition be `CanRegisterDestructor && CGM.getCodeGenOpts().CXAAtExit`? I may > be misunderstanding... I split and expanded the comment and made a variable with a name. See if it makes more sense now. http://reviews.llvm.org/D19275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff updated this revision to Diff 54274. dschuff marked 2 inline comments as done. dschuff added a comment. - Clean up condition, add ARM to test - Clarify condition, remove redundant check - more cleanup http://reviews.llvm.org/D19275 Files: lib/CodeGen/CGDeclCXX.cpp test/CodeGenCXX/runtimecc.cpp test/CodeGenCXX/static-destructor.cpp Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their +// signatures do not match the type of its first argument. +// e.g. ARM and WebAssembly have destructors that return this instead of void. + + +class Foo { + public: + ~Foo() { + } +}; + +Foo global; + +// X86 destructors have void return, and are registered directly with __cxa_atexit. +// X86: define internal void @__cxx_global_var_init() +// X86-NEXT: entry: +// X86-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle) + +// Wasm destructors return this, and use a wrapper function, which is registered +// with __cxa_atexit. +// WASM: define internal void @__cxx_global_var_init() +// WASM-NEXT: entry: +// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) + +// WASM: define internal void @__cxx_global_array_dtor(i8*) +// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global) Index: test/CodeGenCXX/runtimecc.cpp === --- test/CodeGenCXX/runtimecc.cpp +++ test/CodeGenCXX/runtimecc.cpp @@ -22,8 +22,13 @@ A global; // CHECK-LABEL:define internal void @__cxx_global_var_init() // CHECK: call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE) -// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* @_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] +// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]] // CHECK-NEXT: ret void + +// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*) +// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE) +// CHECK-NEXT: ret void + } // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]] Index: lib/CodeGen/CGDeclCXX.cpp === --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -86,13 +86,20 @@ llvm::Constant *function; llvm::Constant *argument; - // Special-case non-array C++ destructors, where there's a function - // with the right signature that we can just call. - const CXXRecordDecl *record = nullptr; - if (dtorKind == QualType::DK_cxx_destructor && - (record = type->getAsCXXRecordDecl())) { -assert(!record->hasTrivialDestructor()); -CXXDestructorDecl *dtor = record->getDestructor(); + // Special-case non-array C++ destructors, if they have the right signature. + // Under some ABIs, destructors return this instead of void, and cannot be + // passed directly to __cxa_atexit. + const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); + bool CanRegisterDestructor = Record && + !CGM.getCXXABI().HasThisReturn(GlobalDecl( + Record->getDestructor(), Dtor_Complete)); + // If __cxa_atexit is disabled via a flag, a different helper function is + // generated elsewhere which uses atexit instead, and it takes the destructor + // directly. + bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit; + if (Record && (CanRegisterDestructor || UsingExternalHelper)) { +assert(!Record->hasTrivialDestructor()); +CXXDestructorDecl *dtor = Record->getDestructor(); function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete); argument = llvm::ConstantExpr::getBitCast( Index: test/CodeGenCXX/static-destructor.cpp === --- /dev/null +++ test/CodeGenCXX/static-destructor.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s +// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s +// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s + +// Test that destructors are not passed directly to __cxa_atexit when their
Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit
dschuff added a subscriber: rengolin. dschuff added a comment. any comments from @t.p.northover or perhaps @rengolin ? (This does have a potential new cost on ARM, as it requires one thunk (which is just a tail call) per static initializer on ARM and WebAssembly) http://reviews.llvm.org/D19275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r253259 - Derive nacltools::Linker from GnuTool to get response file support
Author: dschuff Date: Mon Nov 16 16:21:25 2015 New Revision: 253259 URL: http://llvm.org/viewvc/llvm-project?rev=253259&view=rev Log: Derive nacltools::Linker from GnuTool to get response file support It could be derived from gnutools::Linker directly but this way makes it consistent with all the other toolchains around it. Modified: cfe/trunk/lib/Driver/Tools.h Modified: cfe/trunk/lib/Driver/Tools.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=253259&r1=253258&r2=253259&view=diff == --- cfe/trunk/lib/Driver/Tools.h (original) +++ cfe/trunk/lib/Driver/Tools.h Mon Nov 16 16:21:25 2015 @@ -555,9 +555,9 @@ public: const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public Tool { +class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { public: - Linker(const ToolChain &TC) : Tool("NaCl::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : GnuTool("NaCl::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Change F16x8 extract lane to require constant integer. (PR #108116)
@@ -1888,18 +1888,15 @@ static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_splat(float __a) { return (v128_t)__builtin_wasm_splat_f16x8(__a); } -static __inline__ float __FP16_FN_ATTRS wasm_f16x8_extract_lane(v128_t __a, -int __i) -__REQUIRE_CONSTANT(__i) { dschuff wrote: out of curiosity, what does this REQUIRE_CONSTANT actually do? https://github.com/llvm/llvm-project/pull/108116 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Change F16x8 extract lane to require constant integer. (PR #108116)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/108116 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement f16x8 madd and nmadd instructions. (PR #95151)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/95151 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement f16x8.replace_lane instruction. (PR #99388)
@@ -702,6 +702,19 @@ defm "" : ReplaceLane; defm "" : ReplaceLane; defm "" : ReplaceLane; +// For now use an instrinsic for f16x8.replace_lane instead of ReplaceLane above +// since LL generated with half type arguments is not well supported and creates dschuff wrote: I think this just refers to LLVM IR (but I agree that using that term is more consistent with what I've seen elsewhere). https://github.com/llvm/llvm-project/pull/99388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement f16x8.replace_lane instruction. (PR #99388)
https://github.com/dschuff approved this pull request. otherwise LGTM https://github.com/llvm/llvm-project/pull/99388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)
dschuff wrote: I think "generic" is the default CPU so object files will have it enabled by default. You can still specify "mvp" as the CPU as before to avoid it. https://github.com/llvm/llvm-project/pull/80923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)
@@ -147,19 +147,25 @@ void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap &Features, bool WebAssemblyTargetInfo::initFeatureMap( llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector &FeaturesVec) const { - if (CPU == "bleeding-edge") { -Features["nontrapping-fptoint"] = true; + auto addGenericFeatures = [&]() { Features["sign-ext"] = true; +Features["mutable-globals"] = true; +Features["reference-types"] = true; +Features["multivalue"] = true; + }; + auto addBleedingEdgeFeatures = [&]() { +addGenericFeatures(); +Features["nontrapping-fptoint"] = true; dschuff wrote: MV and reftypes are required to use exnref, that's the thing that's on the critical path here. So yes, we definitely want to land these two without blocking on nontrapping-fptoint. Relatedly (to nontrapping-fptoint, but unrelatedly to this PR), I prototyped a Binaryen pass to lower away LLVM's use of nontrapping-fptoint* which is what would allow us to improve codegen. I think it works, but I discovered that some of emscripten's tests fail when we enable nontrapping fptoint, and I haven't yet looked at why that's the case (either a bug in emscripten's tests, or a bug in V8's implementation of nontrapping fptoint). We'd need to also fix that to unblock enabling this. * (This isn't exactly the same as a full lowering of nontrapping-fptoint as spec'ed, because it takes advantage of knowledge of the semantics of LLVM's fptosi intrinsics) https://github.com/llvm/llvm-project/pull/80923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)
https://github.com/dschuff edited https://github.com/llvm/llvm-project/pull/80923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)
https://github.com/dschuff approved this pull request. (also LGTM FTR) https://github.com/llvm/llvm-project/pull/80923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)
dschuff wrote: We are also seeing the Windows failure. Given that there appear to be 2 separate problems, this patch should probably be reverted rather than trying to fix-forward. https://github.com/llvm/llvm-project/pull/83774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)
@@ -842,8 +842,8 @@ class LLVM_LIBRARY_VISIBILITY NaClTargetInfo : public OSTargetInfo { } else if (Triple.getArch() == llvm::Triple::mipsel) { // Handled on mips' setDataLayout. } else { - assert(Triple.getArch() == llvm::Triple::le32); - this->resetDataLayout("e-p:32:32-i64:64"); + assert(Triple.getArch() == llvm::Triple::mipsel); dschuff wrote: this assert will never pass, since the previous `else if` condition is the same. https://github.com/llvm/llvm-project/pull/98497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Disable reference types in generic CPU (PR #90792)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/90792 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Add all remaining features to bleeding-edge (PR #90875)
dschuff wrote: This makes sense to me, I think it was the original intention (although I don't recall it being important to us or anyone else I'm aware of). https://github.com/llvm/llvm-project/pull/90875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Add all remaining features to bleeding-edge (PR #90875)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/90875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement prototype f32.load_f16 instruction. (PR #90906)
https://github.com/dschuff approved this pull request. Overall this looks good, and I think it makes sense to model this as short* for now. I think it will be interesting to see if that ends up causing issues. Out of curiosity does this work if you try `_fp16`? https://github.com/llvm/llvm-project/pull/90906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Make EH depend on multivalue and reference-types (PR #91299)
https://github.com/dschuff approved this pull request. LGTM. Are we currently running wasm-eh tests on the Chromium CI with node 16? If so, I guess this will have the same issue we had when we tried to turn it on by default. I don't think this needs to be a showstopper in the same way (since this isn't the default output of emscripten that we're talking about here, so I think it's fine to say "using EH requires node 17+"). But we may have to either disable some tests on chromium CI, or just make the test runner add a flag. https://github.com/llvm/llvm-project/pull/91299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement prototype f32.store_f16 instruction. (PR #91545)
@@ -192,6 +192,7 @@ TARGET_BUILTIN(__builtin_wasm_relaxed_dot_bf16x8_add_f32_f32x4, "V4fV8UsV8UsV4f" // Half-Precision (fp16) TARGET_BUILTIN(__builtin_wasm_loadf16_f32, "fh*", "nU", "half-precision") +TARGET_BUILTIN(__builtin_wasm_storef16_f32, "vfh*", "nU", "half-precision") dschuff wrote: The only documentation I know of for this is https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html Clang has https://clang.llvm.org/docs/AttributeReference.html but it's not helpful here. I guess a store shouldn't be pure, since it has an observable side effect, and in any case it doesn't return a value. https://github.com/llvm/llvm-project/pull/91545 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Define __WASM_EXCEPTIONS__ for -fwasm-exceptions (PR #92604)
https://github.com/dschuff approved this pull request. LGTM too, I don't see a huge risk of breaking external users using the old define at this point, and as noted we can fix the library usage without breaking anything either. https://github.com/llvm/llvm-project/pull/92604 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [libunwind][WebAssembly] Make libunwind compilable (PR #92192)
https://github.com/dschuff approved this pull request. These changes make sense from the wasm point of view, and it looks like you've address the comment, so LGTM https://github.com/llvm/llvm-project/pull/92192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [libunwind][WebAssembly] Make libunwind compilable (PR #92192)
https://github.com/dschuff edited https://github.com/llvm/llvm-project/pull/92192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement prototype f16x8.splat instruction. (PR #93228)
@@ -90,6 +90,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo { StringRef getABI() const override; bool setABI(const std::string &Name) override; + bool useFP16ConversionIntrinsics() const override { return false; } dschuff wrote: Is this used? https://github.com/llvm/llvm-project/pull/93228 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Re-enable reference types by default (PR #93261)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/93261 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement prototype f16x8.extract_lane instruction. (PR #93272)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/93272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Implement prototype f16x8.extract_lane instruction. (PR #93272)
https://github.com/dschuff closed https://github.com/llvm/llvm-project/pull/93272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d0d8d2d - [clang][Driver] use DWARF4 for wasm
Author: Derek Schuff Date: 2022-01-24T15:46:54-08:00 New Revision: d0d8d2d572cd1db54d0f6d90f8dd3825f9c7b36b URL: https://github.com/llvm/llvm-project/commit/d0d8d2d572cd1db54d0f6d90f8dd3825f9c7b36b DIFF: https://github.com/llvm/llvm-project/commit/d0d8d2d572cd1db54d0f6d90f8dd3825f9c7b36b.diff LOG: [clang][Driver] use DWARF4 for wasm Opt into the old default of DWARF4 for now. Differential Revision: https://reviews.llvm.org/D118082 Added: Modified: clang/lib/Driver/ToolChains/WebAssembly.h clang/test/Driver/debug-options.c Removed: diff --git a/clang/lib/Driver/ToolChains/WebAssembly.h b/clang/lib/Driver/ToolChains/WebAssembly.h index c84e596759466..b4c3082a089a0 100644 --- a/clang/lib/Driver/ToolChains/WebAssembly.h +++ b/clang/lib/Driver/ToolChains/WebAssembly.h @@ -51,6 +51,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly final : public ToolChain { bool hasBlocksRuntime() const override; bool SupportsProfiling() const override; bool HasNativeLLVMSupport() const override; + unsigned GetDefaultDwarfVersion() const override { return 4; } void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 22e05140f2618..e4a49269a8c70 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -132,6 +132,13 @@ // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff -gcolumn-info \ // RUN: 2>&1 | FileCheck -check-prefix=CI %s +// WebAssembly. +// WebAssembly should default to DWARF4. +// RUN: %clang -### -c -g %s -target wasm32 2>&1 \ +// RUN: | FileCheck -check-prefix=G_DWARF4 %s +// RUN: %clang -### -c -g %s -target wasm64 2>&1 \ +// RUN: | FileCheck -check-prefix=G_DWARF4 %s + // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \ // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s // ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Change half-precision feature name to fp16. (PR #105434)
dschuff wrote: I'm fine with calling this feature fp16 (I like it better than half-precision anyway) but I also wanted to point out that consistency with the spec is probably more important in the long term than consistency with V8, because the V8 flags eventually disappear (once V8 enabled support for a feature by default), whereas the flags for the tools will probably persist for the long term. Of course the spec names will also go away once the feature is merged into the spec (until we have profiles, I guess) But just something to consider. For that matter, maybe we should make the feature names a tool-convention to line up with wasm-tools. I think feature naming is already kind of a mess, maybe we can avoid making it worse. https://github.com/llvm/llvm-project/pull/105434 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Change half-precision feature name to fp16. (PR #105434)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/105434 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)
@@ -177,8 +177,9 @@ class MergeInputChunk : public InputChunk { inputSectionOffset = seg.SectionOffset; } - MergeInputChunk(const WasmSection &s, ObjFile *f) dschuff wrote: the lld changes look reasonable but /cc @sbc100 just to make sure https://github.com/llvm/llvm-project/pull/111332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)
@@ -584,7 +584,7 @@ void llvm_reset_counters(void) { } } -#if !defined(_WIN32) +#if !defined(_WIN32) && !defined(__wasi__) dschuff wrote: This probably makes sense to make `__wasm__` instead of just `__wasi__` since Emscripten also lacks fork. https://github.com/llvm/llvm-project/pull/111332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [WebAssembly] Enable nontrapping-fptoint and bulk-memory by default. (PR #112049)
@@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %s -o %t.o +; RUN: llc -filetype=obj -mattr=-bulk-memory %s -o %t.o dschuff wrote: Hm, interesting, so we are using passive segments anytime bulk memory is enabled. That makes sense since this was all meant for threads, but is this actually an improvement in the non-threads case? i.e. maybe we don't want the extra explicit initialization code if we can help it? edit: i just checked this out but I'll leave it here FTR: it looks like after linking we actually don't use passive segments unless threads is also enabled. so this seems like not a problem. https://github.com/llvm/llvm-project/pull/112049 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [WebAssembly] Enable nontrapping-fptoint and bulk-memory by default. (PR #112049)
https://github.com/dschuff approved this pull request. I think Emscripten is ready for this now, thanks for working on this! https://github.com/llvm/llvm-project/pull/112049 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Support the new "Lime1" CPU (PR #112035)
dschuff wrote: LGTM too; I just noticed that nowhere does the tool-conventions document mention that "lime" is short for "linear memory" and that the intention is that this is the subset of features useful to toolchains or runtimes that focus on linear memory. Maybe we should add that. https://github.com/llvm/llvm-project/pull/112035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Add `-i128:128` to the `datalayout` string. (PR #119204)
@@ -524,9 +524,7 @@ define i64 @utest_f64i64(double %x) { ; CHECK-NEXT:local.get 0 ; CHECK-NEXT:call __fixunsdfti ; CHECK-NEXT:local.get 1 -; CHECK-NEXT:i32.const 8 -; CHECK-NEXT:i32.add -; CHECK-NEXT:i64.load 0 +; CHECK-NEXT:i64.load 8 dschuff wrote: I'm curious why these layout changes lead to extra folding here, since the alignment of i128 previously matched the alignment for i64 and these are i64 loads... actually I also don't know why the alignment should affect folding anyway. Are we missing a folding opportunity somewhere else too? https://github.com/llvm/llvm-project/pull/119204 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WebAssembly] Add `-i128:128` to the `datalayout` string. (PR #119204)
https://github.com/dschuff approved this pull request. LGTM for updating the LLVM datalayout string to match clang's, I don't think this should affect clang's ABI at all. https://github.com/llvm/llvm-project/pull/119204 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Add error checking for -wasm-use-legacy-ch (PR #122526)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/122526 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits