nickdesaulniers updated this revision to Diff 502781. nickdesaulniers added a comment.
- add sema test to validate 'p' inputs as per @efriedma Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145416/new/ https://reviews.llvm.org/D145416 Files: clang/lib/Basic/TargetInfo.cpp clang/test/CodeGen/inline-asm-p-constraint.c clang/test/Sema/inline-asm-validate.c Index: clang/test/Sema/inline-asm-validate.c =================================================================== --- clang/test/Sema/inline-asm-validate.c +++ clang/test/Sema/inline-asm-validate.c @@ -2,7 +2,9 @@ unsigned t, r, *p; -int foo (void) { +void foo (void) { __asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning{{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}} - return 1; + // Ensure we accept pointer and non-pointer arguments to "p" constrained + // inputs. + asm (""::"p"(t), "p"(p)); } Index: clang/test/CodeGen/inline-asm-p-constraint.c =================================================================== --- clang/test/CodeGen/inline-asm-p-constraint.c +++ clang/test/CodeGen/inline-asm-p-constraint.c @@ -11,5 +11,4 @@ asm ("":"=r"(x):"p"(¤t_task)); } // CHECK: %0 = call i64 asm "", "=r,r"(ptr @current_task) #[[ATTR:[0-9]+]] -// FIXME: should be memory(read) -// CHECK: attributes #[[ATTR]] = { nounwind memory(none) } +// CHECK: attributes #[[ATTR]] = { nounwind memory(read) } Index: clang/lib/Basic/TargetInfo.cpp =================================================================== --- clang/lib/Basic/TargetInfo.cpp +++ clang/lib/Basic/TargetInfo.cpp @@ -896,14 +896,13 @@ Info.setAllowsMemory(); break; case 'g': // general register, memory operand or immediate integer. + case 'p': // address operand. case 'X': // any operand. Info.setAllowsRegister(); Info.setAllowsMemory(); break; case 'E': // immediate floating point. case 'F': // immediate floating point. - case 'p': // address operand. - break; case ',': // multiple alternative constraint. Ignore comma. break; case '#': // Ignore as constraint.
Index: clang/test/Sema/inline-asm-validate.c =================================================================== --- clang/test/Sema/inline-asm-validate.c +++ clang/test/Sema/inline-asm-validate.c @@ -2,7 +2,9 @@ unsigned t, r, *p; -int foo (void) { +void foo (void) { __asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning{{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}} - return 1; + // Ensure we accept pointer and non-pointer arguments to "p" constrained + // inputs. + asm (""::"p"(t), "p"(p)); } Index: clang/test/CodeGen/inline-asm-p-constraint.c =================================================================== --- clang/test/CodeGen/inline-asm-p-constraint.c +++ clang/test/CodeGen/inline-asm-p-constraint.c @@ -11,5 +11,4 @@ asm ("":"=r"(x):"p"(¤t_task)); } // CHECK: %0 = call i64 asm "", "=r,r"(ptr @current_task) #[[ATTR:[0-9]+]] -// FIXME: should be memory(read) -// CHECK: attributes #[[ATTR]] = { nounwind memory(none) } +// CHECK: attributes #[[ATTR]] = { nounwind memory(read) } Index: clang/lib/Basic/TargetInfo.cpp =================================================================== --- clang/lib/Basic/TargetInfo.cpp +++ clang/lib/Basic/TargetInfo.cpp @@ -896,14 +896,13 @@ Info.setAllowsMemory(); break; case 'g': // general register, memory operand or immediate integer. + case 'p': // address operand. case 'X': // any operand. Info.setAllowsRegister(); Info.setAllowsMemory(); break; case 'E': // immediate floating point. case 'F': // immediate floating point. - case 'p': // address operand. - break; case ',': // multiple alternative constraint. Ignore comma. break; case '#': // Ignore as constraint.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits