[llvm] r235770 - IR: Use a bitmask to access GlobalObject subclass data
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Apr 24 13:47:23 PDT 2015
Author: dexonsmith
Date: Fri Apr 24 15:47:23 2015
New Revision: 235770
URL: http://llvm.org/viewvc/llvm-project?rev=235770&view=rev
Log:
IR: Use a bitmask to access GlobalObject subclass data
Make room for more than just `Function::isMaterializable()` in the
`GlobalObject` subclass data bitfield. Since we're treating it like a
bitfield, change `Function::Function()` to zero-out the whole thing.
Modified:
llvm/trunk/include/llvm/IR/Function.h
llvm/trunk/lib/IR/Function.cpp
Modified: llvm/trunk/include/llvm/IR/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Function.h?rev=235770&r1=235769&r2=235770&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Function.h (original)
+++ llvm/trunk/include/llvm/IR/Function.h Fri Apr 24 15:47:23 2015
@@ -77,6 +77,16 @@ private:
* bit 3-6: CallingConvention
*/
+ /// Bits from GlobalObject::GlobalObjectSubclassData.
+ enum {
+ /// Whether this function is materializable.
+ IsMaterializableBit = 1 << 0
+ };
+ void setGlobalObjectBit(unsigned Mask, bool Value) {
+ setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
+ (Value ? Mask : 0u));
+ }
+
friend class SymbolTableListTraits<Function, Module>;
void setParent(Module *parent);
Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=235770&r1=235769&r2=235770&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Fri Apr 24 15:47:23 2015
@@ -206,10 +206,12 @@ void Argument::removeAttr(AttributeSet A
//===----------------------------------------------------------------------===//
bool Function::isMaterializable() const {
- return getGlobalObjectSubClassData();
+ return getGlobalObjectSubClassData() & IsMaterializableBit;
}
-void Function::setIsMaterializable(bool V) { setGlobalObjectSubClassData(V); }
+void Function::setIsMaterializable(bool V) {
+ setGlobalObjectBit(IsMaterializableBit, V);
+}
LLVMContext &Function::getContext() const {
return getType()->getContext();
@@ -244,7 +246,7 @@ Function::Function(FunctionType *Ty, Lin
Ty(Ty) {
assert(FunctionType::isValidReturnType(getReturnType()) &&
"invalid return type");
- setIsMaterializable(false);
+ setGlobalObjectSubClassData(0);
SymTab = new ValueSymbolTable();
// If the function has arguments, mark them as lazily built.
More information about the llvm-commits
mailing list