File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
test/Transforms/InferFunctionAttrs Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ ; RUN: opt -S -mtriple=amdgcn-- -passes=inferattrs %s | FileCheck -check-prefix=NOBUILTIN %s
2+ ; RUN: opt -S -enable-builtin=malloc -mtriple=amdgcn-- -passes=inferattrs %s | FileCheck -check-prefix=WITHBUILTIN %s
3+
4+ ; Test that the -enable-builtin flag works and forces recognition of
5+ ; malloc despite the target's default TargetLibraryInfo.
6+
7+ ; NOBUILTIN: declare ptr @malloc(i64)
8+
9+ ; WITHBUILTIN: declare noalias noundef ptr @malloc(i64 noundef) #0
10+ ; WITHBUILTIN: attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
11+
12+ declare ptr @malloc (i64 )
13+
Original file line number Diff line number Diff line change @@ -203,6 +203,10 @@ static cl::list<std::string> DisableBuiltins(
203203 " disable-builtin" ,
204204 cl::desc (" Disable specific target library builtin function" ));
205205
206+ static cl::list<std::string> EnableBuiltins (
207+ " enable-builtin" ,
208+ cl::desc (" Enable specific target library builtin functions" ));
209+
206210static cl::opt<bool > EnableDebugify (
207211 " enable-debugify" ,
208212 cl::desc (
@@ -670,14 +674,25 @@ extern "C" int optMain(
670674 else {
671675 // Disable individual builtin functions in TargetLibraryInfo.
672676 LibFunc F;
673- for (auto &FuncName : DisableBuiltins)
677+ for (auto &FuncName : DisableBuiltins) {
674678 if (TLII.getLibFunc (FuncName, F))
675679 TLII.setUnavailable (F);
676680 else {
677681 errs () << argv[0 ] << " : cannot disable nonexistent builtin function "
678682 << FuncName << ' \n ' ;
679683 return 1 ;
680684 }
685+ }
686+
687+ for (auto &FuncName : EnableBuiltins) {
688+ if (TLII.getLibFunc (FuncName, F))
689+ TLII.setAvailable (F);
690+ else {
691+ errs () << argv[0 ] << " : cannot enable nonexistent builtin function "
692+ << FuncName << ' \n ' ;
693+ return 1 ;
694+ }
695+ }
681696 }
682697
683698 if (UseNPM) {
You can’t perform that action at this time.
0 commit comments