summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix alignment issues in LLVM.James Y Knight2015-06-173-7/+37
| | | | | | | | | | | | | | | | | | Adds static_asserts to ensure alignment of concatenated objects is correct, and fixes them where they are not. Also changes the definition of AlignOf to use constexpr, except on MSVC, to avoid enum comparison warnings from GCC. (There's not too much of this in llvm itself, most of the fun is in clang). This seems to make LLVM actually work without Bus Error on 32bit sparc. Differential Revision: http://reviews.llvm.org/D10271 llvm-svn: 239872
* Silence an MSVC warning about not all control paths returning a value; NFC.Aaron Ballman2015-06-161-0/+1
| | | | llvm-svn: 239814
* Debug Info IR: Switch DIObjCProperty to use DITypeRef.Adrian Prantl2015-06-152-2/+3
| | | | | | | | This is a prerequisite for turning on ODR type uniquing for ObjC++. rdar://problem/21377883 llvm-svn: 239780
* Protection against stack-based memory corruption errors using SafeStackPeter Collingbourne2015-06-152-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the safe stack instrumentation pass to LLVM, which separates the program stack into a safe stack, which stores return addresses, register spills, and local variables that are statically verified to be accessed in a safe way, and the unsafe stack, which stores everything else. Such separation makes it much harder for an attacker to corrupt objects on the safe stack, including function pointers stored in spilled registers and return addresses. You can find more information about the safe stack, as well as other parts of or control-flow hijack protection technique in our OSDI paper on code-pointer integrity (http://dslab.epfl.ch/pubs/cpi.pdf) and our project website (http://levee.epfl.ch). The overhead of our implementation of the safe stack is very close to zero (0.01% on the Phoronix benchmarks). This is lower than the overhead of stack cookies, which are supported by LLVM and are commonly used today, yet the security guarantees of the safe stack are strictly stronger than stack cookies. In some cases, the safe stack improves performance due to better cache locality. Our current implementation of the safe stack is stable and robust, we used it to recompile multiple projects on Linux including Chromium, and we also recompiled the entire FreeBSD user-space system and more than 100 packages. We ran unit tests on the FreeBSD system and many of the packages and observed no errors caused by the safe stack. The safe stack is also fully binary compatible with non-instrumented code and can be applied to parts of a program selectively. This patch is our implementation of the safe stack on top of LLVM. The patches make the following changes: - Add the safestack function attribute, similar to the ssp, sspstrong and sspreq attributes. - Add the SafeStack instrumentation pass that applies the safe stack to all functions that have the safestack attribute. This pass moves all unsafe local variables to the unsafe stack with a separate stack pointer, whereas all safe variables remain on the regular stack that is managed by LLVM as usual. - Invoke the pass as the last stage before code generation (at the same time the existing cookie-based stack protector pass is invoked). - Add unit tests for the safe stack. Original patch by Volodymyr Kuznetsov and others at the Dependable Systems Lab at EPFL; updates and upstreaming by myself. Differential Revision: http://reviews.llvm.org/D6094 llvm-svn: 239761
* MIR Serialization: Connect the machine function analysis pass to the MIR parser.Alex Lorenz2015-06-153-17/+31
| | | | | | | | | | | | | | | | | | | | | This commit connects the machine function analysis pass (which creates machine functions) to the MIR parser, which will initialize the machine functions with the state from the MIR file and reconstruct the machine IR. This commit introduces a new interface called 'MachineFunctionInitializer', which can be used to provide custom initialization for the machine functions. This commit also introduces a new diagnostic class called 'DiagnosticInfoMIRParser' which is used for MIR parsing errors. This commit modifies the default diagnostic handling in LLVMContext - now the the diagnostics are printed directly into llvm::errs() so that the MIR parsing errors can be printed with colours. Reviewers: Justin Bogner Differential Revision: http://reviews.llvm.org/D9928 llvm-svn: 239753
* De-duplicate common expression, NFC.Yaron Keren2015-06-151-3/+3
| | | | llvm-svn: 239736
* C++11 Rangify loops in AssemblyWriter::printModule, NFC.Yaron Keren2015-06-131-11/+8
| | | | llvm-svn: 239686
* Refix a use of explicit pointer types in GEP constant foldingDavid Blaikie2015-06-121-4/+4
| | | | | | | | | | | | | | | | | In the glorious future of opaque pointer types, it won't be possible to retrieve the pointee type of a pointer type which is what's being done in this GEP loop - but the first iteration is always a pointer type and the loop doesn't care about that case, except whether or not the index is a constant. So pull that special case out before the loop and start at the second iteration (index 1) instead. Originally committed in r236670 and reverted with a test case in r239015. This change keeps the test case working while also avoiding depending on pointee types. llvm-svn: 239629
* Move OperandList to be allocated prior to User for hung off subclasses.Pete Cooper2015-06-121-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For hung off uses, we need a Use* to tell use where the operands are. This was User::OperandList but we want to remove that to save space of all subclasses which aren't making use of 'hung off uses'. Hung off uses now allocate their own 'OperandList' Use* in the User::new which they call. getOperandList() now uses the hung off uses bit to work out where the Use* for the OperandList lives. If a User has hung off uses, then this bit tells them to go back a single Use* from the User* and use that value as the OperandList. If a User has no hung off uses, then we get the first operand by subtracting (NumOperands * sizeof(Use)) from the User this pointer. This saves a pointer from User and all subclasses. Given the average size of a subclass of User is 112 or 128 bytes, this saves around 7% of space With malloc tending to align to 16-bytes the real saving is typically more like 3.5%. On 'opt -O2 verify-uselistorder.lto.bc', peak memory usage prior to this change is 149MB and after is 143MB so the savings are around 2.5% of peak. Looking at some passes which allocate many Instructions and Values, parseIR drops from 54.25MB to 52.21MB while the Inliner calls to Instruction::clone() drops from 28.20MB to 27.05MB. Reviewed by Duncan Exon Smith. llvm-svn: 239623
* Added a version of User::new for hung off uses.Pete Cooper2015-06-121-4/+12
| | | | | | | | | | | | | | | | | There are now 2 versions of User::new. The first takes a size_t and is the current implementation for subclasses which need 0 or more Use's allocated for their operands. The new version takes no extra arguments to say that this subclass needs 'hung off uses'. The HungOffUses bool is now set in this version of User::new and we can assert in allocHungOffUses that we are allowed to have hung off uses. This ensures we call the correct version of User::new for subclasses which need hung off uses. A future commit will then allocate space for a single Use* which will be used in place of User::OperandList once that field has been removed. Reviewed by Duncan Exon Smith. llvm-svn: 239622
* Rename NumOperands to make it clear its managed by the User. NFC.Pete Cooper2015-06-124-24/+33
| | | | | | | | | | | | | | | | | | | | | This is to try make it very clear that subclasses shouldn't be changing the value directly. Now that OperandList for normal instructions is computed using the NumOperands, its critical that the NumOperands is accurate or we could compute the wrong offset to the first operand. I looked over all places which update NumOperands and they are all safe. Hung off use User's don't use NumOperands to compute the OperandList so they are safe to continue to manipulate it. The only other User which changed it was GlobalVariable which has an optional init list but always allocated space for a single Use. It was correctly setting NumOperands to 1 before setting an initializer, and setting it to 0 after clearing the init list, so the order was safe. Added some comments to that code to make sure that this isn't changed in future without being aware of this constraint. Reviewed by Duncan Exon Smith. llvm-svn: 239621
* Replace all accesses to User::OperandList with getter and setter methods. NFC.Pete Cooper2015-06-123-11/+19
| | | | | | | | | | We don't want anyone to access OperandList directly as its going to be removed and computed instead. This uses getter's and setter's instead in which we can later change the underlying implementation of OperandList. Reviewed by Duncan Exon Smith. llvm-svn: 239620
* Set proper debug location for branch added in BasicBlock::splitBasicBlock().Alexey Samsonov2015-06-111-1/+4
| | | | | | | | | | | | | | | | This improves debug locations in passes that do a lot of basic block transformations. Important case is LoopUnroll pass, the test for correct debug locations accompanies this change. Test Plan: regression test suite Reviewers: dblaikie, sanjoy Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10367 llvm-svn: 239551
* Replace an instance of custom atomics with standard ones.Benjamin Kramer2015-06-111-3/+3
| | | | | | | Eventually I want to get rid of them entirely, but Statistic.h is still blocked on MSVC bugs. No functionality change. llvm-svn: 239545
* Revert "Move dllimport name mangling to IR mangler."Reid Kleckner2015-06-111-4/+0
| | | | | | | | | This reverts commit r239437. This broke clang-cl self-hosts. We'd end up calling the __imp_ symbol directly instead of using it to do an indirect function call. llvm-svn: 239502
* Stop returning a Use* from allocHungOffUses.Pete Cooper2015-06-102-17/+16
| | | | | | | | | This always just set the User::OperandList which is now set in that method instead of being returned. Reviewed by Duncan Exon Smith. llvm-svn: 239493
* Add User::growHungoffUses and use it to grow the hung off uses. NFC.Pete Cooper2015-06-102-30/+31
| | | | | | | | | | | | | PhiNode, SwitchInst, LandingPad and IndirectBr all had virtually identical logic for growing the hung off uses. Move it to User so that they can all call a single shared implementation. Their destructors were all empty after this change and were deleted. They all have virtual clone_impl methods which can be used as vtable anchors. Reviewed by Duncan Exon Smith. llvm-svn: 239492
* Delete User::dropHungOffUses and move it in to ~User which is the only ↵Pete Cooper2015-06-101-16/+0
| | | | | | | | | | | caller. NFC. Now that the subclasses which care about hung off uses let ~User clean it up, there's no need for a separate method. Just inline it to ~User and delete it. Reviewed by Duncan Exon Smith. llvm-svn: 239491
* Make User track whether a class has 'hung off uses' and delete them in its ↵Pete Cooper2015-06-101-2/+7
| | | | | | | | | | | | | | | | | | | | | destructor. Currently all of the logic for deleting hung off uses, which PHI/switch/etc use, is in their classes. This adds a bit to Value which tracks whether that user had hung off uses, then User can be responsible for clearing them instead of the sub classes. Note, the bit used here was taken from NumOperands which was 30-bits. Given the reduction to 29 bits, and the average User being just over 100 bytes, a single User with 29-bits of num operands would need 50GB of RAM for itself so its reasonable to assume that 29-bits is enough for now. This is a step towards hiding all the hung off uses logic in the User. Reviewed by Duncan Exon Smith. llvm-svn: 239490
* Move the special Phi logic for hung off uses in to User::allocHungOffUses. NFC.Pete Cooper2015-06-102-13/+4
| | | | | | | | | | | | PhiNode's need to allocate space for an array of Use[N] and then BasicBlock*[N]. They had their own allocHungOffUses to handle all of this. This moves the logic in to User::allocHungOffUses and PhiNode passes in a bool to say to allocate the BB* space too. Reviewed by Duncan Exon Smith. llvm-svn: 239489
* ArgumentPromotion: Drop sret attribute on functions that are only called ↵Peter Collingbourne2015-06-101-3/+1
| | | | | | | | | | | | | | | | | | | directly. If the first argument to a function is a 'this' argument and the second has the sret attribute, the ArgumentPromotion pass may promote the 'this' argument to more than one argument, violating the IR constraint that 'sret' may only be applied to the first or second argument. Although this IR constraint is arguably unnecessary, it highlighted the fact that ArgPromotion does not need to preserve this attribute. Dropping the attribute reduces register pressure in the backend by avoiding the register copy required by sret. Because sret implies noalias, we also replace the former with the latter. Differential Revision: http://reviews.llvm.org/D10353 llvm-svn: 239488
* Move dllimport name mangling to IR mangler.Peter Collingbourne2015-06-091-0/+4
| | | | | | | | This ensures that LTO clients see the correct external symbol name. Differential Revision: http://reviews.llvm.org/D10318 llvm-svn: 239437
* Prefer copy init over direct init. NFC.Benjamin Kramer2015-06-081-1/+1
| | | | llvm-svn: 239327
* [AsmWriter] Rewrite module asm printing using StringRef::split.Benjamin Kramer2015-06-071-16/+9
| | | | | | No change in output intended. llvm-svn: 239251
* Rangify more for loops in LegacyPassManager.cpp.Yaron Keren2015-06-051-39/+21
| | | | llvm-svn: 239166
* Rangify for loops in LegacyPassManager.cpp.Yaron Keren2015-06-051-19/+10
| | | | llvm-svn: 239155
* [C API] Add LLVMStructGetTypeAtIndex.Peter Zotov2015-06-041-0/+5
| | | | | | Patch by deadalnix (Amaury SECHET). llvm-svn: 239029
* [ConstantFold] Don't skip the first gep index when folding gepsDavid Majnemer2015-06-041-3/+3
| | | | | | | | | We neglected to check if the first index made the GEP ineligible for 'inbounds'. This fixes PR23753. llvm-svn: 239015
* Int128 is also a built-in preconstructed type.Nick Lewycky2015-06-021-6/+7
| | | | llvm-svn: 238889
* [IR/AsmWriter] Output escape sequences if the first character isdigit()Filipe Cabecinhas2015-06-022-9/+11
| | | | | | | | | | | | | | | If the first character in a metadata attachment's name is a digit, it has to be output using an escape sequence, otherwise it's not valid text IR. Removed an over-zealous assert from LLVMContext which didn't allow this. The rule should only apply to text IR. Actual names can have any sequence of non-NUL bytes. Also added some documentation on accepted names. Bug found with AFL fuzz. llvm-svn: 238867
* clang-format a few functions. NFCFilipe Cabecinhas2015-06-022-10/+8
| | | | llvm-svn: 238865
* Move the name pointer out of Value into a map that lives on theOwen Anderson2015-06-013-10/+41
| | | | | | | | | | | | | | | | LLVMContext. Production builds of clang do not set names on most Value's, so this is wasted space on almost all subclasses of Value. This reduces the size of all Value subclasses by 8 bytes on 64 bit hosts. The one tricky part of this change is averting compile time regression by keeping Value::hasName() fast. This required stealing bits out of NumOperands. With this change, peak memory usage on verify-uselistorder-nodbg.lto.bc is decreased by approximately 2.3% (~3MB absolute on my machine). llvm-svn: 238791
* Add isConstant argument to MDBuilder::createTBAAStructTagNodeArtur Pilipenko2015-06-011-4/+11
| | | | | | | | | | According to the TBAA description struct-path tag node can have an optional IsConstant field. Add corresponding argument to MDBuilder::createTBAAStructTagNode. Reviewed By: hfinkel Differential Revision: http://reviews.llvm.org/D10160 llvm-svn: 238749
* [opaque pointer type] Explicitly store the pointee type of the result of a GEPDavid Blaikie2015-06-011-1/+2
| | | | | | | | Alternatively, this type could be derived on-demand whenever getResultElementType is called - if someone thinks that's the better choice (simple time/space tradeoff), I'm happy to give it a go. llvm-svn: 238716
* [IR] fptrunc-of-fptrunc isn't an EliminableCastPair.Ahmed Bougacha2015-05-291-1/+1
| | | | | | | Double and single rounding can produce different results. This is the IR counterpart to r228911. llvm-svn: 238531
* Add initial support for the convergent attribute.Owen Anderson2015-05-262-1/+5
| | | | llvm-svn: 238264
* [PlaceSafepoints] Cleanup InsertSafepointPoll functionPhilip Reames2015-05-262-0/+9
| | | | | | While working on another change, I noticed that the naming in this function was mildly deceptive. While fixing that, I took the oppurtunity to modernize some of the code. NFC intended. llvm-svn: 238252
* This patch adds support for the vector quadword add/sub instructions introducedKit Barton2015-05-251-1/+5
| | | | | | | | | | | | | | | | | | | | in POWER8: vadduqm vaddeuqm vaddcuq vaddecuq vsubuqm vsubeuqm vsubcuq vsubecuq In addition to adding the instructions themselves, it also adds support for the v1i128 type for intrinsics (Intrinsics.td, Function.cpp, and IntrinsicEmitter.cpp). http://reviews.llvm.org/D9081 llvm-svn: 238144
* Simplify and rename function overrideFunctionAttributes. NFC.Akira Hatanaka2015-05-231-13/+0
| | | | | | | This is in preparation to making changes needed to stop resetting NoFramePointerElim in resetTargetOptions. llvm-svn: 238079
* Use Op<0> accessor instead of OperandList for Instructions. NFCPete Cooper2015-05-212-6/+6
| | | | | | This is consistent with other uses of the operand list. I'm planning a future commit where this will actually matter. llvm-svn: 237967
* Put GEPOperator member function definition in the appropriate .cpp fileDavid Blaikie2015-05-212-30/+31
| | | | | | Last commit put it in Constants.cpp instead of Operator.cpp llvm-svn: 237960
* [opaque pointer type] Allow gep_type_iterator to work with the pointee type ↵David Blaikie2015-05-211-0/+30
| | | | | | | | | | | from the GEP instruction The raw non-instruction/constant form of this is still relying on being able to access the pointee type from a pointer type - those will be cleaned up later. For now, just focus on the cases where the pointee type is easily accessible. llvm-svn: 237958
* IR / debug info: Add a DWOId field to DICompileUnit,Adrian Prantl2015-05-214-10/+14
| | | | | | | | | | | | | | | | | | | | | | so DWARF skeleton CUs can be expression in IR. A skeleton CU is a (typically empty) DW_TAG_compile_unit that has a DW_AT_(GNU)_dwo_name and a DW_AT_(GNU)_dwo_id attribute. It is used to refer to external debug info. This is a prerequisite for clang module debugging as discussed in http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/040076.html. In order to refer to external types stored in split DWARF (dwo) objects, such as clang modules, we need to emit skeleton CUs, which identify the dwarf object (i.e., the clang module) by filename (the SplitDebugFilename) and a hash value, the dwo_id. This patch only contains the IR changes. The idea is that a CUs with a non-zero dwo_id field will be emitted together with a DW_AT_GNU_dwo_name and DW_AT_GNU_dwo_id attribute. http://reviews.llvm.org/D9488 rdar://problem/20091852 llvm-svn: 237949
* [opaque pointer type] Pass explicit pointee type in another case of GEP ↵David Blaikie2015-05-211-1/+1
| | | | | | constant folding llvm-svn: 237860
* [opaque pointer type] Pass explicit type to Load instruction creation in ↵David Blaikie2015-05-203-11/+11
| | | | | | AutoUpgrade llvm-svn: 237838
* [opaque pointer type] LoadInst: assert that the explicit type matches the ↵David Blaikie2015-05-201-0/+1
| | | | | | implicit one llvm-svn: 237830
* Change Function::getIntrinsicID() to return an Intrinsic::ID. NFC.Pete Cooper2015-05-203-6/+5
| | | | | | | | Now that Intrinsic::ID is a typed enum, we can forward declare it and so return it from this method. This updates all users which were either using an unsigned to store it, or had a now unnecessary cast. llvm-svn: 237810
* Dereferenceable, dereferenceable_or_null metadata for loadsSanjoy Das2015-05-191-1/+12
| | | | | | | | | | | | | | | | | | | | Summary: Introduce dereferenceable, dereferenceable_or_null metadata for loads with the same semantic as corresponding attributes. This patch depends on http://reviews.llvm.org/D9253 Patch by Artur Pilipenko! Reviewers: hfinkel, sanjoy, reames Reviewed By: sanjoy, reames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9365 llvm-svn: 237720
* As r237678 was reverted, this is no longer needed.Yaron Keren2015-05-191-2/+1
| | | | llvm-svn: 237687
* Fix Visual C++ errors C2784, C2780, C2782 after r237678.Yaron Keren2015-05-191-1/+2
| | | | | | It does not like std::min(unsigned, uint32_t). llvm-svn: 237683
OpenPOWER on IntegriCloud