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(
203
203
" disable-builtin" ,
204
204
cl::desc (" Disable specific target library builtin function" ));
205
205
206
+ static cl::list<std::string> EnableBuiltins (
207
+ " enable-builtin" ,
208
+ cl::desc (" Enable specific target library builtin functions" ));
209
+
206
210
static cl::opt<bool > EnableDebugify (
207
211
" enable-debugify" ,
208
212
cl::desc (
@@ -670,14 +674,25 @@ extern "C" int optMain(
670
674
else {
671
675
// Disable individual builtin functions in TargetLibraryInfo.
672
676
LibFunc F;
673
- for (auto &FuncName : DisableBuiltins)
677
+ for (auto &FuncName : DisableBuiltins) {
674
678
if (TLII.getLibFunc (FuncName, F))
675
679
TLII.setUnavailable (F);
676
680
else {
677
681
errs () << argv[0 ] << " : cannot disable nonexistent builtin function "
678
682
<< FuncName << ' \n ' ;
679
683
return 1 ;
680
684
}
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
+ }
681
696
}
682
697
683
698
if (UseNPM) {
You can’t perform that action at this time.
0 commit comments