Taints the non-acquire RMW's store address with the load part
[oota-llvm.git] / include / llvm / IR / GlobalObject.h
1 //===-- llvm/GlobalObject.h - Class to represent global objects -*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This represents an independent object. That is, a function or a global
11 // variable, but not an alias.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_IR_GLOBALOBJECT_H
16 #define LLVM_IR_GLOBALOBJECT_H
17
18 #include "llvm/IR/Constant.h"
19 #include "llvm/IR/DerivedTypes.h"
20 #include "llvm/IR/GlobalValue.h"
21
22 namespace llvm {
23 class Comdat;
24 class Module;
25
26 class GlobalObject : public GlobalValue {
27   GlobalObject(const GlobalObject &) = delete;
28
29 protected:
30   GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
31                LinkageTypes Linkage, const Twine &Name,
32                unsigned AddressSpace = 0)
33       : GlobalValue(Ty, VTy, Ops, NumOps, Linkage, Name, AddressSpace),
34         ObjComdat(nullptr) {
35     setGlobalValueSubClassData(0);
36   }
37
38   std::string Section;     // Section to emit this into, empty means default
39   Comdat *ObjComdat;
40   static const unsigned AlignmentBits = 5;
41   static const unsigned GlobalObjectSubClassDataBits =
42       GlobalValueSubClassDataBits - AlignmentBits;
43
44 private:
45   static const unsigned AlignmentMask = (1 << AlignmentBits) - 1;
46
47 public:
48   unsigned getAlignment() const {
49     unsigned Data = getGlobalValueSubClassData();
50     unsigned AlignmentData = Data & AlignmentMask;
51     return (1u << AlignmentData) >> 1;
52   }
53   void setAlignment(unsigned Align);
54
55   unsigned getGlobalObjectSubClassData() const;
56   void setGlobalObjectSubClassData(unsigned Val);
57
58   bool hasSection() const { return !StringRef(getSection()).empty(); }
59   const char *getSection() const { return Section.c_str(); }
60   void setSection(StringRef S);
61
62   bool hasComdat() const { return getComdat() != nullptr; }
63   const Comdat *getComdat() const { return ObjComdat; }
64   Comdat *getComdat() { return ObjComdat; }
65   void setComdat(Comdat *C) { ObjComdat = C; }
66
67   void copyAttributesFrom(const GlobalValue *Src) override;
68
69   // Methods for support type inquiry through isa, cast, and dyn_cast:
70   static inline bool classof(const Value *V) {
71     return V->getValueID() == Value::FunctionVal ||
72            V->getValueID() == Value::GlobalVariableVal;
73   }
74 };
75
76 } // End llvm namespace
77
78 #endif