aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Targets/WebAssembly.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-30[WebAssembly] Add gc target feature to addBleedingEdgeFeatures (#151294)Hood Chatham1-11/+12
Also alphebetize feature list, add `-mgc` and `-mno-gc` flags, and add some missing feature tests. Reland of #151107. https://github.com/llvm/llvm-project/pull/150201#discussion_r2237982637
2025-07-29Revert "[WebAssembly] Add gc target feature to addBleedingEdgeFeatures" ↵ronlieb1-12/+11
(#151268) Reverts llvm/llvm-project#151107
2025-07-29[WebAssembly] Add gc target feature to addBleedingEdgeFeatures (#151107)Hood Chatham1-11/+12
See suggestion here: https://github.com/llvm/llvm-project/pull/150201#discussion_r2237982637
2025-07-25[WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (#150201)Hood Chatham1-0/+16
Tests if the runtime type of the function pointer matches the static type. If this returns false, calling the function pointer will trap. Uses `@llvm.wasm.ref.test.func` added in #147486. Also adds a "gc" wasm feature to gate the use of the ref.test instruction.
2025-07-09[Clang] Respect MS layout attributes during CUDA/HIP device compilation ↵Yaxun (Sam) Liu1-3/+3
(#146620) This patch fixes an issue where Microsoft-specific layout attributes, such as __declspec(empty_bases), were ignored during CUDA/HIP device compilation on a Windows host. This caused a critical memory layout mismatch between host and device objects, breaking libraries that rely on these attributes for ABI compatibility. The fix introduces a centralized hasMicrosoftRecordLayout() check within the TargetInfo class. This check is aware of the auxiliary (host) target and is set during TargetInfo::adjust if the host uses a Microsoft ABI. The empty_bases, layout_version, and msvc::no_unique_address attributes now use this centralized flag, ensuring device code respects them and maintains layout consistency with the host. Fixes: https://github.com/llvm/llvm-project/issues/146047
2025-02-04[StrTable] Switch Clang builtins to use string tablesChandler Carruth1-11/+18
This both reapplies #118734, the initial attempt at this, and updates it significantly. First, it uses the newly added `StringTable` abstraction for string tables, and simplifies the construction to build the string table and info arrays separately. This should reduce any `constexpr` compile time memory or CPU cost of the original PR while significantly improving the APIs throughout. It also restructures the builtins to support sharding across several independent tables. This accomplishes two improvements from the original PR: 1) It improves the APIs used significantly. 2) When builtins are defined from different sources (like SVE vs MVE in AArch64), this allows each of them to build their own string table independently rather than having to merge the string tables and info structures. 3) It allows each shard to factor out a common prefix, often cutting the size of the strings needed for the builtins by a factor two. The second point is important both to allow different mechanisms of construction (for example a `.def` file and a tablegen'ed `.inc` file, or different tablegen'ed `.inc files), it also simply reduces the sizes of these tables which is valuable given how large they are in some cases. The third builds on that size reduction. Initially, we use this new sharding rather than merging tables in AArch64, LoongArch, RISCV, and X86. Mostly this helps ensure the system works, as without further changes these still push scaling limits. Subsequent commits will more deeply leverage the new structure, including using the prefix capabilities which cannot be easily factored out here and requires deep changes to the targets.
2024-12-13Revert "Switch builtin strings to use string tables" (#119638)Chandler Carruth1-15/+11
Reverts llvm/llvm-project#118734 There are currently some specific versions of MSVC that are miscompiling this code (we think). We don't know why as all the other build bots and at least some folks' local Windows builds work fine. This is a candidate revert to help the relevant folks catch their builders up and have time to debug the issue. However, the expectation is to roll forward at some point with a workaround if at all possible.
2024-12-10[clang] wasm cpu name is supposed to be lime1, not lime (#119262)Jacob Lifshay1-1/+1
Originally added in #112035 cc @sunfishcode
2024-12-08Switch builtin strings to use string tables (#118734)Chandler Carruth1-11/+15
The Clang binary (and any binary linking Clang as a library), when built using PIE, ends up with a pretty shocking number of dynamic relocations to apply to the executable image: roughly 400k. Each of these takes up binary space in the executable, and perhaps most interestingly takes start-up time to apply the relocations. The largest pattern I identified were the strings used to describe target builtins. The addresses of these string literals were stored into huge arrays, each one requiring a dynamic relocation. The way to avoid this is to design the target builtins to use a single large table of strings and offsets within the table for the individual strings. This switches the builtin management to such a scheme. This saves over 100k dynamic relocations by my measurement, an over 25% reduction. Just looking at byte size improvements, using the `bloaty` tool to compare a newly built `clang` binary to an old one: ``` FILE SIZE VM SIZE -------------- -------------- +1.4% +653Ki +1.4% +653Ki .rodata +0.0% +960 +0.0% +960 .text +0.0% +197 +0.0% +197 .dynstr +0.0% +184 +0.0% +184 .eh_frame +0.0% +96 +0.0% +96 .dynsym +0.0% +40 +0.0% +40 .eh_frame_hdr +114% +32 [ = ] 0 [Unmapped] +0.0% +20 +0.0% +20 .gnu.hash +0.0% +8 +0.0% +8 .gnu.version +0.9% +7 +0.9% +7 [LOAD #2 [R]] [ = ] 0 -75.4% -3.00Ki .relro_padding -16.1% -802Ki -16.1% -802Ki .data.rel.ro -27.3% -2.52Mi -27.3% -2.52Mi .rela.dyn -1.6% -2.66Mi -1.6% -2.66Mi TOTAL ``` We get a 16% reduction in the `.data.rel.ro` section, and nearly 30% reduction in `.rela.dyn` where those reloctaions are stored. This is also visible in my benchmarking of binary start-up overhead at least: ``` Benchmark 1: ./old_clang --version Time (mean ± σ): 17.6 ms ± 1.5 ms [User: 4.1 ms, System: 13.3 ms] Range (min … max): 14.2 ms … 22.8 ms 162 runs Benchmark 2: ./new_clang --version Time (mean ± σ): 15.5 ms ± 1.4 ms [User: 3.6 ms, System: 11.8 ms] Range (min … max): 12.4 ms … 20.3 ms 216 runs Summary './new_clang --version' ran 1.13 ± 0.14 times faster than './old_clang --version' ``` We get about 2ms faster `--version` runs. While there is a lot of noise in binary execution time, this delta is pretty consistent, and represents over 10% improvement. This is particularly interesting to me because for very short source files, repeatedly starting the `clang` binary is actually the dominant cost. For example, `configure` scripts running against the `clang` compiler are slow in large part because of binary start up time, not the time to process the actual inputs to the compiler. ---- This PR implements the string tables using `constexpr` code and the existing macro system. I understand that the builtins are moving towards a TableGen model, and if complete that would provide more options for modeling this. Unfortunately, that migration isn't complete, and even the parts that are migrated still rely on the ability to break out of the TableGen model and directly expand an X-macro style `BUILTIN(...)` textually. I looked at trying to complete the move to TableGen, but it would both require the difficult migration of the remaining targets, and solving some tricky problems with how to move away from any macro-based expansion. I was also able to find a reasonably clean and effective way of doing this with the existing macros and some `constexpr` code that I think is clean enough to be a pretty good intermediate state, and maybe give a good target for the eventual TableGen solution. I was also able to factor the macros into set of consistent patterns that avoids a significant regression in overall boilerplate.
2024-12-03[WebAssembly] Support the new "Lime1" CPU (#112035)Dan Gohman1-1/+14
This adds WebAssembly support for the new [Lime1 CPU]. First, this defines some new target features. These are subsets of existing features that reflect implementation concerns: - "call-indirect-overlong" - implied by "reference-types"; just the overlong encoding for the `call_indirect` immediate, and not the actual reference types. - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and `memory.fill`, and not the other instructions in the bulk-memory proposal. Next, this defines a new target CPU, "lime1", which enables mutable-globals, bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const, and call-indirect-overlong. Unlike the default "generic" CPU, "lime1" is meant to be frozen, and followed up by "lime2" and so on when new features are desired. [Lime1 CPU]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1 --------- Co-authored-by: Heejin Ahn <aheejin@gmail.com>
2024-12-02[WebAssembly] Define call-indirect-overlong and bulk-memory-opt features ↵Dan Gohman1-0/+34
(#117087) This defines some new target features. These are subsets of existing features that reflect implementation concerns: - "call-indirect-overlong" - implied by "reference-types"; just the overlong encoding for the `call_indirect` immediate, and not the actual reference types. - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and `memory.fill`, and not the other instructions in the bulk-memory proposal. This is split out from https://github.com/llvm/llvm-project/pull/112035. --------- Co-authored-by: Heejin Ahn <aheejin@gmail.com>
2024-10-25[WebAssembly] Enable nontrapping-fptoint and bulk-memory by default. (#112049)Dan Gohman1-2/+2
We were prepared to enable these features [back in February], but they got pulled for what appear to be unrelated reasons. So let's have another try at enabling them! Another motivation here is that it'd be convenient for the [Lime1 proposal] if "lime1" is close to a subset of "generic" (missing only for extended-const). [back in February]: https://github.com/WebAssembly/tool-conventions/issues/158#issuecomment-1931119512 [Lime1 proposal]: https://github.com/llvm/llvm-project/pull/112035
2024-10-23[WebAssembly] Implement the wide-arithmetic proposal (#111598)Alex Crichton1-0/+12
This commit implements the [wide-arithmetic] proposal which has recently reached phase 2 in the WebAssembly proposals process. The goal here is to implement support in LLVM for emitting these instructions which are gated behind a new feature flag by default. A new `wide-arithmetic` feature flag is introduced which gates these four new instructions from being emitted. Emission of each instruction itself is relatively simple given LLVM's preexisting lowering rules and infrastructure. The main gotcha is that due to the multi-result nature of all of these instructions it needed the lowerings to be implemented in C++ rather than in TableGen. [wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic
2024-08-22[WebAssembly] Change half-precision feature name to fp16. (#105434)Brendan Dahl1-8/+8
This better aligns with how the feature is being referred to and what runtimes (V8) are calling it.
2024-06-20[WebAssembly] Re-enable reference types by default (#93261)Heejin Ahn1-1/+1
Now that we are about to upgrade emsdk's default node to v18.20.3 (https://github.com/emscripten-core/emsdk/pull/1387), we can re-enable reference-types by default again. This effectively reverts #90792.
2024-05-03[WebAssembly] Add all remaining features to bleeding-edge (#90875)Heejin Ahn1-1/+3
I'm not entirely sure what the criteria for 'bleeding-edge' used to be, but at this point it seems to be the set of all added features in LLVM. This adds remaining features to bleeding-edge config.
2024-05-02[WebAssembly] Sort target features (NFC) (#90777)Heejin Ahn1-83/+83
2024-05-01[WebAssembly] Disable reference types in generic CPU (#90792)Heejin Ahn1-1/+1
#80923 newly enabled multivalue and reference-types in the generic CPU. But enabling reference-types ended up breaking up Wasm's Chromium CI (https://chromium-review.googlesource.com/c/emscripten-releases/+/5500231) because the way the table index is encoded is different from MVP (u32) vs. reference-types (LEB), which caused different encodings for `call_indirect`. And Chromium CI's and Emscripten's minimum required node version is v16, which does not yet support reference-types, which does not recognize that table index encoding. reference-types is first supported in node v17.2. We knew the current minimum required node for Emscripten (v16) did not support reference-types, but thought it was fine because unless you explicitly use `__funcref` or `__externref` things would be fine, and if you want to use them explicitly, you would have a newer node. But it turned out it also affected the encoding of `call_indirect`. While we are discussing the potential solutions, I will disable reference-types to unblock the rolls.
2024-04-30[WebAssembly] Add preprocessor define for half-precision (#90528)Heejin Ahn1-0/+2
This adds the preprocessor define for the half-precision feature and also adds preprocessor tests.
2024-04-29[WebAssembly] Enable multivalue and reference-types in generic CPU config ↵Heejin Ahn1-7/+13
(#80923) This enables multivalue and reference-types in `-mcpu=generic` configuration. These proposals have been standardized and supported in all major browsers for several years at this point: https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md
2024-04-26[WebAssembly] Add half-precision feature (#90248)Brendan Dahl1-0/+11
This currently only defines a constant, but in the future will be used to gate builtins for experimenting and prototyping half-precision proposal (https://github.com/WebAssembly/half-precision).
2024-04-24[WebAssembly] Tidy up wasm-target-features.c (#89778)Heejin Ahn1-6/+6
This tidies up `wasm-target-features.c` cosmetically: - Sorts the feature tests alphabetically - Adds a space after colons
2023-08-21[WebAssembly] Add multiple memories featureAshley Nelson1-0/+12
Adding to allow users to get this flag into the target features section for future use cases. Reviewed By: tlively, aheejin Differential Revision: https://reviews.llvm.org/D158409
2023-06-10[clang][WebAssembly] Implement support for table types and builtinsPaulo Matos1-0/+1
This commit implements support for WebAssembly table types and respective builtins. Table tables are WebAssembly objects to store reference types. They have a large amount of semantic restrictions including, but not limited to, only being allowed to be declared at the top-level as static arrays of zero-length. Not being arguments or result of functions, not being stored ot memory, etc. This commit introduces the __attribute__((wasm_table)) to attach to arrays of WebAssembly reference types. And the following builtins to manage tables: * ref __builtin_wasm_table_get(table, idx) * void __builtin_wasm_table_set(table, idx, ref) * uint __builtin_wasm_table_size(table) * uint __builtin_wasm_table_grow(table, ref, uint) * void __builtin_wasm_table_fill(table, idx, ref, uint) * void __builtin_wasm_table_copy(table, table, uint, uint, uint) This commit also enables reference-types feature at bleeding-edge. This is joint work with Alex Bradbury (@asb). Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D139010
2023-01-23[clang] Optimize clang::Builtin::Info densityserge-sans-paille1-3/+3
Reorganize clang::Builtin::Info to have them naturally align on 4 bytes boundaries. Instead of storing builtin headers as a straight char pointer, enumerate them and store the enum. It allows to use a small enum instead of a pointer to reference them. On a 64 bit machine, this brings sizeof(clang::Builtin::Info) from 56 down to 48 bytes. On a release build on my Linux 64 bit machine, it shrinks the size of libclang-cpp.so by 193kB. The impact on performance is negligible in terms of instruction count, but the wall time seems better, see https://llvm-compile-time-tracker.com/compare.php?from=b3d8639f3536a4876b511aca9fb7948ff9266cee&to=a89b56423f98b550260a58c41e64aff9e56b76be&stat=task-clock Differential Revision: https://reviews.llvm.org/D142024
2023-01-09Move from llvm::makeArrayRef to ArrayRef deduction guides - clang/ partserge-sans-paille1-2/+2
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141139
2023-01-05[Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macrosBrad Smith1-0/+5
Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros Reviewed By: kparzysz, aheejin, MaskRay Differential Revision: https://reviews.llvm.org/D140757
2022-12-27[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille1-1/+1
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This a recommit of e953ae5bbc313fd0cc980ce021d487e5b5199ea4 and the subsequent fixes caa713559bd38f337d7d35de35686775e8fb5175 and 06b90e2e9c991e211fecc97948e533320a825470. The above patchset caused some version of GCC to take eons to compile clang/lib/Basic/Targets/AArch64.cpp, as spotted in aa171833ab0017d9732e82b8682c9848ab25ff9e. The fix is to make BuiltinInfo tables a compilation unit static variable, instead of a private static variable. Differential Revision: https://reviews.llvm.org/D139881
2022-10-25[WebAssembly] Update supported features in the generic CPU configurationDan Gohman1-0/+3
Enable sign-ext and mutable-globals in -mcpu=generic. This makes these features enabled by default. These features are all [finished proposals], and all major wasm engines support them. [finished proposals]: https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md Differential Revision: https://reviews.llvm.org/D125728
2022-08-08[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song1-3/+3
With C++17 there is no Clang pedantic warning or MSVC C5051. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D131346
2022-03-07[WebAssembly] Add new target feature in support of 'extended-const' proposalSam Clegg1-0/+11
We don't yet do anything when this feature is enabled, this change just lays the ground work by accepting that there is such a feature. See https://github.com/WebAssembly/extended-const Differential Revision: https://reviews.llvm.org/D121151
2022-03-04[WebAssembly] Check bulk-memory when adjusting lang optsThomas Lively1-3/+4
We previously had logic to disable pthreads, set the ThreadModel to Single, and disable thread-safe statics when the atomics target features is disabled, since that means that the resulting program will not be used in a threaded context. Similarly check for the presence of the bulk-memory feature, since that is also necessary to produce multithreaded programs. Differential Revision: https://reviews.llvm.org/D121014
2022-02-10[clang][WebAssemmbly] Call TargetInfo::adjust in derived method.Sam Clegg1-0/+1
The superclass method handles a bunch of useful things. For example it applies flags such as `-fnew-alignment` which doesn't work without this patch. Differential Revision: https://reviews.llvm.org/D118573
2022-01-31[clang][WebAssembly] Imply -fno-threadsafe-static when threading is disabledSam Clegg1-0/+1
When we don't enable atomics we completely disabled threading in which case there is no point in generating thread safe code for static initialization. This should always be safe because, in WebAssembly, it is not possible to link object compiled without the atomics feature into a mutli-threaded program. See https://github.com/emscripten-core/emscripten/pull/16152 Differential Revision: https://reviews.llvm.org/D118571
2021-10-10[Basic] Use llvm::is_contained (NFC)Kazu Hirata1-1/+1
2021-09-22[WebAssembly] Add relaxed-simd featureZhi An Ng1-0/+19
This currently only defines a constant, but it the future will be used to gate builtins for experimenting and prototyping relaxed-simd proposal (https://github.com/WebAssembly/relaxed-simd/). Differential Revision: https://reviews.llvm.org/D110111
2021-06-29[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to ↵Melanie Blower1-1/+2
allow diagnostics on target-unsupported options Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104729
2021-06-28Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass ↵Melanie Blower1-2/+1
DiagnosticsEngine to allow diagnostics on target-unsupported options" This reverts commit 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0. More buildbot failures
2021-06-28[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to ↵Melanie Blower1-1/+2
allow diagnostics on target-unsupported options Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104729
2021-06-28Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass ↵Melanie Blower1-2/+1
DiagnosticsEngine to allow diagnostics on target-unsupported options" This reverts commit 2c02b0c3f45414ac6c64583e006a26113c028304. buildbot fails
2021-06-28[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to ↵Melanie Blower1-1/+2
allow diagnostics on target-unsupported options Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104729
2021-06-10Revert "Implementation of global.get/set for reftypes in LLVM IR"David Spickett1-2/+0
This reverts commit 31859f896cf90d64904134ce7b31230f374c3fcc. Causing SVE and RISCV-V test failures on bots.
2021-06-10Implementation of global.get/set for reftypes in LLVM IRPaulo Matos1-0/+2
This change implements new DAG notes GLOBAL_GET/GLOBAL_SET, and lowering methods for load and stores of reference types from IR globals. Once the lowering creates the new nodes, tablegen pattern matches those and converts them to Wasm global.get/set. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D95425
2021-03-18[WebAssembly] Remove unimplemented-simd target featureThomas Lively1-19/+0
Now that the WebAssembly SIMD specification is finalized and engines are generally up-to-date, there is no need for a separate target feature for gating SIMD instructions that engines have not implemented. With this change, v128.const is now enabled by default with the simd128 target feature. Differential Revision: https://reviews.llvm.org/D98457
2021-02-04[WebAssembly] Use single-threaded mode when -matomics isn't enabled.Dan Gohman1-0/+9
When the -matomics feature is not enabled, disable POSIXThreads mode and set the thread model to Single, so that we don't predefine macros like `__STDCPP_THREADS__`. Differential Revision: https://reviews.llvm.org/D96091
2020-08-12[WebAssembly] Don't depend on the flags set by handleTargetFeatures in ↵Craig Topper1-29/+31
initFeatureMap. Properly set "simd128" in the feature map when "unimplemented-simd128" is requested. initFeatureMap is used to create the feature vector used by handleTargetFeatures. There are later calls to initFeatureMap in CodeGen that were using these flags to recreate the map. But the original feature vector should be passed to those calls. So that should be enough to rebuild the map. The only issue seemed to be that simd128 was not enabled in the map by the first call to initFeatureMap. Using the SIMDLevel set by handleTargetFeatures in the later calls allowed simd128 to be set in the later versions of the map. To fix this I've added an override of setFeatureEnabled that will update the map the first time with the correct simd dependency. Differential Revision: https://reviews.llvm.org/D85806
2020-02-04[WebAssembly] Add experimental multivalue calling ABIThomas Lively1-0/+10
Summary: For now, this ABI simply expands all possible aggregate arguments and returns all possible aggregates directly. This ABI will change rapidly as we prototype and benchmark a new ABI that takes advantage of multivalue return and possibly other changes from the MVP ABI. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72972
2020-01-24[WebAssembly] Update bleeding-edge CPU featuresHeejin Ahn1-0/+2
Summary: This adds bulk memory and tail call to "bleeding-edge" CPU, since their implementation in LLVM/clang seems mostly complete. Reviewers: tlively Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73322
2020-01-24[WebAssembly] Add reference types target featureHeejin Ahn1-0/+13
Summary: This adds the reference types target feature. This does not enable any more functionality in LLVM/clang for now, but this is necessary to embed the info in the target features section, which is used by Binaryen and Emscripten. It turned out that after D69832 `-fwasm-exceptions` crashed because we didn't have the reference types target feature. Reviewers: tlively Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D73320
2019-05-23[WebAssembly] Add multivalue and tail-call target featuresThomas Lively1-0/+26
Summary: These features will both be implemented soon, so I thought I would save time by adding the boilerplate for both of them at the same time. Reviewers: aheejin Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62047 llvm-svn: 361516