Stop lying about pointers' required alignments.

These extra specializations were added in the depths of history (r67984 from
2009) and are clearly problematic now. The pointers actually are aligned to the
default (8 bytes), since otherwise UBsan would be complaining loudly.

I *think* it originally made sense because there was no "alignof" to infer the
correct value so the generic case went with what malloc returned (8-byte
aliged objects), and on 32-bit machines this specialization was correct. It
became wrong when we started compiling for 64-bit, and caused a UBSan failure
when we tried to put a ValueHandle into a DenseMap.

Should fix the Green Dragon UBSan bot.

llvm-svn: 289496
This commit is contained in:
Tim Northover 2016-12-12 23:29:07 +00:00
parent 681e904419
commit d82cc61744
4 changed files with 0 additions and 53 deletions

View File

@ -599,21 +599,6 @@ private:
Instruction *cloneImpl() const;
};
// Instruction* is only 4-byte aligned.
template<>
class PointerLikeTypeTraits<Instruction*> {
typedef Instruction* PT;
public:
static inline void *getAsVoidPointer(PT P) { return P; }
static inline PT getFromVoidPointer(void *P) {
return static_cast<PT>(P);
}
enum { NumLowBitsAvailable = 2 };
};
} // end namespace llvm
#endif // LLVM_IR_INSTRUCTION_H

View File

@ -36,18 +36,6 @@ class User;
class Use;
template <typename> struct simplify_type;
// Use** is only 4-byte aligned.
template <> class PointerLikeTypeTraits<Use **> {
public:
static inline void *getAsVoidPointer(Use **P) { return P; }
static inline Use **getFromVoidPointer(void *P) {
return static_cast<Use **>(P);
}
enum { NumLowBitsAvailable = 2 };
};
/// \brief A Use represents the edge between a Value definition and its users.
///
/// This is notionally a two-dimensional linked list. It supports traversing

View File

@ -793,21 +793,6 @@ template <> struct isa_impl<GlobalObject, Value> {
}
};
// Value* is only 4-byte aligned.
template<>
class PointerLikeTypeTraits<Value*> {
typedef Value* PT;
public:
static inline void *getAsVoidPointer(PT P) { return P; }
static inline PT getFromVoidPointer(void *P) {
return static_cast<PT>(P);
}
enum { NumLowBitsAvailable = 2 };
};
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_ISA_CONVERSION_FUNCTIONS(Value, LLVMValueRef)

View File

@ -22,17 +22,6 @@ namespace llvm {
class ValueHandleBase;
template<typename From> struct simplify_type;
// ValueHandleBase** is only 4-byte aligned.
template<>
class PointerLikeTypeTraits<ValueHandleBase**> {
public:
static inline void *getAsVoidPointer(ValueHandleBase** P) { return P; }
static inline ValueHandleBase **getFromVoidPointer(void *P) {
return static_cast<ValueHandleBase**>(P);
}
enum { NumLowBitsAvailable = 2 };
};
/// \brief This is the common base class of value handles.
///
/// ValueHandle's are smart pointers to Value's that have special behavior when