Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FuncSpec] Allow ConstExprs that are function pointers
This is a follow up of D110529 that disallowed constexprs. That change introduced a regression as this also disallowed constexprs that are function pointers, which is actually one of the motivating use cases that we do want to support. Differential Revision: https://reviews.llvm.org/D111567
- Loading branch information
Sjoerd Meijer
committed
Oct 12, 2021
1 parent
cd0ba9d
commit fc0fa85
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
llvm/test/Transforms/FunctionSpecialization/function-specialization-constant-expression3.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -function-specialization -force-function-specialization -S < %s | FileCheck %s | ||
|
||
define i32 @main() { | ||
; CHECK-LABEL: @main( | ||
; CHECK-NEXT: bb: | ||
; CHECK-NEXT: tail call void @wombat.1(i8* undef, i64 undef, i64 undef, i32 (i8*, i8*)* bitcast (i32 ()* @quux to i32 (i8*, i8*)*)) | ||
; CHECK-NEXT: tail call void @wombat.2(i8* undef, i64 undef, i64 undef, i32 (i8*, i8*)* bitcast (i32 ()* @eggs to i32 (i8*, i8*)*)) | ||
; CHECK-NEXT: ret i32 undef | ||
; | ||
bb: | ||
tail call void @wombat(i8* undef, i64 undef, i64 undef, i32 (i8*, i8*)* bitcast (i32 ()* @quux to i32 (i8*, i8*)*)) | ||
tail call void @wombat(i8* undef, i64 undef, i64 undef, i32 (i8*, i8*)* bitcast (i32 ()* @eggs to i32 (i8*, i8*)*)) | ||
ret i32 undef | ||
} | ||
|
||
declare i32 @quux() | ||
declare i32 @eggs() | ||
|
||
define internal void @wombat(i8* %arg, i64 %arg1, i64 %arg2, i32 (i8*, i8*)* %arg3) { | ||
; CHECK-LABEL: @wombat( | ||
; CHECK-NEXT: bb4: | ||
; CHECK-NEXT: [[TMP:%.*]] = tail call i32 [[ARG3:%.*]](i8* undef, i8* undef) | ||
; CHECK-NEXT: ret void | ||
; | ||
bb4: | ||
%tmp = tail call i32 %arg3(i8* undef, i8* undef) | ||
ret void | ||
} |