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