1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
llvm-mirror/lib/IR
Duncan P. N. Exon Smith 6a8d2b6215 IR: Drop uniquing when an MDNode Value operand is deleted
This is a fix for PR28697.

An MDNode can indirectly refer to a GlobalValue, through a
ConstantAsMetadata.  When the GlobalValue is deleted, the MDNode operand
is reset to `nullptr`.  If the node is uniqued, this can lead to a
hard-to-detect cache invalidation in a Metadata map that's shared across
an LLVMContext.

Consider:

 1. A map from Metadata* to `T` called RemappedMDs.
 2. A node that references a global variable, `!{i1* @GV}`.
 3. Insert `!{i1* @GV} -> SomeT` in the map.
 4. Delete `@GV`, leaving behind `!{null} -> SomeT`.

Looking up the generic and uninteresting `!{null}` gives you `SomeT`,
which is likely related to `@GV`.  Worse, `SomeT`'s lifetime may be tied
to the deleted `@GV`.

This occurs in practice in the shared ValueMap used since r266579 in the
IRMover.  Other code that handles more than one Module (with different
lifetimes) in the same LLVMContext could hit it too.

The fix here is a partial revert of r225223: in the rare case that an
MDNode operand is a ConstantAsMetadata (i.e., wrapping a node from the
Value hierarchy), drop uniquing if it gets replaced with `nullptr`.
This changes step #4 above to leave behind `distinct !{null} -> SomeT`,
which can't be confused with the generic `!{null}`.

In theory, this can cause some churn in the LLVMContext's MDNode
uniquing map when Values are being deleted.  However:

  - The number of GlobalValues referenced from uniqued MDNodes is
    expected to be quite small.  E.g., the debug info metadata schema
    only references GlobalValues from distinct nodes.

  - Other Constants have the lifetime of the LLVMContext, whose teardown
    is careful to drop references before deleting the constants.

As a result, I don't expect a compile time regression from this change.

llvm-svn: 277625
2016-08-03 18:19:43 +00:00
..
AsmWriter.cpp Revert "Don't invoke getName() from Function::isIntrinsic().", rL276942. 2016-07-28 23:58:15 +00:00
AttributeImpl.h Expose AttributeSetNode, use it to provide aggregate getter for attribute in the C API. 2016-07-21 04:25:06 +00:00
Attributes.cpp Fix -Wreturn-type with gcc 4.8 and libc++ 2016-07-18 22:12:46 +00:00
AttributesCompatFunc.td
AttributeSetNode.h Add missing import to fix the build 2016-07-21 04:31:38 +00:00
AutoUpgrade.cpp Invariant start/end intrinsics overloaded for address space 2016-07-22 17:49:40 +00:00
BasicBlock.cpp Apply clang-tidy's modernize-loop-convert to most of lib/IR. 2016-06-26 14:10:56 +00:00
CMakeLists.txt Move ProfileSummary to IR. 2016-05-19 21:07:12 +00:00
Comdat.cpp [NFC] Remove some dead code: 2016-05-11 16:38:40 +00:00
ConstantFold.cpp [ConstantFold] Don't incorrectly infer inbounds on array GEP 2016-07-13 03:24:41 +00:00
ConstantFold.h [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
ConstantRange.cpp fix formatting, typo; NFC 2016-06-19 17:20:27 +00:00
Constants.cpp Apply clang-tidy's modernize-loop-convert to most of lib/IR. 2016-06-26 14:10:56 +00:00
ConstantsContext.h Increase SmallVector size for ConstantUniqueMap::getHashValue() (NFC) 2016-04-19 00:17:55 +00:00
Core.cpp Expose AttributeSetNode, use it to provide aggregate getter for attribute in the C API. 2016-07-21 04:25:06 +00:00
DataLayout.cpp [IR] Introduce a non-integral pointer type 2016-07-28 23:43:38 +00:00
DebugInfo.cpp StripDebugInfo: uses isa<DbgInfoIntrinsic> instead of matching against llvm.dbg.* (NFC) 2016-05-14 04:58:35 +00:00
DebugInfoMetadata.cpp [codeview] Add DISubprogram::ThisAdjustment 2016-07-01 02:41:21 +00:00
DebugLoc.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
DiagnosticInfo.cpp [OptRemark,LDist] RFC: Add hotness attribute 2016-07-15 17:23:20 +00:00
DiagnosticPrinter.cpp
DIBuilder.cpp [DIBuilder] Remove dead code. NFC. 2016-07-02 13:18:38 +00:00
Dominators.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
Function.cpp CodeGen: add new "intrinsic" MachineOperand kind. 2016-07-29 20:32:59 +00:00
GCOV.cpp llvm-cov: Fix reading gcov data that does not have function names 2016-02-08 22:49:40 +00:00
Globals.cpp [IR] [DAE] Copy comdats during DAE, and don't copy comdats in GlobalObject::copyAttributesFrom. 2016-06-15 23:20:15 +00:00
GVMaterializer.cpp
InlineAsm.cpp [InlineAsm] Avoid creating extra string instances in ConstraintInfo::Parse() 2016-05-23 13:58:04 +00:00
Instruction.cpp [IR] andIRFlags and copyIRFlags needs to handle GEP 2016-07-15 05:02:31 +00:00
Instructions.cpp Add getReturnedArgOperand to Call/InvokeInst, CallSite 2016-07-10 23:01:32 +00:00
IntrinsicInst.cpp [NFC] Remove some dead code: 2016-05-11 16:38:40 +00:00
IRBuilder.cpp Add invariant start call creation in IRBuilder.NFC 2016-07-22 20:57:23 +00:00
IRPrintingPasses.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
LegacyPassManager.cpp Remove doInitialization() and doFinalization() member declarations without definitions. 2016-04-28 19:21:30 +00:00
LLVMBuild.txt
LLVMContext.cpp [OptRemark,LDist] RFC: Add hotness attribute 2016-07-15 17:23:20 +00:00
LLVMContextImpl.cpp [OptRemark,LDist] RFC: Add hotness attribute 2016-07-15 17:23:20 +00:00
LLVMContextImpl.h Fixed "copy-paste" mistake from revision 255245. 2016-07-31 14:41:50 +00:00
Mangler.cpp
MDBuilder.cpp Fix the assertion failure caused by http://reviews.llvm.org/D22118 2016-07-11 17:36:02 +00:00
Metadata.cpp IR: Drop uniquing when an MDNode Value operand is deleted 2016-08-03 18:19:43 +00:00
MetadataImpl.h
Module.cpp Remove interface to get/set MaxFunctionCount 2016-06-20 21:36:38 +00:00
ModuleSummaryIndex.cpp [ThinLTO] Introduce typedef for commonly-used map type (NFC) 2016-04-25 21:09:51 +00:00
Operator.cpp
OptBisect.cpp Removing unused function. 2016-04-22 22:24:20 +00:00
Pass.cpp Re-commit optimization bisect support (r267022) without new pass manager support. 2016-04-22 22:06:11 +00:00
PassManager.cpp [PM] Run clang-format over various parts of the new pass manager code 2016-06-17 07:15:29 +00:00
PassRegistry.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
ProfileSummary.cpp Reapply r271728 after adding move cobstructor for ProfileSummaryInfo 2016-06-03 22:54:26 +00:00
Statepoint.cpp Introduce an GCRelocateInst class [NFC] 2016-04-12 18:05:10 +00:00
SymbolTableListTraitsImpl.h
Type.cpp fix documentation comments; NFC 2016-06-02 20:37:52 +00:00
TypeFinder.cpp Apply clang-tidy's modernize-loop-convert to most of lib/IR. 2016-06-26 14:10:56 +00:00
Use.cpp
User.cpp
Value.cpp BasicAA should look through functions with returned arguments 2016-07-11 01:32:20 +00:00
ValueSymbolTable.cpp Apply clang-tidy's modernize-loop-convert to most of lib/IR. 2016-06-26 14:10:56 +00:00
ValueTypes.cpp Add isScalarInteger helper to EVT/MVT 2016-03-01 18:01:28 +00:00
Verifier.cpp [Verifier] Disallow illegal ptr<->int casts in ConstantExprs 2016-08-02 02:55:57 +00:00