llvm/lib/IR
Duncan P. N. Exon Smith 41e362dd89 Reapply "ValueMapper: Treat LocalAsMetadata more like function-local Values"
This reverts commit r265765, reapplying r265759 after changing a call from
LocalAsMetadata::get to ValueAsMetadata::get (and adding a unit test).  When a
local value is mapped to a constant (like "i32 %a" => "i32 7"), the new debug
intrinsic operand may no longer be pointing at a local.

    http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_build/19020/

The previous coommit message follows:

--

This is a partial re-commit -- maybe more of a re-implementation -- of
r265631 (reverted in r265637).

This makes RF_IgnoreMissingLocals behave (almost) consistently between
the Value and the Metadata hierarchy.  In particular:

  - MapValue returns nullptr or "metadata !{}" for missing locals in
    MetadataAsValue/LocalAsMetadata bridging paris, depending on
    the RF_IgnoreMissingLocals flag.

  - MapValue doesn't memoize LocalAsMetadata-related results.

  - MapMetadata no longer deals with LocalAsMetadata or
    RF_IgnoreMissingLocals at all.  (This wasn't in r265631 at all, but
    I realized during testing it would make the patch simpler with no
    loss of generality.)

r265631 went too far, making both functions universally ignore
RF_IgnoreMissingLocals.  This broke building (e.g.) compiler-rt.
Reassociate (and possibly other passes) don't currently maintain
dominates-use invariants for metadata operands, resulting in IR like
this:

    define void @foo(i32 %arg) {
      call void @llvm.some.intrinsic(metadata i32 %x)
      %x = add i32 1, i32 %arg
    }

If the inliner chooses to inline @foo into another function, then
RemapInstruction will call `MapValue(metadata i32 %x)` and assert that
the return is not nullptr.

I've filed PR27273 to add a Verifier check and fix the underlying
problem in the optimization passes.

As a workaround, return `!{}` instead of nullptr for unmapped
LocalAsMetadata when RF_IgnoreMissingLocals is unset.  Otherwise, match
the behaviour of r265631.

Original commit message:

    ValueMapper: Make LocalAsMetadata match function-local Values

    Start treating LocalAsMetadata similarly to function-local members of
    the Value hierarchy in MapValue and MapMetadata.

      - Don't memoize them.
      - Return nullptr if they are missing.

    This also cleans up ConstantAsMetadata to stop listening to the
    RF_IgnoreMissingLocals flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265768 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 03:13:22 +00:00
..
AsmWriter.cpp [GCC] Attribute ifunc support in llvm 2016-04-07 12:32:19 +00:00
AttributeImpl.h Remove TrailingObjects::operator delete. It's still suffering from 2016-02-09 02:09:16 +00:00
Attributes.cpp Fix non-determinism in order of LLVM attributes 2016-04-04 23:06:05 +00:00
AttributesCompatFunc.td Provide a way to specify inliner's attribute compatibility and merging. 2015-12-22 23:57:37 +00:00
AutoUpgrade.cpp IR: Stop upgrading !llvm.loop attachments via MDString 2016-03-25 00:56:13 +00:00
BasicBlock.cpp Introduce @llvm.experimental.deoptimize 2016-03-11 19:08:34 +00:00
CMakeLists.txt [ThinLTO] Renaming of function index to module summary index (NFC) 2016-03-15 00:04:37 +00:00
Comdat.cpp IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
ConstantFold.cpp fix documentation comments; NFC 2016-04-05 18:23:30 +00:00
ConstantFold.h Minor code cleanup. NFC. 2016-03-22 04:37:32 +00:00
ConstantRange.cpp [ConstantRange] Generalize makeGuaranteedNoWrapRegion to work on ranges 2016-03-03 18:31:16 +00:00
Constants.cpp IR: Introduce ConstantAggregate, NFC 2016-04-05 21:10:45 +00:00
ConstantsContext.h IR: Use DenseSet instead of DenseMap for ConstantUniqueMap; NFC 2016-04-06 17:56:08 +00:00
Core.cpp [llvm-c] Add LLVMGetValueKind. 2016-04-06 22:21:29 +00:00
DataLayout.cpp Replace Type::getInt32Ty() and comparison by isIntegerTy(32). NFC. 2016-01-22 03:30:27 +00:00
DebugInfo.cpp Remove llvm::getDISubprogram in favor of Function::getSubprogram 2016-03-11 02:14:16 +00:00
DebugInfoMetadata.cpp Move the DebugEmissionKind enum from DIBuilder into DICompileUnit. 2016-03-31 23:56:58 +00:00
DebugLoc.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
DiagnosticInfo.cpp Refactor backend diagnostics for unsupported features 2016-02-02 13:52:43 +00:00
DiagnosticPrinter.cpp MIR Serialization: Connect the machine function analysis pass to the MIR parser. 2015-06-15 20:30:22 +00:00
DIBuilder.cpp Move the DebugEmissionKind enum from DIBuilder into DICompileUnit. 2016-03-31 23:56:58 +00:00
Dominators.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
Function.cpp IRMover: Steal arguments when moving functions, NFC 2016-04-06 06:38:15 +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 [GCC] Attribute ifunc support in llvm 2016-04-07 12:32:19 +00:00
GVMaterializer.cpp
InlineAsm.cpp Fix SEGV in InlineAsm::ConstraintInfo::Parse. 2015-09-03 15:41:37 +00:00
Instruction.cpp NFC: make AtomicOrdering an enum class 2016-04-06 21:19:33 +00:00
Instructions.cpp NFC: make AtomicOrdering an enum class 2016-04-06 21:19:33 +00:00
IntrinsicInst.cpp IR: Add DbgInfoIntrinsic::getVariableLocation 2016-03-29 18:56:03 +00:00
IRBuilder.cpp Revert "Support arbitrary addrspace pointers in masked load/store intrinsics" 2016-03-22 20:24:34 +00:00
IRPrintingPasses.cpp Recommit r256952 "Filtering IR printing for print-after-all/print-before-all" 2016-01-06 22:55:03 +00:00
LegacyPassManager.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
LLVMBuild.txt
LLVMContext.cpp 80 lines column after renaming "shouldDiscardValueNames" (NFC) 2016-04-02 03:59:58 +00:00
LLVMContextImpl.cpp IR: Use DenseSet instead of DenseMap for ConstantUniqueMap; NFC 2016-04-06 17:56:08 +00:00
LLVMContextImpl.h IR: Move MDStrings to a BumpPtrAllocator 2016-04-06 06:41:54 +00:00
Mangler.cpp Update to use new name alignTo(). 2016-01-14 21:06:47 +00:00
MDBuilder.cpp [MDBuilder] Simplify code using initializer lists. NFC. 2015-11-22 18:03:17 +00:00
Metadata.cpp IR: Lazily create ReplaceableMetadataImpl on MDNode 2016-04-03 21:23:52 +00:00
MetadataImpl.h DI: Disallow uniquable DICompileUnits 2015-08-03 17:26:41 +00:00
Module.cpp [GCC] Attribute ifunc support in llvm 2016-04-07 12:32:19 +00:00
module.modulemap [modules] Add module maps for LLVM. These are not quite ready for prime-time 2014-05-21 02:46:14 +00:00
ModuleSummaryIndex.cpp Add parentheses around && within || to avoid compiler warning message. 2016-04-05 09:07:47 +00:00
Operator.cpp [opaque pointer types] [NFC] GEP: replace get(Pointer)ElementType uses with get{Source,Result}ElementType. 2016-01-19 17:28:00 +00:00
Pass.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
PassManager.cpp [PM] Implement the final conclusion as to how the analysis IDs should 2016-03-11 10:22:49 +00:00
PassRegistry.cpp Revert r231276 (including r231277): Add a lock() function in PassRegistry to speed up multi-thread synchronization. 2015-03-05 17:53:00 +00:00
Statepoint.cpp [Statepoints] Separate out logic for statepoint directives; NFC 2016-03-17 01:56:10 +00:00
SymbolTableListTraitsImpl.h IR: Remove implicit iterator conversions from lib/IR, NFC 2015-10-08 23:49:46 +00:00
Type.cpp [IR] Mark the Type subclass helper methods 'inline' and move their definitions to DerivedTypes.h so they can be inlined by the compiler. 2015-12-25 04:06:20 +00:00
TypeFinder.cpp Re-reapply "[IR] Move optional data in llvm::Function into a hungoff uselist" 2015-12-19 08:52:49 +00:00
Use.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
User.cpp [IR] Teach llvm::User to co-allocate a descriptor. 2015-09-24 01:00:49 +00:00
Value.cpp Don't IPO over functions that can be de-refined 2016-04-08 00:48:30 +00:00
ValueSymbolTable.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
ValueTypes.cpp Add isScalarInteger helper to EVT/MVT 2016-03-01 18:01:28 +00:00
Verifier.cpp Reapply "ValueMapper: Treat LocalAsMetadata more like function-local Values" 2016-04-08 03:13:22 +00:00