llvm.org GIT mirror llvm / 7597e7f
Add, and infer, a nofree function attribute This patch adds a function attribute, nofree, to indicate that a function does not, directly or indirectly, call a memory-deallocation function (e.g., free, C++'s operator delete). Reviewers: jdoerfert Differential Revision: https://reviews.llvm.org/D49165 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365336 91177308-0d34-0410-b5e6-96231b3b80d8 Brian Homerding a month ago
30 changed file(s) with 596 addition(s) and 334 deletion(s). Raw diff Collapse all Expand all
14521452 duplicated by inlining. That implies that the function has
14531453 internal linkage and only has one call site, so the original
14541454 call is dead after inlining.
1455 ``nofree``
1456 This function attribute indicates that the function does not, directly or
1457 indirectly, call a memory-deallocation function (free, for example). As a
1458 result, uncaptured pointers that are known to be dereferenceable prior to a
1459 call to a function with the ``nofree`` attribute are still known to be
1460 dereferenceable after the call (the capturing condition is necessary in
1461 environments where the function might communicate the pointer to another thread
1462 which then deallocates the memory).
14551463 ``noimplicitfloat``
14561464 This attributes disables implicit floating-point instructions.
14571465 ``noinline``
1717 #include "llvm/ADT/DenseMap.h"
1818 #include "llvm/ADT/SmallPtrSet.h"
1919 #include "llvm/Analysis/TargetFolder.h"
20 #include "llvm/Analysis/TargetLibraryInfo.h"
2021 #include "llvm/IR/CallSite.h"
2122 #include "llvm/IR/IRBuilder.h"
2223 #include "llvm/IR/InstVisitor.h"
8283 bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI,
8384 bool LookThroughBitCast = false);
8485
86 /// Tests if a value is a call or invoke to a library function that
87 /// reallocates memory (e.g., realloc).
88 bool isReallocLikeFn(const Value *V, const TargetLibraryInfo *TLI,
89 bool LookThroughBitCast = false);
90
91 /// Tests if a function is a call or invoke to a library function that
92 /// reallocates memory (e.g., realloc).
93 bool isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI);
94
8595 //===----------------------------------------------------------------------===//
8696 // malloc Call Utility Functions.
8797 //
132142 //===----------------------------------------------------------------------===//
133143 // free Call Utility Functions.
134144 //
145
146 /// isLibFreeFunction - Returns true if the function is a builtin free()
147 bool isLibFreeFunction(const Function *F, const LibFunc TLIFn);
135148
136149 /// isFreeCall - Returns non-null if the value is a call to the builtin free()
137150 const CallInst *isFreeCall(const Value *I, const TargetLibraryInfo *TLI);
99 // string representation array definition for TargetLibraryInfo.
1010 // Which is defined depends on whether TLI_DEFINE_ENUM is defined or
1111 // TLI_DEFINE_STRING is defined. Only one should be defined at a time.
12
13 // NOTE: The nofree attribute is added to Libfuncs which are not
14 // listed as free or realloc functions in MemoryBuiltins.cpp
15 //
16 // When adding a function which frees memory include the LibFunc
17 // in lib/Analysis/MemoryBuiltins.cpp "isLibFreeFunction".
18 //
19 // When adding a LibFunc which reallocates memory include the LibFunc
20 // in lib/Analysis/MemoryBuiltins.cpp "AllocationFnData[]".
1221
1322 #if !(defined(TLI_DEFINE_ENUM) || defined(TLI_DEFINE_STRING))
1423 #error "Must define TLI_DEFINE_ENUM or TLI_DEFINE_STRING for TLI .def."
628628 ATTR_KIND_SPECULATIVE_LOAD_HARDENING = 59,
629629 ATTR_KIND_IMMARG = 60,
630630 ATTR_KIND_WILLRETURN = 61,
631 ATTR_KIND_NOFREE = 62
631632 };
632633
633634 enum ComdatSelectionKindCodes {
8383
8484 /// Call cannot be duplicated.
8585 def NoDuplicate : EnumAttr<"noduplicate">;
86
87 /// Function does not deallocate memory.
88 def NoFree : EnumAttr<"nofree">;
8689
8790 /// Disable implicit floating point insts.
8891 def NoImplicitFloat : EnumAttr<"noimplicitfloat">;
563563 addFnAttr(Attribute::Speculatable);
564564 }
565565
566 /// Determine if the call might deallocate memory.
567 bool doesNotFreeMemory() const {
568 return onlyReadsMemory() || hasFnAttribute(Attribute::NoFree);
569 }
570 void setDoesNotFreeMemory() {
571 addFnAttr(Attribute::NoFree);
572 }
573
566574 /// Determine if the function is known not to recurse, directly or
567575 /// indirectly.
568576 bool doesNotRecurse() const {
262262 return getAllocationData(V, AllocLike, TLI, LookThroughBitCast).hasValue();
263263 }
264264
265 /// Tests if a value is a call or invoke to a library function that
266 /// reallocates memory (e.g., realloc).
267 bool llvm::isReallocLikeFn(const Value *V, const TargetLibraryInfo *TLI,
268 bool LookThroughBitCast) {
269 return getAllocationData(V, ReallocLike, TLI, LookThroughBitCast).hasValue();
270 }
271
272 /// Tests if a functions is a call or invoke to a library function that
273 /// reallocates memory (e.g., realloc).
274 bool llvm::isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI) {
275 return getAllocationDataForFunction(F, ReallocLike, TLI).hasValue();
276 }
277
265278 /// extractMallocCall - Returns the corresponding CallInst if the instruction
266279 /// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we
267280 /// ignore InvokeInst here.
357370 return isCallocLikeFn(I, TLI) ? cast(I) : nullptr;
358371 }
359372
360 /// isFreeCall - Returns non-null if the value is a call to the builtin free()
361 const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
362 bool IsNoBuiltinCall;
363 const Function *Callee =
364 getCalledFunction(I, /*LookThroughBitCast=*/false, IsNoBuiltinCall);
365 if (Callee == nullptr || IsNoBuiltinCall)
366 return nullptr;
367
368 StringRef FnName = Callee->getName();
369 LibFunc TLIFn;
370 if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn))
371 return nullptr;
372
373 /// isLibFreeFunction - Returns true if the function is a builtin free()
374 bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
373375 unsigned ExpectedNumParams;
374376 if (TLIFn == LibFunc_free ||
375377 TLIFn == LibFunc_ZdlPv || // operator delete(void*)
400402 TLIFn == LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t) // delete[](void*, align_val_t, nothrow)
401403 ExpectedNumParams = 3;
402404 else
403 return nullptr;
405 return false;
404406
405407 // Check free prototype.
406408 // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin
407409 // attribute will exist.
408 FunctionType *FTy = Callee->getFunctionType();
410 FunctionType *FTy = F->getFunctionType();
409411 if (!FTy->getReturnType()->isVoidTy())
412 return false;
413 if (FTy->getNumParams() != ExpectedNumParams)
414 return false;
415 if (FTy->getParamType(0) != Type::getInt8PtrTy(F->getContext()))
416 return false;
417
418 return true;
419 }
420
421 /// isFreeCall - Returns non-null if the value is a call to the builtin free()
422 const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
423 bool IsNoBuiltinCall;
424 const Function *Callee =
425 getCalledFunction(I, /*LookThroughBitCast=*/false, IsNoBuiltinCall);
426 if (Callee == nullptr || IsNoBuiltinCall)
410427 return nullptr;
411 if (FTy->getNumParams() != ExpectedNumParams)
428
429 StringRef FnName = Callee->getName();
430 LibFunc TLIFn;
431 if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn))
412432 return nullptr;
413 if (FTy->getParamType(0) != Type::getInt8PtrTy(Callee->getContext()))
414 return nullptr;
415
416 return dyn_cast(I);
417 }
433
434 return isLibFreeFunction(Callee, TLIFn) ? dyn_cast(I) : nullptr;
435 }
436
418437
419438 //===----------------------------------------------------------------------===//
420439 // Utility functions to compute size of objects.
649649 KEYWORD(nobuiltin);
650650 KEYWORD(nocapture);
651651 KEYWORD(noduplicate);
652 KEYWORD(nofree);
652653 KEYWORD(noimplicitfloat);
653654 KEYWORD(noinline);
654655 KEYWORD(norecurse);
12791279 case lltok::kw_naked: B.addAttribute(Attribute::Naked); break;
12801280 case lltok::kw_nobuiltin: B.addAttribute(Attribute::NoBuiltin); break;
12811281 case lltok::kw_noduplicate: B.addAttribute(Attribute::NoDuplicate); break;
1282 case lltok::kw_nofree: B.addAttribute(Attribute::NoFree); break;
12821283 case lltok::kw_noimplicitfloat:
12831284 B.addAttribute(Attribute::NoImplicitFloat); break;
12841285 case lltok::kw_noinline: B.addAttribute(Attribute::NoInline); break;
194194 kw_nobuiltin,
195195 kw_nocapture,
196196 kw_noduplicate,
197 kw_nofree,
197198 kw_noimplicitfloat,
198199 kw_noinline,
199200 kw_norecurse,
12771277 return 1ULL << 61;
12781278 case Attribute::WillReturn:
12791279 return 1ULL << 62;
1280 case Attribute::NoFree:
1281 return 1ULL << 63;
12801282 case Attribute::Dereferenceable:
12811283 llvm_unreachable("dereferenceable attribute not supported in raw format");
12821284 break;
14411443 return Attribute::NoCapture;
14421444 case bitc::ATTR_KIND_NO_DUPLICATE:
14431445 return Attribute::NoDuplicate;
1446 case bitc::ATTR_KIND_NOFREE:
1447 return Attribute::NoFree;
14441448 case bitc::ATTR_KIND_NO_IMPLICIT_FLOAT:
14451449 return Attribute::NoImplicitFloat;
14461450 case bitc::ATTR_KIND_NO_INLINE:
638638 return bitc::ATTR_KIND_NO_CAPTURE;
639639 case Attribute::NoDuplicate:
640640 return bitc::ATTR_KIND_NO_DUPLICATE;
641 case Attribute::NoFree:
642 return bitc::ATTR_KIND_NOFREE;
641643 case Attribute::NoImplicitFloat:
642644 return bitc::ATTR_KIND_NO_IMPLICIT_FLOAT;
643645 case Attribute::NoInline:
320320 return "nocapture";
321321 if (hasAttribute(Attribute::NoDuplicate))
322322 return "noduplicate";
323 if (hasAttribute(Attribute::NoFree))
324 return "nofree";
323325 if (hasAttribute(Attribute::NoImplicitFloat))
324326 return "noimplicitfloat";
325327 if (hasAttribute(Attribute::NoInline))
14961496 case Attribute::NoCfCheck:
14971497 case Attribute::NoUnwind:
14981498 case Attribute::NoInline:
1499 case Attribute::NoFree:
14991500 case Attribute::AlwaysInline:
15001501 case Attribute::OptimizeForSize:
15011502 case Attribute::StackProtect:
2626 #include "llvm/Analysis/CallGraphSCCPass.h"
2727 #include "llvm/Analysis/CaptureTracking.h"
2828 #include "llvm/Analysis/LazyCallGraph.h"
29 #include "llvm/Analysis/MemoryBuiltins.h"
2930 #include "llvm/Analysis/MemoryLocation.h"
3031 #include "llvm/Analysis/ValueTracking.h"
3132 #include "llvm/IR/Argument.h"
7475 STATISTIC(NumNonNullReturn, "Number of function returns marked nonnull");
7576 STATISTIC(NumNoRecurse, "Number of functions marked as norecurse");
7677 STATISTIC(NumNoUnwind, "Number of functions marked as nounwind");
78 STATISTIC(NumNoFree, "Number of functions marked as nofree");
7779
7880 // FIXME: This is disabled by default to avoid exposing security vulnerabilities
7981 // in C/C++ code compiled by clang:
8688 static cl::opt DisableNoUnwindInference(
8789 "disable-nounwind-inference", cl::Hidden,
8890 cl::desc("Stop inferring nounwind attribute during function-attrs pass"));
91
92 static cl::opt DisableNoFreeInference(
93 "disable-nofree-inference", cl::Hidden,
94 cl::desc("Stop inferring nofree attribute during function-attrs pass"));
8995
9096 namespace {
9197
12261232 return true;
12271233 }
12281234
1235 /// Helper for NoFree inference predicate InstrBreaksAttribute.
1236 static bool InstrBreaksNoFree(Instruction &I, const SCCNodeSet &SCCNodes) {
1237 CallSite CS(&I);
1238 if (!CS)
1239 return false;
1240
1241 Function *Callee = CS.getCalledFunction();
1242 if (!Callee)
1243 return true;
1244
1245 if (Callee->doesNotFreeMemory())
1246 return false;
1247
1248 if (SCCNodes.count(Callee) > 0)
1249 return false;
1250
1251 return true;
1252 }
1253
12291254 /// Infer attributes from all functions in the SCC by scanning every
12301255 /// instruction for compliance to the attribute assumptions. Currently it
12311256 /// does:
12791304 },
12801305 /* RequiresExactDefinition= */ true});
12811306
1307 if (!DisableNoFreeInference)
1308 // Request to infer nofree attribute for all the functions in the SCC if
1309 // every callsite within the SCC does not directly or indirectly free
1310 // memory (except for calls to functions within the SCC). Note that nofree
1311 // attribute suffers from derefinement - results may change depending on
1312 // how functions are optimized. Thus it can be inferred only from exact
1313 // definitions.
1314 AI.registerAttrInference(AttributeInferer::InferenceDescriptor{
1315 Attribute::NoFree,
1316 // Skip functions known not to free memory.
1317 [](const Function &F) { return F.doesNotFreeMemory(); },
1318 // Instructions that break non-deallocating assumption.
1319 [SCCNodes](Instruction &I) {
1320 return InstrBreaksNoFree(I, SCCNodes);
1321 },
1322 [](Function &F) {
1323 LLVM_DEBUG(dbgs()
1324 << "Adding nofree attr to fn " << F.getName() << "\n");
1325 F.setDoesNotFreeMemory();
1326 ++NumNoFree;
1327 },
1328 /* RequiresExactDefinition= */ true});
1329
12821330 // Perform all the requested attribute inference actions.
12831331 return AI.run(SCCNodes);
12841332 }
13211369 }
13221370
13231371 template
1324 static bool deriveAttrsInPostOrder(SCCNodeSet &SCCNodes, AARGetterT &&AARGetter,
1372 static bool deriveAttrsInPostOrder(SCCNodeSet &SCCNodes,
1373 AARGetterT &&AARGetter,
13251374 bool HasUnknownCall) {
13261375 bool Changed = false;
13271376
13511400 CGSCCUpdateResult &) {
13521401 FunctionAnalysisManager &FAM =
13531402 AM.getResult(C, CG).getManager();
1403
1404 const ModuleAnalysisManager &MAM =
1405 AM.getResult(C, CG).getManager();
1406 assert(C.size() > 0 && "Cannot handle an empty SCC!");
1407 Module &M = *C.begin()->getFunction().getParent();
13541408
13551409 // We pass a lambda into functions to wire them up to the analysis manager
13561410 // for getting function analyses.
2121 #include "llvm/IR/LLVMContext.h"
2222 #include "llvm/IR/Module.h"
2323 #include "llvm/IR/Type.h"
24 #include "llvm/Analysis/MemoryBuiltins.h"
2425
2526 using namespace llvm;
2627
119120 return true;
120121 }
121122
123 static bool setDoesNotFreeMemory(Function &F) {
124 if (F.hasFnAttribute(Attribute::NoFree))
125 return false;
126 F.addFnAttr(Attribute::NoFree);
127 return true;
128 }
129
122130 bool llvm::inferLibFuncAttributes(Module *M, StringRef Name,
123131 const TargetLibraryInfo &TLI) {
124132 Function *F = M->getFunction(Name);
133141 return false;
134142
135143 bool Changed = false;
144
145 if(!isLibFreeFunction(&F, TheLibFunc) && !isReallocLikeFn(&F, &TLI))
146 Changed |= setDoesNotFreeMemory(F);
136147
137148 if (F.getParent() != nullptr && F.getParent()->getRtLibUseGOT())
138149 Changed |= setNonLazyBind(F);
813813 case Attribute::InlineHint:
814814 case Attribute::MinSize:
815815 case Attribute::NoDuplicate:
816 case Attribute::NoFree:
816817 case Attribute::NoImplicitFloat:
817818 case Attribute::NoInline:
818819 case Attribute::NonLazyBind:
7272 declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i1) nounwind
7373
7474 ; CHECK: attributes #0 = { norecurse nounwind readnone }
75 ; CHECK: attributes #1 = { norecurse nounwind writeonly }
75 ; CHECK: attributes #1 = { nofree norecurse nounwind writeonly }
7676 ; CHECK: attributes #2 = { nounwind readonly }
7777 ; CHECK: attributes #3 = { nounwind }
7878 ; CHECK: attributes #4 = { nounwind readnone }
79 ; CHECK: attributes #5 = { norecurse nounwind }
79 ; CHECK: attributes #5 = { nofree norecurse nounwind }
8080 ; CHECK: attributes #6 = { argmemonly nounwind }
8181
8282 ; Root note.
203203 ; CHECK: define void @f34()
204204 {
205205 call void @nobuiltin() nobuiltin
206 ; CHECK: call void @nobuiltin() #37
206 ; CHECK: call void @nobuiltin() #38
207207 ret void;
208208 }
209209
353353 ; CHECK: define void @f60() #36
354354 define void @f60() willreturn
355355 {
356 ret void
357 }
358
359 ; CHECK: define void @f61() #37
360 define void @f61() nofree {
356361 ret void
357362 }
358363
393398 ; CHECK: attributes #34 = { sanitize_hwaddress }
394399 ; CHECK: attributes #35 = { shadowcallstack }
395400 ; CHECK: attributes #36 = { willreturn }
396 ; CHECK: attributes #37 = { nobuiltin }
401 ; CHECK: attributes #37 = { nofree }
402 ; CHECK: attributes #38 = { nobuiltin }
66 ; GCN: %mul.i = fmul float %load, 1.500000e+01
77
88 ; UNSAFE: attributes #0 = { norecurse nounwind readnone "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }
9 ; UNSAFE: attributes #1 = { norecurse nounwind "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }
9 ; UNSAFE: attributes #1 = { nofree norecurse nounwind "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }
1010
1111 ; NOINFS: attributes #0 = { norecurse nounwind readnone "no-infs-fp-math"="true" }
12 ; NOINFS: attributes #1 = { norecurse nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="true" "no-nans-fp-math"="false" "unsafe-fp-math"="false" }
12 ; NOINFS: attributes #1 = { nofree norecurse nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="true" "no-nans-fp-math"="false" "unsafe-fp-math"="false" }
1313
1414 ; NONANS: attributes #0 = { norecurse nounwind readnone "no-nans-fp-math"="true" }
15 ; NONANS: attributes #1 = { norecurse nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="true" "unsafe-fp-math"="false" }
15 ; NONANS: attributes #1 = { nofree norecurse nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="true" "unsafe-fp-math"="false" }
1616
1717 define float @foo(float %x) #0 {
1818 entry:
1111 ret void
1212 }
1313
14 ; CHECK: Function Attrs: nounwind nonlazybind
14 ; CHECK: Function Attrs: nofree nounwind nonlazybind
1515 ; CHECK-NEXT: declare i32 @puts(i8* nocapture readonly)
1616
1717 !llvm.module.flags = !{!0}
55 define void @test_0(i32* %x) {
66 ; FunctionAttrs must not infer readonly / readnone for %x
77
8 ; CHECK-LABEL: define void @test_0(i32* %x) {
8 ; CHECK-LABEL: define void @test_0(i32* %x) #2 {
99 entry:
1010 ; CHECK: call void @f_readonly() [ "foo"(i32* %x) ]
1111 call void @f_readonly() [ "foo"(i32* %x) ]
1515 define void @test_1(i32* %x) {
1616 ; FunctionAttrs must not infer readonly / readnone for %x
1717
18 ; CHECK-LABEL: define void @test_1(i32* %x) {
18 ; CHECK-LABEL: define void @test_1(i32* %x) #2 {
1919 entry:
2020 ; CHECK: call void @f_readnone() [ "foo"(i32* %x) ]
2121 call void @f_readnone() [ "foo"(i32* %x) ]
3030 call void @f_readonly() [ "deopt"(i32* %x) ]
3131 ret void
3232 }
33
34 ; CHECK: attributes #2 = { nofree }
35
2020 }
2121
2222 ; CHECK: attributes #0 = { norecurse nounwind readnone ssp uwtable }
23 ; CHECK: attributes #1 = { norecurse nounwind ssp uwtable }
23 ; CHECK: attributes #1 = { nofree norecurse nounwind ssp uwtable }
0 ; RUN: opt < %s -functionattrs -S | FileCheck %s
1 ; RUN: opt < %s -passes=function-attrs -S | FileCheck %s
2
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
5
6 ; CHECK: define void @_Z4foo1Pi(i32* nocapture readnone %a) local_unnamed_addr #0 {
7 define void @_Z4foo1Pi(i32* nocapture readnone %a) local_unnamed_addr #0 {
8 entry:
9 tail call void @_Z3extv()
10 ret void
11 }
12
13 declare void @_Z3extv() local_unnamed_addr
14
15 ; CHECK: define void @_Z4foo2Pi(i32* nocapture %a) local_unnamed_addr #1 {
16 define void @_Z4foo2Pi(i32* nocapture %a) local_unnamed_addr #1 {
17 entry:
18 %0 = bitcast i32* %a to i8*
19 tail call void @free(i8* %0) #2
20 ret void
21 }
22
23 declare void @free(i8* nocapture) local_unnamed_addr #2
24
25 ; CHECK: define i32 @_Z4foo3Pi(i32* nocapture readonly %a) local_unnamed_addr #3 {
26 define i32 @_Z4foo3Pi(i32* nocapture readonly %a) local_unnamed_addr #3 {
27 entry:
28 %0 = load i32, i32* %a, align 4
29 ret i32 %0
30 }
31
32 ; CHECK: define double @_Z4foo4Pd(double* nocapture readonly %a) local_unnamed_addr #1 {
33 define double @_Z4foo4Pd(double* nocapture readonly %a) local_unnamed_addr #1 {
34 entry:
35 %0 = load double, double* %a, align 8
36 %call = tail call double @cos(double %0) #2
37 ret double %call
38 }
39
40 declare double @cos(double) local_unnamed_addr #2
41
42 ; CHECK: define noalias i32* @_Z4foo5Pm(i64* nocapture readonly %a) local_unnamed_addr #1 {
43 define noalias i32* @_Z4foo5Pm(i64* nocapture readonly %a) local_unnamed_addr #1 {
44 entry:
45 %0 = load i64, i64* %a, align 8
46 %call = tail call noalias i8* @malloc(i64 %0) #2
47 %1 = bitcast i8* %call to i32*
48 ret i32* %1
49 }
50
51 declare noalias i8* @malloc(i64) local_unnamed_addr #2
52
53 ; CHECK: define noalias i64* @_Z4foo6Pm(i64* nocapture %a) local_unnamed_addr #1 {
54 define noalias i64* @_Z4foo6Pm(i64* nocapture %a) local_unnamed_addr #1 {
55 entry:
56 %0 = bitcast i64* %a to i8*
57 %1 = load i64, i64* %a, align 8
58 %call = tail call i8* @realloc(i8* %0, i64 %1) #2
59 %2 = bitcast i8* %call to i64*
60 ret i64* %2
61 }
62
63 declare noalias i8* @realloc(i8* nocapture, i64) local_unnamed_addr #2
64
65 ; CHECK: define void @_Z4foo7Pi(i32* %a) local_unnamed_addr #1 {
66 define void @_Z4foo7Pi(i32* %a) local_unnamed_addr #1 {
67 entry:
68 %isnull = icmp eq i32* %a, null
69 br i1 %isnull, label %delete.end, label %delete.notnull
70
71 delete.notnull: ; preds = %entry
72 %0 = bitcast i32* %a to i8*
73 tail call void @_ZdlPv(i8* %0) #5
74 br label %delete.end
75
76 delete.end: ; preds = %delete.notnull, %entry
77 ret void
78 }
79
80 declare void @_ZdlPv(i8*) local_unnamed_addr #4
81
82 ; CHECK: define void @_Z4foo8Pi(i32* %a) local_unnamed_addr #1 {
83 define void @_Z4foo8Pi(i32* %a) local_unnamed_addr #1 {
84 entry:
85 %isnull = icmp eq i32* %a, null
86 br i1 %isnull, label %delete.end, label %delete.notnull
87
88 delete.notnull: ; preds = %entry
89 %0 = bitcast i32* %a to i8*
90 tail call void @_ZdaPv(i8* %0) #5
91 br label %delete.end
92
93 delete.end: ; preds = %delete.notnull, %entry
94 ret void
95 }
96
97 declare void @_ZdaPv(i8*) local_unnamed_addr #4
98
99 attributes #0 = { uwtable }
100 attributes #1 = { nounwind uwtable }
101 attributes #2 = { nounwind }
102 attributes #3 = { norecurse nounwind readonly uwtable }
103 attributes #4 = { nobuiltin nounwind }
104 attributes #5 = { builtin nounwind }
105
106 ; CHECK: attributes #0 = { uwtable }
107 ; CHECK: attributes #1 = { nounwind uwtable }
108 ; CHECK: attributes #2 = { nounwind }
109 ; CHECK: attributes #3 = { norecurse nounwind readonly uwtable }
110 ; CHECK: attributes #4 = { nobuiltin nounwind }
111 ; CHECK: attributes #5 = { builtin nounwind }
112
1313 }
1414
1515
16 ; CHECK: attributes #0 = { nounwind }
16 ; CHECK: attributes #0 = { nofree nounwind }
2929 ;
3030 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3131
32 ; CHECK: Function Attrs: nounwind
32 ; CHECK: Function Attrs: nofree nounwind
3333 ; CHECK-NEXT: define i32* @external_ret2_nrw(i32* %n0, i32* %r0, i32* %w0)
3434 define i32* @external_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
3535 entry:
4040 ret i32* %call3
4141 }
4242
43 ; CHECK: Function Attrs: nounwind
43 ; CHECK: Function Attrs: nofree nounwind
4444 ; CHECK-NEXT: define internal i32* @internal_ret0_nw(i32* %n0, i32* %w0)
4545 define internal i32* @internal_ret0_nw(i32* %n0, i32* %w0) {
4646 entry:
6969 ret i32* %retval.0
7070 }
7171
72 ; CHECK: Function Attrs: nounwind
72 ; CHECK: Function Attrs: nofree nounwind
7373 ; CHECK-NEXT: define internal i32* @internal_ret1_rrw(i32* %r0, i32* %r1, i32* %w0)
7474 define internal i32* @internal_ret1_rrw(i32* %r0, i32* %r1, i32* %w0) {
7575 entry:
101101 ret i32* %retval.0
102102 }
103103
104 ; CHECK: Function Attrs: norecurse nounwind
104 ; CHECK: Function Attrs: nofree norecurse nounwind
105105 ; CHECK-NEXT: define i32* @external_sink_ret2_nrw(i32* readnone %n0, i32* nocapture readonly %r0, i32* returned %w0)
106106 define i32* @external_sink_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
107107 entry:
120120 ret i32* %w0
121121 }
122122
123 ; CHECK: Function Attrs: nounwind
123 ; CHECK: Function Attrs: nofree nounwind
124124 ; CHECK-NEXT: define internal i32* @internal_ret1_rw(i32* %r0, i32* %w0)
125125 define internal i32* @internal_ret1_rw(i32* %r0, i32* %w0) {
126126 entry:
146146 ret i32* %retval.0
147147 }
148148
149 ; CHECK: Function Attrs: nounwind
149 ; CHECK: Function Attrs: nofree nounwind
150150 ; CHECK-NEXT: define i32* @external_source_ret2_nrw(i32* %n0, i32* %r0, i32* %w0)
151151 define i32* @external_source_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
152152 entry:
159159 ; for a subset relation.
160160 ;
161161 ; CHECK-NOT: attributes #
162 ; CHECK: attributes #{{.*}} = { nounwind }
163 ; CHECK: attributes #{{.*}} = { norecurse nounwind }
162 ; CHECK: attributes #{{.*}} = { nofree nounwind }
163 ; CHECK: attributes #{{.*}} = { nofree norecurse nounwind }
164164 ; CHECK-NOT: attributes #
44 ; RUN: opt < %s -mtriple=nvptx -inferattrs -S | FileCheck -check-prefix=CHECK-NVPTX %s
55
66 ; operator new routines
7 declare i8* @_Znwj(i64)
8 ; CHECK: declare noalias nonnull i8* @_Znwj(i64)
7 declare i8* @_Znwj(i64 )
8 ; CHECK: declare noalias nonnull i8* @_Znwj(i64) [[G0:#[0-9]+]]
99 declare i8* @_Znwm(i64)
10 ; CHECK: declare noalias nonnull i8* @_Znwm(i64)
10 ; CHECK: declare noalias nonnull i8* @_Znwm(i64) [[G0]]
1111
1212 declare i32 @__nvvm_reflect(i8*)
1313 ; CHECK-NVPTX: declare i32 @__nvvm_reflect(i8*) [[G0:#[0-9]+]]
14 ; CHECK-NVPTX: attributes [[G0]] = { nounwind readnone }
14 ; CHECK-NVPTX: attributes [[G0]] = { nofree nounwind readnone }
1515
1616
1717 ; Check all the libc functions (thereby also exercising the prototype check).
159159 ; CHECK: declare float @__sinpif(float)
160160 declare float @__sinpif(float)
161161
162 ; CHECK: declare i32 @abs(i32)
162 ; CHECK: declare i32 @abs(i32) [[G0]]
163163 declare i32 @abs(i32)
164164
165 ; CHECK: declare i32 @access(i8* nocapture readonly, i32) [[G0:#[0-9]+]]
165 ; CHECK: declare i32 @access(i8* nocapture readonly, i32) [[G1:#[0-9]+]]
166166 declare i32 @access(i8*, i32)
167167
168 ; CHECK: declare double @acos(double)
168 ; CHECK: declare double @acos(double) [[G0]]
169169 declare double @acos(double)
170170
171 ; CHECK: declare float @acosf(float)
171 ; CHECK: declare float @acosf(float) [[G0]]
172172 declare float @acosf(float)
173173
174 ; CHECK: declare double @acosh(double)
174 ; CHECK: declare double @acosh(double) [[G0]]
175175 declare double @acosh(double)
176176
177 ; CHECK: declare float @acoshf(float)
177 ; CHECK: declare float @acoshf(float) [[G0]]
178178 declare float @acoshf(float)
179179
180 ; CHECK: declare x86_fp80 @acoshl(x86_fp80)
180 ; CHECK: declare x86_fp80 @acoshl(x86_fp80) [[G0]]
181181 declare x86_fp80 @acoshl(x86_fp80)
182182
183 ; CHECK: declare x86_fp80 @acosl(x86_fp80)
183 ; CHECK: declare x86_fp80 @acosl(x86_fp80) [[G0]]
184184 declare x86_fp80 @acosl(x86_fp80)
185185
186 ; CHECK: declare double @asin(double)
186 ; CHECK: declare double @asin(double) [[G0]]
187187 declare double @asin(double)
188188
189 ; CHECK: declare float @asinf(float)
189 ; CHECK: declare float @asinf(float) [[G0]]
190190 declare float @asinf(float)
191191
192 ; CHECK: declare double @asinh(double)
192 ; CHECK: declare double @asinh(double) [[G0]]
193193 declare double @asinh(double)
194194
195 ; CHECK: declare float @asinhf(float)
195 ; CHECK: declare float @asinhf(float) [[G0]]
196196 declare float @asinhf(float)
197197
198 ; CHECK: declare x86_fp80 @asinhl(x86_fp80)
198 ; CHECK: declare x86_fp80 @asinhl(x86_fp80) [[G0]]
199199 declare x86_fp80 @asinhl(x86_fp80)
200200
201 ; CHECK: declare x86_fp80 @asinl(x86_fp80)
201 ; CHECK: declare x86_fp80 @asinl(x86_fp80) [[G0]]
202202 declare x86_fp80 @asinl(x86_fp80)
203203
204 ; CHECK: declare double @atan(double)
204 ; CHECK: declare double @atan(double) [[G0]]
205205 declare double @atan(double)
206206
207 ; CHECK: declare double @atan2(double, double)
207 ; CHECK: declare double @atan2(double, double) [[G0]]
208208 declare double @atan2(double, double)
209209
210 ; CHECK: declare float @atan2f(float, float)
210 ; CHECK: declare float @atan2f(float, float) [[G0]]
211211 declare float @atan2f(float, float)
212212
213 ; CHECK: declare x86_fp80 @atan2l(x86_fp80, x86_fp80)
213 ; CHECK: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[G0]]
214214 declare x86_fp80 @atan2l(x86_fp80, x86_fp80)
215215
216 ; CHECK: declare float @atanf(float)
216 ; CHECK: declare float @atanf(float) [[G0]]
217217 declare float @atanf(float)
218218
219 ; CHECK: declare double @atanh(double)
219 ; CHECK: declare double @atanh(double) [[G0]]
220220 declare double @atanh(double)
221221
222 ; CHECK: declare float @atanhf(float)
222 ; CHECK: declare float @atanhf(float) [[G0]]
223223 declare float @atanhf(float)
224224
225 ; CHECK: declare x86_fp80 @atanhl(x86_fp80)
225 ; CHECK: declare x86_fp80 @atanhl(x86_fp80) [[G0]]
226226 declare x86_fp80 @atanhl(x86_fp80)
227227
228 ; CHECK: declare x86_fp80 @atanl(x86_fp80)
228 ; CHECK: declare x86_fp80 @atanl(x86_fp80) [[G0]]
229229 declare x86_fp80 @atanl(x86_fp80)
230230
231 ; CHECK: declare double @atof(i8* nocapture) [[G1:#[0-9]+]]
231 ; CHECK: declare double @atof(i8* nocapture) [[G2:#[0-9]+]]
232232 declare double @atof(i8*)
233233
234 ; CHECK: declare i32 @atoi(i8* nocapture) [[G1]]
234 ; CHECK: declare i32 @atoi(i8* nocapture) [[G2]]
235235 declare i32 @atoi(i8*)
236236
237 ; CHECK: declare i64 @atol(i8* nocapture) [[G1]]
237 ; CHECK: declare i64 @atol(i8* nocapture) [[G2]]
238238 declare i64 @atol(i8*)
239239
240 ; CHECK: declare i64 @atoll(i8* nocapture) [[G1]]
240 ; CHECK: declare i64 @atoll(i8* nocapture) [[G2]]
241241 declare i64 @atoll(i8*)
242242
243 ; CHECK-DARWIN: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G1]]
244 ; CHECK-LINUX: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G1]]
245 ; CHECK-UNKNOWN-NOT: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G1]]
246 ; CHECK-NVPTX-NOT: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G1]]
243 ; CHECK-DARWIN: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G2]]
244 ; CHECK-LINUX: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G2]]
245 ; CHECK-UNKNOWN-NOT: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G2]]
246 ; CHECK-NVPTX-NOT: declare i32 @bcmp(i8* nocapture, i8* nocapture, i64) [[G2]]
247247 declare i32 @bcmp(i8*, i8*, i64)
248248
249 ; CHECK: declare void @bcopy(i8* nocapture readonly, i8* nocapture, i64) [[G0]]
249 ; CHECK: declare void @bcopy(i8* nocapture readonly, i8* nocapture, i64) [[G1]]
250250 declare void @bcopy(i8*, i8*, i64)
251251
252 ; CHECK: declare void @bzero(i8* nocapture, i64) [[G0]]
252 ; CHECK: declare void @bzero(i8* nocapture, i64) [[G1]]
253253 declare void @bzero(i8*, i64)
254254
255 ; CHECK: declare noalias i8* @calloc(i64, i64) [[G0]]
255 ; CHECK: declare noalias i8* @calloc(i64, i64) [[G1]]
256256 declare i8* @calloc(i64, i64)
257257
258 ; CHECK: declare double @cbrt(double)
258 ; CHECK: declare double @cbrt(double) [[G0]]
259259 declare double @cbrt(double)
260260
261 ; CHECK: declare float @cbrtf(float)
261 ; CHECK: declare float @cbrtf(float) [[G0]]
262262 declare float @cbrtf(float)
263263
264 ; CHECK: declare x86_fp80 @cbrtl(x86_fp80)
264 ; CHECK: declare x86_fp80 @cbrtl(x86_fp80) [[G0]]
265265 declare x86_fp80 @cbrtl(x86_fp80)
266266
267 ; CHECK: declare double @ceil(double)
267 ; CHECK: declare double @ceil(double) [[G0]]
268268 declare double @ceil(double)
269269
270 ; CHECK: declare float @ceilf(float)
270 ; CHECK: declare float @ceilf(float) [[G0]]
271271 declare float @ceilf(float)
272272
273 ; CHECK: declare x86_fp80 @ceill(x86_fp80)
273 ; CHECK: declare x86_fp80 @ceill(x86_fp80) [[G0]]
274274 declare x86_fp80 @ceill(x86_fp80)
275275
276 ; CHECK: declare i32 @chmod(i8* nocapture readonly, i16 zeroext) [[G0]]
276 ; CHECK: declare i32 @chmod(i8* nocapture readonly, i16 zeroext) [[G1]]
277277 declare i32 @chmod(i8*, i16 zeroext)
278278
279 ; CHECK: declare i32 @chown(i8* nocapture readonly, i32, i32) [[G0]]
279 ; CHECK: declare i32 @chown(i8* nocapture readonly, i32, i32) [[G1]]
280280 declare i32 @chown(i8*, i32, i32)
281281
282 ; CHECK: declare void @clearerr(%opaque* nocapture) [[G0]]
282 ; CHECK: declare void @clearerr(%opaque* nocapture) [[G1]]
283283 declare void @clearerr(%opaque*)
284284
285 ; CHECK: declare i32 @closedir(%opaque* nocapture) [[G0]]
285 ; CHECK: declare i32 @closedir(%opaque* nocapture) [[G1]]
286286 declare i32 @closedir(%opaque*)
287287
288 ; CHECK: declare double @copysign(double, double)
288 ; CHECK: declare double @copysign(double, double) [[G0]]
289289 declare double @copysign(double, double)
290290
291 ; CHECK: declare float @copysignf(float, float)
291 ; CHECK: declare float @copysignf(float, float) [[G0]]
292292 declare float @copysignf(float, float)
293293
294 ; CHECK: declare x86_fp80 @copysignl(x86_fp80, x86_fp80)
294 ; CHECK: declare x86_fp80 @copysignl(x86_fp80, x86_fp80) [[G0]]
295295 declare x86_fp80 @copysignl(x86_fp80, x86_fp80)
296296
297 ; CHECK: declare double @cos(double)
297 ; CHECK: declare double @cos(double) [[G0]]
298298 declare double @cos(double)
299299
300 ; CHECK: declare float @cosf(float)
300 ; CHECK: declare float @cosf(float) [[G0]]
301301 declare float @cosf(float)
302302
303 ; CHECK: declare double @cosh(double)
303 ; CHECK: declare double @cosh(double) [[G0]]
304304 declare double @cosh(double)
305305
306 ; CHECK: declare float @coshf(float)
306 ; CHECK: declare float @coshf(float) [[G0]]
307307 declare float @coshf(float)
308308
309 ; CHECK: declare x86_fp80 @coshl(x86_fp80)
309 ; CHECK: declare x86_fp80 @coshl(x86_fp80) [[G0]]
310310 declare x86_fp80 @coshl(x86_fp80)
311311
312 ; CHECK: declare x86_fp80 @cosl(x86_fp80)
312 ; CHECK: declare x86_fp80 @cosl(x86_fp80) [[G0]]
313313 declare x86_fp80 @cosl(x86_fp80)
314314
315 ; CHECK: declare i8* @ctermid(i8* nocapture) [[G0]]
315 ; CHECK: declare i8* @ctermid(i8* nocapture) [[G1]]
316316 declare i8* @ctermid(i8*)
317317
318 ; CHECK: declare double @exp(double)
318 ; CHECK: declare double @exp(double) [[G0]]
319319 declare double @exp(double)
320320
321 ; CHECK: declare double @exp2(double)
321 ; CHECK: declare double @exp2(double) [[G0]]
322322 declare double @exp2(double)
323323
324 ; CHECK: declare float @exp2f(float)
324 ; CHECK: declare float @exp2f(float) [[G0]]
325325 declare float @exp2f(float)
326326
327 ; CHECK: declare x86_fp80 @exp2l(x86_fp80)
327 ; CHECK: declare x86_fp80 @exp2l(x86_fp80) [[G0]]
328328 declare x86_fp80 @exp2l(x86_fp80)
329329
330 ; CHECK: declare float @expf(float)
330 ; CHECK: declare float @expf(float) [[G0]]
331331 declare float @expf(float)
332332
333 ; CHECK: declare x86_fp80 @expl(x86_fp80)
333 ; CHECK: declare x86_fp80 @expl(x86_fp80) [[G0]]
334334 declare x86_fp80 @expl(x86_fp80)
335335
336 ; CHECK: declare double @expm1(double)
336 ; CHECK: declare double @expm1(double) [[G0]]
337337 declare double @expm1(double)
338338
339 ; CHECK: declare float @expm1f(float)
339 ; CHECK: declare float @expm1f(float) [[G0]]
340340 declare float @expm1f(float)
341341
342 ; CHECK: declare x86_fp80 @expm1l(x86_fp80)
342 ; CHECK: declare x86_fp80 @expm1l(x86_fp80) [[G0]]
343343 declare x86_fp80 @expm1l(x86_fp80)
344344
345 ; CHECK: declare double @fabs(double)
345 ; CHECK: declare double @fabs(double) [[G0]]
346346 declare double @fabs(double)
347347
348 ; CHECK: declare float @fabsf(float)
348 ; CHECK: declare float @fabsf(float) [[G0]]
349349 declare float @fabsf(float)
350350
351 ; CHECK: declare x86_fp80 @fabsl(x86_fp80)
351 ; CHECK: declare x86_fp80 @fabsl(x86_fp80) [[G0]]
352352 declare x86_fp80 @fabsl(x86_fp80)
353353
354 ; CHECK: declare i32 @fclose(%opaque* nocapture) [[G0]]
354 ; CHECK: declare i32 @fclose(%opaque* nocapture) [[G1]]
355355 declare i32 @fclose(%opaque*)
356356
357 ; CHECK: declare noalias %opaque* @fdopen(i32, i8* nocapture readonly) [[G0]]
357 ; CHECK: declare noalias %opaque* @fdopen(i32, i8* nocapture readonly) [[G1]]
358358 declare %opaque* @fdopen(i32, i8*)
359359
360 ; CHECK: declare i32 @feof(%opaque* nocapture) [[G0]]
360 ; CHECK: declare i32 @feof(%opaque* nocapture) [[G1]]
361361 declare i32 @feof(%opaque*)
362362
363 ; CHECK: declare i32 @ferror(%opaque* nocapture) [[G1]]
363 ; CHECK: declare i32 @ferror(%opaque* nocapture) [[G2]]
364364 declare i32 @ferror(%opaque*)
365365
366 ; CHECK: declare i32 @fflush(%opaque* nocapture) [[G0]]
366 ; CHECK: declare i32 @fflush(%opaque* nocapture) [[G1]]
367367 declare i32 @fflush(%opaque*)
368368
369 ; CHECK: declare i32 @ffs(i32)
369 ; CHECK: declare i32 @ffs(i32) [[G0]]
370370 declare i32 @ffs(i32)
371371
372 ; CHECK: declare i32 @ffsl(i64)
372 ; CHECK: declare i32 @ffsl(i64) [[G0]]
373373 declare i32 @ffsl(i64)
374374
375 ; CHECK: declare i32 @ffsll(i64)
375 ; CHECK: declare i32 @ffsll(i64) [[G0]]
376376 declare i32 @ffsll(i64)
377377
378 ; CHECK: declare i32 @fgetc(%opaque* nocapture) [[G0]]
378 ; CHECK: declare i32 @fgetc(%opaque* nocapture) [[G1]]
379379 declare i32 @fgetc(%opaque*)
380380
381 ; CHECK: declare i32 @fgetpos(%opaque* nocapture, i64* nocapture) [[G0]]
381 ; CHECK: declare i32 @fgetpos(%opaque* nocapture, i64* nocapture) [[G1]]
382382 declare i32 @fgetpos(%opaque*, i64*)
383383
384 ; CHECK: declare i8* @fgets(i8*, i32, %opaque* nocapture) [[G0]]
384 ; CHECK: declare i8* @fgets(i8*, i32, %opaque* nocapture) [[G1]]
385385 declare i8* @fgets(i8*, i32, %opaque*)
386386
387 ; CHECK: declare i32 @fileno(%opaque* nocapture) [[G0]]
387 ; CHECK: declare i32 @fileno(%opaque* nocapture) [[G1]]
388388 declare i32 @fileno(%opaque*)
389389
390 ; CHECK: declare void @flockfile(%opaque* nocapture) [[G0]]
390 ; CHECK: declare void @flockfile(%opaque* nocapture) [[G1]]
391391 declare void @flockfile(%opaque*)
392392
393 ; CHECK: declare double @floor(double)
393 ; CHECK: declare double @floor(double) [[G0]]
394394 declare double @floor(double)
395395
396 ; CHECK: declare float @floorf(float)
396 ; CHECK: declare float @floorf(float) [[G0]]
397397 declare float @floorf(float)
398398
399 ; CHECK: declare x86_fp80 @floorl(x86_fp80)
399 ; CHECK: declare x86_fp80 @floorl(x86_fp80) [[G0]]
400400 declare x86_fp80 @floorl(x86_fp80)
401401
402402 ; CHECK: declare i32 @fls(i32)
408408 ; CHECK: declare i32 @flsll(i64)
409409 declare i32 @flsll(i64)
410410
411 ; CHECK: declare double @fmax(double, double)
411 ; CHECK: declare double @fmax(double, double) [[G0]]
412412 declare double @fmax(double, double)
413413
414 ; CHECK: declare float @fmaxf(float, float)
414 ; CHECK: declare float @fmaxf(float, float) [[G0]]
415415 declare float @fmaxf(float, float)
416416
417 ; CHECK: declare x86_fp80 @fmaxl(x86_fp80, x86_fp80)
417 ; CHECK: declare x86_fp80 @fmaxl(x86_fp80, x86_fp80) [[G0]]
418418 declare x86_fp80 @fmaxl(x86_fp80, x86_fp80)
419419
420 ; CHECK: declare double @fmin(double, double)
420 ; CHECK: declare double @fmin(double, double) [[G0]]
421421 declare double @fmin(double, double)
422422
423 ; CHECK: declare float @fminf(float, float)
423 ; CHECK: declare float @fminf(float, float) [[G0]]
424424 declare float @fminf(float, float)
425425
426 ; CHECK: declare x86_fp80 @fminl(x86_fp80, x86_fp80)
426 ; CHECK: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[G0]]
427427 declare x86_fp80 @fminl(x86_fp80, x86_fp80)
428428
429 ; CHECK: declare double @fmod(double, double)
429 ; CHECK: declare double @fmod(double, double) [[G0]]
430430 declare double @fmod(double, double)
431431
432 ; CHECK: declare float @fmodf(float, float)
432 ; CHECK: declare float @fmodf(float, float) [[G0]]
433433 declare float @fmodf(float, float)
434434
435 ; CHECK: declare x86_fp80 @fmodl(x86_fp80, x86_fp80)
435 ; CHECK: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[G0]]
436436 declare x86_fp80 @fmodl(x86_fp80, x86_fp80)
437437
438 ; CHECK: declare noalias %opaque* @fopen(i8* nocapture readonly, i8* nocapture readonly) [[G0]]
438 ; CHECK: declare noalias %opaque* @fopen(i8* nocapture readonly, i8* nocapture readonly) [[G1]]
439439 declare %opaque* @fopen(i8*, i8*)
440440
441 ; CHECK: declare i32 @fprintf(%opaque* nocapture, i8* nocapture readonly, ...) [[G0]]
441 ; CHECK: declare i32 @fprintf(%opaque* nocapture, i8* nocapture readonly, ...) [[G1]]
442442 declare i32 @fprintf(%opaque*, i8*, ...)
443443
444 ; CHECK: declare i32 @fputc(i32, %opaque* nocapture) [[G0]]
444 ; CHECK: declare i32 @fputc(i32, %opaque* nocapture) [[G1]]
445445 declare i32 @fputc(i32, %opaque*)
446446
447 ; CHECK: declare i32 @fputs(i8* nocapture readonly, %opaque* nocapture) [[G0]]
447 ; CHECK: declare i32 @fputs(i8* nocapture readonly, %opaque* nocapture) [[G1]]
448448 declare i32 @fputs(i8*, %opaque*)
449449
450 ; CHECK: declare i64 @fread(i8* nocapture, i64, i64, %opaque* nocapture) [[G0]]
450 ; CHECK: declare i64 @fread(i8* nocapture, i64, i64, %opaque* nocapture) [[G1]]
451451 declare i64 @fread(i8*, i64, i64, %opaque*)
452452
453 ; CHECK: declare void @free(i8* nocapture) [[G0]]
453 ; CHECK: declare void @free(i8* nocapture) [[G3:#[0-9]+]]
454454 declare void @free(i8*)
455455
456 ; CHECK: declare double @frexp(double, i32* nocapture) [[G0]]
456 ; CHECK: declare double @frexp(double, i32* nocapture) [[G1]]
457457 declare double @frexp(double, i32*)
458458
459 ; CHECK: declare float @frexpf(float, i32* nocapture) [[G0]]
459 ; CHECK: declare float @frexpf(float, i32* nocapture) [[G1]]
460460 declare float @frexpf(float, i32*)
461461
462 ; CHECK: declare x86_fp80 @frexpl(x86_fp80, i32* nocapture) [[G0]]
462 ; CHECK: declare x86_fp80 @frexpl(x86_fp80, i32* nocapture) [[G1]]
463463 declare x86_fp80 @frexpl(x86_fp80, i32*)
464464
465 ; CHECK: declare i32 @fscanf(%opaque* nocapture, i8* nocapture readonly, ...) [[G0]]
465 ; CHECK: declare i32 @fscanf(%opaque* nocapture, i8* nocapture readonly, ...) [[G1]]
466466 declare i32 @fscanf(%opaque*, i8*, ...)
467467
468 ; CHECK: declare i32 @fseek(%opaque* nocapture, i64, i32) [[G0]]
468 ; CHECK: declare i32 @fseek(%opaque* nocapture, i64, i32) [[G1]]
469469 declare i32 @fseek(%opaque*, i64, i32)
470470
471 ; CHECK: declare i32 @fseeko(%opaque* nocapture, i64, i32) [[G0]]
471 ; CHECK: declare i32 @fseeko(%opaque* nocapture, i64, i32) [[G1]]
472472 declare i32 @fseeko(%opaque*, i64, i32)
473473
474 ; CHECK-LINUX: declare i32 @fseeko64(%opaque* nocapture, i64, i32) [[G0]]
474 ; CHECK-LINUX: declare i32 @fseeko64(%opaque* nocapture, i64, i32) [[G1]]
475475 declare i32 @fseeko64(%opaque*, i64, i32)
476476
477 ; CHECK: declare i32 @fsetpos(%opaque* nocapture, i64*) [[G0]]
477 ; CHECK: declare i32 @fsetpos(%opaque* nocapture, i64*) [[G1]]
478478 declare i32 @fsetpos(%opaque*, i64*)
479479
480 ; CHECK: declare i32 @fstat(i32, %opaque* nocapture) [[G0]]
480 ; CHECK: declare i32 @fstat(i32, %opaque* nocapture) [[G1]]
481481 declare i32 @fstat(i32, %opaque*)
482482
483 ; CHECK-LINUX: declare i32 @fstat64(i32, %opaque* nocapture) [[G0]]
483 ; CHECK-LINUX: declare i32 @fstat64(i32, %opaque* nocapture) [[G1]]
484484 declare i32 @fstat64(i32, %opaque*)
485485
486 ; CHECK: declare i32 @fstatvfs(i32, %opaque* nocapture) [[G0]]
486 ; CHECK: declare i32 @fstatvfs(i32, %opaque* nocapture) [[G1]]
487487 declare i32 @fstatvfs(i32, %opaque*)
488488
489 ; CHECK-LINUX: declare i32 @fstatvfs64(i32, %opaque* nocapture) [[G0]]
489 ; CHECK-LINUX: declare i32 @fstatvfs64(i32, %opaque* nocapture) [[G1]]
490490 declare i32 @fstatvfs64(i32, %opaque*)
491491
492 ; CHECK: declare i64 @ftell(%opaque* nocapture) [[G0]]
492 ; CHECK: declare i64 @ftell(%opaque* nocapture) [[G1]]
493493 declare i64 @ftell(%opaque*)
494494
495 ; CHECK: declare i64 @ftello(%opaque* nocapture) [[G0]]
495 ; CHECK: declare i64 @ftello(%opaque* nocapture) [[G1]]
496496 declare i64 @ftello(%opaque*)
497497
498 ; CHECK-LINUX: declare i64 @ftello64(%opaque* nocapture) [[G0]]
498 ; CHECK-LINUX: declare i64 @ftello64(%opaque* nocapture) [[G1]]
499499 declare i64 @ftello64(%opaque*)
500500
501 ; CHECK: declare i32 @ftrylockfile(%opaque* nocapture) [[G0]]
501 ; CHECK: declare i32 @ftrylockfile(%opaque* nocapture) [[G1]]
502502 declare i32 @ftrylockfile(%opaque*)
503503
504 ; CHECK: declare void @funlockfile(%opaque* nocapture) [[G0]]
504 ; CHECK: declare void @funlockfile(%opaque* nocapture) [[G1]]
505505 declare void @funlockfile(%opaque*)
506506
507 ; CHECK: declare i64 @fwrite(i8* nocapture, i64, i64, %opaque* nocapture) [[G0]]
507 ; CHECK: declare i64 @fwrite(i8* nocapture, i64, i64, %opaque* nocapture) [[G1]]
508508 declare i64 @fwrite(i8*, i64, i64, %opaque*)
509509
510 ; CHECK: declare i32 @getc(%opaque* nocapture) [[G0]]
510 ; CHECK: declare i32 @getc(%opaque* nocapture) [[G1]]
511511 declare i32 @getc(%opaque*)
512512
513 ; CHECK: declare i32 @getc_unlocked(%opaque* nocapture) [[G0]]
513 ; CHECK: declare i32 @getc_unlocked(%opaque* nocapture) [[G1]]
514514 declare i32 @getc_unlocked(%opaque*)
515515
516 ; CHECK: declare i32 @getchar()
516 ; CHECK: declare i32 @getchar() [[G1]]
517517 declare i32 @getchar()
518518
519 ; CHECK: declare i32 @getchar_unlocked()
519 ; CHECK: declare i32 @getchar_unlocked() [[G1]]
520520 declare i32 @getchar_unlocked()
521521
522 ; CHECK: declare i8* @getenv(i8* nocapture) [[G1]]
522 ; CHECK: declare i8* @getenv(i8* nocapture) [[G2]]
523523 declare i8* @getenv(i8*)
524524
525 ; CHECK: declare i32 @getitimer(i32, %opaque* nocapture) [[G0]]
525 ; CHECK: declare i32 @getitimer(i32, %opaque* nocapture) [[G1]]
526526 declare i32 @getitimer(i32, %opaque*)
527527
528 ; CHECK: declare i32 @getlogin_r(i8* nocapture, i64) [[G0]]
528 ; CHECK: declare i32 @getlogin_r(i8* nocapture, i64) [[G1]]
529529 declare i32 @getlogin_r(i8*, i64)
530530
531 ; CHECK: declare %opaque* @getpwnam(i8* nocapture readonly) [[G0]]
531 ; CHECK: declare %opaque* @getpwnam(i8* nocapture readonly) [[G1]]
532532 declare %opaque* @getpwnam(i8*)
533533
534 ; CHECK: declare i8* @gets(i8*)
534 ; CHECK: declare i8* @gets(i8*) [[G1]]
535535 declare i8* @gets(i8*)
536536
537 ; CHECK: declare i32 @gettimeofday(%opaque* nocapture, i8* nocapture) [[G0]]
537 ; CHECK: declare i32 @gettimeofday(%opaque* nocapture, i8* nocapture) [[G1]]
538538 declare i32 @gettimeofday(%opaque*, i8*)
539539
540 ; CHECK: declare i32 @isascii(i32)
540 ; CHECK: declare i32 @isascii(i32) [[G0]]
541541 declare i32 @isascii(i32)
542542
543 ; CHECK: declare i32 @isdigit(i32)
543 ; CHECK: declare i32 @isdigit(i32) [[G0]]
544544 declare i32 @isdigit(i32)
545545
546 ; CHECK: declare i64 @labs(i64)
546 ; CHECK: declare i64 @labs(i64) [[G0]]
547547 declare i64 @labs(i64)
548548
549 ; CHECK: declare i32 @lchown(i8* nocapture readonly, i32, i32) [[G0]]
549 ; CHECK: declare i32 @lchown(i8* nocapture readonly, i32, i32) [[G1]]
550550 declare i32 @lchown(i8*, i32, i32)
551551
552 ; CHECK: declare double @ldexp(double, i32)
552 ; CHECK: declare double @ldexp(double, i32) [[G0]]
553553 declare double @ldexp(double, i32)
554554
555 ; CHECK: declare float @ldexpf(float, i32)
555 ; CHECK: declare float @ldexpf(float, i32) [[G0]]
556556 declare float @ldexpf(float, i32)
557557
558 ; CHECK: declare x86_fp80 @ldexpl(x86_fp80, i32)
558 ; CHECK: declare x86_fp80 @ldexpl(x86_fp80, i32) [[G0]]
559559 declare x86_fp80 @ldexpl(x86_fp80, i32)
560560
561 ; CHECK: declare i64 @llabs(i64)
561 ; CHECK: declare i64 @llabs(i64) [[G0]]
562562 declare i64 @llabs(i64)
563563
564 ; CHECK: declare double @log(double)
564 ; CHECK: declare double @log(double) [[G0]]
565565 declare double @log(double)
566566
567 ; CHECK: declare double @log10(double)
567 ; CHECK: declare double @log10(double) [[G0]]
568568 declare double @log10(double)
569569
570 ; CHECK: declare float @log10f(float)
570 ; CHECK: declare float @log10f(float) [[G0]]
571571 declare float @log10f(float)
572572
573 ; CHECK: declare x86_fp80 @log10l(x86_fp80)
573 ; CHECK: declare x86_fp80 @log10l(x86_fp80) [[G0]]
574574 declare x86_fp80 @log10l(x86_fp80)
575575
576 ; CHECK: declare double @log1p(double)
576 ; CHECK: declare double @log1p(double) [[G0]]
577577 declare double @log1p(double)
578578
579 ; CHECK: declare float @log1pf(float)
579 ; CHECK: declare float @log1pf(float) [[G0]]
580580 declare float @log1pf(float)
581581
582 ; CHECK: declare x86_fp80 @log1pl(x86_fp80)
582 ; CHECK: declare x86_fp80 @log1pl(x86_fp80) [[G0]]
583583 declare x86_fp80 @log1pl(x86_fp80)
584584
585 ; CHECK: declare double @log2(double)
585 ; CHECK: declare double @log2(double) [[G0]]
586586 declare double @log2(double)
587587
588 ; CHECK: declare float @log2f(float)
588 ; CHECK: declare float @log2f(float) [[G0]]
589589 declare float @log2f(float)
590590
591 ; CHECK: declare x86_fp80 @log2l(x86_fp80)
591 ; CHECK: declare x86_fp80 @log2l(x86_fp80) [[G0]]
592592 declare x86_fp80 @log2l(x86_fp80)
593593
594 ; CHECK: declare double @logb(double)
594 ; CHECK: declare double @logb(double) [[G0]]
595595 declare double @logb(double)
596596
597 ; CHECK: declare float @logbf(float)
597 ; CHECK: declare float @logbf(float) [[G0]]
598598 declare float @logbf(float)
599599
600 ; CHECK: declare x86_fp80 @logbl(x86_fp80)
600 ; CHECK: declare x86_fp80 @logbl(x86_fp80) [[G0]]
601601 declare x86_fp80 @logbl(x86_fp80)
602602
603 ; CHECK: declare float @logf(float)
603 ; CHECK: declare float @logf(float) [[G0]]
604604 declare float @logf(float)
605605
606 ; CHECK: declare x86_fp80 @logl(x86_fp80)
606 ; CHECK: declare x86_fp80 @logl(x86_fp80) [[G0]]
607607 declare x86_fp80 @logl(x86_fp80)
608608
609 ; CHECK: declare i32 @lstat(i8* nocapture readonly, %opaque* nocapture) [[G0]]
609 ; CHECK: declare i32 @lstat(i8* nocapture readonly, %opaque* nocapture) [[G1]]
610610 declare i32 @lstat(i8*, %opaque*)
611611
612 ; CHECK-LINUX: declare i32 @lstat64(i8* nocapture readonly, %opaque* nocapture) [[G0]]
612 ; CHECK-LINUX: declare i32 @lstat64(i8* nocapture readonly, %opaque* nocapture) [[G1]]
613613 declare i32 @lstat64(i8*, %opaque*)
614614
615 ; CHECK: declare noalias i8* @malloc(i64) [[G0]]
615 ; CHECK: declare noalias i8* @malloc(i64) [[G1]]
616616 declare i8* @malloc(i64)
617617
618 ; CHECK-LINUX: declare noalias i8* @memalign(i64, i64)
618 ; CHECK-LINUX: declare noalias i8* @memalign(i64, i64) [[G0]]
619619 declare i8* @memalign(i64, i64)
620620
621 ; CHECK: declare i8* @memccpy(i8*, i8* nocapture readonly, i32, i64) [[G0]]
621 ; CHECK: declare i8* @memccpy(i8*, i8* nocapture readonly, i32, i64) [[G1]]
622622 declare i8* @memccpy(i8*, i8*, i32, i64)
623623
624 ; CHECK: declare i8* @memchr(i8*, i32, i64) [[G1]]
624 ; CHECK: declare i8* @memchr(i8*, i32, i64) [[G2]]
625625 declare i8* @memchr(i8*, i32, i64)
626626
627 ; CHECK: declare i32 @memcmp(i8* nocapture, i8* nocapture, i64) [[G1]]
627 ; CHECK: declare i32 @memcmp(i8* nocapture, i8* nocapture, i64) [[G2]]
628628 declare i32 @memcmp(i8*, i8*, i64)
629629
630 ; CHECK: declare i8* @memcpy(i8* returned, i8* nocapture readonly, i64) [[G0]]
630 ; CHECK: declare i8* @memcpy(i8* returned, i8* nocapture readonly, i64) [[G1]]
631631 declare i8* @memcpy(i8*, i8*, i64)
632632
633 ; CHECK: declare i8* @mempcpy(i8*, i8* nocapture readonly, i64) [[G0]]
633 ; CHECK: declare i8* @mempcpy(i8*, i8* nocapture readonly, i64) [[G1]]
634634 declare i8* @mempcpy(i8*, i8*, i64)
635635
636 ; CHECK: declare i8* @memmove(i8* returned, i8* nocapture readonly, i64) [[G0]]
636 ; CHECK: declare i8* @memmove(i8* returned, i8* nocapture readonly, i64) [[G1]]
637637 declare i8* @memmove(i8*, i8*, i64)
638638
639 ; CHECK: declare i8* @memset(i8*, i32, i64)
639 ; CHECK: declare i8* @memset(i8*, i32, i64) [[G0]]
640640 declare i8* @memset(i8*, i32, i64)
641641
642 ; CHECK: declare i32 @mkdir(i8* nocapture readonly, i16 zeroext) [[G0]]
642 ; CHECK: declare i32 @mkdir(i8* nocapture readonly, i16 zeroext) [[G1]]
643643 declare i32 @mkdir(i8*, i16 zeroext)
644644
645 ; CHECK: declare i64 @mktime(%opaque* nocapture) [[G0]]
645 ; CHECK: declare i64 @mktime(%opaque* nocapture) [[G1]]
646646 declare i64 @mktime(%opaque*)
647647
648 ; CHECK: declare double @modf(double, double* nocapture) [[G0]]
648 ; CHECK: declare double @modf(double, double* nocapture) [[G1]]
649649 declare double @modf(double, double*)
650650
651 ; CHECK: declare float @modff(float, float* nocapture) [[G0]]
651 ; CHECK: declare float @modff(float, float* nocapture) [[G1]]
652652 declare float @modff(float, float*)
653653
654 ; CHECK: declare x86_fp80 @modfl(x86_fp80, x86_fp80* nocapture) [[G0]]
654 ; CHECK: declare x86_fp80 @modfl(x86_fp80, x86_fp80* nocapture) [[G1]]
655655 declare x86_fp80 @modfl(x86_fp80, x86_fp80*)
656656
657 ; CHECK: declare double @nearbyint(double)
657 ; CHECK: declare double @nearbyint(double) [[G0]]
658658 declare double @nearbyint(double)
659659
660 ; CHECK: declare float @nearbyintf(float)
660 ; CHECK: declare float @nearbyintf(float) [[G0]]
661661 declare float @nearbyintf(float)
662662
663 ; CHECK: declare x86_fp80 @nearbyintl(x86_fp80)
663 ; CHECK: declare x86_fp80 @nearbyintl(x86_fp80) [[G0]]
664664 declare x86_fp80 @nearbyintl(x86_fp80)
665665
666 ; CHECK: declare i32 @open(i8* nocapture readonly, i32, ...)
666 ; CHECK: declare i32 @open(i8* nocapture readonly, i32, ...) [[G0]]
667667 declare i32 @open(i8*, i32, ...)
668668
669 ; CHECK-LINUX: declare i32 @open64(i8* nocapture readonly, i32, ...)
669 ; CHECK-LINUX: declare i32 @open64(i8* nocapture readonly, i32, ...) [[G0]]
670670 declare i32 @open64(i8*, i32, ...)
671671
672 ; CHECK: declare noalias %opaque* @opendir(i8* nocapture readonly) [[G0]]
672 ; CHECK: declare noalias %opaque* @opendir(i8* nocapture readonly) [[G1]]
673673 declare %opaque* @opendir(i8*)
674674
675 ; CHECK: declare i32 @pclose(%opaque* nocapture) [[G0]]
675 ; CHECK: declare i32 @pclose(%opaque* nocapture) [[G1]]
676676 declare i32 @pclose(%opaque*)
677677
678 ; CHECK: declare void @perror(i8* nocapture readonly) [[G0]]
678 ; CHECK: declare void @perror(i8* nocapture readonly) [[G1]]
679679 declare void @perror(i8*)
680680
681 ; CHECK: declare noalias %opaque* @popen(i8* nocapture readonly, i8* nocapture readonly) [[G0]]
681 ; CHECK: declare noalias %opaque* @popen(i8* nocapture readonly, i8* nocapture readonly) [[G1]]
682682 declare %opaque* @popen(i8*, i8*)
683683
684 ; CHECK: declare i32 @posix_memalign(i8**, i64, i64)
684 ; CHECK: declare i32 @posix_memalign(i8**, i64, i64) [[G0]]
685685 declare i32 @posix_memalign(i8**, i64, i64)
686686
687 ; CHECK: declare double @pow(double, double)
687 ; CHECK: declare double @pow(double, double) [[G0]]
688688 declare double @pow(double, double)
689689
690 ; CHECK: declare float @powf(float, float)
690 ; CHECK: declare float @powf(float, float) [[G0]]
691691 declare float @powf(float, float)
692692
693 ; CHECK: declare x86_fp80 @powl(x86_fp80, x86_fp80)
693 ; CHECK: declare x86_fp80 @powl(x86_fp80, x86_fp80) [[G0]]
694694 declare x86_fp80 @powl(x86_fp80, x86_fp80)
695695
696 ; CHECK: declare i64 @pread(i32, i8* nocapture, i64, i64)
696 ; CHECK: declare i64 @pread(i32, i8* nocapture, i64, i64) [[G0]]
697697 declare i64 @pread(i32, i8*, i64, i64)
698698
699 ; CHECK: declare i32 @printf(i8* nocapture readonly, ...) [[G0]]
699 ; CHECK: declare i32 @printf(i8* nocapture readonly, ...) [[G1]]
700700 declare i32 @printf(i8*, ...)
701701
702 ; CHECK: declare i32 @putc(i32, %opaque* nocapture) [[G0]]
702 ; CHECK: declare i32 @putc(i32, %opaque* nocapture) [[G1]]
703703 declare i32 @putc(i32, %opaque*)
704704
705 ; CHECK: declare i32 @putchar(i32)
705 ; CHECK: declare i32 @putchar(i32) [[G1]]
706706 declare i32 @putchar(i32)
707707
708 ; CHECK: declare i32 @putchar_unlocked(i32)
708 ; CHECK: declare i32 @putchar_unlocked(i32) [[G1]]
709709 declare i32 @putchar_unlocked(i32)
710710
711 ; CHECK: declare i32 @puts(i8* nocapture readonly) [[G0]]
711 ; CHECK: declare i32 @puts(i8* nocapture readonly) [[G1]]
712712 declare i32 @puts(i8*)
713713
714 ; CHECK: declare i64 @pwrite(i32, i8* nocapture readonly, i64, i64)
714 ; CHECK: declare i64 @pwrite(i32, i8* nocapture readonly, i64, i64) [[G0]]
715715 declare i64 @pwrite(i32, i8*, i64, i64)
716716
717 ; CHECK: declare void @qsort(i8*, i64, i64, i32 (i8*, i8*)* nocapture)
717 ; CHECK: declare void @qsort(i8*, i64, i64, i32 (i8*, i8*)* nocapture) [[G0]]
718718 declare void @qsort(i8*, i64, i64, i32 (i8*, i8*)*)
719719
720 ; CHECK: declare i64 @read(i32, i8* nocapture, i64)
720 ; CHECK: declare i64 @read(i32, i8* nocapture, i64) [[G0]]
721721 declare i64 @read(i32, i8*, i64)
722722
723 ; CHECK: declare i64 @readlink(i8* nocapture readonly, i8* nocapture, i64) [[G0]]
723 ; CHECK: declare i64 @readlink(i8* nocapture readonly, i8* nocapture, i64) [[G1]]
724724 declare i64 @readlink(i8*, i8*, i64)
725725
726 ; CHECK: declare noalias i8* @realloc(i8* nocapture, i64) [[G0]]
726 ; CHECK: declare noalias i8* @realloc(i8* nocapture, i64) [[G3]]
727727 declare i8* @realloc(i8*, i64)
728728
729729 ; CHECK: declare i8* @reallocf(i8*, i64)
730730 declare i8* @reallocf(i8*, i64)
731731
732 ; CHECK: declare i8* @realpath(i8* nocapture readonly, i8*)
732 ; CHECK: declare i8* @realpath(i8* nocapture readonly, i8*) [[G1]]
733733 declare i8* @realpath(i8*, i8*)
734734
735 ; CHECK: declare i32 @remove(i8* nocapture readonly) [[G0]]
735 ; CHECK: declare i32 @remove(i8* nocapture readonly) [[G1]]
736736 declare i32 @remove(i8*)
737737
738 ; CHECK: declare i32 @rename(i8* nocapture readonly, i8* nocapture readonly) [[G0]]
738 ; CHECK: declare i32 @rename(i8* nocapture readonly, i8* nocapture readonly) [[G1]]
739739 declare i32 @rename(i8*, i8*)
740740
741 ; CHECK: declare void @rewind(%opaque* nocapture) [[G0]]
741 ; CHECK: declare void @rewind(%opaque* nocapture) [[G1]]
742742 declare void @rewind(%opaque*)
743743
744 ; CHECK: declare double @rint(double)
744 ; CHECK: declare double @rint(double) [[G0]]
745745 declare double @rint(double)
746746
747 ; CHECK: declare float @rintf(float)
747 ; CHECK: declare float @rintf(float) [[G0]]
748748 declare float @rintf(float)
749749
750 ; CHECK: declare x86_fp80 @rintl(x86_fp80)
750 ; CHECK: declare x86_fp80 @rintl(x86_fp80) [[G0]]
751751 declare x86_fp80 @rintl(x86_fp80)
752752
753 ; CHECK: declare i32 @rmdir(i8* nocapture readonly) [[G0]]
753 ; CHECK: declare i32 @rmdir(i8* nocapture readonly) [[G1]]
754754 declare i32 @rmdir(i8*)
755755
756 ; CHECK: declare double @round(double)
756 ; CHECK: declare double @round(double) [[G0]]
757757 declare double @round(double)
758758
759 ; CHECK: declare float @roundf(float)
759 ; CHECK: declare float @roundf(float) [[G0]]
760760 declare float @roundf(float)
761761
762 ; CHECK: declare x86_fp80 @roundl(x86_fp80)
762 ; CHECK: declare x86_fp80 @roundl(x86_fp80) [[G0]]
763763 declare x86_fp80 @roundl(x86_fp80)
764764
765 ; CHECK: declare i32 @scanf(i8* nocapture readonly, ...) [[G0]]
765 ; CHECK: declare i32 @scanf(i8* nocapture readonly, ...) [[G1]]
766766 declare i32 @scanf(i8*, ...)
767767
768 ; CHECK: declare void @setbuf(%opaque* nocapture, i8*) [[G0]]
768 ; CHECK: declare void @setbuf(%opaque* nocapture, i8*) [[G1]]
769769 declare void @setbuf(%opaque*, i8*)
770770
771 ; CHECK: declare i32 @setitimer(i32, %opaque* nocapture readonly, %opaque* nocapture) [[G0]]
771 ; CHECK: declare i32 @setitimer(i32, %opaque* nocapture readonly, %opaque* nocapture) [[G1]]
772772 declare i32 @setitimer(i32, %opaque*, %opaque*)
773773
774 ; CHECK: declare i32 @setvbuf(%opaque* nocapture, i8*, i32, i64) [[G0]]
774 ; CHECK: declare i32 @setvbuf(%opaque* nocapture, i8*, i32, i64) [[G1]]
775775 declare i32 @setvbuf(%opaque*, i8*, i32, i64)
776776
777 ; CHECK: declare double @sin(double)
777 ; CHECK: declare double @sin(double) [[G0]]
778778 declare double @sin(double)
779779
780 ; CHECK: declare float @sinf(float)
780 ; CHECK: declare float @sinf(float) [[G0]]
781781 declare float @sinf(float)
782782
783 ; CHECK: declare double @sinh(double)
783 ; CHECK: declare double @sinh(double) [[G0]]
784784 declare double @sinh(double)
785785
786 ; CHECK: declare float @sinhf(float)
786 ; CHECK: declare float @sinhf(float) [[G0]]
787787 declare float @sinhf(float)
788788
789 ; CHECK: declare x86_fp80 @sinhl(x86_fp80)
789 ; CHECK: declare x86_fp80 @sinhl(x86_fp80) [[G0]]
790790 declare x86_fp80 @sinhl(x86_fp80)
791791
792 ; CHECK: declare x86_fp80 @sinl(x86_fp80)
792 ; CHECK: declare x86_fp80 @sinl(x86_fp80) [[G0]]
793793 declare x86_fp80 @sinl(x86_fp80)
794794
795 ; CHECK: declare i32 @snprintf(i8* nocapture, i64, i8* nocapture readonly, ...) [[G0]]
795 ; CHECK: declare i32 @snprintf(i8* nocapture, i64, i8* nocapture readonly, ...) [[G1]]
796796 declare i32 @snprintf(i8*, i64, i8*, ...)
797797
798 ; CHECK: declare i32 @sprintf(i8* nocapture, i8* nocapture readonly, ...) [[G0]]
798 ; CHECK: declare i32 @sprintf(i8* nocapture, i8* nocapture readonly, ...) [[G1]]
799799 declare i32 @sprintf(i8*, i8*, ...)
800800
801 ; CHECK: declare double @sqrt(double)
801 ; CHECK: declare double @sqrt(double) [[G0]]
802802 declare double @sqrt(double)
803803
804 ; CHECK: declare float @sqrtf(float)
804 ; CHECK: declare float @sqrtf(float) [[G0]]
805805 declare float @sqrtf(float)
806806
807 ; CHECK: declare x86_fp80 @sqrtl(x86_fp80)
807 ; CHECK: declare x86_fp80 @sqrtl(x86_fp80) [[G0]]
808808 declare x86_fp80 @sqrtl(x86_fp80)
809809
810 ; CHECK: declare i32 @sscanf(i8* nocapture readonly, i8* nocapture readonly, ...) [[G0]]
810 ; CHECK: declare i32 @sscanf(i8* nocapture readonly, i8* nocapture readonly, ...) [[G1]]
811811 declare i32 @sscanf(i8*, i8*, ...)
812812
813 ; CHECK: declare i32 @stat(i8* nocapture readonly, %opaque* nocapture) [[G0]]
813 ; CHECK: declare i32 @stat(i8* nocapture readonly, %opaque* nocapture) [[G1]]
814814 declare i32 @stat(i8*, %opaque*)
815815
816 ; CHECK-LINUX: declare i32 @stat64(i8* nocapture readonly, %opaque* nocapture) [[G0]]
816 ; CHECK-LINUX: declare i32 @stat64(i8* nocapture readonly, %opaque* nocapture) [[G1]]
817817 declare i32 @stat64(i8*, %opaque*)
818818
819 ; CHECK: declare i32 @statvfs(i8* nocapture readonly, %opaque* nocapture) [[G0]]
819 ; CHECK: declare i32 @statvfs(i8* nocapture readonly, %opaque* nocapture) [[G1]]
820820 declare i32 @statvfs(i8*, %opaque*)
821821
822 ; CHECK-LINUX: declare i32 @statvfs64(i8* nocapture readonly, %opaque* nocapture) [[G0]]
822 ; CHECK-LINUX: declare i32 @statvfs64(i8* nocapture readonly, %opaque* nocapture) [[G1]]
823823 declare i32 @statvfs64(i8*, %opaque*)
824824
825 ; CHECK: declare i8* @stpcpy(i8*, i8* nocapture readonly) [[G0]]
825 ; CHECK: declare i8* @stpcpy(i8*, i8* nocapture readonly) [[G1]]
826826 declare i8* @stpcpy(i8*, i8*)
827827
828 ; CHECK: declare i8* @stpncpy(i8*, i8* nocapture readonly, i64) [[G0]]
828 ; CHECK: declare i8* @stpncpy(i8*, i8* nocapture readonly, i64) [[G1]]
829829 declare i8* @stpncpy(i8*, i8*, i64)
830830
831 ; CHECK: declare i32 @strcasecmp(i8* nocapture, i8* nocapture) [[G1]]
831 ; CHECK: declare i32 @strcasecmp(i8* nocapture, i8* nocapture) [[G2]]
832832 declare i32 @strcasecmp(i8*, i8*)
833833
834 ; CHECK: declare i8* @strcat(i8* returned, i8* nocapture readonly) [[G0]]
834 ; CHECK: declare i8* @strcat(i8* returned, i8* nocapture readonly) [[G1]]
835835 declare i8* @strcat(i8*, i8*)
836836
837 ; CHECK: declare i8* @strchr(i8*, i32) [[G1]]
837 ; CHECK: declare i8* @strchr(i8*, i32) [[G2]]
838838 declare i8* @strchr(i8*, i32)
839839
840 ; CHECK: declare i32 @strcmp(i8* nocapture, i8* nocapture) [[G1]]
840 ; CHECK: declare i32 @strcmp(i8* nocapture, i8* nocapture) [[G2]]
841841 declare i32 @strcmp(i8*, i8*)
842842
843 ; CHECK: declare i32 @strcoll(i8* nocapture, i8* nocapture) [[G1]]
843 ; CHECK: declare i32 @strcoll(i8* nocapture, i8* nocapture) [[G2]]
844844 declare i32 @strcoll(i8*, i8*)
845845
846 ; CHECK: declare i8* @strcpy(i8* returned, i8* nocapture readonly) [[G0]]
846 ; CHECK: declare i8* @strcpy(i8* returned, i8* nocapture readonly) [[G1]]
847847 declare i8* @strcpy(i8*, i8*)
848848
849 ; CHECK: declare i64 @strcspn(i8* nocapture, i8* nocapture) [[G1]]
849 ; CHECK: declare i64 @strcspn(i8* nocapture, i8* nocapture) [[G2]]
850850 declare i64 @strcspn(i8*, i8*)
851851
852 ; CHECK: declare noalias i8* @strdup(i8* nocapture readonly) [[G0]]
852 ; CHECK: declare noalias i8* @strdup(i8* nocapture readonly) [[G1]]
853853 declare i8* @strdup(i8*)
854854
855 ; CHECK: declare i64 @strlen(i8* nocapture) [[G2:#[0-9]+]]
855 ; CHECK: declare i64 @strlen(i8* nocapture) [[G4:#[0-9]+]]
856856 declare i64 @strlen(i8*)
857857
858 ; CHECK: declare i32 @strncasecmp(i8* nocapture, i8* nocapture, i64) [[G1]]
858 ; CHECK: declare i32 @strncasecmp(i8* nocapture, i8* nocapture, i64) [[G2]]
859859 declare i32 @strncasecmp(i8*, i8*, i64)
860860
861 ; CHECK: declare i8* @strncat(i8* returned, i8* nocapture readonly, i64) [[G0]]
861 ; CHECK: declare i8* @strncat(i8* returned, i8* nocapture readonly, i64) [[G1]]
862862 declare i8* @strncat(i8*, i8*, i64)
863863
864 ; CHECK: declare i32 @strncmp(i8* nocapture, i8* nocapture, i64) [[G1]]
864 ; CHECK: declare i32 @strncmp(i8* nocapture, i8* nocapture, i64) [[G2]]
865865 declare i32 @strncmp(i8*, i8*, i64)
866866
867 ; CHECK: declare i8* @strncpy(i8* returned, i8* nocapture readonly, i64) [[G0]]
867 ; CHECK: declare i8* @strncpy(i8* returned, i8* nocapture readonly, i64) [[G1]]
868868 declare i8* @strncpy(i8*, i8*, i64)
869869
870 ; CHECK: declare noalias i8* @strndup(i8* nocapture readonly, i64) [[G0]]
870 ; CHECK: declare noalias i8* @strndup(i8* nocapture readonly, i64) [[G1]]
871871 declare i8* @strndup(i8*, i64)
872872
873 ; CHECK: declare i64 @strnlen(i8*, i64)
873 ; CHECK: declare i64 @strnlen(i8*, i64) [[G0]]
874874 declare i64 @strnlen(i8*, i64)
875875
876 ; CHECK: declare i8* @strpbrk(i8*, i8* nocapture) [[G1]]
876 ; CHECK: declare i8* @strpbrk(i8*, i8* nocapture) [[G2]]
877877 declare i8* @strpbrk(i8*, i8*)
878878
879 ; CHECK: declare i8* @strrchr(i8*, i32) [[G1]]
879 ; CHECK: declare i8* @strrchr(i8*, i32) [[G2]]
880880 declare i8* @strrchr(i8*, i32)
881881
882 ; CHECK: declare i64 @strspn(i8* nocapture, i8* nocapture) [[G1]]
882 ; CHECK: declare i64 @strspn(i8* nocapture, i8* nocapture) [[G2]]
883883 declare i64 @strspn(i8*, i8*)
884884
885 ; CHECK: declare i8* @strstr(i8*, i8* nocapture) [[G1]]
885 ; CHECK: declare i8* @strstr(i8*, i8* nocapture) [[G2]]
886886 declare i8* @strstr(i8*, i8*)
887887
888 ; CHECK: declare double @strtod(i8* readonly, i8** nocapture) [[G0]]
888 ; CHECK: declare double @strtod(i8* readonly, i8** nocapture) [[G1]]
889889 declare double @strtod(i8*, i8**)
890890
891 ; CHECK: declare float @strtof(i8* readonly, i8** nocapture) [[G0]]
891 ; CHECK: declare float @strtof(i8* readonly, i8** nocapture) [[G1]]
892892 declare float @strtof(i8*, i8**)
893893
894 ; CHECK: declare i8* @strtok(i8*, i8* nocapture readonly) [[G0]]
894 ; CHECK: declare i8* @strtok(i8*, i8* nocapture readonly) [[G1]]
895895 declare i8* @strtok(i8*, i8*)
896896
897 ; CHECK: declare i8* @strtok_r(i8*, i8* nocapture readonly, i8**) [[G0]]
897 ; CHECK: declare i8* @strtok_r(i8*, i8* nocapture readonly, i8**) [[G1]]
898898 declare i8* @strtok_r(i8*, i8*, i8**)
899899
900 ; CHECK: declare i64 @strtol(i8* readonly, i8** nocapture, i32) [[G0]]
900 ; CHECK: declare i64 @strtol(i8* readonly, i8** nocapture, i32) [[G1]]
901901 declare i64 @strtol(i8*, i8**, i32)
902902
903 ; CHECK: declare x86_fp80 @strtold(i8* readonly, i8** nocapture) [[G0]]
903 ; CHECK: declare x86_fp80 @strtold(i8* readonly, i8** nocapture) [[G1]]
904904 declare x86_fp80 @strtold(i8*, i8**)
905905
906 ; CHECK: declare i64 @strtoll(i8* readonly, i8** nocapture, i32) [[G0]]
906 ; CHECK: declare i64 @strtoll(i8* readonly, i8** nocapture, i32) [[G1]]
907907 declare i64 @strtoll(i8*, i8**, i32)
908908
909 ; CHECK: declare i64 @strtoul(i8* readonly, i8** nocapture, i32) [[G0]]
909 ; CHECK: declare i64 @strtoul(i8* readonly, i8** nocapture, i32) [[G1]]
910910 declare i64 @strtoul(i8*, i8**, i32)
911911
912 ; CHECK: declare i64 @strtoull(i8* readonly, i8** nocapture, i32) [[G0]]
912 ; CHECK: declare i64 @strtoull(i8* readonly, i8** nocapture, i32) [[G1]]
913913 declare i64 @strtoull(i8*, i8**, i32)
914914
915 ; CHECK: declare i64 @strxfrm(i8* nocapture, i8* nocapture readonly, i64) [[G0]]
915 ; CHECK: declare i64 @strxfrm(i8* nocapture, i8* nocapture readonly, i64) [[G1]]
916916 declare i64 @strxfrm(i8*, i8*, i64)
917917
918 ; CHECK: declare i32 @system(i8* nocapture readonly)
918 ; CHECK: declare i32 @system(i8* nocapture readonly) [[G0]]
919919 declare i32 @system(i8*)
920920
921 ; CHECK: declare double @tan(double)
921 ; CHECK: declare double @tan(double) [[G0]]
922922 declare double @tan(double)
923923
924 ; CHECK: declare float @tanf(float)
924 ; CHECK: declare float @tanf(float) [[G0]]
925925 declare float @tanf(float)
926926
927 ; CHECK: declare double @tanh(double)
927 ; CHECK: declare double @tanh(double) [[G0]]
928928 declare double @tanh(double)
929929
930 ; CHECK: declare float @tanhf(float)
930 ; CHECK: declare float @tanhf(float) [[G0]]
931931 declare float @tanhf(float)
932932
933 ; CHECK: declare x86_fp80 @tanhl(x86_fp80)
933 ; CHECK: declare x86_fp80 @tanhl(x86_fp80) [[G0]]
934934 declare x86_fp80 @tanhl(x86_fp80)
935935
936 ; CHECK: declare x86_fp80 @tanl(x86_fp80)
936 ; CHECK: declare x86_fp80 @tanl(x86_fp80) [[G0]]
937937 declare x86_fp80 @tanl(x86_fp80)
938938
939 ; CHECK: declare i64 @times(%opaque* nocapture) [[G0]]
939 ; CHECK: declare i64 @times(%opaque* nocapture) [[G1]]
940940 declare i64 @times(%opaque*)
941941
942 ; CHECK: declare noalias %opaque* @tmpfile() [[G0]]
942 ; CHECK: declare noalias %opaque* @tmpfile() [[G1]]
943943 declare %opaque* @tmpfile()
944944
945 ; CHECK-LINUX: declare noalias %opaque* @tmpfile64() [[G0]]
945 ; CHECK-LINUX: declare noalias %opaque* @tmpfile64() [[G1]]
946946 declare %opaque* @tmpfile64()
947947
948 ; CHECK: declare i32 @toascii(i32)
948 ; CHECK: declare i32 @toascii(i32) [[G0]]
949949 declare i32 @toascii(i32)
950950
951 ; CHECK: declare double @trunc(double)
951 ; CHECK: declare double @trunc(double) [[G0]]
952952 declare double @trunc(double)
953953
954 ; CHECK: declare float @truncf(float)
954 ; CHECK: declare float @truncf(float) [[G0]]
955955 declare float @truncf(float)
956956
957 ; CHECK: declare x86_fp80 @truncl(x86_fp80)
957 ; CHECK: declare x86_fp80 @truncl(x86_fp80) [[G0]]
958958 declare x86_fp80 @truncl(x86_fp80)
959959
960 ; CHECK: declare i32 @uname(%opaque* nocapture) [[G0]]
960 ; CHECK: declare i32 @uname(%opaque* nocapture) [[G1]]
961961 declare i32 @uname(%opaque*)
962962
963 ; CHECK: declare i32 @ungetc(i32, %opaque* nocapture) [[G0]]
963 ; CHECK: declare i32 @ungetc(i32, %opaque* nocapture) [[G1]]
964964 declare i32 @ungetc(i32, %opaque*)
965965
966 ; CHECK: declare i32 @unlink(i8* nocapture readonly) [[G0]]
966 ; CHECK: declare i32 @unlink(i8* nocapture readonly) [[G1]]
967967 declare i32 @unlink(i8*)
968968
969 ; CHECK: declare i32 @unsetenv(i8* nocapture readonly) [[G0]]
969 ; CHECK: declare i32 @unsetenv(i8* nocapture readonly) [[G1]]
970970 declare i32 @unsetenv(i8*)
971971
972 ; CHECK: declare i32 @utime(i8* nocapture readonly, %opaque* nocapture readonly) [[G0]]
972 ; CHECK: declare i32 @utime(i8* nocapture readonly, %opaque* nocapture readonly) [[G1]]
973973 declare i32 @utime(i8*, %opaque*)
974974
975 ; CHECK: declare i32 @utimes(i8* nocapture readonly, %opaque* nocapture readonly) [[G0]]
975 ; CHECK: declare i32 @utimes(i8* nocapture readonly, %opaque* nocapture readonly) [[G1]]
976976 declare i32 @utimes(i8*, %opaque*)
977977
978 ; CHECK: declare noalias i8* @valloc(i64) [[G0]]
978 ; CHECK: declare noalias i8* @valloc(i64) [[G1]]
979979 declare i8* @valloc(i64)
980980
981 ; CHECK: declare i32 @vfprintf(%opaque* nocapture, i8* nocapture readonly, %opaque*) [[G0]]
981 ; CHECK: declare i32 @vfprintf(%opaque* nocapture, i8* nocapture readonly, %opaque*) [[G1]]
982982 declare i32 @vfprintf(%opaque*, i8*, %opaque*)
983983
984 ; CHECK: declare i32 @vfscanf(%opaque* nocapture, i8* nocapture readonly, %opaque*) [[G0]]
984 ; CHECK: declare i32 @vfscanf(%opaque* nocapture, i8* nocapture readonly, %opaque*) [[G1]]
985985 declare i32 @vfscanf(%opaque*, i8*, %opaque*)
986986
987 ; CHECK: declare i32 @vprintf(i8* nocapture readonly, %opaque*) [[G0]]
987 ; CHECK: declare i32 @vprintf(i8* nocapture readonly, %opaque*) [[G1]]
988988 declare i32 @vprintf(i8*, %opaque*)
989989
990 ; CHECK: declare i32 @vscanf(i8* nocapture readonly, %opaque*) [[G0]]
990 ; CHECK: declare i32 @vscanf(i8* nocapture readonly, %opaque*) [[G1]]
991991 declare i32 @vscanf(i8*, %opaque*)
992992
993 ; CHECK: declare i32 @vsnprintf(i8* nocapture, i64, i8* nocapture readonly, %opaque*) [[G0]]
993 ; CHECK: declare i32 @vsnprintf(i8* nocapture, i64, i8* nocapture readonly, %opaque*) [[G1]]
994994 declare i32 @vsnprintf(i8*, i64, i8*, %opaque*)
995995
996 ; CHECK: declare i32 @vsprintf(i8* nocapture, i8* nocapture readonly, %opaque*) [[G0]]
996 ; CHECK: declare i32 @vsprintf(i8* nocapture, i8* nocapture readonly, %opaque*) [[G1]]
997997 declare i32 @vsprintf(i8*, i8*, %opaque*)
998998
999 ; CHECK: declare i32 @vsscanf(i8* nocapture readonly, i8* nocapture readonly, %opaque*) [[G0]]
999 ; CHECK: declare i32 @vsscanf(i8* nocapture readonly, i8* nocapture readonly, %opaque*) [[G1]]
10001000 declare i32 @vsscanf(i8*, i8*, %opaque*)
10011001
1002 ; CHECK: declare i64 @write(i32, i8* nocapture readonly, i64)
1002 ; CHECK: declare i64 @write(i32, i8* nocapture readonly, i64) [[G0]]
10031003 declare i64 @write(i32, i8*, i64)
10041004
10051005
10061006 ; memset_pattern16 isn't available everywhere.
1007 ; CHECK-DARWIN: declare void @memset_pattern16(i8* nocapture, i8* nocapture readonly, i64) [[G3:#[0-9]+]]
1007 ; CHECK-DARWIN: declare void @memset_pattern16(i8* nocapture, i8* nocapture readonly, i64) [[G5:#[0-9]+]]
10081008 declare void @memset_pattern16(i8*, i8*, i64)
10091009
1010
1011 ; CHECK: attributes [[G0]] = { nounwind }
1012 ; CHECK: attributes [[G1]] = { nounwind readonly }
1013 ; CHECK: attributes [[G2]] = { argmemonly nounwind readonly }
1014 ; CHECK-DARWIN: attributes [[G3]] = { argmemonly }
1010 ; CHECK: attributes [[G0]] = { nofree }
1011 ; CHECK: attributes [[G1]] = { nofree nounwind }
1012 ; CHECK: attributes [[G2]] = { nofree nounwind readonly }
1013 ; CHECK: attributes [[G3]] = { nounwind }
1014 ; CHECK: attributes [[G4]] = { argmemonly nofree nounwind readonly }
1015 ; CHECK-DARWIN: attributes [[G5]] = { argmemonly nofree }
5151 !28 = !DILocation(line: 9, column: 18, scope: !2)
5252 !29 = !DILocation(line: 10, column: 1, scope: !2)
5353
54 ; CHECK: attributes #0 = { norecurse nounwind }
54 ; CHECK: attributes #0 = { nofree norecurse nounwind }
5555 ; CHECK-NOT foo.coefficient1
1212 }
1313
1414 ; CHECK: declare i64 @strlen(i8* nocapture) #0
15 ; CHECK: attributes #0 = { argmemonly nounwind readonly }
15 ; CHECK: attributes #0 = { argmemonly nofree nounwind readonly }
1616 declare i64 @strlen(i8*)
1717
1818
708708
709709 ; Validate that "memset_pattern" has the proper attributes.
710710 ; CHECK: declare void @memset_pattern16(i8* nocapture, i8* nocapture readonly, i64) [[ATTRS:#[0-9]+]]
711 ; CHECK: [[ATTRS]] = { argmemonly }
711 ; CHECK: [[ATTRS]] = { argmemonly nofree }