[PATCH] D130224: [Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 28 04:40:03 PDT 2022
aaron.ballman added a comment.
FWIW, precommit CI has some relevant failures for a change:
******************** TEST 'Clang :: CodeGen/attr-maybeundef-template.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1'; c:\ws\w4\llvm-project\premerge-checks\build\bin\clang.exe -cc1 -internal-isystem c:\ws\w4\llvm-project\premerge-checks\build\lib\clang\16.0.0\include -nostdsysteminc -no-opaque-pointers -emit-llvm C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp -o - | c:\ws\w4\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp
--
Exit Code: 1
Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\ws\w4\llvm-project\premerge-checks\build\bin\clang.exe" "-cc1" "-internal-isystem" "c:\ws\w4\llvm-project\premerge-checks\build\lib\clang\16.0.0\include" "-nostdsysteminc" "-no-opaque-pointers" "-emit-llvm" "C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp" "-o" "-"
$ "c:\ws\w4\llvm-project\premerge-checks\build\bin\filecheck.exe" "C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp"
# command stderr:
C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp:3:11: error: CHECK: expected string not found in input
// CHECK: define weak_odr void @_Z5test4IfEvT_(float noundef [[TMP1:%.*]])
^
<stdin>:1:1: note: scanning from here
; ModuleID = 'C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp'
^
<stdin>:11:14: note: possible intended match here
define weak_odr dso_local void @"??$test4 at M@@YAXM at Z"(float noundef %arg) #0 comdat {
^
Input file: <stdin>
Check file: C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp
-dump-input=help explains the following input dump.
Input was:
<<<<<<
1: ; ModuleID = 'C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef-template.cpp'
check:3'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
2: source_filename = "C:\\ws\\w4\\llvm-project\\premerge-checks\\clang\\test\\CodeGen\\attr-maybeundef-template.cpp"
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3: target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4: target triple = "x86_64-pc-windows-msvc"
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5:
check:3'0 ~
6: $"??$test4 at M@@YAXM at Z" = comdat any
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7:
check:3'0 ~
8: $"??$test4 at H@@YAXH at Z" = comdat any
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9:
check:3'0 ~
10: ; Function Attrs: mustprogress noinline nounwind optnone
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11: define weak_odr dso_local void @"??$test4 at M@@YAXM at Z"(float noundef %arg) #0 comdat {
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:3'1 ? possible intended match
12: entry:
check:3'0 ~~~~~~~
13: %arg.addr = alloca float, align 4
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14: store float %arg, float* %arg.addr, align 4
check:3'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15: ret void
check:3'0 ~~~~~~~~~~
16: }
check:3'0 ~~
.
.
.
>>>>>>
error: command failed with exit status: 1
--
********************
FAIL: Clang :: CodeGen/attr-maybeundef.c (4048 of 15750)
******************** TEST 'Clang :: CodeGen/attr-maybeundef.c' FAILED ********************
Script:
--
: 'RUN: at line 1'; c:\ws\w4\llvm-project\premerge-checks\build\bin\clang.exe -cc1 -internal-isystem c:\ws\w4\llvm-project\premerge-checks\build\lib\clang\16.0.0\include -nostdsysteminc -no-opaque-pointers -emit-llvm C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c -o - | c:\ws\w4\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c
--
Exit Code: 1
Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\ws\w4\llvm-project\premerge-checks\build\bin\clang.exe" "-cc1" "-internal-isystem" "c:\ws\w4\llvm-project\premerge-checks\build\lib\clang\16.0.0\include" "-nostdsysteminc" "-no-opaque-pointers" "-emit-llvm" "C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c" "-o" "-"
# command stderr:
C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c:33:6: warning: 'maybe_undef' attribute only applies to parameters [-Wignored-attributes]
void __maybe_undef t2(int param1, int param2, float param3) {
^
C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c:3:38: note: expanded from macro '__maybe_undef'
#define __maybe_undef __attribute__((maybe_undef))
^
1 warning generated.
$ "c:\ws\w4\llvm-project\premerge-checks\build\bin\filecheck.exe" "C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c"
# command stderr:
C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c:7:16: error: CHECK-NEXT: is not on the line after the previous match
// CHECK-NEXT: [[TMP4:%.*]] = alloca i32, align 4
^
<stdin>:10:2: note: 'next' match was here
%param2.addr = alloca i32, align 4
^
<stdin>:8:7: note: previous match ended here
entry:
^
<stdin>:9:1: note: non-matching line after previous match is here
%param3.addr = alloca float, align 4
^
Input file: <stdin>
Check file: C:\ws\w4\llvm-project\premerge-checks\clang\test\CodeGen\attr-maybeundef.c
-dump-input=help explains the following input dump.
Input was:
<<<<<<
.
.
.
5:
6: ; Function Attrs: noinline nounwind optnone
7: define dso_local void @t1(i32 noundef %param1, i32 noundef %param2, float noundef %param3) #0 {
8: entry:
9: %param3.addr = alloca float, align 4
10: %param2.addr = alloca i32, align 4
next:7 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: match on wrong line
11: %param1.addr = alloca i32, align 4
12: store float %param3, float* %param3.addr, align 4
13: store i32 %param2, i32* %param2.addr, align 4
14: store i32 %param1, i32* %param1.addr, align 4
15: ret void
.
.
.
>>>>>>
error: command failed with exit status: 1
--
In D130224#3683831 <https://reviews.llvm.org/D130224#3683831>, @arsenm wrote:
> I can't see a scenario where we would need this with a variadic call. Ultimately these wrap specific physical instructions, not some kind of arbitrary call
Excellent, that removes that concern. Thanks! Aside from the test failures and a minor coding style nit, I think this is close to ready to go.
================
Comment at: clang/lib/CodeGen/CGCall.cpp:2063-2065
+ if (Param && Param->hasAttr<MaybeUndefAttr>()) {
+ return true;
+ }
----------------
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130224/new/
https://reviews.llvm.org/D130224
More information about the cfe-commits
mailing list