[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos added a comment. Ping. Just a polite ping to keep it alive. I hope that's all right. Not urgent at all. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos added a comment. Ping. I made the change suggested by @erichkeane . CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos marked an inline comment as done. nigelp-xmos added inline comments. Comment at: clang/test/CodeGen/xcore-unused-inline.c:4 + +inline void dead_function(void) {} erichkeane wrote: > What is this test validating? It should likely have a check line of some sort. Currently this file crashes clang with xcore target, so it was to check there is no crash. I will add a comment to explain. I can add a CHECK too. Thank you. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D77068: Fix crash on XCore on unused inline in EmitTargetMetadata
nigelp-xmos updated this revision to Diff 273100. nigelp-xmos retitled this revision from "[XCore] fix crash on unused inline in EmitTargetMetadata" to "Fix crash on XCore on unused inline in EmitTargetMetadata". nigelp-xmos added a comment. Added explanatory comment and CHECK lines to test case, as per review comment. Removed "[XCore]" from title as the changes are not all in XCore-only code. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 Files: clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h clang/test/CodeGen/xcore-unused-inline.c Index: clang/test/CodeGen/xcore-unused-inline.c === --- /dev/null +++ clang/test/CodeGen/xcore-unused-inline.c @@ -0,0 +1,13 @@ +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore-unknown-unknown -emit-llvm -o - %s | FileCheck %s + +// D77068 fixes a segmentation fault and assertion failure "Unexpected null +// Value" in the case of an unused inline function, when targeting xcore. This +// test verifies that clang does not crash and does not produce code for such a +// function. + +// CHECK: target triple = "xcore-unknown-unknown" + +// CHECK-NOT: dead_function + +inline void dead_function(void) {} Index: clang/lib/CodeGen/TargetInfo.h === --- clang/lib/CodeGen/TargetInfo.h +++ clang/lib/CodeGen/TargetInfo.h @@ -57,10 +57,11 @@ virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const {} - /// emitTargetMD - Provides a convenient hook to handle extra - /// target-specific metadata for the given global. - virtual void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, -CodeGen::CodeGenModule &M) const {} + /// emitTargetMetadata - Provides a convenient hook to handle extra + /// target-specific metadata for the given globals. + virtual void emitTargetMetadata( + CodeGen::CodeGenModule &CGM, + const llvm::MapVector &MangledDeclNames) const {} /// Determines the size of struct _Unwind_Exception on this platform, /// in 8-bit units. The Itanium ABI defines this as: Index: clang/lib/CodeGen/TargetInfo.cpp === --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -9535,11 +9535,15 @@ class XCoreTargetCodeGenInfo : public TargetCodeGenInfo { mutable TypeStringCache TSC; + void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, +const CodeGen::CodeGenModule &M) const; + public: XCoreTargetCodeGenInfo(CodeGenTypes &CGT) : TargetCodeGenInfo(std::make_unique(CGT)) {} - void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, -CodeGen::CodeGenModule &M) const override; + void emitTargetMetadata(CodeGen::CodeGenModule &CGM, + const llvm::MapVector + &MangledDeclNames) const override; }; } // End anonymous namespace. @@ -9700,11 +9704,13 @@ /// The output is tested by test/CodeGen/xcore-stringtype.c. /// static bool getTypeString(SmallStringEnc &Enc, const Decl *D, - CodeGen::CodeGenModule &CGM, TypeStringCache &TSC); + const CodeGen::CodeGenModule &CGM, + TypeStringCache &TSC); /// XCore uses emitTargetMD to emit TypeString metadata for global symbols. -void XCoreTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) const { +void XCoreTargetCodeGenInfo::emitTargetMD( +const Decl *D, llvm::GlobalValue *GV, +const CodeGen::CodeGenModule &CGM) const { SmallStringEnc Enc; if (getTypeString(Enc, D, CGM, TSC)) { llvm::LLVMContext &Ctx = CGM.getModule().getContext(); @@ -9716,6 +9722,21 @@ } } +void XCoreTargetCodeGenInfo::emitTargetMetadata( +CodeGen::CodeGenModule &CGM, +const llvm::MapVector &MangledDeclNames) const { + // Warning, new MangledDeclNames may be appended within this loop. + // We rely on MapVector insertions adding new elements to the end + // of the container. + for (unsigned I = 0; I != MangledDeclNames.size(); ++I) { +auto Val = *(MangledDeclNames.begin() + I); +llvm::GlobalValue *GV = CGM.GetGlobalValue(Val.second); +if (GV) { + const Decl *D = Val.first.getDecl()->getMostRecentDecl(); + emitTargetMD(D, GV, CGM); +} + } +} //===--===// // SPIR ABI Implementation //===--===// @@ -10049,7 +10070,8 @@ } static bool getTypeString(SmallStringEnc &Enc, const Decl *D, -
[PATCH] D77068: Fix crash on XCore on unused inline in EmitTargetMetadata
nigelp-xmos added a comment. I do not have commit access, so if this is approved, please could it be committed against author "Nigel Perks" nig...@xmos.com ? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos added a comment. This patches fixes two Clang tests which are failing for XCore target on 2020-04-27 with "unexpected null value" assert failures: CodeGen/2003-12-14-ExternInlineSupport.c CoverageMapping/unused_names.c Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos added reviewers: jasonliu, erichkeane, RKSimon, jhibbits, ctetreau, george.burgess.iv, efriedma. nigelp-xmos added a comment. Adding code reviewer suggestions from git history. I would be grateful for review and/or reviewer suggestions. Many thanks. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos added a comment. Thanks for the comment, I will look into that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos updated this revision to Diff 264827. nigelp-xmos added a comment. As suggested by FIXME comment in code, and review comment, moved the EmitTargetMetadata loop into XCore target. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77068/new/ https://reviews.llvm.org/D77068 Files: clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h clang/test/CodeGen/xcore-unused-inline.c Index: clang/test/CodeGen/xcore-unused-inline.c === --- /dev/null +++ clang/test/CodeGen/xcore-unused-inline.c @@ -0,0 +1,4 @@ +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore-unknown-unknown -emit-llvm -o - %s + +inline void dead_function(void) {} Index: clang/lib/CodeGen/TargetInfo.h === --- clang/lib/CodeGen/TargetInfo.h +++ clang/lib/CodeGen/TargetInfo.h @@ -57,10 +57,11 @@ virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const {} - /// emitTargetMD - Provides a convenient hook to handle extra - /// target-specific metadata for the given global. - virtual void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, -CodeGen::CodeGenModule &M) const {} + /// emitTargetMetadata - Provides a convenient hook to handle extra + /// target-specific metadata for the given globals. + virtual void emitTargetMetadata( + CodeGen::CodeGenModule &CGM, + const llvm::MapVector &MangledDeclNames) const {} /// Determines the size of struct _Unwind_Exception on this platform, /// in 8-bit units. The Itanium ABI defines this as: Index: clang/lib/CodeGen/TargetInfo.cpp === --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -9394,11 +9394,15 @@ class XCoreTargetCodeGenInfo : public TargetCodeGenInfo { mutable TypeStringCache TSC; + void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, +const CodeGen::CodeGenModule &M) const; + public: XCoreTargetCodeGenInfo(CodeGenTypes &CGT) : TargetCodeGenInfo(std::make_unique(CGT)) {} - void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, -CodeGen::CodeGenModule &M) const override; + void emitTargetMetadata(CodeGen::CodeGenModule &CGM, + const llvm::MapVector + &MangledDeclNames) const override; }; } // End anonymous namespace. @@ -9559,11 +9563,13 @@ /// The output is tested by test/CodeGen/xcore-stringtype.c. /// static bool getTypeString(SmallStringEnc &Enc, const Decl *D, - CodeGen::CodeGenModule &CGM, TypeStringCache &TSC); + const CodeGen::CodeGenModule &CGM, + TypeStringCache &TSC); /// XCore uses emitTargetMD to emit TypeString metadata for global symbols. -void XCoreTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) const { +void XCoreTargetCodeGenInfo::emitTargetMD( +const Decl *D, llvm::GlobalValue *GV, +const CodeGen::CodeGenModule &CGM) const { SmallStringEnc Enc; if (getTypeString(Enc, D, CGM, TSC)) { llvm::LLVMContext &Ctx = CGM.getModule().getContext(); @@ -9575,6 +9581,21 @@ } } +void XCoreTargetCodeGenInfo::emitTargetMetadata( +CodeGen::CodeGenModule &CGM, +const llvm::MapVector &MangledDeclNames) const { + // Warning, new MangledDeclNames may be appended within this loop. + // We rely on MapVector insertions adding new elements to the end + // of the container. + for (unsigned I = 0; I != MangledDeclNames.size(); ++I) { +auto Val = *(MangledDeclNames.begin() + I); +llvm::GlobalValue *GV = CGM.GetGlobalValue(Val.second); +if (GV) { + const Decl *D = Val.first.getDecl()->getMostRecentDecl(); + emitTargetMD(D, GV, CGM); +} + } +} //===--===// // SPIR ABI Implementation //===--===// @@ -9908,7 +9929,8 @@ } static bool getTypeString(SmallStringEnc &Enc, const Decl *D, - CodeGen::CodeGenModule &CGM, TypeStringCache &TSC) { + const CodeGen::CodeGenModule &CGM, + TypeStringCache &TSC) { if (!D) return false; Index: clang/lib/CodeGen/CodeGenModule.h === --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -1508,9 +1508,6 @@ /// Emit the Clang commandline as llvm.commandline metadata. void EmitCommandLineMetadata(); - /// Emits target specific Metadata for
[PATCH] D92108: Fix inconsistent availability attribute message string literal check.
nigelp-xmos added a comment. Many thanks for review and approval. Please could it be committed as I do not have commit access? (I will request.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92108/new/ https://reviews.llvm.org/D92108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D92108: Fix inconsistent availability attribute message string literal check.
nigelp-xmos created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. nigelp-xmos requested review of this revision. Function Parser::ParseAvailabilityAttribute checks that the message string of an availability attribute is not a wide string literal. Test case clang/test/Parser/attr-availability.c specifies that a string literal is expected. The code checked that the first token in a string concatenation is a string literal, and then that the concatenated string consists of 1-byte characters. On a target where wide character is 1 byte, a string concatenation "a" L"b" passes both those checks, but L"b" alone is rejected. More generally, "a" u8"b" passes the checks, but u8"b" alone is rejected. So check isAscii() instead of character size. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D92108 Files: clang/lib/Parse/ParseDecl.cpp clang/test/Parser/attr-availability-xcore.c clang/test/Parser/attr-availability.c Index: clang/test/Parser/attr-availability.c === --- clang/test/Parser/attr-availability.c +++ clang/test/Parser/attr-availability.c @@ -22,6 +22,14 @@ void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} +void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + // rdar://10095131 enum E{ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/test/Parser/attr-availability-xcore.c === --- /dev/null +++ clang/test/Parser/attr-availability-xcore.c @@ -0,0 +1,11 @@ +// Test availability message string type when wide characters are 1 byte. +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore -fsyntax-only -verify %s + +#if !__has_feature(attribute_availability) +# error 'availability' attribute is not available +#endif + +void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/lib/Parse/ParseDecl.cpp === --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -1118,7 +1118,7 @@ // Also reject wide string literals. if (StringLiteral *MessageStringLiteral = cast_or_null(MessageExpr.get())) { -if (MessageStringLiteral->getCharByteWidth() != 1) { +if (!MessageStringLiteral->isAscii()) { Diag(MessageStringLiteral->getSourceRange().getBegin(), diag::err_expected_string_literal) << /*Source='availability attribute'*/ 2; Index: clang/test/Parser/attr-availability.c === --- clang/test/Parser/attr-availability.c +++ clang/test/Parser/attr-availability.c @@ -22,6 +22,14 @@ void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} +void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + // rdar://10095131 enum E{ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/test/Parser/attr-availability-xcore.c ===
[PATCH] D92108: Fix inconsistent availability attribute message string literal check.
nigelp-xmos added a comment. Alternatively, if all 1-byte-character strings are acceptable, should I remove the check that the first token is a string literal, and omit the failing test case on XCore? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92108/new/ https://reviews.llvm.org/D92108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D92108: Fix inconsistent availability attribute message string literal check.
nigelp-xmos updated this revision to Diff 307636. nigelp-xmos added a comment. Run clang-format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92108/new/ https://reviews.llvm.org/D92108 Files: clang/lib/Parse/ParseDecl.cpp clang/test/Parser/attr-availability-xcore.c clang/test/Parser/attr-availability.c Index: clang/test/Parser/attr-availability.c === --- clang/test/Parser/attr-availability.c +++ clang/test/Parser/attr-availability.c @@ -22,6 +22,14 @@ void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} +void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + // rdar://10095131 enum E{ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/test/Parser/attr-availability-xcore.c === --- /dev/null +++ clang/test/Parser/attr-availability-xcore.c @@ -0,0 +1,11 @@ +// Test availability message string type when wide characters are 1 byte. +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore -fsyntax-only -verify %s + +#if !__has_feature(attribute_availability) +# error 'availability' attribute is not available +#endif + +void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/lib/Parse/ParseDecl.cpp === --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -1118,7 +1118,7 @@ // Also reject wide string literals. if (StringLiteral *MessageStringLiteral = cast_or_null(MessageExpr.get())) { -if (MessageStringLiteral->getCharByteWidth() != 1) { +if (!MessageStringLiteral->isAscii()) { Diag(MessageStringLiteral->getSourceRange().getBegin(), diag::err_expected_string_literal) << /*Source='availability attribute'*/ 2; Index: clang/test/Parser/attr-availability.c === --- clang/test/Parser/attr-availability.c +++ clang/test/Parser/attr-availability.c @@ -22,6 +22,14 @@ void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} +void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + // rdar://10095131 enum E{ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/test/Parser/attr-availability-xcore.c === --- /dev/null +++ clang/test/Parser/attr-availability-xcore.c @@ -0,0 +1,11 @@ +// Test availability message string type when wide characters are 1 byte. +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore -fsyntax-only -verify %s + +#if !__has_feature(attribute_availability) +# error 'availability' attribute is not available +#endif + +void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f8() __attribute__((availability(macosx,message="a" L"b"))); // exp
[PATCH] D92108: Fix inconsistent availability attribute message string literal check.
nigelp-xmos updated this revision to Diff 307638. nigelp-xmos added a comment. Run clang-format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92108/new/ https://reviews.llvm.org/D92108 Files: clang/lib/Parse/ParseDecl.cpp clang/test/Parser/attr-availability-xcore.c clang/test/Parser/attr-availability.c Index: clang/test/Parser/attr-availability.c === --- clang/test/Parser/attr-availability.c +++ clang/test/Parser/attr-availability.c @@ -22,6 +22,14 @@ void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} +void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + // rdar://10095131 enum E{ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/test/Parser/attr-availability-xcore.c === --- /dev/null +++ clang/test/Parser/attr-availability-xcore.c @@ -0,0 +1,11 @@ +// Test availability message string type when wide characters are 1 byte. +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore -fsyntax-only -verify %s + +#if !__has_feature(attribute_availability) +# error 'availability' attribute is not available +#endif + +void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/lib/Parse/ParseDecl.cpp === --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -1118,7 +1118,7 @@ // Also reject wide string literals. if (StringLiteral *MessageStringLiteral = cast_or_null(MessageExpr.get())) { -if (MessageStringLiteral->getCharByteWidth() != 1) { +if (!MessageStringLiteral->isAscii()) { Diag(MessageStringLiteral->getSourceRange().getBegin(), diag::err_expected_string_literal) << /*Source='availability attribute'*/ 2; Index: clang/test/Parser/attr-availability.c === --- clang/test/Parser/attr-availability.c +++ clang/test/Parser/attr-availability.c @@ -22,6 +22,14 @@ void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} +void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + // rdar://10095131 enum E{ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}} Index: clang/test/Parser/attr-availability-xcore.c === --- /dev/null +++ clang/test/Parser/attr-availability-xcore.c @@ -0,0 +1,11 @@ +// Test availability message string type when wide characters are 1 byte. +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore -fsyntax-only -verify %s + +#if !__has_feature(attribute_availability) +# error 'availability' attribute is not available +#endif + +void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + +void f8() __attribute__((availability(macosx,message="a" L"b"))); // exp
[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata
nigelp-xmos created this revision. nigelp-xmos added a reviewer: rsmith. nigelp-xmos added a project: clang. EmitTargetMetadata passes to emitTargetMD a null pointer as returned from GetGlobalValue for an unused inline function which has been removed from the module at that point. Richard Smith comments in CodeGenModule.cpp that the calling code in EmitTargetMetadata should be moved into the one target that needs it (XCore). I thought it best to start with the quicker change, restricted to XCore code, checking for null, to prevent the crash. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D77068 Files: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/xcore-unused-inline.c Index: clang/test/CodeGen/xcore-unused-inline.c === --- /dev/null +++ clang/test/CodeGen/xcore-unused-inline.c @@ -0,0 +1,4 @@ +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore-unknown-unknown -emit-llvm -o - %s + +inline void dead_function(void) {} Index: clang/lib/CodeGen/TargetInfo.cpp === --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -9354,6 +9354,8 @@ /// XCore uses emitTargetMD to emit TypeString metadata for global symbols. void XCoreTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { + if (!GV) +return; SmallStringEnc Enc; if (getTypeString(Enc, D, CGM, TSC)) { llvm::LLVMContext &Ctx = CGM.getModule().getContext(); Index: clang/test/CodeGen/xcore-unused-inline.c === --- /dev/null +++ clang/test/CodeGen/xcore-unused-inline.c @@ -0,0 +1,4 @@ +// REQUIRES: xcore-registered-target +// RUN: %clang_cc1 -triple xcore-unknown-unknown -emit-llvm -o - %s + +inline void dead_function(void) {} Index: clang/lib/CodeGen/TargetInfo.cpp === --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -9354,6 +9354,8 @@ /// XCore uses emitTargetMD to emit TypeString metadata for global symbols. void XCoreTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { + if (!GV) +return; SmallStringEnc Enc; if (getTypeString(Enc, D, CGM, TSC)) { llvm::LLVMContext &Ctx = CGM.getModule().getContext(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144195: [XCore] Adapt Clang tests to opaque pointers.
nigelp-xmos created this revision. Herald added a project: All. nigelp-xmos requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144195 Files: clang/test/CodeGen/xcore-abi.c clang/test/CodeGen/xcore-stringtype.c Index: clang/test/CodeGen/xcore-stringtype.c === --- clang/test/CodeGen/xcore-stringtype.c +++ clang/test/CodeGen/xcore-stringtype.c @@ -1,5 +1,5 @@ // REQUIRES: xcore-registered-target -// RUN: %clang_cc1 -no-opaque-pointers -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s // CHECK: target triple = "xcore-unknown-unknown" @@ -23,8 +23,7 @@ // test BuiltinType -// CHECK: !{{[0-9]+}} = !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32, -// CHECK: i32, i32, i32, i64, i64, i64, float, double, double)* +// CHECK: !{{[0-9]+}} = !{ptr // CHECK: @builtinType, !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl, // CHECK: ul,sl,sll,ull,sll,ft,d,ld)"} void builtinType(_Bool B, char C, unsigned char UC, signed char SC, short S, @@ -36,14 +35,14 @@ // test FunctionType & Qualifiers -// CHECK: !{{[0-9]+}} = !{void ()* @gI, !"f{0}()"} -// CHECK: !{{[0-9]+}} = !{void (...)* @eI, !"f{0}()"} -// CHECK: !{{[0-9]+}} = !{void ()* @gV, !"f{0}(0)"} -// CHECK: !{{[0-9]+}} = !{void ()* @eV, !"f{0}(0)"} -// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @gVA, !"f{0}(si,va)"} -// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @eVA, !"f{0}(si,va)"} -// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @gQ, !"f{crv:p(cv:si)}(p(cv:si))"} -// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @eQ, !"f{crv:p(cv:si)}(p(cv:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @gI, !"f{0}()"} +// CHECK: !{{[0-9]+}} = !{ptr @eI, !"f{0}()"} +// CHECK: !{{[0-9]+}} = !{ptr @gV, !"f{0}(0)"} +// CHECK: !{{[0-9]+}} = !{ptr @eV, !"f{0}(0)"} +// CHECK: !{{[0-9]+}} = !{ptr @gVA, !"f{0}(si,va)"} +// CHECK: !{{[0-9]+}} = !{ptr @eVA, !"f{0}(si,va)"} +// CHECK: !{{[0-9]+}} = !{ptr @gQ, !"f{crv:p(cv:si)}(p(cv:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @eQ, !"f{crv:p(cv:si)}(p(cv:si))"} extern void eI(); void gI() {eI();}; extern void eV(void); @@ -57,10 +56,10 @@ // test PointerType -// CHECK: !{{[0-9]+}} = !{i32* (i32*, i32* (i32*)*)* +// CHECK: !{{[0-9]+}} = !{ptr // CHECK: @pointerType, !"f{p(si)}(p(si),p(f{p(si)}(p(si"} -// CHECK: !{{[0-9]+}} = !{i32** @EP, !"p(si)"} -// CHECK: !{{[0-9]+}} = !{i32** @GP, !"p(si)"} +// CHECK: !{{[0-9]+}} = !{ptr @EP, !"p(si)"} +// CHECK: !{{[0-9]+}} = !{ptr @GP, !"p(si)"} extern int* EP; int* GP; int* pointerType(int *I, int * (*FP)(int *)) { @@ -68,19 +67,19 @@ } // test ArrayType -// CHECK: !{{[0-9]+}} = !{[2 x i32]* (i32*, i32*, [2 x i32]*, [2 x i32]*, i32*)* +// CHECK: !{{[0-9]+}} = !{ptr // CHECK: @arrayType, !"f{p(a(2:si))}(p(si),p(cv:si),p(a(2:si)), // CHECK: p(a(2:si)),p(si))"} -// CHECK: !{{[0-9]+}} = !{[0 x i32]* @EA1, !"a(*:cv:si)"} -// CHECK: !{{[0-9]+}} = !{[2 x i32]* @EA2, !"a(2:si)"} -// CHECK: !{{[0-9]+}} = !{[0 x [2 x i32]]* @EA3, !"a(*:a(2:si))"} -// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @EA4, !"a(3:a(2:si))"} -// CHECK: !{{[0-9]+}} = !{[2 x i32]* @GA1, !"a(2:cv:si)"} -// CHECK: !{{[0-9]+}} = !{void ([2 x i32]*)* @arrayTypeVariable1, +// CHECK: !{{[0-9]+}} = !{ptr @EA1, !"a(*:cv:si)"} +// CHECK: !{{[0-9]+}} = !{ptr @EA2, !"a(2:si)"} +// CHECK: !{{[0-9]+}} = !{ptr @EA3, !"a(*:a(2:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @EA4, !"a(3:a(2:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @GA1, !"a(2:cv:si)"} +// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable1, // CHECK: !"f{0}(p(a(2:si)))"} -// CHECK: !{{[0-9]+}} = !{void (void ([2 x i32]*)*)* @arrayTypeVariable2, +// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable2, // CHECK: !"f{0}(p(f{0}(p(a(2:si)"} -// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @GA2, !"a(3:a(2:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @GA2, !"a(3:a(2:si))"} extern int GA2[3][2]; extern const volatile int EA1[]; extern int EA2[2]; @@ -108,16 +107,16 @@ // test StructureType -// CHECK: !{{[0-9]+}} = !{void (%struct.S1*)* @structureType1, +// CHECK: !{{[0-9]+}} = !{ptr @structureType1, // CHECK: !"f{0}(s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}})"} -// CHECK: !{{[0-9]+}} = !{void (%struct.S2*)* @structureType2, +// CHECK: !{{[0-9]+}} = !{ptr @structureType2, // CHECK: !"f{0}(s(S2){m(ps3){p(s(S3){m(s1){s(S1){m(ps2){p(s(S2){}))}})"} -// CHECK: !{{[0-9]+}} = !{void (%struct.S3*)* @structureType3, +// CHECK: !{{[0-9]+}} = !{ptr @structureType3, // CHECK: !"f{0}(s(S3){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){})}}))"} -// CHECK: !{{[0-9]+}} = !{void (%struct.S4*)* @structureType4, +// CHECK: !{{[0-9]+}} = !{ptr @structureType4, // CHECK: !"f{0}(s(S4){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3)
[PATCH] D144195: [XCore] Adapt Clang tests to opaque pointers.
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG0871337d97f7: [XCore] Adapt Clang tests to opaque pointers. (authored by nigelp-xmos). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144195/new/ https://reviews.llvm.org/D144195 Files: clang/test/CodeGen/xcore-abi.c clang/test/CodeGen/xcore-stringtype.c Index: clang/test/CodeGen/xcore-stringtype.c === --- clang/test/CodeGen/xcore-stringtype.c +++ clang/test/CodeGen/xcore-stringtype.c @@ -1,5 +1,5 @@ // REQUIRES: xcore-registered-target -// RUN: %clang_cc1 -no-opaque-pointers -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s // CHECK: target triple = "xcore-unknown-unknown" @@ -23,8 +23,7 @@ // test BuiltinType -// CHECK: !{{[0-9]+}} = !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32, -// CHECK: i32, i32, i32, i64, i64, i64, float, double, double)* +// CHECK: !{{[0-9]+}} = !{ptr // CHECK: @builtinType, !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl, // CHECK: ul,sl,sll,ull,sll,ft,d,ld)"} void builtinType(_Bool B, char C, unsigned char UC, signed char SC, short S, @@ -36,14 +35,14 @@ // test FunctionType & Qualifiers -// CHECK: !{{[0-9]+}} = !{void ()* @gI, !"f{0}()"} -// CHECK: !{{[0-9]+}} = !{void (...)* @eI, !"f{0}()"} -// CHECK: !{{[0-9]+}} = !{void ()* @gV, !"f{0}(0)"} -// CHECK: !{{[0-9]+}} = !{void ()* @eV, !"f{0}(0)"} -// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @gVA, !"f{0}(si,va)"} -// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @eVA, !"f{0}(si,va)"} -// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @gQ, !"f{crv:p(cv:si)}(p(cv:si))"} -// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @eQ, !"f{crv:p(cv:si)}(p(cv:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @gI, !"f{0}()"} +// CHECK: !{{[0-9]+}} = !{ptr @eI, !"f{0}()"} +// CHECK: !{{[0-9]+}} = !{ptr @gV, !"f{0}(0)"} +// CHECK: !{{[0-9]+}} = !{ptr @eV, !"f{0}(0)"} +// CHECK: !{{[0-9]+}} = !{ptr @gVA, !"f{0}(si,va)"} +// CHECK: !{{[0-9]+}} = !{ptr @eVA, !"f{0}(si,va)"} +// CHECK: !{{[0-9]+}} = !{ptr @gQ, !"f{crv:p(cv:si)}(p(cv:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @eQ, !"f{crv:p(cv:si)}(p(cv:si))"} extern void eI(); void gI() {eI();}; extern void eV(void); @@ -57,10 +56,10 @@ // test PointerType -// CHECK: !{{[0-9]+}} = !{i32* (i32*, i32* (i32*)*)* +// CHECK: !{{[0-9]+}} = !{ptr // CHECK: @pointerType, !"f{p(si)}(p(si),p(f{p(si)}(p(si"} -// CHECK: !{{[0-9]+}} = !{i32** @EP, !"p(si)"} -// CHECK: !{{[0-9]+}} = !{i32** @GP, !"p(si)"} +// CHECK: !{{[0-9]+}} = !{ptr @EP, !"p(si)"} +// CHECK: !{{[0-9]+}} = !{ptr @GP, !"p(si)"} extern int* EP; int* GP; int* pointerType(int *I, int * (*FP)(int *)) { @@ -68,19 +67,19 @@ } // test ArrayType -// CHECK: !{{[0-9]+}} = !{[2 x i32]* (i32*, i32*, [2 x i32]*, [2 x i32]*, i32*)* +// CHECK: !{{[0-9]+}} = !{ptr // CHECK: @arrayType, !"f{p(a(2:si))}(p(si),p(cv:si),p(a(2:si)), // CHECK: p(a(2:si)),p(si))"} -// CHECK: !{{[0-9]+}} = !{[0 x i32]* @EA1, !"a(*:cv:si)"} -// CHECK: !{{[0-9]+}} = !{[2 x i32]* @EA2, !"a(2:si)"} -// CHECK: !{{[0-9]+}} = !{[0 x [2 x i32]]* @EA3, !"a(*:a(2:si))"} -// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @EA4, !"a(3:a(2:si))"} -// CHECK: !{{[0-9]+}} = !{[2 x i32]* @GA1, !"a(2:cv:si)"} -// CHECK: !{{[0-9]+}} = !{void ([2 x i32]*)* @arrayTypeVariable1, +// CHECK: !{{[0-9]+}} = !{ptr @EA1, !"a(*:cv:si)"} +// CHECK: !{{[0-9]+}} = !{ptr @EA2, !"a(2:si)"} +// CHECK: !{{[0-9]+}} = !{ptr @EA3, !"a(*:a(2:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @EA4, !"a(3:a(2:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @GA1, !"a(2:cv:si)"} +// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable1, // CHECK: !"f{0}(p(a(2:si)))"} -// CHECK: !{{[0-9]+}} = !{void (void ([2 x i32]*)*)* @arrayTypeVariable2, +// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable2, // CHECK: !"f{0}(p(f{0}(p(a(2:si)"} -// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @GA2, !"a(3:a(2:si))"} +// CHECK: !{{[0-9]+}} = !{ptr @GA2, !"a(3:a(2:si))"} extern int GA2[3][2]; extern const volatile int EA1[]; extern int EA2[2]; @@ -108,16 +107,16 @@ // test StructureType -// CHECK: !{{[0-9]+}} = !{void (%struct.S1*)* @structureType1, +// CHECK: !{{[0-9]+}} = !{ptr @structureType1, // CHECK: !"f{0}(s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}})"} -// CHECK: !{{[0-9]+}} = !{void (%struct.S2*)* @structureType2, +// CHECK: !{{[0-9]+}} = !{ptr @structureType2, // CHECK: !"f{0}(s(S2){m(ps3){p(s(S3){m(s1){s(S1){m(ps2){p(s(S2){}))}})"} -// CHECK: !{{[0-9]+}} = !{void (%struct.S3*)* @structureType3, +// CHECK: !{{[0-9]+}} = !{ptr @structureType3, // CHECK: !"f{0}(s(S3){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){})}}))"} -// CHECK: !{{[0-9]+}} = !{void (%struct.S4*)* @structureType