Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 1 | //===- BuildLibCalls.cpp - Utility builder for libcalls -------------------===// |
| 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 file implements some functions that will create standard C libcalls. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/Transforms/Utils/BuildLibCalls.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/SmallString.h" |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/Statistic.h" |
Weiming Zhao | 45d4cb9 | 2015-11-24 18:57:06 +0000 | [diff] [blame] | 17 | #include "llvm/Analysis/TargetLibraryInfo.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 18 | #include "llvm/IR/Constants.h" |
| 19 | #include "llvm/IR/DataLayout.h" |
| 20 | #include "llvm/IR/Function.h" |
| 21 | #include "llvm/IR/IRBuilder.h" |
| 22 | #include "llvm/IR/Intrinsics.h" |
| 23 | #include "llvm/IR/LLVMContext.h" |
| 24 | #include "llvm/IR/Module.h" |
| 25 | #include "llvm/IR/Type.h" |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 26 | |
| 27 | using namespace llvm; |
| 28 | |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 29 | #define DEBUG_TYPE "build-libcalls" |
| 30 | |
| 31 | //- Infer Attributes ---------------------------------------------------------// |
| 32 | |
| 33 | STATISTIC(NumReadNone, "Number of functions inferred as readnone"); |
| 34 | STATISTIC(NumReadOnly, "Number of functions inferred as readonly"); |
| 35 | STATISTIC(NumArgMemOnly, "Number of functions inferred as argmemonly"); |
| 36 | STATISTIC(NumNoUnwind, "Number of functions inferred as nounwind"); |
| 37 | STATISTIC(NumNoCapture, "Number of arguments inferred as nocapture"); |
| 38 | STATISTIC(NumReadOnlyArg, "Number of arguments inferred as readonly"); |
| 39 | STATISTIC(NumNoAlias, "Number of function returns inferred as noalias"); |
| 40 | STATISTIC(NumNonNull, "Number of function returns inferred as nonnull returns"); |
| 41 | |
| 42 | static bool setDoesNotAccessMemory(Function &F) { |
| 43 | if (F.doesNotAccessMemory()) |
| 44 | return false; |
| 45 | F.setDoesNotAccessMemory(); |
| 46 | ++NumReadNone; |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | static bool setOnlyReadsMemory(Function &F) { |
| 51 | if (F.onlyReadsMemory()) |
| 52 | return false; |
| 53 | F.setOnlyReadsMemory(); |
| 54 | ++NumReadOnly; |
| 55 | return true; |
| 56 | } |
| 57 | |
| 58 | static bool setOnlyAccessesArgMemory(Function &F) { |
| 59 | if (F.onlyAccessesArgMemory()) |
| 60 | return false; |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 61 | F.setOnlyAccessesArgMemory(); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 62 | ++NumArgMemOnly; |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | static bool setDoesNotThrow(Function &F) { |
| 67 | if (F.doesNotThrow()) |
| 68 | return false; |
| 69 | F.setDoesNotThrow(); |
| 70 | ++NumNoUnwind; |
| 71 | return true; |
| 72 | } |
| 73 | |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 74 | static bool setRetDoesNotAlias(Function &F) { |
| 75 | if (F.hasAttribute(AttributeList::ReturnIndex, Attribute::NoAlias)) |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 76 | return false; |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 77 | F.addAttribute(AttributeList::ReturnIndex, Attribute::NoAlias); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 78 | ++NumNoAlias; |
| 79 | return true; |
| 80 | } |
| 81 | |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 82 | static bool setDoesNotCapture(Function &F, unsigned ArgNo) { |
| 83 | if (F.hasParamAttribute(ArgNo, Attribute::NoCapture)) |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 84 | return false; |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 85 | F.addParamAttr(ArgNo, Attribute::NoCapture); |
| 86 | ++NumNoCapture; |
| 87 | return true; |
| 88 | } |
| 89 | |
| 90 | static bool setOnlyReadsMemory(Function &F, unsigned ArgNo) { |
| 91 | if (F.hasParamAttribute(ArgNo, Attribute::ReadOnly)) |
| 92 | return false; |
| 93 | F.addParamAttr(ArgNo, Attribute::ReadOnly); |
| 94 | ++NumReadOnlyArg; |
| 95 | return true; |
| 96 | } |
| 97 | |
| 98 | static bool setRetNonNull(Function &F) { |
| 99 | assert(F.getReturnType()->isPointerTy() && |
| 100 | "nonnull applies only to pointers"); |
| 101 | if (F.hasAttribute(AttributeList::ReturnIndex, Attribute::NonNull)) |
| 102 | return false; |
| 103 | F.addAttribute(AttributeList::ReturnIndex, Attribute::NonNull); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 104 | ++NumNonNull; |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 109 | LibFunc TheLibFunc; |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 110 | if (!(TLI.getLibFunc(F, TheLibFunc) && TLI.has(TheLibFunc))) |
| 111 | return false; |
| 112 | |
| 113 | bool Changed = false; |
| 114 | switch (TheLibFunc) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 115 | case LibFunc_strlen: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 116 | Changed |= setOnlyReadsMemory(F); |
| 117 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 118 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 119 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 120 | case LibFunc_strchr: |
| 121 | case LibFunc_strrchr: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 122 | Changed |= setOnlyReadsMemory(F); |
| 123 | Changed |= setDoesNotThrow(F); |
| 124 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 125 | case LibFunc_strtol: |
| 126 | case LibFunc_strtod: |
| 127 | case LibFunc_strtof: |
| 128 | case LibFunc_strtoul: |
| 129 | case LibFunc_strtoll: |
| 130 | case LibFunc_strtold: |
| 131 | case LibFunc_strtoull: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 132 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 133 | Changed |= setDoesNotCapture(F, 1); |
| 134 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 135 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 136 | case LibFunc_strcpy: |
| 137 | case LibFunc_stpcpy: |
| 138 | case LibFunc_strcat: |
| 139 | case LibFunc_strncat: |
| 140 | case LibFunc_strncpy: |
| 141 | case LibFunc_stpncpy: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 142 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 143 | Changed |= setDoesNotCapture(F, 1); |
| 144 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 145 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 146 | case LibFunc_strxfrm: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 147 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 148 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 149 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 150 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 151 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 152 | case LibFunc_strcmp: // 0,1 |
| 153 | case LibFunc_strspn: // 0,1 |
| 154 | case LibFunc_strncmp: // 0,1 |
| 155 | case LibFunc_strcspn: // 0,1 |
| 156 | case LibFunc_strcoll: // 0,1 |
| 157 | case LibFunc_strcasecmp: // 0,1 |
| 158 | case LibFunc_strncasecmp: // |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 159 | Changed |= setOnlyReadsMemory(F); |
| 160 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 161 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 162 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 163 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 164 | case LibFunc_strstr: |
| 165 | case LibFunc_strpbrk: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 166 | Changed |= setOnlyReadsMemory(F); |
| 167 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 168 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 169 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 170 | case LibFunc_strtok: |
| 171 | case LibFunc_strtok_r: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 172 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 173 | Changed |= setDoesNotCapture(F, 1); |
| 174 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 175 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 176 | case LibFunc_scanf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 177 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 178 | Changed |= setDoesNotCapture(F, 0); |
| 179 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 180 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 181 | case LibFunc_setbuf: |
| 182 | case LibFunc_setvbuf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 183 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 184 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 185 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 186 | case LibFunc_strdup: |
| 187 | case LibFunc_strndup: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 188 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 189 | Changed |= setRetDoesNotAlias(F); |
| 190 | Changed |= setDoesNotCapture(F, 0); |
| 191 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 192 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 193 | case LibFunc_stat: |
| 194 | case LibFunc_statvfs: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 195 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 196 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 197 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 198 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 199 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 200 | case LibFunc_sscanf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 201 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 202 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 203 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 204 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 205 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 206 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 207 | case LibFunc_sprintf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 208 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 209 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 210 | Changed |= setDoesNotCapture(F, 1); |
| 211 | Changed |= setOnlyReadsMemory(F, 1); |
| 212 | return Changed; |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 213 | case LibFunc_snprintf: |
| 214 | Changed |= setDoesNotThrow(F); |
| 215 | Changed |= setDoesNotCapture(F, 0); |
| 216 | Changed |= setDoesNotCapture(F, 2); |
| 217 | Changed |= setOnlyReadsMemory(F, 2); |
| 218 | return Changed; |
| 219 | case LibFunc_setitimer: |
| 220 | Changed |= setDoesNotThrow(F); |
| 221 | Changed |= setDoesNotCapture(F, 1); |
| 222 | Changed |= setDoesNotCapture(F, 2); |
| 223 | Changed |= setOnlyReadsMemory(F, 1); |
| 224 | return Changed; |
| 225 | case LibFunc_system: |
| 226 | // May throw; "system" is a valid pthread cancellation point. |
| 227 | Changed |= setDoesNotCapture(F, 0); |
| 228 | Changed |= setOnlyReadsMemory(F, 0); |
| 229 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 230 | case LibFunc_malloc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 231 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 232 | Changed |= setRetDoesNotAlias(F); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 233 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 234 | case LibFunc_memcmp: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 235 | Changed |= setOnlyReadsMemory(F); |
| 236 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 237 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 238 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 239 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 240 | case LibFunc_memchr: |
| 241 | case LibFunc_memrchr: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 242 | Changed |= setOnlyReadsMemory(F); |
| 243 | Changed |= setDoesNotThrow(F); |
| 244 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 245 | case LibFunc_modf: |
| 246 | case LibFunc_modff: |
| 247 | case LibFunc_modfl: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 248 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 249 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 250 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 251 | case LibFunc_memcpy: |
| 252 | case LibFunc_mempcpy: |
| 253 | case LibFunc_memccpy: |
| 254 | case LibFunc_memmove: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 255 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 256 | Changed |= setDoesNotCapture(F, 1); |
| 257 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 258 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 259 | case LibFunc_memcpy_chk: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 260 | Changed |= setDoesNotThrow(F); |
| 261 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 262 | case LibFunc_memalign: |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 263 | Changed |= setRetDoesNotAlias(F); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 264 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 265 | case LibFunc_mkdir: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 266 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 267 | Changed |= setDoesNotCapture(F, 0); |
| 268 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 269 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 270 | case LibFunc_mktime: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 271 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 272 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 273 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 274 | case LibFunc_realloc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 275 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 276 | Changed |= setRetDoesNotAlias(F); |
| 277 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 278 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 279 | case LibFunc_read: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 280 | // May throw; "read" is a valid pthread cancellation point. |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 281 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 282 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 283 | case LibFunc_rewind: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 284 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 285 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 286 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 287 | case LibFunc_rmdir: |
| 288 | case LibFunc_remove: |
| 289 | case LibFunc_realpath: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 290 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 291 | Changed |= setDoesNotCapture(F, 0); |
| 292 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 293 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 294 | case LibFunc_rename: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 295 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 296 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 297 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 298 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 299 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 300 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 301 | case LibFunc_readlink: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 302 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 303 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 304 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 305 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 306 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 307 | case LibFunc_write: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 308 | // May throw; "write" is a valid pthread cancellation point. |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 309 | Changed |= setDoesNotCapture(F, 1); |
| 310 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 311 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 312 | case LibFunc_bcopy: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 313 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 314 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 315 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 316 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 317 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 318 | case LibFunc_bcmp: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 319 | Changed |= setDoesNotThrow(F); |
| 320 | Changed |= setOnlyReadsMemory(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 321 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 322 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 323 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 324 | case LibFunc_bzero: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 325 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 326 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 327 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 328 | case LibFunc_calloc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 329 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 330 | Changed |= setRetDoesNotAlias(F); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 331 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 332 | case LibFunc_chmod: |
| 333 | case LibFunc_chown: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 334 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 335 | Changed |= setDoesNotCapture(F, 0); |
| 336 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 337 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 338 | case LibFunc_ctermid: |
| 339 | case LibFunc_clearerr: |
| 340 | case LibFunc_closedir: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 341 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 342 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 343 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 344 | case LibFunc_atoi: |
| 345 | case LibFunc_atol: |
| 346 | case LibFunc_atof: |
| 347 | case LibFunc_atoll: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 348 | Changed |= setDoesNotThrow(F); |
| 349 | Changed |= setOnlyReadsMemory(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 350 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 351 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 352 | case LibFunc_access: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 353 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 354 | Changed |= setDoesNotCapture(F, 0); |
| 355 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 356 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 357 | case LibFunc_fopen: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 358 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 359 | Changed |= setRetDoesNotAlias(F); |
| 360 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 361 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 362 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 363 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 364 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 365 | case LibFunc_fdopen: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 366 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 367 | Changed |= setRetDoesNotAlias(F); |
| 368 | Changed |= setDoesNotCapture(F, 1); |
| 369 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 370 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 371 | case LibFunc_feof: |
| 372 | case LibFunc_free: |
| 373 | case LibFunc_fseek: |
| 374 | case LibFunc_ftell: |
| 375 | case LibFunc_fgetc: |
| 376 | case LibFunc_fseeko: |
| 377 | case LibFunc_ftello: |
| 378 | case LibFunc_fileno: |
| 379 | case LibFunc_fflush: |
| 380 | case LibFunc_fclose: |
| 381 | case LibFunc_fsetpos: |
| 382 | case LibFunc_flockfile: |
| 383 | case LibFunc_funlockfile: |
| 384 | case LibFunc_ftrylockfile: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 385 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 386 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 387 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 388 | case LibFunc_ferror: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 389 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 390 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 391 | Changed |= setOnlyReadsMemory(F); |
| 392 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 393 | case LibFunc_fputc: |
| 394 | case LibFunc_fstat: |
| 395 | case LibFunc_frexp: |
| 396 | case LibFunc_frexpf: |
| 397 | case LibFunc_frexpl: |
| 398 | case LibFunc_fstatvfs: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 399 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 400 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 401 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 402 | case LibFunc_fgets: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 403 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 404 | Changed |= setDoesNotCapture(F, 2); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 405 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 406 | case LibFunc_fread: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 407 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 408 | Changed |= setDoesNotCapture(F, 0); |
| 409 | Changed |= setDoesNotCapture(F, 3); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 410 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 411 | case LibFunc_fwrite: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 412 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 413 | Changed |= setDoesNotCapture(F, 0); |
| 414 | Changed |= setDoesNotCapture(F, 3); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 415 | // FIXME: readonly #1? |
| 416 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 417 | case LibFunc_fputs: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 418 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 419 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 420 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 421 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 422 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 423 | case LibFunc_fscanf: |
| 424 | case LibFunc_fprintf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 425 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 426 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 427 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 428 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 429 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 430 | case LibFunc_fgetpos: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 431 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 432 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 433 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 434 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 435 | case LibFunc_getc: |
| 436 | case LibFunc_getlogin_r: |
| 437 | case LibFunc_getc_unlocked: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 438 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 439 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 440 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 441 | case LibFunc_getenv: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 442 | Changed |= setDoesNotThrow(F); |
| 443 | Changed |= setOnlyReadsMemory(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 444 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 445 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 446 | case LibFunc_gets: |
| 447 | case LibFunc_getchar: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 448 | Changed |= setDoesNotThrow(F); |
| 449 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 450 | case LibFunc_getitimer: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 451 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 452 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 453 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 454 | case LibFunc_getpwnam: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 455 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 456 | Changed |= setDoesNotCapture(F, 0); |
| 457 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 458 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 459 | case LibFunc_ungetc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 460 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 461 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 462 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 463 | case LibFunc_uname: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 464 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 465 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 466 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 467 | case LibFunc_unlink: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 468 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 469 | Changed |= setDoesNotCapture(F, 0); |
| 470 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 471 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 472 | case LibFunc_unsetenv: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 473 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 474 | Changed |= setDoesNotCapture(F, 0); |
| 475 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 476 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 477 | case LibFunc_utime: |
| 478 | case LibFunc_utimes: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 479 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 480 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 481 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 482 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 483 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 484 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 485 | case LibFunc_putc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 486 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 487 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 488 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 489 | case LibFunc_puts: |
| 490 | case LibFunc_printf: |
| 491 | case LibFunc_perror: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 492 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 493 | Changed |= setDoesNotCapture(F, 0); |
| 494 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 495 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 496 | case LibFunc_pread: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 497 | // May throw; "pread" is a valid pthread cancellation point. |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 498 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 499 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 500 | case LibFunc_pwrite: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 501 | // May throw; "pwrite" is a valid pthread cancellation point. |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 502 | Changed |= setDoesNotCapture(F, 1); |
| 503 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 504 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 505 | case LibFunc_putchar: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 506 | Changed |= setDoesNotThrow(F); |
| 507 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 508 | case LibFunc_popen: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 509 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 510 | Changed |= setRetDoesNotAlias(F); |
| 511 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 512 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 513 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 514 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 515 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 516 | case LibFunc_pclose: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 517 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 518 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 519 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 520 | case LibFunc_vscanf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 521 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 522 | Changed |= setDoesNotCapture(F, 0); |
| 523 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 524 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 525 | case LibFunc_vsscanf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 526 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 527 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 528 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 529 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 530 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 531 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 532 | case LibFunc_vfscanf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 533 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 534 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 535 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 536 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 537 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 538 | case LibFunc_valloc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 539 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 540 | Changed |= setRetDoesNotAlias(F); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 541 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 542 | case LibFunc_vprintf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 543 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 544 | Changed |= setDoesNotCapture(F, 0); |
| 545 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 546 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 547 | case LibFunc_vfprintf: |
| 548 | case LibFunc_vsprintf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 549 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 550 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 551 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 552 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 553 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 554 | case LibFunc_vsnprintf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 555 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 556 | Changed |= setDoesNotCapture(F, 0); |
| 557 | Changed |= setDoesNotCapture(F, 2); |
| 558 | Changed |= setOnlyReadsMemory(F, 2); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 559 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 560 | case LibFunc_open: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 561 | // May throw; "open" is a valid pthread cancellation point. |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 562 | Changed |= setDoesNotCapture(F, 0); |
| 563 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 564 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 565 | case LibFunc_opendir: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 566 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 567 | Changed |= setRetDoesNotAlias(F); |
| 568 | Changed |= setDoesNotCapture(F, 0); |
| 569 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 570 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 571 | case LibFunc_tmpfile: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 572 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 573 | Changed |= setRetDoesNotAlias(F); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 574 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 575 | case LibFunc_times: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 576 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 577 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 578 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 579 | case LibFunc_htonl: |
| 580 | case LibFunc_htons: |
| 581 | case LibFunc_ntohl: |
| 582 | case LibFunc_ntohs: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 583 | Changed |= setDoesNotThrow(F); |
| 584 | Changed |= setDoesNotAccessMemory(F); |
| 585 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 586 | case LibFunc_lstat: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 587 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 588 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 589 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 590 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 591 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 592 | case LibFunc_lchown: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 593 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 594 | Changed |= setDoesNotCapture(F, 0); |
| 595 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 596 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 597 | case LibFunc_qsort: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 598 | // May throw; places call through function pointer. |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 599 | Changed |= setDoesNotCapture(F, 3); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 600 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 601 | case LibFunc_dunder_strdup: |
| 602 | case LibFunc_dunder_strndup: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 603 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 604 | Changed |= setRetDoesNotAlias(F); |
| 605 | Changed |= setDoesNotCapture(F, 0); |
| 606 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 607 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 608 | case LibFunc_dunder_strtok_r: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 609 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 610 | Changed |= setDoesNotCapture(F, 1); |
| 611 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 612 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 613 | case LibFunc_under_IO_getc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 614 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 615 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 616 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 617 | case LibFunc_under_IO_putc: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 618 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 619 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 620 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 621 | case LibFunc_dunder_isoc99_scanf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 622 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 623 | Changed |= setDoesNotCapture(F, 0); |
| 624 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 625 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 626 | case LibFunc_stat64: |
| 627 | case LibFunc_lstat64: |
| 628 | case LibFunc_statvfs64: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 629 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 630 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 631 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 632 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 633 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 634 | case LibFunc_dunder_isoc99_sscanf: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 635 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 636 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 637 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 638 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 639 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 640 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 641 | case LibFunc_fopen64: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 642 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 643 | Changed |= setRetDoesNotAlias(F); |
| 644 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 645 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 646 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 647 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 648 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 649 | case LibFunc_fseeko64: |
| 650 | case LibFunc_ftello64: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 651 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 652 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 653 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 654 | case LibFunc_tmpfile64: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 655 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 656 | Changed |= setRetDoesNotAlias(F); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 657 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 658 | case LibFunc_fstat64: |
| 659 | case LibFunc_fstatvfs64: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 660 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 661 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 662 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 663 | case LibFunc_open64: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 664 | // May throw; "open" is a valid pthread cancellation point. |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 665 | Changed |= setDoesNotCapture(F, 0); |
| 666 | Changed |= setOnlyReadsMemory(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 667 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 668 | case LibFunc_gettimeofday: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 669 | // Currently some platforms have the restrict keyword on the arguments to |
| 670 | // gettimeofday. To be conservative, do not add noalias to gettimeofday's |
| 671 | // arguments. |
| 672 | Changed |= setDoesNotThrow(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 673 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 674 | Changed |= setDoesNotCapture(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 675 | return Changed; |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 676 | case LibFunc_Znwj: // new(unsigned int) |
| 677 | case LibFunc_Znwm: // new(unsigned long) |
| 678 | case LibFunc_Znaj: // new[](unsigned int) |
| 679 | case LibFunc_Znam: // new[](unsigned long) |
| 680 | case LibFunc_msvc_new_int: // new(unsigned int) |
| 681 | case LibFunc_msvc_new_longlong: // new(unsigned long long) |
| 682 | case LibFunc_msvc_new_array_int: // new[](unsigned int) |
| 683 | case LibFunc_msvc_new_array_longlong: // new[](unsigned long long) |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 684 | // Operator new always returns a nonnull noalias pointer |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 685 | Changed |= setRetNonNull(F); |
| 686 | Changed |= setRetDoesNotAlias(F); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 687 | return Changed; |
| 688 | //TODO: add LibFunc entries for: |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 689 | //case LibFunc_memset_pattern4: |
| 690 | //case LibFunc_memset_pattern8: |
| 691 | case LibFunc_memset_pattern16: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 692 | Changed |= setOnlyAccessesArgMemory(F); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 693 | Changed |= setDoesNotCapture(F, 0); |
Ahmed Bougacha | 44c1987 | 2016-04-27 19:04:43 +0000 | [diff] [blame] | 694 | Changed |= setDoesNotCapture(F, 1); |
Reid Kleckner | a0b45f4 | 2017-05-03 18:17:31 +0000 | [diff] [blame^] | 695 | Changed |= setOnlyReadsMemory(F, 1); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 696 | return Changed; |
| 697 | // int __nvvm_reflect(const char *) |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 698 | case LibFunc_nvvm_reflect: |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 699 | Changed |= setDoesNotAccessMemory(F); |
| 700 | Changed |= setDoesNotThrow(F); |
| 701 | return Changed; |
| 702 | |
| 703 | default: |
| 704 | // FIXME: It'd be really nice to cover all the library functions we're |
| 705 | // aware of here. |
| 706 | return false; |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | //- Emit LibCalls ------------------------------------------------------------// |
| 711 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 712 | Value *llvm::castToCStr(Value *V, IRBuilder<> &B) { |
Matt Arsenault | be55888 | 2014-04-23 20:58:57 +0000 | [diff] [blame] | 713 | unsigned AS = V->getType()->getPointerAddressSpace(); |
| 714 | return B.CreateBitCast(V, B.getInt8PtrTy(AS), "cstr"); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 715 | } |
| 716 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 717 | Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 718 | const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 719 | if (!TLI->has(LibFunc_strlen)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 720 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 721 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 722 | Module *M = B.GetInsertBlock()->getModule(); |
Chandler Carruth | 7ec5085 | 2012-11-01 08:07:29 +0000 | [diff] [blame] | 723 | LLVMContext &Context = B.GetInsertBlock()->getContext(); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 724 | Constant *StrLen = M->getOrInsertFunction("strlen", DL.getIntPtrType(Context), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 725 | B.getInt8PtrTy()); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 726 | inferLibFuncAttributes(*M->getFunction("strlen"), *TLI); |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 727 | CallInst *CI = B.CreateCall(StrLen, castToCStr(Ptr, B), "strlen"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 728 | if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts())) |
| 729 | CI->setCallingConv(F->getCallingConv()); |
| 730 | |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 731 | return CI; |
| 732 | } |
| 733 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 734 | Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 735 | const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 736 | if (!TLI->has(LibFunc_strchr)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 737 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 738 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 739 | Module *M = B.GetInsertBlock()->getModule(); |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 740 | Type *I8Ptr = B.getInt8PtrTy(); |
| 741 | Type *I32Ty = B.getInt32Ty(); |
Mehdi Amini | db11fdf | 2017-04-06 20:23:57 +0000 | [diff] [blame] | 742 | Constant *StrChr = |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 743 | M->getOrInsertFunction("strchr", I8Ptr, I8Ptr, I32Ty); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 744 | inferLibFuncAttributes(*M->getFunction("strchr"), *TLI); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 745 | CallInst *CI = B.CreateCall( |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 746 | StrChr, {castToCStr(Ptr, B), ConstantInt::get(I32Ty, C)}, "strchr"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 747 | if (const Function *F = dyn_cast<Function>(StrChr->stripPointerCasts())) |
| 748 | CI->setCallingConv(F->getCallingConv()); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 749 | return CI; |
| 750 | } |
| 751 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 752 | Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 753 | const DataLayout &DL, const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 754 | if (!TLI->has(LibFunc_strncmp)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 755 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 756 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 757 | Module *M = B.GetInsertBlock()->getModule(); |
Chandler Carruth | 7ec5085 | 2012-11-01 08:07:29 +0000 | [diff] [blame] | 758 | LLVMContext &Context = B.GetInsertBlock()->getContext(); |
Mehdi Amini | db11fdf | 2017-04-06 20:23:57 +0000 | [diff] [blame] | 759 | Value *StrNCmp = M->getOrInsertFunction("strncmp", B.getInt32Ty(), |
| 760 | B.getInt8PtrTy(), B.getInt8PtrTy(), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 761 | DL.getIntPtrType(Context)); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 762 | inferLibFuncAttributes(*M->getFunction("strncmp"), *TLI); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 763 | CallInst *CI = B.CreateCall( |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 764 | StrNCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "strncmp"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 765 | |
| 766 | if (const Function *F = dyn_cast<Function>(StrNCmp->stripPointerCasts())) |
| 767 | CI->setCallingConv(F->getCallingConv()); |
| 768 | |
Benjamin Kramer | 1118860 | 2010-06-15 21:34:25 +0000 | [diff] [blame] | 769 | return CI; |
| 770 | } |
| 771 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 772 | Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 773 | const TargetLibraryInfo *TLI, StringRef Name) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 774 | if (!TLI->has(LibFunc_strcpy)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 775 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 776 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 777 | Module *M = B.GetInsertBlock()->getModule(); |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 778 | Type *I8Ptr = B.getInt8PtrTy(); |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 779 | Value *StrCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 780 | inferLibFuncAttributes(*M->getFunction(Name), *TLI); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 781 | CallInst *CI = |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 782 | B.CreateCall(StrCpy, {castToCStr(Dst, B), castToCStr(Src, B)}, Name); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 783 | if (const Function *F = dyn_cast<Function>(StrCpy->stripPointerCasts())) |
| 784 | CI->setCallingConv(F->getCallingConv()); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 785 | return CI; |
| 786 | } |
| 787 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 788 | Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 789 | const TargetLibraryInfo *TLI, StringRef Name) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 790 | if (!TLI->has(LibFunc_strncpy)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 791 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 792 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 793 | Module *M = B.GetInsertBlock()->getModule(); |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 794 | Type *I8Ptr = B.getInt8PtrTy(); |
Mehdi Amini | db11fdf | 2017-04-06 20:23:57 +0000 | [diff] [blame] | 795 | Value *StrNCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr, |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 796 | Len->getType()); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 797 | inferLibFuncAttributes(*M->getFunction(Name), *TLI); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 798 | CallInst *CI = B.CreateCall( |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 799 | StrNCpy, {castToCStr(Dst, B), castToCStr(Src, B), Len}, "strncpy"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 800 | if (const Function *F = dyn_cast<Function>(StrNCpy->stripPointerCasts())) |
| 801 | CI->setCallingConv(F->getCallingConv()); |
Eric Christopher | 43dc11c | 2010-03-11 01:25:07 +0000 | [diff] [blame] | 802 | return CI; |
| 803 | } |
| 804 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 805 | Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 806 | IRBuilder<> &B, const DataLayout &DL, |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 807 | const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 808 | if (!TLI->has(LibFunc_memcpy_chk)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 809 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 810 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 811 | Module *M = B.GetInsertBlock()->getModule(); |
Reid Kleckner | b518054 | 2017-03-21 16:57:19 +0000 | [diff] [blame] | 812 | AttributeList AS; |
| 813 | AS = AttributeList::get(M->getContext(), AttributeList::FunctionIndex, |
| 814 | Attribute::NoUnwind); |
Chandler Carruth | 7ec5085 | 2012-11-01 08:07:29 +0000 | [diff] [blame] | 815 | LLVMContext &Context = B.GetInsertBlock()->getContext(); |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 816 | Value *MemCpy = M->getOrInsertFunction( |
Reid Kleckner | b518054 | 2017-03-21 16:57:19 +0000 | [diff] [blame] | 817 | "__memcpy_chk", AttributeList::get(M->getContext(), AS), B.getInt8PtrTy(), |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 818 | B.getInt8PtrTy(), B.getInt8PtrTy(), DL.getIntPtrType(Context), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 819 | DL.getIntPtrType(Context)); |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 820 | Dst = castToCStr(Dst, B); |
| 821 | Src = castToCStr(Src, B); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 822 | CallInst *CI = B.CreateCall(MemCpy, {Dst, Src, Len, ObjSize}); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 823 | if (const Function *F = dyn_cast<Function>(MemCpy->stripPointerCasts())) |
| 824 | CI->setCallingConv(F->getCallingConv()); |
Evan Cheng | d9e8223 | 2010-03-23 15:48:04 +0000 | [diff] [blame] | 825 | return CI; |
| 826 | } |
| 827 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 828 | Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 829 | const DataLayout &DL, const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 830 | if (!TLI->has(LibFunc_memchr)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 831 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 832 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 833 | Module *M = B.GetInsertBlock()->getModule(); |
Chandler Carruth | 7ec5085 | 2012-11-01 08:07:29 +0000 | [diff] [blame] | 834 | LLVMContext &Context = B.GetInsertBlock()->getContext(); |
Mehdi Amini | db11fdf | 2017-04-06 20:23:57 +0000 | [diff] [blame] | 835 | Value *MemChr = M->getOrInsertFunction("memchr", B.getInt8PtrTy(), |
| 836 | B.getInt8PtrTy(), B.getInt32Ty(), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 837 | DL.getIntPtrType(Context)); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 838 | inferLibFuncAttributes(*M->getFunction("memchr"), *TLI); |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 839 | CallInst *CI = B.CreateCall(MemChr, {castToCStr(Ptr, B), Val, Len}, "memchr"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 840 | |
| 841 | if (const Function *F = dyn_cast<Function>(MemChr->stripPointerCasts())) |
| 842 | CI->setCallingConv(F->getCallingConv()); |
| 843 | |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 844 | return CI; |
| 845 | } |
| 846 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 847 | Value *llvm::emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 848 | const DataLayout &DL, const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 849 | if (!TLI->has(LibFunc_memcmp)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 850 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 851 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 852 | Module *M = B.GetInsertBlock()->getModule(); |
Chandler Carruth | 7ec5085 | 2012-11-01 08:07:29 +0000 | [diff] [blame] | 853 | LLVMContext &Context = B.GetInsertBlock()->getContext(); |
Mehdi Amini | db11fdf | 2017-04-06 20:23:57 +0000 | [diff] [blame] | 854 | Value *MemCmp = M->getOrInsertFunction("memcmp", B.getInt32Ty(), |
| 855 | B.getInt8PtrTy(), B.getInt8PtrTy(), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 856 | DL.getIntPtrType(Context)); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 857 | inferLibFuncAttributes(*M->getFunction("memcmp"), *TLI); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 858 | CallInst *CI = B.CreateCall( |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 859 | MemCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "memcmp"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 860 | |
| 861 | if (const Function *F = dyn_cast<Function>(MemCmp->stripPointerCasts())) |
| 862 | CI->setCallingConv(F->getCallingConv()); |
| 863 | |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 864 | return CI; |
| 865 | } |
| 866 | |
Yi Jiang | 6ab044e | 2013-12-16 22:42:40 +0000 | [diff] [blame] | 867 | /// Append a suffix to the function name according to the type of 'Op'. |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 868 | static void appendTypeSuffix(Value *Op, StringRef &Name, |
Sanjay Patel | b50325e | 2016-01-19 19:17:47 +0000 | [diff] [blame] | 869 | SmallString<20> &NameBuffer) { |
Yi Jiang | 6ab044e | 2013-12-16 22:42:40 +0000 | [diff] [blame] | 870 | if (!Op->getType()->isDoubleTy()) { |
| 871 | NameBuffer += Name; |
| 872 | |
| 873 | if (Op->getType()->isFloatTy()) |
| 874 | NameBuffer += 'f'; |
| 875 | else |
| 876 | NameBuffer += 'l'; |
| 877 | |
| 878 | Name = NameBuffer; |
| 879 | } |
Yi Jiang | 6ab044e | 2013-12-16 22:42:40 +0000 | [diff] [blame] | 880 | } |
| 881 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 882 | Value *llvm::emitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B, |
Reid Kleckner | b518054 | 2017-03-21 16:57:19 +0000 | [diff] [blame] | 883 | const AttributeList &Attrs) { |
Benjamin Kramer | b106bcc | 2011-11-15 19:12:09 +0000 | [diff] [blame] | 884 | SmallString<20> NameBuffer; |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 885 | appendTypeSuffix(Op, Name, NameBuffer); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 886 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 887 | Module *M = B.GetInsertBlock()->getModule(); |
Mehdi Amini | db11fdf | 2017-04-06 20:23:57 +0000 | [diff] [blame] | 888 | Value *Callee = M->getOrInsertFunction(Name, Op->getType(), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 889 | Op->getType()); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 890 | CallInst *CI = B.CreateCall(Callee, Op, Name); |
Matt Arsenault | 6a288c1 | 2017-05-03 02:26:10 +0000 | [diff] [blame] | 891 | |
| 892 | // The incoming attribute set may have come from a speculatable intrinsic, but |
| 893 | // is being replaced with a library call which is not allowed to be |
| 894 | // speculatable. |
| 895 | CI->setAttributes(Attrs.removeAttribute(B.getContext(), |
| 896 | AttributeList::FunctionIndex, |
| 897 | Attribute::Speculatable)); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 898 | if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts())) |
| 899 | CI->setCallingConv(F->getCallingConv()); |
| 900 | |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 901 | return CI; |
| 902 | } |
| 903 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 904 | Value *llvm::emitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name, |
Reid Kleckner | b518054 | 2017-03-21 16:57:19 +0000 | [diff] [blame] | 905 | IRBuilder<> &B, const AttributeList &Attrs) { |
Yi Jiang | 6ab044e | 2013-12-16 22:42:40 +0000 | [diff] [blame] | 906 | SmallString<20> NameBuffer; |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 907 | appendTypeSuffix(Op1, Name, NameBuffer); |
Yi Jiang | 6ab044e | 2013-12-16 22:42:40 +0000 | [diff] [blame] | 908 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 909 | Module *M = B.GetInsertBlock()->getModule(); |
Sanjay Patel | b50325e | 2016-01-19 19:17:47 +0000 | [diff] [blame] | 910 | Value *Callee = M->getOrInsertFunction(Name, Op1->getType(), Op1->getType(), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 911 | Op2->getType()); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 912 | CallInst *CI = B.CreateCall(Callee, {Op1, Op2}, Name); |
Yi Jiang | 6ab044e | 2013-12-16 22:42:40 +0000 | [diff] [blame] | 913 | CI->setAttributes(Attrs); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 914 | if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts())) |
| 915 | CI->setCallingConv(F->getCallingConv()); |
| 916 | |
Yi Jiang | 6ab044e | 2013-12-16 22:42:40 +0000 | [diff] [blame] | 917 | return CI; |
| 918 | } |
| 919 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 920 | Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B, |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 921 | const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 922 | if (!TLI->has(LibFunc_putchar)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 923 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 924 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 925 | Module *M = B.GetInsertBlock()->getModule(); |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 926 | Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(), B.getInt32Ty()); |
Craig Topper | 0f5063c | 2017-03-17 23:48:02 +0000 | [diff] [blame] | 927 | inferLibFuncAttributes(*M->getFunction("putchar"), *TLI); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 928 | CallInst *CI = B.CreateCall(PutChar, |
| 929 | B.CreateIntCast(Char, |
| 930 | B.getInt32Ty(), |
| 931 | /*isSigned*/true, |
| 932 | "chari"), |
| 933 | "putchar"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 934 | |
| 935 | if (const Function *F = dyn_cast<Function>(PutChar->stripPointerCasts())) |
| 936 | CI->setCallingConv(F->getCallingConv()); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 937 | return CI; |
| 938 | } |
| 939 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 940 | Value *llvm::emitPutS(Value *Str, IRBuilder<> &B, |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 941 | const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 942 | if (!TLI->has(LibFunc_puts)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 943 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 944 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 945 | Module *M = B.GetInsertBlock()->getModule(); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 946 | Value *PutS = |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 947 | M->getOrInsertFunction("puts", B.getInt32Ty(), B.getInt8PtrTy()); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 948 | inferLibFuncAttributes(*M->getFunction("puts"), *TLI); |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 949 | CallInst *CI = B.CreateCall(PutS, castToCStr(Str, B), "puts"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 950 | if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts())) |
| 951 | CI->setCallingConv(F->getCallingConv()); |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 952 | return CI; |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 953 | } |
| 954 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 955 | Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 956 | const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 957 | if (!TLI->has(LibFunc_fputc)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 958 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 959 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 960 | Module *M = B.GetInsertBlock()->getModule(); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 961 | Constant *F = M->getOrInsertFunction("fputc", B.getInt32Ty(), B.getInt32Ty(), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 962 | File->getType()); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 963 | if (File->getType()->isPointerTy()) |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 964 | inferLibFuncAttributes(*M->getFunction("fputc"), *TLI); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 965 | Char = B.CreateIntCast(Char, B.getInt32Ty(), /*isSigned*/true, |
| 966 | "chari"); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 967 | CallInst *CI = B.CreateCall(F, {Char, File}, "fputc"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 968 | |
| 969 | if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts())) |
| 970 | CI->setCallingConv(Fn->getCallingConv()); |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 971 | return CI; |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 974 | Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 975 | const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 976 | if (!TLI->has(LibFunc_fputs)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 977 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 978 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 979 | Module *M = B.GetInsertBlock()->getModule(); |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 980 | StringRef FPutsName = TLI->getName(LibFunc_fputs); |
Mehdi Amini | db11fdf | 2017-04-06 20:23:57 +0000 | [diff] [blame] | 981 | Constant *F = M->getOrInsertFunction( |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 982 | FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType()); |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 983 | if (File->getType()->isPointerTy()) |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 984 | inferLibFuncAttributes(*M->getFunction(FPutsName), *TLI); |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 985 | CallInst *CI = B.CreateCall(F, {castToCStr(Str, B), File}, "fputs"); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 986 | |
| 987 | if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts())) |
| 988 | CI->setCallingConv(Fn->getCallingConv()); |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 989 | return CI; |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 990 | } |
| 991 | |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 992 | Value *llvm::emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B, |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 993 | const DataLayout &DL, const TargetLibraryInfo *TLI) { |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 994 | if (!TLI->has(LibFunc_fwrite)) |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 995 | return nullptr; |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 996 | |
Sanjay Patel | d4af297 | 2016-01-19 19:58:49 +0000 | [diff] [blame] | 997 | Module *M = B.GetInsertBlock()->getModule(); |
Chandler Carruth | 7ec5085 | 2012-11-01 08:07:29 +0000 | [diff] [blame] | 998 | LLVMContext &Context = B.GetInsertBlock()->getContext(); |
David L. Jones | d21529f | 2017-01-23 23:16:46 +0000 | [diff] [blame] | 999 | StringRef FWriteName = TLI->getName(LibFunc_fwrite); |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 1000 | Constant *F = M->getOrInsertFunction( |
| 1001 | FWriteName, DL.getIntPtrType(Context), B.getInt8PtrTy(), |
Serge Guelton | 59a2d7b | 2017-04-11 15:01:18 +0000 | [diff] [blame] | 1002 | DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType()); |
| 1003 | |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 1004 | if (File->getType()->isPointerTy()) |
Ahmed Bougacha | b0624a2 | 2016-04-27 19:04:40 +0000 | [diff] [blame] | 1005 | inferLibFuncAttributes(*M->getFunction(FWriteName), *TLI); |
Mehdi Amini | a28d91d | 2015-03-10 02:37:25 +0000 | [diff] [blame] | 1006 | CallInst *CI = |
Sanjay Patel | d3112a5 | 2016-01-19 19:46:10 +0000 | [diff] [blame] | 1007 | B.CreateCall(F, {castToCStr(Ptr, B), Size, |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 1008 | ConstantInt::get(DL.getIntPtrType(Context), 1), File}); |
Evan Cheng | ad6efbf | 2014-03-12 18:09:37 +0000 | [diff] [blame] | 1009 | |
| 1010 | if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts())) |
| 1011 | CI->setCallingConv(Fn->getCallingConv()); |
Nuno Lopes | 89702e9 | 2012-07-25 16:46:31 +0000 | [diff] [blame] | 1012 | return CI; |
Eric Christopher | 87abfc5 | 2010-03-05 22:25:30 +0000 | [diff] [blame] | 1013 | } |