summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Allow the creation of human-friendly ASTDumper to arbitrary output streamAlexander Kornienko2018-04-062-6/+9
| | | | | | | | | | | | | | | | | | | | | Summary: `ASTPrinter` allows setting the ouput to any O-Stream, but that printer creates source-code-like syntax (and is also marked with a `FIXME`). The nice, colourful, mostly human-readable `ASTDumper` only works on the standard output, which is not feasible in case a user wants to see the AST of a file through a code navigation/comprehension tool. This small addition of an overload solves generating a nice colourful AST block for the users of a tool I'm working on, [[ http://github.com/Ericsson/CodeCompass | CodeCompass ]], as opposed to having to duplicate the behaviour of definitions that only exist in the anonymous namespace of implementation TUs related to this module. Reviewers: alexfh, klimek, rsmith Reviewed By: alexfh Subscribers: rnkovacs, dkrupp, gsd, xazax.hun, cfe-commits, #clang Tags: #clang Patch by Whisperity! Differential Revision: https://reviews.llvm.org/D45096 llvm-svn: 329391
* [XRay][clang] Add a flag to enable/disable linking XRay deps explicitlyDean Michael Berris2018-04-061-0/+4
| | | | | | | | | | | | | | | | | | | | Summary: This change introduces `-fxray-link-deps` and `-fnoxray-link-deps`. The `-fnoxray-link-deps` allows for directly controlling which specific XRay runtime to link. The default is for clang to link the XRay runtime that is shipped with the compiler (if there are any), but users may want to explicitly add the XRay dependencies from other locations or other means. Reviewers: eizan, echristo, chandlerc Reviewed By: eizan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45354 llvm-svn: 329376
* [XRay][clang] Consolidate runtime and link-time flag processing (NFC)Dean Michael Berris2018-04-065-81/+37
| | | | | | | | | | | | | | | | | | | Summary: This change fixes http://llvm.org/PR36985 to define a single place in CommonArgs.{h,cpp} where XRay runtime flags and link-time dependencies are processed for all toolchains that support XRay instrumentation. This is a refactoring of the same functionality spread across multiple toolchain definitions. Reviewers: echristo, devnexen, eizan Reviewed By: eizan Subscribers: emaste, cfe-commits Differential Revision: https://reviews.llvm.org/D45243 llvm-svn: 329372
* CMake option to allow enabling experimental new pass manager by defaultPetr Hosek2018-04-062-2/+2
| | | | | | | | | This CMake flag allows setting the default value for the -f[no]-experimental-new-pass-manager flag. Differential Revision: https://reviews.llvm.org/D44330 llvm-svn: 329366
* [Sema] Revert r329346 because of memory sanitizer failures.Eugene Zelenko2018-04-054-66/+44
| | | | llvm-svn: 329357
* [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-04-054-44/+66
| | | | | | other minor fixes (NFC). llvm-svn: 329346
* PR36992: do not store beyond the dsize of a class object unless we knowRichard Smith2018-04-0515-115/+226
| | | | | | | | | | | | | | the tail padding is not reused. We track on the AggValueSlot (and through a couple of other initialization actions) whether we're dealing with an object that might share its tail padding with some other object, so that we can avoid emitting stores into the tail padding if that's the case. We still widen stores into tail padding when we can do so. Differential Revision: https://reviews.llvm.org/D45306 llvm-svn: 329342
* DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standardRichard Smith2018-04-055-47/+190
| | | | | | | | | | | | | | | | | layout" rules. The new rules say that a standard-layout struct has its first non-static data member and all base classes at offset 0, and consider a class to not be standard-layout if that would result in multiple subobjects of a single type having the same address. We track "is C++11 standard-layout class" separately from "is standard-layout class" so that the ABIs that need this information can still use it. Differential Revision: https://reviews.llvm.org/D45176 llvm-svn: 329332
* Remove the temporary availability checking workaround forAlex Lorenz2018-04-051-22/+0
| | | | | | | | the nested declarations in @interface. rdar://28825862 llvm-svn: 329324
* [ASTImporter] Fix for importing unnamed structsAleksei Sidorin2018-04-052-3/+6
| | | | | | | | Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D30876 llvm-svn: 329301
* Disable -fmerge-all-constants as default.Manoj Gupta2018-04-053-7/+4
| | | | | | | | | | | | | | | | | | | Summary: "-fmerge-all-constants" is a non-conforming optimization and should not be the default. It is also causing miscompiles when building Linux Kernel (https://lkml.org/lkml/2018/3/20/872). Fixes PR18538. Reviewers: rjmccall, rsmith, chandlerc Reviewed By: rsmith, chandlerc Subscribers: srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D45289 llvm-svn: 329300
* [clang-format] Support lightweight Objective-C genericsBen Hamilton2018-04-051-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, `clang-format` didn't understand lightweight Objective-C generics, which have the form: ``` @interface Foo <KeyType, ValueTypeWithConstraint : Foo, AnotherValueTypeWithGenericConstraint: Bar<Baz>, ... > ... ``` The lightweight generic specifier list appears before the base class, if present, but because it starts with < like the protocol specifier list, `UnwrappedLineParser` was getting confused and failed to parse interfaces with both generics and protocol lists: ``` @interface Foo <KeyType> : NSObject <NSCopying> ``` Since the parsed line would be incomplete, the format result would be very confused (e.g., https://bugs.llvm.org/show_bug.cgi?id=24381). This fixes the issue by explicitly parsing the ObjC lightweight generic conformance list, so the line is fully parsed. Fixes: https://bugs.llvm.org/show_bug.cgi?id=24381 Test Plan: New tests added. Ran tests with: % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: djasper, jolesiak Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45185 llvm-svn: 329298
* [clang-format] Ensure ObjC selectors with 0 args are annotated correctlyBen Hamilton2018-04-051-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would incorrectly annotate 0-argument Objective-C selector names as TT_TrailingAnnotation: ``` % echo "-(void)foo;" > /tmp/test.m % ./bin/clang-format -debug /tmp/test.m Language: Objective-C ---- Line(0, FSC=0): minus[T=68, OC=0] l_paren[T=68, OC=1] void[T=68, OC=2] r_paren[T=68, OC=6] identifier[T=68, OC=7] semi[T=68, OC=10] Line(0, FSC=0): eof[T=68, OC=0] Run 0... AnnotatedTokens(L=0): M=0 C=0 T=ObjCMethodSpecifier S=1 B=0 BK=0 P=0 Name=minus L=1 PPK=2 FakeLParens= FakeRParens=0 Text='-' M=0 C=1 T=Unknown S=1 B=0 BK=0 P=33 Name=l_paren L=3 PPK=2 FakeLParens= FakeRParens=0 Text='(' M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=void L=7 PPK=2 FakeLParens= FakeRParens=0 Text='void' M=0 C=0 T=CastRParen S=0 B=0 BK=0 P=43 Name=r_paren L=8 PPK=2 FakeLParens= FakeRParens=0 Text=')' M=0 C=1 T=TrailingAnnotation S=0 B=0 BK=0 P=120 Name=identifier L=11 PPK=2 FakeLParens= FakeRParens=0 Text='foo' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=semi L=12 PPK=2 FakeLParens= FakeRParens=0 Text=';' ``` This caused us to incorrectly indent 0-argument wrapped selectors when Style.IndentWrappedFunctionNames was false, as we thought the 0-argument ObjC selector name was actually a trailing annotation (which is always indented). This diff fixes the issue and adds tests. Test Plan: New tests added. Confirmed tests failed before diff. After diff, tests passed. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: djasper, jolesiak Reviewed By: djasper, jolesiak Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44996 llvm-svn: 329297
* [ObjC] Make C++ triviality type traits available to non-trivial CAkira Hatanaka2018-04-051-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | structs. r326307 and r327870 made changes that allowed using non-trivial C structs with fields qualified with __strong or __weak. This commit makes the following C++ triviality type traits available to non-trivial C structs: __has_trivial_assign __has_trivial_move_assign __has_trivial_copy __has_trivial_move_constructor __has_trivial_constructor __has_trivial_destructor This reapplies r328680. This commit fixes a bug where the copy/move __has_trivial_* traits would return false when a volatile type was being passed. Thanks to Richard Smith for pointing out the mistake. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D44913 llvm-svn: 329289
* [PATCH] [RISCV] Extend getTargetDefines for RISCVTargetInfoShiva Chen2018-04-052-1/+64
| | | | | | | | | | | | | | Summary: This patch extend getTargetDefines and implement handleTargetFeatures and hasFeature. and define corresponding marco for those features. Reviewers: asb, apazos, eli.friedman Differential Revision: https://reviews.llvm.org/D44727 Patch by Kito Cheng. llvm-svn: 329278
* [clang-format] Preserve spaces before a percent in (text) protosKrasimir Georgiev2018-04-051-0/+4
| | | | | | | This makes sure that we do not change the meaning of pieces of text with format specifiers. llvm-svn: 329263
* Revert r328680 ("[ObjC] Make C++ triviality type traits available to ↵Richard Smith2018-04-051-12/+0
| | | | | | | | | non-trivial C structs.") It unintentionally caused the values of the __has_* type traits to change in C++ for trivially-copyable classes with volatile members. llvm-svn: 329247
* [AST] Don't track lambda captures when checking a potential constant expression.Erik Pilkington2018-04-051-6/+19
| | | | | | | | Fixes PR36054. Differential revision: https://reviews.llvm.org/D45194 llvm-svn: 329244
* Enable msan unconditionally on Linux.Evgeniy Stepanov2018-04-041-2/+1
| | | | | | | | | | | | | | | | | | Memory sanitizer compatibility are already done in MemorySanitizer::doInitialization. It verifies whether the necessary offsets exist and bails out if not. For this reason it is no good to duplicate two checks in two projects. This patch removes clang check and postpones msan compatibility validation till MemorySanitizer::doInitialization. Another reason for this patch is to allow using msan with any CPU (given compatible runtime) and custom mapping provided via the arguments added by https://reviews.llvm.org/D44926. Patch by vit9696. Differential Revision: https://reviews.llvm.org/D44927 llvm-svn: 329241
* AArch64: Implement support for the shadowcallstack attribute.Peter Collingbourne2018-04-042-1/+12
| | | | | | | | | | | | The implementation of shadow call stack on aarch64 is quite different to the implementation on x86_64. Instead of reserving a segment register for the shadow call stack, we reserve the platform register, x18. Any function that spills lr to sp also spills it to the shadow call stack, a pointer to which is stored in x18. Differential Revision: https://reviews.llvm.org/D45239 llvm-svn: 329236
* [Driver] Include the Android multiarch includes.Dan Albert2018-04-041-1/+22
| | | | | | | | | | | | | | | | Summary: Most Android headers live in a single directory, but a small handful live in multiarch directories. Reviewers: srhines Reviewed By: srhines Subscribers: javed.absar, cfe-commits Differential Revision: https://reviews.llvm.org/D44995 llvm-svn: 329234
* [CUDA] Add amdgpu sub archsYaxun Liu2018-04-046-42/+152
| | | | | | | | | Patch by Greg Rodgers. Revised and lit tests added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D45277 llvm-svn: 329232
* Revert "[CUDA] Check initializers of instantiated template variables."Artem Belevich2018-04-043-58/+52
| | | | | | | This (temporarily) reverts commit r329127 due to the problems it exposed in TensorFlow. llvm-svn: 329229
* Fixes errors with FS iterators caused by https://reviews.llvm.org/D44960Max Moroz2018-04-041-6/+8
| | | | | | | | | | | | | | | | | | | | Summary: In https://reviews.llvm.org/D44960, file status check is executed every time a real file system directory iterator is constructed or incremented, and emits an error code. This change list fixes the errors in VirtualFileSystem caused by https://reviews.llvm.org/D44960. Patch by Yuke Liao (@liaoyuke). Reviewers: vsk, pcc, zturner, liaoyuke Reviewed By: vsk Subscribers: mgrang, cfe-commits Differential Revision: https://reviews.llvm.org/D45178 llvm-svn: 329223
* [XRay][clang] Allow clang to build XRay instrumented binaries in OpenBSDDean Michael Berris2018-04-042-1/+30
| | | | | | | | | | | | | | | | | | | Summary: This patch was originally reviewed in D45126. It enables clang to add the XRay runtime and the link-time dependencies for XRay instrumentation in OpenBSD. Landing for devnexen. Reviewers: brad, dberris Subscribers: dberris, krytarowski, cfe-commits Author: devnexen Differential Revision: https://reviews.llvm.org/D45126 llvm-svn: 329183
* Make helpers static. NFC.Benjamin Kramer2018-04-042-5/+4
| | | | llvm-svn: 329170
* Fix typo in ASTStructuralEquivalence.cpp for UnaryTransform types.Eric Fiselier2018-04-041-1/+1
| | | | | | | | | | | | | | Previously UnaryTransformType nodes were comparing the same node for structural equivalence. This was due to a typo where T1 was on both sides of the comparison. This patch corrects that typo. Unfortunately I couldn't find a way to test this change. It seems that currently UnaryTransform nodes are never actually checked for equivalence, only their canonical types are. None the less, this correction seemed appropriate. llvm-svn: 329151
* [ObjC] Use the name specified by objc_runtime_name instead of the classAkira Hatanaka2018-04-031-2/+6
| | | | | | | | | | | | | identifier. This patch fixes a few places in CGObjCMac.cpp where the class identifier was used instead of the name specified by objc_runtime_name. rdar://problem/37910822 Differential Revision: https://reviews.llvm.org/D45101 llvm-svn: 329128
* [CUDA] Check initializers of instantiated template variables.Artem Belevich2018-04-033-52/+58
| | | | | | | | | We were already performing checks on non-template variables, but the checks on templated ones were missing. Differential Revision: https://reviews.llvm.org/D45231 llvm-svn: 329127
* Add the -fsanitize=shadow-call-stack flagVlad Tsyrklevich2018-04-035-1/+14
| | | | | | | | | | | | | | | | | Summary: Add support for the -fsanitize=shadow-call-stack flag which causes clang to add ShadowCallStack attribute to functions compiled with that flag enabled. Reviewers: pcc, kcc Reviewed By: pcc, kcc Subscribers: cryptoad, cfe-commits, kcc Differential Revision: https://reviews.llvm.org/D44801 llvm-svn: 329122
* [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-04-032-126/+140
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 329115
* [driver][darwin] Do not infer -simulator environment for non-simulator SDKsAlex Lorenz2018-04-031-5/+19
| | | | | | rdar://36369832 llvm-svn: 329110
* [analyzer] Fix diagnostics in callees of interesting callees.Artem Dergachev2018-04-031-9/+6
| | | | | | | | | | | | | | | removeUnneededCalls() is responsible for removing path diagnostic pieces within functions that don't contain "interesting" events. It makes bug reports much tidier. When a stack frame is known to be interesting, the function doesn't descend into it to prune anything within it, even other callees that are totally boring. Fix the function to prune boring callees in interesting stack frames. Differential Revision: https://reviews.llvm.org/D45117 llvm-svn: 329102
* Revert "Set calling convention for CUDA kernel"Artem Belevich2018-04-0310-45/+1
| | | | | | | This reverts r328795 which introduced an issue with referencing __global__ function templates. More details in the original review D44747. llvm-svn: 329099
* [Hexagon] Remove -mhvx-double and the corresponding subtarget featureKrzysztof Parzyszek2018-04-032-19/+8
| | | | | | | Specifying the HVX vector length should be done via the -mhvx-length option. llvm-svn: 329077
* [clang-format/ObjC] Do not detect "[]" as ObjC method expressionBen Hamilton2018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The following C++ code was being detected by `guessLanguage()` as Objective-C: #define FOO(...) auto bar = [] __VA_ARGS__; This was because `[] __VA_ARGS__` is not currently detected as a C++ lambda expression (it has no parens or braces), so `TokenAnnotator::parseSquare()` incorrectly treats the opening square as an ObjC method expression. We have two options to fix this: 1. Parse `[] __VA_ARGS__` explicitly as a C++ lambda 2. Make it so `[]` is never parsed as an Objective-C method expression This diff implements option 2, which causes the `[` to be parsed as `TT_ArraySubscriptLSquare` instead of `TT_ObjCMethodExpr`. Note that when I fixed this, it caused one change in formatting behavior, where the following was implicitly relying on the `[` being parsed as `TT_ObjCMethodExpr`: A<int * []> a; becomes: A<int *[]> a; with `Style.PointerAlignment = Middle`. I don't really know what the desired format is for this syntax; the test was added by Janusz Sobczak and integrated by @djasper in https://github.com/llvm-mirror/clang/commit/b511fe9818829d7ece0cc0b2ce1fbe04a1f0739a . I went ahead and changed the test for now. Test Plan: New tests added. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Fixes: https://bugs.llvm.org/show_bug.cgi?id=36248 Reviewers: djasper, jolesiak Reviewed By: djasper Subscribers: klimek, cfe-commits, djasper Differential Revision: https://reviews.llvm.org/D45169 llvm-svn: 329070
* [clang-format/ObjC] Do not insert space after opening brace of ObjC dict literalBen Hamilton2018-04-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: D44816 attempted to fix a few cases where `clang-format` incorrectly inserted a space before the closing brace of an Objective-C dictionary literal. This revealed there were still a few cases where we inserted a space after the opening brace of an Objective-C dictionary literal. This fixes the formatting to be consistent and adds more tests. Test Plan: New tests added. Confirmed tests failed before diff and passed after diff. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: djasper, jolesiak, krasimir Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45168 llvm-svn: 329069
* [AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).Eugene Zelenko2018-04-034-399/+379
| | | | llvm-svn: 329036
* [Driver] Wire up the -f[no-]rtlib-add-rpath flag and testsPetr Hosek2018-04-021-0/+4
| | | | | | | | | | D30700 added the -f[no-]rtlib-add-rpath flag, but that flag was never wired up in the driver and tests were updated to check whether it actually does anything. This patch wires up the flag and updates test. Differential Revision: https://reviews.llvm.org/D45145 llvm-svn: 329032
* CodeGenCXX: support PreserveMostCC in MS ABISaleem Abdulrasool2018-04-022-0/+2
| | | | | | | | Microsoft has reserved 'U' for the PreserveMostCC which is used in the swift runtime. Add support for this. This allows the swift runtime to be built for Windows again. llvm-svn: 329025
* [MS] Emit vftable thunks for functions with incomplete prototypesReid Kleckner2018-04-027-103/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The following class hierarchy requires that we be able to emit a this-adjusting thunk for B::foo in C's vftable: struct Incomplete; struct A { virtual A* foo(Incomplete p) = 0; }; struct B : virtual A { void foo(Incomplete p) override; }; struct C : B { int c; }; This TU is valid, but lacks a definition of 'Incomplete', which makes it hard to build a thunk for the final overrider, B::foo. Before this change, Clang gives up attempting to emit the thunk, because it assumes that if the parameter types are incomplete, it must be emitting the thunk for optimization purposes. This is untrue for the MS ABI, where the implementation of B::foo has no idea what thunks C's vftable may require. Clang needs to emit the thunk without necessarily having access to the complete prototype of foo. This change makes Clang emit a musttail variadic call when it needs such a thunk. I call these "unprototyped" thunks, because they only prototype the "this" parameter, which must always come first in the MS C++ ABI. These thunks work, but they create ugly LLVM IR. If the call to the thunk is devirtualized, it will be a call to a bitcast of a function pointer. Today, LLVM cannot inline through such a call, but I want to address that soon, because we also use this pattern for virtual member pointer thunks. This change also implements an old FIXME in the code about reusing the thunk's computed CGFunctionInfo as much as possible. Now we don't end up computing the thunk's mangled name and arranging it's prototype up to around three times. Fixes PR25641 Reviewers: rjmccall, rsmith, hans Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D45112 llvm-svn: 329009
* Fix some DenseMap use-after-rehash bugs and hoist MethodVFTableLocationReid Kleckner2018-04-024-42/+30
| | | | | | | | | | | | | | This re-lands r328845 with fixes for crbug.com/827810. The initial motiviation was to hoist MethodVFTableLocation to global scope so it could be forward declared. In this patch, I noticed that MicrosoftVTableContext uses some risky patterns. It has methods that return references to data stored in DenseMaps. I've made some of them return by value for trivial structs and I've moved some things into separate allocations. llvm-svn: 329007
* [Attr] [NFC] Revert accidental change from r327405Joel E. Denny2018-04-021-1/+1
| | | | llvm-svn: 329005
* Temporarily revert r328404:Eric Christopher2018-04-021-18/+0
| | | | | | | | | | | | | | commit 519b97132a4c960e8dedbfe4290d86970d92e995 Author: Richard Trieu <rtrieu@google.com> Date: Sat Mar 24 00:52:44 2018 +0000 [ODRHash] Support pointer and reference types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328404 91177308-0d34-0410-b5e6-96231b3b80d8 As it's breaking some tests. I've communicated with Richard offline about testcases. llvm-svn: 329001
* Add -fclang-abi-compat=6 flag for upcoming ABI changes.Richard Smith2018-04-021-0/+2
| | | | llvm-svn: 329000
* Add helper to determine if a field is a zero-length bitfield.Richard Smith2018-04-027-21/+20
| | | | llvm-svn: 328999
* [CUDA] Let device-side shared variables be initialized with undefYaxun Liu2018-04-021-4/+6
| | | | | | | | | | | CUDA shared variable should be initialized with undef. Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44985 llvm-svn: 328994
* [coroutines] Add __builtin_coro_noop => llvm.coro.noopGor Nishanov2018-04-021-0/+2
| | | | | | | | | | | | | A recent addition to Coroutines TS (https://wg21.link/p0913) adds a pre-defined coroutine noop_coroutine that does nothing. To implement this feature, we implemented an llvm.coro.noop intrinsic that returns a coroutine handle to a coroutine that does nothing when resumed or destroyed. This patch adds a builtin __builtin_coro_noop() that maps to llvm.coro.noop intrinsic. Related llvm change: https://reviews.llvm.org/D45114 llvm-svn: 328993
* Fix unused variable warning introduced at revision 328910.Andrea Di Biagio2018-04-021-2/+1
| | | | llvm-svn: 328968
* [Coroutines] Schedule coro-split before asanBrian Gesiak2018-04-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The docs for the LLVM coroutines intrinsic `@llvm.coro.id` state that "The second argument, if not null, designates a particular alloca instruction to be a coroutine promise." However, if the address sanitizer pass is run before the `@llvm.coro.id` intrinsic is lowered, the `alloca` instruction passed to the intrinsic as its second argument is converted, as per the https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm docs, to an `inttoptr` instruction that accesses the address of the promise. On optimization levels `-O1` and above, the `-asan` pass is run after `-coro-early`, `-coro-split`, and `-coro-elide`, and before `-coro-cleanup`, and so there is no issue. At `-O0`, however, `-asan` is run in between `-coro-early` and `-coro-split`, which causes an assertion to be hit when the `inttoptr` instruction is forcibly cast to an `alloca`. Rearrange the passes such that the coroutine passes are registered before the sanitizer passes. Test Plan: Compile a simple C++ program that uses coroutines in `-O0` with `-fsanitize-address`, and confirm no assertion is hit: `clang++ coro-example.cpp -fcoroutines-ts -g -fsanitize=address -fno-omit-frame-pointer`. Reviewers: GorNishanov, lewissbaker, EricWF Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43927 llvm-svn: 328951
OpenPOWER on IntegriCloud