clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name PPCMachineFunctionInfo.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/source/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-17/lib/clang/17 -D _DEBUG -D _GLIBCXX_ASSERTIONS -D _GNU_SOURCE -D _LIBCPP_ENABLE_ASSERTIONS -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I lib/Target/PowerPC -I /build/source/llvm/lib/Target/PowerPC -I include -I /build/source/llvm/include -D _FORTIFY_SOURCE=2 -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-17/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/source/= -fcoverage-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/source/= -source-date-epoch 1683717183 -O2 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -Wno-misleading-indentation -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/build/source/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/source/= -ferror-limit 19 -fvisibility=hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2023-05-10-133810-16478-1 -x c++ /build/source/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #include "PPCMachineFunctionInfo.h" |
10 | #include "llvm/ADT/Twine.h" |
11 | #include "llvm/BinaryFormat/XCOFF.h" |
12 | #include "llvm/IR/DataLayout.h" |
13 | #include "llvm/MC/MCContext.h" |
14 | #include "llvm/Support/CommandLine.h" |
15 | |
16 | using namespace llvm; |
17 | static cl::opt<bool> PPCDisableNonVolatileCR( |
18 | "ppc-disable-non-volatile-cr", |
19 | cl::desc("Disable the use of non-volatile CR register fields"), |
20 | cl::init(false), cl::Hidden); |
21 | |
22 | void PPCFunctionInfo::anchor() {} |
23 | PPCFunctionInfo::PPCFunctionInfo(const Function &F, |
24 | const TargetSubtargetInfo *STI) |
25 | : DisableNonVolatileCR(PPCDisableNonVolatileCR) {} |
26 | |
27 | MachineFunctionInfo * |
28 | PPCFunctionInfo::clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, |
29 | const DenseMap<MachineBasicBlock *, MachineBasicBlock *> |
30 | &Src2DstMBB) const { |
31 | return DestMF.cloneInfo<PPCFunctionInfo>(*this); |
32 | } |
33 | |
34 | MCSymbol *PPCFunctionInfo::getPICOffsetSymbol(MachineFunction &MF) const { |
35 | const DataLayout &DL = MF.getDataLayout(); |
36 | return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + |
37 | Twine(MF.getFunctionNumber()) + |
38 | "$poff"); |
39 | } |
40 | |
41 | MCSymbol *PPCFunctionInfo::getGlobalEPSymbol(MachineFunction &MF) const { |
42 | const DataLayout &DL = MF.getDataLayout(); |
43 | return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + |
44 | "func_gep" + |
45 | Twine(MF.getFunctionNumber())); |
46 | } |
47 | |
48 | MCSymbol *PPCFunctionInfo::getLocalEPSymbol(MachineFunction &MF) const { |
49 | const DataLayout &DL = MF.getDataLayout(); |
50 | return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + |
51 | "func_lep" + |
52 | Twine(MF.getFunctionNumber())); |
53 | } |
54 | |
55 | MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol(MachineFunction &MF) const { |
56 | const DataLayout &DL = MF.getDataLayout(); |
57 | return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + |
58 | "func_toc" + |
59 | Twine(MF.getFunctionNumber())); |
60 | } |
61 | |
62 | bool PPCFunctionInfo::isLiveInSExt(Register VReg) const { |
63 | for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs) |
64 | if (LiveIn.first == VReg) |
65 | return LiveIn.second.isSExt(); |
66 | return false; |
67 | } |
68 | |
69 | bool PPCFunctionInfo::isLiveInZExt(Register VReg) const { |
70 | for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs) |
71 | if (LiveIn.first == VReg) |
72 | return LiveIn.second.isZExt(); |
73 | return false; |
74 | } |
75 | |
76 | void PPCFunctionInfo::appendParameterType(ParamType Type) { |
77 | |
78 | ParamtersType.push_back(Type); |
79 | switch (Type) { |
80 | case FixedType: |
81 | ++FixedParmsNum; |
82 | return; |
83 | case ShortFloatingPoint: |
84 | case LongFloatingPoint: |
85 | ++FloatingParmsNum; |
86 | return; |
87 | case VectorChar: |
88 | case VectorShort: |
89 | case VectorInt: |
90 | case VectorFloat: |
91 | ++VectorParmsNum; |
92 | return; |
93 | } |
94 | llvm_unreachable("Error ParamType type."); |
95 | } |
96 | |
97 | uint32_t PPCFunctionInfo::getVecExtParmsType() const { |
98 | |
99 | uint32_t VectExtParamInfo = 0; |
100 | unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType; |
101 | int Bits = 0; |
102 | |
103 | if (!hasVectorParms()) |
| |
104 | return 0; |
105 | |
106 | for (const auto &Elt : ParamtersType) { |
| 2 | | Assuming '__begin1' is equal to '__end1' | |
|
107 | switch (Elt) { |
108 | case VectorChar: |
109 | VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
110 | VectExtParamInfo |= |
111 | XCOFF::TracebackTable::ParmTypeIsVectorCharBit >> ShiftBits; |
112 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
113 | break; |
114 | case VectorShort: |
115 | VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
116 | VectExtParamInfo |= |
117 | XCOFF::TracebackTable::ParmTypeIsVectorShortBit >> ShiftBits; |
118 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
119 | break; |
120 | case VectorInt: |
121 | VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
122 | VectExtParamInfo |= |
123 | XCOFF::TracebackTable::ParmTypeIsVectorIntBit >> ShiftBits; |
124 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
125 | break; |
126 | case VectorFloat: |
127 | VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
128 | VectExtParamInfo |= |
129 | XCOFF::TracebackTable::ParmTypeIsVectorFloatBit >> ShiftBits; |
130 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
131 | break; |
132 | default: |
133 | break; |
134 | } |
135 | |
136 | |
137 | if (Bits >= 32) |
138 | break; |
139 | } |
140 | return Bits < 32 ? VectExtParamInfo << (32 - Bits) : VectExtParamInfo; |
| |
| 4 | | The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'uint32_t' |
|
141 | } |
142 | |
143 | uint32_t PPCFunctionInfo::getParmsType() const { |
144 | uint32_t ParamsTypeInfo = 0; |
145 | unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType; |
146 | |
147 | int Bits = 0; |
148 | for (const auto &Elt : ParamtersType) { |
149 | |
150 | if (Bits > 31 || (Bits > 30 && (Elt != FixedType || hasVectorParms()))) |
151 | break; |
152 | |
153 | switch (Elt) { |
154 | case FixedType: |
155 | if (hasVectorParms()) { |
156 | |
157 | ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
158 | ParamsTypeInfo |= |
159 | XCOFF::TracebackTable::ParmTypeIsFixedBits >> ShiftBits; |
160 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
161 | } else { |
162 | |
163 | ParamsTypeInfo <<= 1; |
164 | ++Bits; |
165 | } |
166 | break; |
167 | case ShortFloatingPoint: |
168 | |
169 | ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
170 | ParamsTypeInfo |= |
171 | XCOFF::TracebackTable::ParmTypeIsFloatingBits >> ShiftBits; |
172 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
173 | break; |
174 | case LongFloatingPoint: |
175 | |
176 | ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
177 | ParamsTypeInfo |= |
178 | XCOFF::TracebackTable::ParmTypeIsDoubleBits >> ShiftBits; |
179 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
180 | break; |
181 | case VectorChar: |
182 | case VectorShort: |
183 | case VectorInt: |
184 | case VectorFloat: |
185 | |
186 | ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType; |
187 | ParamsTypeInfo |= |
188 | XCOFF::TracebackTable::ParmTypeIsVectorBits >> ShiftBits; |
189 | Bits += XCOFF::TracebackTable::WidthOfParamType; |
190 | break; |
191 | } |
192 | } |
193 | |
194 | return Bits < 32 ? ParamsTypeInfo << (32 - Bits) : ParamsTypeInfo; |
195 | } |