summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-11/+11
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* s/LLVM_ON_WIN32/_WIN32/, llvmNico Weber2018-04-291-1/+1
| | | | | | | | | | | | | | LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. This moves over all uses of the macro, but doesn't remove the definition of it in (llvm-)config.h yet. llvm-svn: 331127
* InstCombine: Fix layering by not including Scalar.h in InstCombineDavid Blaikie2018-04-241-1/+2
| | | | | | | | (notionally Scalar.h is part of libLLVMScalarOpts, so it shouldn't be included by InstCombine which doesn't/shouldn't need to depend on ScalarOpts) llvm-svn: 330669
* [ORC] Errorize the ORC APIs.Lang Hames2017-07-071-1/+1
| | | | | | | | This patch updates the ORC layers and utilities to return and propagate llvm::Errors where appropriate. This is necessary to allow ORC to safely handle error cases in cross-process and remote JITing. llvm-svn: 307350
* Update Kaleidoscope tutorial and improve Windows supportMehdi Amini2017-02-111-2/+8
| | | | | | | | | | | | | | | Many quoted code blocks were not in sync with the actual toy.cpp files. Improve tutorial text slightly in several places. Added some step descriptions crucial to avoid crashes (like InitializeNativeTarget* calls). Solve/workaround problems with Windows (JIT'ed method not found, using custom and standard library functions from host process). Patch by: Moritz Kroll <moritz.kroll@gmx.de> Differential Revision: https://reviews.llvm.org/D29864 llvm-svn: 294870
* Use print() instead of dump() in codeMatthias Braun2017-01-281-2/+4
| | | | | | | The dump() functions are meant to be used in a debugger, code should typically use something like print(errs()); llvm-svn: 293365
* [Examples] Fix some Clang-tidy modernize-use-default and Include What You ↵Eugene Zelenko2016-11-181-1/+12
| | | | | | | | Use warnings; other minor fixes. Differential revision: https://reviews.llvm.org/D26433 llvm-svn: 287384
* [Kaleidoscope] Fix static global ordering to prevent crash on exit.Lang Hames2016-05-221-1/+1
| | | | | | | If TheModule is declared before LLVMContext then it will be destructed after it, crashing when it tries to deregister itself from the destructed context. llvm-svn: 270381
* Fix some Clang-tidy modernize-use-bool-literals and Include What You Use ↵Eugene Zelenko2016-05-191-6/+15
| | | | | | | | warnings in examples; other minor fixes. Differential revision: http://reviews.llvm.org/D20397 llvm-svn: 270008
* Remove every uses of getGlobalContext() in LLVM (but the C API)Mehdi Amini2016-04-141-9/+8
| | | | | | | | | | | At the same time, fixes InstructionsTest::CastInst unittest: yes you can leave the IR in an invalid state and exit when you don't destroy the context (like the global one), no longer now. This is the first part of http://reviews.llvm.org/D19094 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266379
* [Kaleidoscope] Rename Error -> LogError in Chapters 2-5.Lang Hames2016-03-251-16/+16
| | | | | | | This keeps the naming consistent with Chapters 6-8, where Error was renamed to LogError in r264426 to avoid clashes with the new Error class in libSupport. llvm-svn: 264427
* [PM] Update Kaleidoscope with the new header file.Chandler Carruth2016-03-111-0/+1
| | | | llvm-svn: 263223
* Fix Clang-tidy modernize-use-nullptr warnings in examples and include ↵Hans Wennborg2015-09-291-1/+2
| | | | | | | | | | directories; other minor cleanups. Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13172 llvm-svn: 248811
* [PM/AA] Rebuild LLVM's alias analysis infrastructure in a way compatibleChandler Carruth2015-09-091-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with the new pass manager, and no longer relying on analysis groups. This builds essentially a ground-up new AA infrastructure stack for LLVM. The core ideas are the same that are used throughout the new pass manager: type erased polymorphism and direct composition. The design is as follows: - FunctionAAResults is a type-erasing alias analysis results aggregation interface to walk a single query across a range of results from different alias analyses. Currently this is function-specific as we always assume that aliasing queries are *within* a function. - AAResultBase is a CRTP utility providing stub implementations of various parts of the alias analysis result concept, notably in several cases in terms of other more general parts of the interface. This can be used to implement only a narrow part of the interface rather than the entire interface. This isn't really ideal, this logic should be hoisted into FunctionAAResults as currently it will cause a significant amount of redundant work, but it faithfully models the behavior of the prior infrastructure. - All the alias analysis passes are ported to be wrapper passes for the legacy PM and new-style analysis passes for the new PM with a shared result object. In some cases (most notably CFL), this is an extremely naive approach that we should revisit when we can specialize for the new pass manager. - BasicAA has been restructured to reflect that it is much more fundamentally a function analysis because it uses dominator trees and loop info that need to be constructed for each function. All of the references to getting alias analysis results have been updated to use the new aggregation interface. All the preservation and other pass management code has been updated accordingly. The way the FunctionAAResultsWrapperPass works is to detect the available alias analyses when run, and add them to the results object. This means that we should be able to continue to respect when various passes are added to the pipeline, for example adding CFL or adding TBAA passes should just cause their results to be available and to get folded into this. The exception to this rule is BasicAA which really needs to be a function pass due to using dominator trees and loop info. As a consequence, the FunctionAAResultsWrapperPass directly depends on BasicAA and always includes it in the aggregation. This has significant implications for preserving analyses. Generally, most passes shouldn't bother preserving FunctionAAResultsWrapperPass because rebuilding the results just updates the set of known AA passes. The exception to this rule are LoopPass instances which need to preserve all the function analyses that the loop pass manager will end up needing. This means preserving both BasicAAWrapperPass and the aggregating FunctionAAResultsWrapperPass. Now, when preserving an alias analysis, you do so by directly preserving that analysis. This is only necessary for non-immutable-pass-provided alias analyses though, and there are only three of interest: BasicAA, GlobalsAA (formerly GlobalsModRef), and SCEVAA. Usually BasicAA is preserved when needed because it (like DominatorTree and LoopInfo) is marked as a CFG-only pass. I've expanded GlobalsAA into the preserved set everywhere we previously were preserving all of AliasAnalysis, and I've added SCEVAA in the intersection of that with where we preserve SCEV itself. One significant challenge to all of this is that the CGSCC passes were actually using the alias analysis implementations by taking advantage of a pretty amazing set of loop holes in the old pass manager's analysis management code which allowed analysis groups to slide through in many cases. Moving away from analysis groups makes this problem much more obvious. To fix it, I've leveraged the flexibility the design of the new PM components provides to just directly construct the relevant alias analyses for the relevant functions in the IPO passes that need them. This is a bit hacky, but should go away with the new pass manager, and is already in many ways cleaner than the prior state. Another significant challenge is that various facilities of the old alias analysis infrastructure just don't fit any more. The most significant of these is the alias analysis 'counter' pass. That pass relied on the ability to snoop on AA queries at different points in the analysis group chain. Instead, I'm planning to build printing functionality directly into the aggregation layer. I've not included that in this patch merely to keep it smaller. Note that all of this needs a nearly complete rewrite of the AA documentation. I'm planning to do that, but I'd like to make sure the new design settles, and to flesh out a bit more of what it looks like in the new pass manager first. Differential Revision: http://reviews.llvm.org/D12080 llvm-svn: 247167
* Kaleidoscope: Prune __attribute__((used)). Some compilers wouldn't accept one.NAKAMURA Takumi2015-08-281-2/+2
| | | | llvm-svn: 246268
* Recommit r246175 - Add Kaleidoscope regression tests, with a fix to make sureLang Hames2015-08-271-4/+4
| | | | | | the kaleidoscope 'library' functions aren't dead-stripped in release builds. llvm-svn: 246201
* Revert r246175 to get builder green again.Lang Hames2015-08-271-2/+2
| | | | llvm-svn: 246185
* Add Kaleidoscope regression tests.Lang Hames2015-08-271-2/+2
| | | | | | These will be run if LLVM_BUILD_EXAMPLES is enabled. llvm-svn: 246175
* Big Kaleidoscope tutorial update.Lang Hames2015-08-261-312/+107
| | | | | | | | | | | | | This commit switches the underlying JIT for the Kaleidoscope tutorials from MCJIT to a custom ORC-based JIT, KaleidoscopeJIT. This fixes a lot of the bugs in Kaleidoscope that were introduced when we deleted the legacy JIT. The documentation for Chapter 4, which introduces the JIT APIs, is updated to reflect the change. Also included are a number of C++11 modernizations and general cleanup. Where appropriate, the docs have been updated to reflect these changes too. llvm-svn: 246002
* [Kaleidoscope] More inter-chapter diff reduction.Lang Hames2015-08-191-1/+3
| | | | llvm-svn: 245474
* [Kaleidoscope] Clang-format the Kaleidoscope tutorials.Lang Hames2015-08-191-29/+41
| | | | | | Also reduces changes between tutorial chapters. llvm-svn: 245472
* [Kaleidoscope] Start C++11'ifying the kaleidoscope tutorials.Lang Hames2015-08-181-90/+90
| | | | llvm-svn: 245322
* [PM/AA] Hoist the interface for BasicAA into a header file.Chandler Carruth2015-08-061-0/+1
| | | | | | | | | | | | | This is the first mechanical step in preparation for making this and all the other alias analysis passes available to the new pass manager. I'm factoring out all the totally boring changes I can so I'm moving code around here with no other changes. I've even minimized the formatting churn. I'll reformat and freshen comments on the interface now that its located in the right place so that the substantive changes don't triger this. llvm-svn: 244197
* Fix Kaleidoscope tuto: ExecutionEngine->getDataLayout() returns a refMehdi Amini2015-07-161-1/+1
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 242416
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-6/+6
| | | | | | | | | | | | | | The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' \ -j=32 -fix -format http://reviews.llvm.org/D8925 llvm-svn: 234679
* Fix the build of the gold-plugin and examples.Rafael Espindola2015-03-041-1/+1
| | | | llvm-svn: 231279
* Make DataLayout Non-Optional in the ModuleMehdi Amini2015-03-041-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: DataLayout keeps the string used for its creation. As a side effect it is no longer needed in the Module. This is "almost" NFC, the string is no longer canonicalized, you can't rely on two "equals" DataLayout having the same string returned by getStringRepresentation(). Get rid of DataLayoutPass: the DataLayout is in the Module The DataLayout is "per-module", let's enforce this by not duplicating it more than necessary. One more step toward non-optionality of the DataLayout in the module. Make DataLayout Non-Optional in the Module Module->getDataLayout() will never returns nullptr anymore. Reviewers: echristo Subscribers: resistor, llvm-commits, jholewinski Differential Revision: http://reviews.llvm.org/D7992 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 231270
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-2/+2
| | | | | | requiring the macro. NFC; LLVM edition. llvm-svn: 229340
* [PM] Update the examples to reflect the removal of theChandler Carruth2015-02-131-1/+1
| | | | | | | | | | | llvm/PassManager.h wrapper header and its using declarations. These now directly use the legacy namespace. I had updated the #include lines in my large commit but forgot that the examples weren't being built and didn't update the code to use the correct namespace. Sorry for the noise here. llvm-svn: 229095
* [PM] Remove the old 'PassManager.h' header file at the top level ofChandler Carruth2015-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | LLVM's include tree and the use of using declarations to hide the 'legacy' namespace for the old pass manager. This undoes the primary modules-hostile change I made to keep out-of-tree targets building. I sent an email inquiring about whether this would be reasonable to do at this phase and people seemed fine with it, so making it a reality. This should allow us to start bootstrapping with modules to a certain extent along with making it easier to mix and match headers in general. The updates to any code for users of LLVM are very mechanical. Switch from including "llvm/PassManager.h" to "llvm/IR/LegacyPassManager.h". Qualify the types which now produce compile errors with "legacy::". The most common ones are "PassManager", "PassManagerBase", and "FunctionPassManager". llvm-svn: 229094
* [Kaleidoscope] Run clang-format over chapter 4 of kaleidoscope.Lang Hames2015-01-161-44/+38
| | | | | | I forgot to do this for r226308. Thanks to Eric Christopher for the reminder. llvm-svn: 226327
* [Kaleidoscope] Fix a bug in Chapter 4 of the Kaleidoscope tutorial where repeatLang Hames2015-01-161-55/+253
| | | | | | | | calls to functions weren't evaluated correctly. Patch by Charlie Turner. Thanks Charlie! llvm-svn: 226308
* Fix KS tutorial build failure.Eric Christopher2014-12-081-106/+154
| | | | | | | make all doesn't build the examples and it was uniquified since last build. llvm-svn: 223675
* Fix the JIT code for the Kaleidoscope tutorial.Eric Christopher2014-12-081-2/+9
| | | | llvm-svn: 223670
* Add doInitialization/doFinalization to DataLayoutPass.Rafael Espindola2014-09-101-1/+1
| | | | | | | | | | | | | With this a DataLayoutPass can be reused for multiple modules. Once we have doInitialization/doFinalization, it doesn't seem necessary to pass a Module to the constructor. Overall this change seems in line with the idea of making DataLayout a required part of Module. With it the only way of having a DataLayout used is to add it to the Module. llvm-svn: 217548
* Reinstate "Nuke the old JIT."Eric Christopher2014-09-021-1/+0
| | | | | | | | Approved by Jim Grosbach, Lang Hames, Rafael Espindola. This reinstates commits r215111, 215115, 215116, 215117, 215136. llvm-svn: 216982
* Make it explicit that ExecutionEngine takes ownership of the modules.Rafael Espindola2014-08-191-2/+4
| | | | llvm-svn: 215967
* Temporarily Revert "Nuke the old JIT." as it's not quite ready toEric Christopher2014-08-071-0/+1
| | | | | | | | | | | be deleted. This will be reapplied as soon as possible and before the 3.6 branch date at any rate. Approved by Jim Grosbach, Lang Hames, Rafael Espindola. This reverts commits r215111, 215115, 215116, 215117, 215136. llvm-svn: 215154
* Nuke the old JIT.Rafael Espindola2014-08-071-1/+0
| | | | | | | | | I am sure we will be finding bits and pieces of dead code for years to come, but this is a good start. Thanks to Lang Hames for making MCJIT a good replacement! llvm-svn: 215111
* Use DataLayout from the module when easily available.Rafael Espindola2014-02-251-1/+2
| | | | | | | | | | | | | | | | | Eventually DataLayoutPass should go away, but for now that is the only easy way to get a DataLayout in some APIs. This patch only changes the ones that have easy access to a Module. One interesting issue with sometimes using DataLayoutPass and sometimes fetching it from the Module is that we have to make sure they are equivalent. We can get most of the way there by always constructing the pass with a Module. In fact, the pass could be changed to point to an external DataLayout instead of owning one to make this stricter. Unfortunately, the C api passes a DataLayout, so it has to be up to the caller to make sure the pass and the module are in sync. llvm-svn: 202204
* Make DataLayout a plain object, not a pass.Rafael Espindola2014-02-251-1/+1
| | | | | | | Instead, have a DataLayoutPass that holds one. This will allow parts of LLVM don't don't handle passes to also use DataLayout. llvm-svn: 202168
* [cleanup] Re-sort the examples #include lines with my sort_includesChandler Carruth2014-01-131-1/+1
| | | | | | script. llvm-svn: 199089
* [cleanup] Fix the includes in the examples for r199082.Chandler Carruth2014-01-131-1/+1
| | | | llvm-svn: 199087
* [weak vtables] Place class definitions into anonymous namespaces to prevent ↵Juergen Ributzka2013-11-191-5/+3
| | | | | | | | | | weak vtables. This patch places class definitions in implementation files into anonymous namespaces to prevent weak vtables. This eliminates the need of providing an out-of-line definition to pin the vtable explicitly to the file. llvm-svn: 195092
* [weak vtables] Remove a bunch of weak vtablesJuergen Ributzka2013-11-191-1/+4
| | | | | | | | | | | | This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. The memory leaks in this version have been fixed. Thanks Alexey for pointing them out. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy llvm-svn: 195064
* Revert r194865 and r194874.Alexey Samsonov2013-11-181-3/+1
| | | | | | | | | | | | This change is incorrect. If you delete virtual destructor of both a base class and a subclass, then the following code: Base *foo = new Child(); delete foo; will not cause the destructor for members of Child class. As a result, I observe plently of memory leaks. Notable examples I investigated are: ObjectBuffer and ObjectBufferStream, AttributeImpl and StringSAttributeImpl. llvm-svn: 194997
* [weak vtables] Remove a bunch of weak vtablesJuergen Ributzka2013-11-151-1/+3
| | | | | | | | | | | This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy llvm-svn: 194865
* Add missing #include's to cctype when using isdigit/alpha/etc.Will Dietz2013-10-121-0/+1
| | | | llvm-svn: 192519
* Update the examples for the new header file locations.Chandler Carruth2013-01-021-5/+5
| | | | | | | Sorry for the fallout here, I forgot the examples aren't built by default any more. llvm-svn: 171371
* Sort the #include lines of the examples/... tree.Chandler Carruth2012-12-041-5/+5
| | | | llvm-svn: 169249
OpenPOWER on IntegriCloud