2015-06-23 01:48:35 +02:00
|
|
|
//===-------- llvm/IR/Value.def - File that describes Values ---v-*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains descriptions of the various LLVM values. This is
|
|
|
|
// used as a central place for enumerating the different values.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// NOTE: NO INCLUDE GUARD DESIRED!
|
|
|
|
|
|
|
|
// Provide definitions of macros so that users of this file do not have to
|
|
|
|
// define everything to use it...
|
|
|
|
//
|
|
|
|
#if !(defined HANDLE_GLOBAL_VALUE || defined HANDLE_CONSTANT || \
|
|
|
|
defined HANDLE_INSTRUCTION || defined HANDLE_INLINE_ASM_VALUE || \
|
|
|
|
defined HANDLE_METADATA_VALUE || defined HANDLE_VALUE || \
|
[IR] De-virtualize ~Value to save a vptr
Summary:
Implements PR889
Removing the virtual table pointer from Value saves 1% of RSS when doing
LTO of llc on Linux. The impact on time was positive, but too noisy to
conclusively say that performance improved. Here is a link to the
spreadsheet with the original data:
https://docs.google.com/spreadsheets/d/1F4FHir0qYnV0MEp2sYYp_BuvnJgWlWPhWOwZ6LbW7W4/edit?usp=sharing
This change makes it invalid to directly delete a Value, User, or
Instruction pointer. Instead, such code can be rewritten to a null check
and a call Value::deleteValue(). Value objects tend to have their
lifetimes managed through iplist, so for the most part, this isn't a big
deal. However, there are some places where LLVM deletes values, and
those places had to be migrated to deleteValue. I have also created
llvm::unique_value, which has a custom deleter, so it can be used in
place of std::unique_ptr<Value>.
I had to add the "DerivedUser" Deleter escape hatch for MemorySSA, which
derives from User outside of lib/IR. Code in IR cannot include MemorySSA
headers or call the MemoryAccess object destructors without introducing
a circular dependency, so we need some level of indirection.
Unfortunately, no class derived from User may have any virtual methods,
because adding a virtual method would break User::getHungOffOperands(),
which assumes that it can find the use list immediately prior to the
User object. I've added a static_assert to the appropriate OperandTraits
templates to help people avoid this trap.
Reviewers: chandlerc, mehdi_amini, pete, dberlin, george.burgess.iv
Reviewed By: chandlerc
Subscribers: krytarowski, eraman, george.burgess.iv, mzolotukhin, Prazek, nlewycky, hans, inglorion, pcc, tejohnson, dberlin, llvm-commits
Differential Revision: https://reviews.llvm.org/D31261
llvm-svn: 303362
2017-05-18 19:24:10 +02:00
|
|
|
defined HANDLE_CONSTANT_MARKER || defined HANDLE_MEMORY_VALUE)
|
2015-06-23 01:48:35 +02:00
|
|
|
#error "Missing macro definition of HANDLE_VALUE*"
|
|
|
|
#endif
|
|
|
|
|
[IR] De-virtualize ~Value to save a vptr
Summary:
Implements PR889
Removing the virtual table pointer from Value saves 1% of RSS when doing
LTO of llc on Linux. The impact on time was positive, but too noisy to
conclusively say that performance improved. Here is a link to the
spreadsheet with the original data:
https://docs.google.com/spreadsheets/d/1F4FHir0qYnV0MEp2sYYp_BuvnJgWlWPhWOwZ6LbW7W4/edit?usp=sharing
This change makes it invalid to directly delete a Value, User, or
Instruction pointer. Instead, such code can be rewritten to a null check
and a call Value::deleteValue(). Value objects tend to have their
lifetimes managed through iplist, so for the most part, this isn't a big
deal. However, there are some places where LLVM deletes values, and
those places had to be migrated to deleteValue. I have also created
llvm::unique_value, which has a custom deleter, so it can be used in
place of std::unique_ptr<Value>.
I had to add the "DerivedUser" Deleter escape hatch for MemorySSA, which
derives from User outside of lib/IR. Code in IR cannot include MemorySSA
headers or call the MemoryAccess object destructors without introducing
a circular dependency, so we need some level of indirection.
Unfortunately, no class derived from User may have any virtual methods,
because adding a virtual method would break User::getHungOffOperands(),
which assumes that it can find the use list immediately prior to the
User object. I've added a static_assert to the appropriate OperandTraits
templates to help people avoid this trap.
Reviewers: chandlerc, mehdi_amini, pete, dberlin, george.burgess.iv
Reviewed By: chandlerc
Subscribers: krytarowski, eraman, george.burgess.iv, mzolotukhin, Prazek, nlewycky, hans, inglorion, pcc, tejohnson, dberlin, llvm-commits
Differential Revision: https://reviews.llvm.org/D31261
llvm-svn: 303362
2017-05-18 19:24:10 +02:00
|
|
|
#ifndef HANDLE_MEMORY_VALUE
|
|
|
|
#define HANDLE_MEMORY_VALUE(ValueName) HANDLE_VALUE(ValueName)
|
|
|
|
#endif
|
|
|
|
|
2015-06-23 01:48:35 +02:00
|
|
|
#ifndef HANDLE_GLOBAL_VALUE
|
|
|
|
#define HANDLE_GLOBAL_VALUE(ValueName) HANDLE_CONSTANT(ValueName)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HANDLE_CONSTANT
|
|
|
|
#define HANDLE_CONSTANT(ValueName) HANDLE_VALUE(ValueName)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HANDLE_INSTRUCTION
|
|
|
|
#define HANDLE_INSTRUCTION(ValueName) HANDLE_VALUE(ValueName)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HANDLE_INLINE_ASM_VALUE
|
|
|
|
#define HANDLE_INLINE_ASM_VALUE(ValueName) HANDLE_VALUE(ValueName)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HANDLE_METADATA_VALUE
|
|
|
|
#define HANDLE_METADATA_VALUE(ValueName) HANDLE_VALUE(ValueName)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HANDLE_VALUE
|
|
|
|
#define HANDLE_VALUE(ValueName)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HANDLE_CONSTANT_MARKER
|
|
|
|
#define HANDLE_CONSTANT_MARKER(MarkerName, ValueName)
|
|
|
|
#endif
|
|
|
|
|
2017-11-13 21:57:40 +01:00
|
|
|
// Having constant first makes the range check for isa<Constant> faster
|
|
|
|
// and smaller by one operation.
|
2015-06-23 01:48:35 +02:00
|
|
|
|
2017-11-13 21:57:40 +01:00
|
|
|
// Constant
|
2015-06-23 01:48:35 +02:00
|
|
|
HANDLE_GLOBAL_VALUE(Function)
|
|
|
|
HANDLE_GLOBAL_VALUE(GlobalAlias)
|
2016-04-07 14:32:19 +02:00
|
|
|
HANDLE_GLOBAL_VALUE(GlobalIFunc)
|
2015-06-23 01:48:35 +02:00
|
|
|
HANDLE_GLOBAL_VALUE(GlobalVariable)
|
|
|
|
HANDLE_CONSTANT(BlockAddress)
|
|
|
|
HANDLE_CONSTANT(ConstantExpr)
|
2016-04-05 23:10:45 +02:00
|
|
|
|
|
|
|
// ConstantAggregate.
|
2016-02-21 03:39:49 +01:00
|
|
|
HANDLE_CONSTANT(ConstantArray)
|
|
|
|
HANDLE_CONSTANT(ConstantStruct)
|
|
|
|
HANDLE_CONSTANT(ConstantVector)
|
|
|
|
|
|
|
|
// ConstantData.
|
|
|
|
HANDLE_CONSTANT(UndefValue)
|
2015-06-23 01:48:35 +02:00
|
|
|
HANDLE_CONSTANT(ConstantAggregateZero)
|
|
|
|
HANDLE_CONSTANT(ConstantDataArray)
|
|
|
|
HANDLE_CONSTANT(ConstantDataVector)
|
|
|
|
HANDLE_CONSTANT(ConstantInt)
|
|
|
|
HANDLE_CONSTANT(ConstantFP)
|
|
|
|
HANDLE_CONSTANT(ConstantPointerNull)
|
2015-11-11 22:57:16 +01:00
|
|
|
HANDLE_CONSTANT(ConstantTokenNone)
|
2015-06-23 01:48:35 +02:00
|
|
|
|
|
|
|
HANDLE_CONSTANT_MARKER(ConstantFirstVal, Function)
|
2015-11-11 22:57:16 +01:00
|
|
|
HANDLE_CONSTANT_MARKER(ConstantLastVal, ConstantTokenNone)
|
2016-02-21 03:39:49 +01:00
|
|
|
HANDLE_CONSTANT_MARKER(ConstantDataFirstVal, UndefValue)
|
|
|
|
HANDLE_CONSTANT_MARKER(ConstantDataLastVal, ConstantTokenNone)
|
2016-04-05 23:10:45 +02:00
|
|
|
HANDLE_CONSTANT_MARKER(ConstantAggregateFirstVal, ConstantArray)
|
|
|
|
HANDLE_CONSTANT_MARKER(ConstantAggregateLastVal, ConstantVector)
|
2015-06-23 01:48:35 +02:00
|
|
|
|
2017-11-13 21:57:40 +01:00
|
|
|
HANDLE_VALUE(Argument)
|
|
|
|
HANDLE_VALUE(BasicBlock)
|
|
|
|
|
|
|
|
|
|
|
|
HANDLE_METADATA_VALUE(MetadataAsValue)
|
|
|
|
HANDLE_INLINE_ASM_VALUE(InlineAsm)
|
|
|
|
|
|
|
|
// FIXME: It's awkward that Value.def knows about classes in Analysis. While
|
|
|
|
// this doesn't introduce a strict link or include dependency, we should remove
|
|
|
|
// the circular dependency eventually.
|
|
|
|
HANDLE_MEMORY_VALUE(MemoryUse)
|
|
|
|
HANDLE_MEMORY_VALUE(MemoryDef)
|
|
|
|
HANDLE_MEMORY_VALUE(MemoryPhi)
|
|
|
|
|
|
|
|
HANDLE_INSTRUCTION(Instruction)
|
|
|
|
// Enum values starting at InstructionVal are used for Instructions;
|
|
|
|
// don't add new values here!
|
|
|
|
|
[IR] De-virtualize ~Value to save a vptr
Summary:
Implements PR889
Removing the virtual table pointer from Value saves 1% of RSS when doing
LTO of llc on Linux. The impact on time was positive, but too noisy to
conclusively say that performance improved. Here is a link to the
spreadsheet with the original data:
https://docs.google.com/spreadsheets/d/1F4FHir0qYnV0MEp2sYYp_BuvnJgWlWPhWOwZ6LbW7W4/edit?usp=sharing
This change makes it invalid to directly delete a Value, User, or
Instruction pointer. Instead, such code can be rewritten to a null check
and a call Value::deleteValue(). Value objects tend to have their
lifetimes managed through iplist, so for the most part, this isn't a big
deal. However, there are some places where LLVM deletes values, and
those places had to be migrated to deleteValue. I have also created
llvm::unique_value, which has a custom deleter, so it can be used in
place of std::unique_ptr<Value>.
I had to add the "DerivedUser" Deleter escape hatch for MemorySSA, which
derives from User outside of lib/IR. Code in IR cannot include MemorySSA
headers or call the MemoryAccess object destructors without introducing
a circular dependency, so we need some level of indirection.
Unfortunately, no class derived from User may have any virtual methods,
because adding a virtual method would break User::getHungOffOperands(),
which assumes that it can find the use list immediately prior to the
User object. I've added a static_assert to the appropriate OperandTraits
templates to help people avoid this trap.
Reviewers: chandlerc, mehdi_amini, pete, dberlin, george.burgess.iv
Reviewed By: chandlerc
Subscribers: krytarowski, eraman, george.burgess.iv, mzolotukhin, Prazek, nlewycky, hans, inglorion, pcc, tejohnson, dberlin, llvm-commits
Differential Revision: https://reviews.llvm.org/D31261
llvm-svn: 303362
2017-05-18 19:24:10 +02:00
|
|
|
#undef HANDLE_MEMORY_VALUE
|
2015-06-23 01:48:35 +02:00
|
|
|
#undef HANDLE_GLOBAL_VALUE
|
|
|
|
#undef HANDLE_CONSTANT
|
|
|
|
#undef HANDLE_INSTRUCTION
|
|
|
|
#undef HANDLE_METADATA_VALUE
|
|
|
|
#undef HANDLE_INLINE_ASM_VALUE
|
|
|
|
#undef HANDLE_VALUE
|
|
|
|
#undef HANDLE_CONSTANT_MARKER
|