[PATCH] D29117: SPARC: allow usage of floating-point registers in inline ASM
pboettch updated this revision to Diff 85708. pboettch added a comment. Added test-code. https://reviews.llvm.org/D29117 Files: lib/Basic/Targets.cpp test/CodeGen/sparcv8-inline-asm.c Index: test/CodeGen/sparcv8-inline-asm.c === --- /dev/null +++ test/CodeGen/sparcv8-inline-asm.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s + +// CHECK: define float @fabsf(float %a) #0 { +// CHECK: %2 = call float asm sideeffect "fabss $1, $0;", "=f,f"(float %1) #1 +float fabsf(float a) { + float res; + __asm __volatile__("fabss %1, %0;" + : /* reg out*/ "=f"(res) + : /* reg in */ "f"(a)); + return res; +} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -6707,6 +6707,10 @@ case 'N': // Same as 'K' but zext (required for SIMode) case 'O': // The constant 4096 return true; + +case 'f': + info.setAllowsRegister(); + return true; } return false; } Index: test/CodeGen/sparcv8-inline-asm.c === --- /dev/null +++ test/CodeGen/sparcv8-inline-asm.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s + +// CHECK: define float @fabsf(float %a) #0 { +// CHECK: %2 = call float asm sideeffect "fabss $1, $0;", "=f,f"(float %1) #1 +float fabsf(float a) { + float res; + __asm __volatile__("fabss %1, %0;" + : /* reg out*/ "=f"(res) + : /* reg in */ "f"(a)); + return res; +} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -6707,6 +6707,10 @@ case 'N': // Same as 'K' but zext (required for SIMode) case 'O': // The constant 4096 return true; + +case 'f': + info.setAllowsRegister(); + return true; } return false; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29031: [mips] Add support for static model on N64
slthakur accepted this revision. slthakur added a comment. LGTM Repository: rL LLVM https://reviews.llvm.org/D29031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend
nlopes added a comment. Regarding incremental solving with Z3 (or with most SMT solvers in general), let me just lower the expectations a bit: In Z3, when you do push(), there are a few things that change immediately: 1) it uses a different SAT solver (one that supports incremental reasoning), and 2) some preprocessing steps are disabled completely. The advantage of incremental solving is that it shares the state of the SAT solver between queries. On the other hand, Z3 disables a bunch of nice preprocessors, and also it switches to eager bit-blasting. So whether going incremental pays off, it depends.. I've seen cases where it's faster to create a new solver for each query and cases where incremental is a good thing. It's on our plans to "fix" Z3 to do better preprocessing in incremental mode, but there's no ETA at the moment to start this work.. https://reviews.llvm.org/D28952 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293043 - [analyzer] Fix MacOSXAPIChecker fp with static locals seen from nested blocks.
Author: dergachev Date: Wed Jan 25 04:21:45 2017 New Revision: 293043 URL: http://llvm.org/viewvc/llvm-project?rev=293043&view=rev Log: [analyzer] Fix MacOSXAPIChecker fp with static locals seen from nested blocks. This is an attempt to avoid new false positives caused by the reverted r292800, however the scope of the fix is significantly reduced - some variables are still in incorrect memory spaces. Relevant test cases added. rdar://problem/30105546 rdar://problem/30156693 Differential revision: https://reviews.llvm.org/D28946 Added: cfe/trunk/test/Analysis/null-deref-static.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp cfe/trunk/test/Analysis/dispatch-once.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp?rev=293043&r1=293042&r2=293043&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp Wed Jan 25 04:21:45 2017 @@ -94,11 +94,18 @@ void MacOSXAPIChecker::CheckDispatchOnce bool SuggestStatic = false; os << "Call to '" << FName << "' uses"; if (const VarRegion *VR = dyn_cast(RB)) { +const VarDecl *VD = VR->getDecl(); +// FIXME: These should have correct memory space and thus should be filtered +// out earlier. This branch only fires when we're looking from a block, +// which we analyze as a top-level declaration, onto a static local +// in a function that contains the block. +if (VD->isStaticLocal()) + return; // We filtered out globals earlier, so it must be a local variable // or a block variable which is under UnknownSpaceRegion. if (VR != R) os << " memory within"; -if (VR->getDecl()->hasAttr()) +if (VD->hasAttr()) os << " the block variable '"; else os << " the local variable '"; Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=293043&r1=293042&r2=293043&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Wed Jan 25 04:21:45 2017 @@ -816,9 +816,11 @@ const VarRegion* MemRegionManager::getVa const StackFrameContext *STC = V.get(); -if (!STC) +if (!STC) { + // FIXME: Assign a more sensible memory space to static locals + // we see from within blocks that we analyze as top-level declarations. sReg = getUnknownRegion(); -else { +} else { if (D->hasLocalStorage()) { sReg = isa(D) || isa(D) ? static_cast(getStackArgumentsRegion(STC)) Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=293043&r1=293042&r2=293043&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Wed Jan 25 04:21:45 2017 @@ -1849,6 +1849,8 @@ SVal RegionStoreManager::getBindingForVa // Function-scoped static variables are default-initialized to 0; if they // have an initializer, it would have been processed by now. +// FIXME: This is only true when we're starting analysis from main(). +// We're losing a lot of coverage here. if (isa(MS)) return svalBuilder.makeZeroVal(T); Modified: cfe/trunk/test/Analysis/dispatch-once.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dispatch-once.m?rev=293043&r1=293042&r2=293043&view=diff == --- cfe/trunk/test/Analysis/dispatch-once.m (original) +++ cfe/trunk/test/Analysis/dispatch-once.m Wed Jan 25 04:21:45 2017 @@ -107,3 +107,10 @@ void test_block_var_from_outside_block() }; dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}} } + +void test_static_var_from_outside_block() { + static dispatch_once_t once; + ^{ +dispatch_once(&once, ^{}); // no-warning + }; +} Added: cfe/trunk/test/Analysis/null-deref-static.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-static.m?rev=293043&view=auto == --- cfe/trunk/test/Analysis/null-deref-static.m (added) +++ cfe/trunk/test/Analysis/null-deref-static.m Wed Jan 25 04:21:45 2017 @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -w -fblocks -analyze -analyze
[PATCH] D28946: [analyzer] Fix memory space for block-captured static locals.
This revision was automatically updated to reflect the committed changes. Closed by commit rL293043: [analyzer] Fix MacOSXAPIChecker fp with static locals seen from nested blocks. (authored by dergachev). Changed prior to commit: https://reviews.llvm.org/D28946?vs=85588&id=85722#toc Repository: rL LLVM https://reviews.llvm.org/D28946 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp cfe/trunk/test/Analysis/dispatch-once.m cfe/trunk/test/Analysis/null-deref-static.m Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1849,6 +1849,8 @@ // Function-scoped static variables are default-initialized to 0; if they // have an initializer, it would have been processed by now. +// FIXME: This is only true when we're starting analysis from main(). +// We're losing a lot of coverage here. if (isa(MS)) return svalBuilder.makeZeroVal(T); Index: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -816,9 +816,11 @@ const StackFrameContext *STC = V.get(); -if (!STC) +if (!STC) { + // FIXME: Assign a more sensible memory space to static locals + // we see from within blocks that we analyze as top-level declarations. sReg = getUnknownRegion(); -else { +} else { if (D->hasLocalStorage()) { sReg = isa(D) || isa(D) ? static_cast(getStackArgumentsRegion(STC)) Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp @@ -94,11 +94,18 @@ bool SuggestStatic = false; os << "Call to '" << FName << "' uses"; if (const VarRegion *VR = dyn_cast(RB)) { +const VarDecl *VD = VR->getDecl(); +// FIXME: These should have correct memory space and thus should be filtered +// out earlier. This branch only fires when we're looking from a block, +// which we analyze as a top-level declaration, onto a static local +// in a function that contains the block. +if (VD->isStaticLocal()) + return; // We filtered out globals earlier, so it must be a local variable // or a block variable which is under UnknownSpaceRegion. if (VR != R) os << " memory within"; -if (VR->getDecl()->hasAttr()) +if (VD->hasAttr()) os << " the block variable '"; else os << " the local variable '"; Index: cfe/trunk/test/Analysis/null-deref-static.m === --- cfe/trunk/test/Analysis/null-deref-static.m +++ cfe/trunk/test/Analysis/null-deref-static.m @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,deadcode,alpha.core,debug.ExprInspection -verify %s + +void *malloc(unsigned long); +void clang_analyzer_warnIfReached(); + +void test_static_from_block() { + static int *x; + ^{ +*x; // no-warning + }; +} + +void test_static_within_block() { + ^{ +static int *x; +*x; // expected-warning{{Dereference of null pointer}} + }; +} + +void test_static_control_flow(int y) { + static int *x; + if (x) { +// FIXME: Should be reachable. +clang_analyzer_warnIfReached(); // no-warning + } + if (y) { +// We are not sure if this branch is possible, because the developer +// may argue that function is always called with y == 1 for the first time. +// In this case, we can only advise the developer to add assertions +// for suppressing such path. +*x; // expected-warning{{Dereference of null pointer}} + } else { +x = malloc(1); + } +} Index: cfe/trunk/test/Analysis/dispatch-once.m === --- cfe/trunk/test/Analysis/dispatch-once.m +++ cfe/trunk/test/Analysis/dispatch-once.m @@ -107,3 +107,10 @@ }; dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}} } + +void test_static_var_from_outside_block() { + static dispatch_once_t once; + ^{ +dispatch_once(&once, ^{}); // no-warning + }; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
krasimir updated this revision to Diff 85725. krasimir marked 8 inline comments as done. krasimir added a comment. - Address review comments. https://reviews.llvm.org/D28764 Files: lib/Format/BreakableToken.cpp lib/Format/BreakableToken.h lib/Format/CMakeLists.txt lib/Format/Comments.cpp lib/Format/Comments.h lib/Format/ContinuationIndenter.cpp lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineParser.cpp lib/Format/WhitespaceManager.cpp unittests/Format/FormatTest.cpp unittests/Format/FormatTestSelective.cpp Index: unittests/Format/FormatTestSelective.cpp === --- unittests/Format/FormatTestSelective.cpp +++ unittests/Format/FormatTestSelective.cpp @@ -111,13 +111,19 @@ format("int a; // comment\n" "intb; // comment", 0, 0)); - EXPECT_EQ("int a; // comment\n" -" // line 2\n" + EXPECT_EQ("int a; // comment\n" +" // line 2\n" "int b;", format("int a; // comment\n" "// line 2\n" "int b;", 28, 0)); + EXPECT_EQ("int a; // comment\n" +"// comment 2\n" +"int b;", +format("int a; // comment\n" + "// comment 2\n" + "int b;", 28, 0)); EXPECT_EQ("int aa; // comment\n" "int b;\n" "int c; // unrelated comment", Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1783,6 +1783,463 @@ "0x00, 0x00, 0x00, 0x00};// comment\n"); } +TEST_F(FormatTest, ReflowsComments) { + // Break a long line and reflow with the full next line. + EXPECT_EQ("// long long long\n" +"// long long", +format("// long long long long\n" + "// long", + getLLVMStyleWithColumns(20))); + + // Keep the trailing newline while reflowing. + EXPECT_EQ("// long long long\n" +"// long long\n", +format("// long long long long\n" + "// long\n", + getLLVMStyleWithColumns(20))); + + // Break a long line and reflow with a part of the next line. + EXPECT_EQ("// long long long\n" +"// long long\n" +"// long_long", +format("// long long long long\n" + "// long long_long", + getLLVMStyleWithColumns(20))); + + // Break but do not reflow if the first word from the next line is too long. + EXPECT_EQ("// long long long\n" +"// long\n" +"// long_long_long\n", +format("// long long long long\n" + "// long_long_long\n", + getLLVMStyleWithColumns(20))); + + // Don't break or reflow short lines. + verifyFormat("// long\n" + "// long long long lo\n" + "// long long long lo\n" + "// long", + getLLVMStyleWithColumns(20)); + + // Keep prefixes and decorations while reflowing. + EXPECT_EQ("/// long long long\n" +"/// long long\n", +format("/// long long long long\n" + "/// long\n", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//! long long long\n" +"//! long long\n", +format("//! long long long long\n" + "//! long\n", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("/* long long long\n" +" * long long */", +format("/* long long long long\n" + " * long */", + getLLVMStyleWithColumns(20))); + + // Don't bring leading whitespace up while reflowing. + EXPECT_EQ("/* long long long\n" +" * long long long\n" +" */", +format("/* long long long long\n" + " * long long\n" + " */", + getLLVMStyleWithColumns(20))); + + // Reflow the last line of a block comment with its trailing '*/'. + EXPECT_EQ("/* long long long\n" +" long long */", +format("/* long long long long\n" + " long */", + getLLVMStyleWithColumns(20))); + + // Reflow two short lines; keep the postfix of the last one. + EXPECT_EQ("/* long long long\n" +" * long long long */", +format("/* long long long long\n" + " * long\n" + " * long */", + getLLVMStyleWithColumns(20))); + + // Put the postfix of the last short reflow line on a newline if it doesn't + // fit. + EXPECT_EQ("/* long long long\n" +" * long long longg\n" +" */", +format("/* long long long long\n" + " * long\n" +
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
krasimir added inline comments. Comment at: lib/Format/ContinuationIndenter.cpp:1158-1159 +CommentPragmasRegex.match(Current.TokenText.substr(2)) || +Current.TokenText.substr(2).ltrim().startswith("clang-format on") || +Current.TokenText.substr(2).ltrim().startswith("clang-format off")) return addMultilineToken(Current, State); klimek wrote: > krasimir wrote: > > klimek wrote: > > > krasimir wrote: > > > > klimek wrote: > > > > > Generally, we shouldn't need those here, as those should be part of > > > > > the Token.Finalized state. > > > > Here the problem is that the comments /* clang-format on */ and /* > > > > clang-format off */ control the formatting of the tokens in between, > > > > but do not control their own formatting, that is they are not finalized > > > > themselves. > > > > What happens is that if we rely solely on Token.Finalized and the > > > > ColumnLimit is small, say 20, then: > > > > ``` > > > > /* clang-format off */ > > > > ``` > > > > gets broken into: > > > > ``` > > > > /* clang-format off > > > > */ > > > > ``` > > > > > > > > Add comments about this. > > > Isn't the right fix to change the tokens of the comment to be finalized? > > That's arguable. Consider [[ > > https://github.com/llvm-mirror/clang/blob/master/unittests/Format/FormatTest.cpp#L10916 > > | FormatTest.cpp:10916 ]]: in this case we still want to re-indent the /* > > clang-format on/off */ comments, just not break them. If we finalize the > > token, we can't re-indent. > I see two options: > - mark the comment with a special token type for clang-format on/off > - pull out a function - I see you already have one called mayReflowContent; > can we use that? mayReflowContent is too specific for content during region. I'll add a delimitsRegion method. Comment at: lib/Format/ContinuationIndenter.cpp:1205-1210 +if (SplitBefore.first != StringRef::npos) { + TailOffset = SplitBefore.first + SplitBefore.second; + ReflowInProgress = true; +} else { + ReflowInProgress = false; +} klimek wrote: > (optional) I'd probably write this: > ReflowInProgress = SplitBefore.first != StringRef::npos; > if (ReflowInProgress) { > TailOffset = SplitBefore.first + SplitBefore.second; > } How about this? Comment at: lib/Format/ContinuationIndenter.cpp:1231-1233 + unsigned RemainingTokenColumnsAfterCompress = + Token->getLineLengthAfterCompress(LineIndex, TailOffset, +RemainingTokenColumns, Split); klimek wrote: > I think AfterCompression reads more naturally. Perhaps we should use "trim" > instead of compress, now that I think about it. > So I'd probably go for getTrimmedLineLength or something. I don't agree with "trimmig" because i have a connotation of "trimming" around the ends of strings like in ltrim/rtrim and this fundamentally operates somewhere inside. +1 for AfterCompression, though. Comment at: lib/Format/WhitespaceManager.cpp:131 +Changes[i - 1].Kind == tok::comment && +OriginalWhitespaceStart != PreviousOriginalWhitespaceEnd; } klimek wrote: > Why was this needed? (what breaks without this change) This is a dirty hack. The problem is that WhitespaceManager does its own formatting for trailing comments and sometimes it re-formats a piece of line even after it's been reflown with the previous line. Consider if we reflow the second line up: ``` // line 1 // line 2 ``` That amounts to 2 changes, first (delimited by ()) for the whitespace between the two tokens, and second (delimited by []) for the beginning of the next line: ``` // line 1( )[// ]line 2 ``` So in the end we have two changes like this: ``` // line 1()[ ]line 2 ``` Note that the OriginalWhitespaceStart of the second change is the same as the PreviousOriginalWhitespaceEnd of the first change. In this case, the above code marks the second line as trailing comment and afterwards applies its own trailing-comment-alignment logic to it, which might introduce extra whitespace before "line 2". For a proper solution we need a mechanism to say that a particular change emitted through the whitespace manager breaks the sequence of trailing comments. Comment at: unittests/Format/FormatTest.cpp:2169 + + // Don't reflow lines starting with two punctuation characters. + EXPECT_EQ("// long long long\n" klimek wrote: > But we want to reflow lines starting with one punctuation character? I guess I'm looking at lines that start like this: "ala", 'ala'. So it may be better to special-case these two instead. The heuristic for now, in mayReflowContent is: the content of the line needs to have at least two characters and either the first or the second character must be non-punctuation. Another approach would be to not do these funny things a
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
klimek added inline comments. Comment at: lib/Format/BreakableToken.cpp:279-280 + return Content.size() >= 2 && + Content != "clang-format on" && + Content != "clang-format off" && + !Content.endswith("\\") && Can we now use delimitsRegion here? Comment at: lib/Format/ContinuationIndenter.cpp:1090-1092 +// Checks if Token delimits formatting regions, like /* clang-format off */. +// Token must be a comment. +static bool delimitsRegion(const FormatToken &Token) { delimitsRegion seems overly abstract. Perhaps switchesFormatting? Comment at: lib/Format/ContinuationIndenter.cpp:1205-1210 +if (SplitBefore.first != StringRef::npos) { + TailOffset = SplitBefore.first + SplitBefore.second; + ReflowInProgress = true; +} else { + ReflowInProgress = false; +} krasimir wrote: > klimek wrote: > > (optional) I'd probably write this: > > ReflowInProgress = SplitBefore.first != StringRef::npos; > > if (ReflowInProgress) { > > TailOffset = SplitBefore.first + SplitBefore.second; > > } > How about this? That works. Comment at: lib/Format/ContinuationIndenter.cpp:1231-1233 + unsigned RemainingTokenColumnsAfterCompress = + Token->getLineLengthAfterCompress(LineIndex, TailOffset, +RemainingTokenColumns, Split); krasimir wrote: > klimek wrote: > > I think AfterCompression reads more naturally. Perhaps we should use "trim" > > instead of compress, now that I think about it. > > So I'd probably go for getTrimmedLineLength or something. > I don't agree with "trimmig" because i have a connotation of "trimming" > around the ends of strings like in ltrim/rtrim and this fundamentally > operates somewhere inside. +1 for AfterCompression, though. Yea, correct, I completely missed that this might happen in the middle of the string if we happen to be the first token that runs over, which is a rather interesting case :) Comment at: lib/Format/WhitespaceManager.cpp:131 +Changes[i - 1].Kind == tok::comment && +OriginalWhitespaceStart != PreviousOriginalWhitespaceEnd; } krasimir wrote: > klimek wrote: > > Why was this needed? (what breaks without this change) > This is a dirty hack. The problem is that WhitespaceManager does its own > formatting for trailing comments and sometimes it re-formats a piece of line > even after it's been reflown with the previous line. Consider if we reflow > the second line up: > ``` > // line 1 > // line 2 > ``` > That amounts to 2 changes, first (delimited by ()) for the whitespace between > the two tokens, and second (delimited by []) for the beginning of the next > line: > ``` > // line 1( > )[// ]line 2 > ``` > So in the end we have two changes like this: > ``` > // line 1()[ ]line 2 > ``` > Note that the OriginalWhitespaceStart of the second change is the same as the > PreviousOriginalWhitespaceEnd of the first change. > In this case, the above code marks the second line as trailing comment and > afterwards applies its own trailing-comment-alignment logic to it, which > might introduce extra whitespace before "line 2". > > For a proper solution we need a mechanism to say that a particular change > emitted through the whitespace manager breaks the sequence of trailing > comments. > > Ok. In this case this needs a largish comment with a FIXME, like you just described ;) https://reviews.llvm.org/D28764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293048 - [OpenMP] Support for num_teams-clause on the 'target teams' directive.
Author: arpith Date: Wed Jan 25 05:28:18 2017 New Revision: 293048 URL: http://llvm.org/viewvc/llvm-project?rev=293048&view=rev Log: [OpenMP] Support for num_teams-clause on the 'target teams' directive. The num_teams-clause on the combined directive applies to the 'teams' region of this construct. We modify the NumTeamsClause class to capture the clause expression within the 'target' region. Reviewers: ABataev Differential Revision: https://reviews.llvm.org/D29085 Added: cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp Modified: cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/lib/AST/OpenMPClause.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/OpenMPClause.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=293048&r1=293047&r2=293048&view=diff == --- cfe/trunk/include/clang/AST/OpenMPClause.h (original) +++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Jan 25 05:28:18 2017 @@ -3479,7 +3479,7 @@ public: /// In this example directive '#pragma omp teams' has clause 'num_teams' /// with single expression 'n'. /// -class OMPNumTeamsClause : public OMPClause { +class OMPNumTeamsClause : public OMPClause, public OMPClauseWithPreInit { friend class OMPClauseReader; /// \brief Location of '('. SourceLocation LParenLoc; @@ -3495,20 +3495,27 @@ public: /// \brief Build 'num_teams' clause. /// /// \param E Expression associated with this clause. + /// \param HelperE Helper Expression associated with this clause. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. /// \param StartLoc Starting location of the clause. /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. /// - OMPNumTeamsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, + OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, +SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) - : OMPClause(OMPC_num_teams, StartLoc, EndLoc), LParenLoc(LParenLoc), -NumTeams(E) {} + : OMPClause(OMPC_num_teams, StartLoc, EndLoc), OMPClauseWithPreInit(this), +LParenLoc(LParenLoc), NumTeams(E) { +setPreInitStmt(HelperE, CaptureRegion); + } /// \brief Build an empty clause. /// OMPNumTeamsClause() - : OMPClause(OMPC_num_teams, SourceLocation(), SourceLocation()), -LParenLoc(SourceLocation()), NumTeams(nullptr) {} + : OMPClause(OMPC_num_teams, SourceLocation(), SourceLocation()), +OMPClauseWithPreInit(this), LParenLoc(SourceLocation()), +NumTeams(nullptr) {} /// \brief Sets the location of '('. void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } /// \brief Returns the location of '('. Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=293048&r1=293047&r2=293048&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Jan 25 05:28:18 2017 @@ -2995,6 +2995,7 @@ bool RecursiveASTVisitor::Visit template bool RecursiveASTVisitor::VisitOMPNumTeamsClause( OMPNumTeamsClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); TRY_TO(TraverseStmt(C->getNumTeams())); return true; } Modified: cfe/trunk/lib/AST/OpenMPClause.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=293048&r1=293047&r2=293048&view=diff == --- cfe/trunk/lib/AST/OpenMPClause.cpp (original) +++ cfe/trunk/lib/AST/OpenMPClause.cpp Wed Jan 25 05:28:18 2017 @@ -52,6 +52,8 @@ const OMPClauseWithPreInit *OMPClauseWit return static_cast(C); case OMPC_num_threads: return static_cast(C); + case OMPC_num_teams: +return static_cast(C); case OMPC_default: case OMPC_proc_bind: case OMPC_final: @@ -79,7 +81,6 @@ const OMPClauseWithPreInit *OMPClauseWit case OMPC_threads: case OMPC_simd: case OMPC_map: - case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: case OMPC_grainsize: Modified: cfe/trunk/lib/AST/StmtProfile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=293048&r1=293047&r2=293048&view=diff == --- cfe/trunk/lib/AST/StmtProfile.cpp (original) +++ cfe/trunk/lib/A
[PATCH] D29085: [OpenMP] Support for num_teams-clause on the 'target teams' directive.
This revision was automatically updated to reflect the committed changes. Closed by commit rL293048: [OpenMP] Support for num_teams-clause on the 'target teams' directive. (authored by arpith). Changed prior to commit: https://reviews.llvm.org/D29085?vs=85587&id=85726#toc Repository: rL LLVM https://reviews.llvm.org/D29085 Files: cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/lib/AST/OpenMPClause.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp cfe/trunk/tools/libclang/CIndex.cpp Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h === --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h @@ -2995,6 +2995,7 @@ template bool RecursiveASTVisitor::VisitOMPNumTeamsClause( OMPNumTeamsClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); TRY_TO(TraverseStmt(C->getNumTeams())); return true; } Index: cfe/trunk/include/clang/AST/OpenMPClause.h === --- cfe/trunk/include/clang/AST/OpenMPClause.h +++ cfe/trunk/include/clang/AST/OpenMPClause.h @@ -3479,7 +3479,7 @@ /// In this example directive '#pragma omp teams' has clause 'num_teams' /// with single expression 'n'. /// -class OMPNumTeamsClause : public OMPClause { +class OMPNumTeamsClause : public OMPClause, public OMPClauseWithPreInit { friend class OMPClauseReader; /// \brief Location of '('. SourceLocation LParenLoc; @@ -3495,20 +3495,27 @@ /// \brief Build 'num_teams' clause. /// /// \param E Expression associated with this clause. + /// \param HelperE Helper Expression associated with this clause. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. /// \param StartLoc Starting location of the clause. /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. /// - OMPNumTeamsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, + OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, +SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) - : OMPClause(OMPC_num_teams, StartLoc, EndLoc), LParenLoc(LParenLoc), -NumTeams(E) {} + : OMPClause(OMPC_num_teams, StartLoc, EndLoc), OMPClauseWithPreInit(this), +LParenLoc(LParenLoc), NumTeams(E) { +setPreInitStmt(HelperE, CaptureRegion); + } /// \brief Build an empty clause. /// OMPNumTeamsClause() - : OMPClause(OMPC_num_teams, SourceLocation(), SourceLocation()), -LParenLoc(SourceLocation()), NumTeams(nullptr) {} + : OMPClause(OMPC_num_teams, SourceLocation(), SourceLocation()), +OMPClauseWithPreInit(this), LParenLoc(SourceLocation()), +NumTeams(nullptr) {} /// \brief Sets the location of '('. void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } /// \brief Returns the location of '('. Index: cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp === --- cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp +++ cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp @@ -0,0 +1,344 @@ +// Test host codegen. +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 + +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-i
r293049 - [OpenMP] Support for thread_limit-clause on the 'target teams' directive.
Author: arpith Date: Wed Jan 25 05:44:35 2017 New Revision: 293049 URL: http://llvm.org/viewvc/llvm-project?rev=293049&view=rev Log: [OpenMP] Support for thread_limit-clause on the 'target teams' directive. The thread_limit-clause on the combined directive applies to the 'teams' region of this construct. We modify the ThreadLimitClause class to capture the clause expression within the 'target' region. Reviewers: ABataev Differential Revision: https://reviews.llvm.org/D29087 Added: cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp Modified: cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/lib/AST/OpenMPClause.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/OpenMPClause.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=293049&r1=293048&r2=293049&view=diff == --- cfe/trunk/include/clang/AST/OpenMPClause.h (original) +++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Jan 25 05:44:35 2017 @@ -3541,7 +3541,7 @@ public: /// In this example directive '#pragma omp teams' has clause 'thread_limit' /// with single expression 'n'. /// -class OMPThreadLimitClause : public OMPClause { +class OMPThreadLimitClause : public OMPClause, public OMPClauseWithPreInit { friend class OMPClauseReader; /// \brief Location of '('. SourceLocation LParenLoc; @@ -3557,20 +3557,28 @@ public: /// \brief Build 'thread_limit' clause. /// /// \param E Expression associated with this clause. + /// \param HelperE Helper Expression associated with this clause. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. /// \param StartLoc Starting location of the clause. /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. /// - OMPThreadLimitClause(Expr *E, SourceLocation StartLoc, - SourceLocation LParenLoc, SourceLocation EndLoc) - : OMPClause(OMPC_thread_limit, StartLoc, EndLoc), LParenLoc(LParenLoc), -ThreadLimit(E) {} + OMPThreadLimitClause(Expr *E, Stmt *HelperE, + OpenMPDirectiveKind CaptureRegion, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) + : OMPClause(OMPC_thread_limit, StartLoc, EndLoc), +OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) { +setPreInitStmt(HelperE, CaptureRegion); + } /// \brief Build an empty clause. /// OMPThreadLimitClause() : OMPClause(OMPC_thread_limit, SourceLocation(), SourceLocation()), -LParenLoc(SourceLocation()), ThreadLimit(nullptr) {} +OMPClauseWithPreInit(this), LParenLoc(SourceLocation()), +ThreadLimit(nullptr) {} /// \brief Sets the location of '('. void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } /// \brief Returns the location of '('. Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=293049&r1=293048&r2=293049&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Jan 25 05:44:35 2017 @@ -3003,6 +3003,7 @@ bool RecursiveASTVisitor::Visit template bool RecursiveASTVisitor::VisitOMPThreadLimitClause( OMPThreadLimitClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); TRY_TO(TraverseStmt(C->getThreadLimit())); return true; } Modified: cfe/trunk/lib/AST/OpenMPClause.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=293049&r1=293048&r2=293049&view=diff == --- cfe/trunk/lib/AST/OpenMPClause.cpp (original) +++ cfe/trunk/lib/AST/OpenMPClause.cpp Wed Jan 25 05:44:35 2017 @@ -54,6 +54,8 @@ const OMPClauseWithPreInit *OMPClauseWit return static_cast(C); case OMPC_num_teams: return static_cast(C); + case OMPC_thread_limit: +return static_cast(C); case OMPC_default: case OMPC_proc_bind: case OMPC_final: @@ -81,7 +83,6 @@ const OMPClauseWithPreInit *OMPClauseWit case OMPC_threads: case OMPC_simd: case OMPC_map: - case OMPC_thread_limit: case OMPC_priority: case OMPC_grainsize: case OMPC_nogroup: Modified: cfe/trunk/lib/AST/StmtProfile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=293049&r1=293048&r2=293049&view=diff == ---
[PATCH] D29087: [OpenMP] Support for thread_limit-clause on the 'target teams' directive.
This revision was automatically updated to reflect the committed changes. Closed by commit rL293049: [OpenMP] Support for thread_limit-clause on the 'target teams' directive. (authored by arpith). Changed prior to commit: https://reviews.llvm.org/D29087?vs=85592&id=85728#toc Repository: rL LLVM https://reviews.llvm.org/D29087 Files: cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/lib/AST/OpenMPClause.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp cfe/trunk/tools/libclang/CIndex.cpp Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h === --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h @@ -3003,6 +3003,7 @@ template bool RecursiveASTVisitor::VisitOMPThreadLimitClause( OMPThreadLimitClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); TRY_TO(TraverseStmt(C->getThreadLimit())); return true; } Index: cfe/trunk/include/clang/AST/OpenMPClause.h === --- cfe/trunk/include/clang/AST/OpenMPClause.h +++ cfe/trunk/include/clang/AST/OpenMPClause.h @@ -3541,7 +3541,7 @@ /// In this example directive '#pragma omp teams' has clause 'thread_limit' /// with single expression 'n'. /// -class OMPThreadLimitClause : public OMPClause { +class OMPThreadLimitClause : public OMPClause, public OMPClauseWithPreInit { friend class OMPClauseReader; /// \brief Location of '('. SourceLocation LParenLoc; @@ -3557,20 +3557,28 @@ /// \brief Build 'thread_limit' clause. /// /// \param E Expression associated with this clause. + /// \param HelperE Helper Expression associated with this clause. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. /// \param StartLoc Starting location of the clause. /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. /// - OMPThreadLimitClause(Expr *E, SourceLocation StartLoc, - SourceLocation LParenLoc, SourceLocation EndLoc) - : OMPClause(OMPC_thread_limit, StartLoc, EndLoc), LParenLoc(LParenLoc), -ThreadLimit(E) {} + OMPThreadLimitClause(Expr *E, Stmt *HelperE, + OpenMPDirectiveKind CaptureRegion, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) + : OMPClause(OMPC_thread_limit, StartLoc, EndLoc), +OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) { +setPreInitStmt(HelperE, CaptureRegion); + } /// \brief Build an empty clause. /// OMPThreadLimitClause() : OMPClause(OMPC_thread_limit, SourceLocation(), SourceLocation()), -LParenLoc(SourceLocation()), ThreadLimit(nullptr) {} +OMPClauseWithPreInit(this), LParenLoc(SourceLocation()), +ThreadLimit(nullptr) {} /// \brief Sets the location of '('. void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } /// \brief Returns the location of '('. Index: cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp === --- cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp +++ cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp @@ -0,0 +1,357 @@ +// Test host codegen. +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 + +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c
r293050 - [OpenCL] Diagnose write_only image3d when extension is disabled
Author: stulova Date: Wed Jan 25 06:18:50 2017 New Revision: 293050 URL: http://llvm.org/viewvc/llvm-project?rev=293050&view=rev Log: [OpenCL] Diagnose write_only image3d when extension is disabled Prior to OpenCL 2.0, image3d_t can only be used with the write_only access qualifier when the cl_khr_3d_image_writes extension is enabled, see e.g. OpenCL 1.1 s6.8b. Require the extension for write_only image3d_t types and guard uses of write_only image3d_t in the OpenCL header. Patch by Sven van Haastregt! Review: https://reviews.llvm.org/D28860 Modified: cfe/trunk/include/clang/Basic/OpenCLImageTypes.def cfe/trunk/lib/Headers/opencl-c.h cfe/trunk/test/Headers/opencl-c-header.cl cfe/trunk/test/SemaOpenCL/access-qualifier.cl Modified: cfe/trunk/include/clang/Basic/OpenCLImageTypes.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLImageTypes.def?rev=293050&r1=293049&r2=293050&view=diff == --- cfe/trunk/include/clang/Basic/OpenCLImageTypes.def (original) +++ cfe/trunk/include/clang/Basic/OpenCLImageTypes.def Wed Jan 25 06:18:50 2017 @@ -66,7 +66,7 @@ IMAGE_WRITE_TYPE(image2d_msaa, OCLImage2 IMAGE_WRITE_TYPE(image2d_array_msaa, OCLImage2dArrayMSAA, "cl_khr_gl_msaa_sharing") IMAGE_WRITE_TYPE(image2d_msaa_depth, OCLImage2dMSAADepth, "cl_khr_gl_msaa_sharing") IMAGE_WRITE_TYPE(image2d_array_msaa_depth, OCLImage2dArrayMSAADepth, "cl_khr_gl_msaa_sharing") -IMAGE_WRITE_TYPE(image3d, OCLImage3d, "") +IMAGE_WRITE_TYPE(image3d, OCLImage3d, "cl_khr_3d_image_writes") IMAGE_READ_WRITE_TYPE(image1d, OCLImage1d, "") IMAGE_READ_WRITE_TYPE(image1d_array, OCLImage1dArray, "") Modified: cfe/trunk/lib/Headers/opencl-c.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=293050&r1=293049&r2=293050&view=diff == --- cfe/trunk/lib/Headers/opencl-c.h (original) +++ cfe/trunk/lib/Headers/opencl-c.h Wed Jan 25 06:18:50 2017 @@ -16,6 +16,12 @@ #endif //cl_khr_depth_images #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 +#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 +#ifdef cl_khr_3d_image_writes +#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable +#endif //cl_khr_3d_image_writes +#endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0 + #define __ovld __attribute__((overloadable)) #define __conv __attribute__((convergent)) @@ -15995,9 +16001,11 @@ void __ovld write_imagef(write_only imag void __ovld write_imagei(write_only image1d_array_t image_array, int2 coord, int4 color); void __ovld write_imageui(write_only image1d_array_t image_array, int2 coord, uint4 color); +#ifdef cl_khr_3d_image_writes void __ovld write_imagef(write_only image3d_t image, int4 coord, float4 color); void __ovld write_imagei(write_only image3d_t image, int4 coord, int4 color); void __ovld write_imageui(write_only image3d_t image, int4 coord, uint4 color); +#endif #ifdef cl_khr_depth_images void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, float color); @@ -16025,16 +16033,20 @@ void __ovld write_imageui(write_only ima void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int lod, float color); void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, int lod, float color); +#ifdef cl_khr_3d_image_writes void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, float4 color); void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 color); void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, uint4 color); +#endif #endif //cl_khr_mipmap_image // Image write functions for half4 type #ifdef cl_khr_fp16 void __ovld write_imageh(write_only image1d_t image, int coord, half4 color); void __ovld write_imageh(write_only image2d_t image, int2 coord, half4 color); +#ifdef cl_khr_3d_image_writes void __ovld write_imageh(write_only image3d_t image, int4 coord, half4 color); +#endif void __ovld write_imageh(write_only image1d_array_t image, int2 coord, half4 color); void __ovld write_imageh(write_only image2d_array_t image, int4 coord, half4 color); void __ovld write_imageh(write_only image1d_buffer_t image, int coord, half4 color); @@ -16062,9 +16074,11 @@ void __ovld write_imagef(read_write imag void __ovld write_imagei(read_write image1d_array_t image_array, int2 coord, int4 color); void __ovld write_imageui(read_write image1d_array_t image_array, int2 coord, uint4 color); +#ifdef cl_khr_3d_image_writes void __ovld write_imagef(read_write image3d_t image, int4 coord, float4 color); void __ovld write_imagei(read_write image3d_t image, int4 coord, int4 color); void __ovld write_imageui(read_write image3d_t image, int4 coord, uint4 color); +#endif #ifdef cl_khr_depth_images void __ovld write_imagef(read_write image2d_depth_t image, int2 coord, float color); @@ -16091,16 +
[PATCH] D28860: [OpenCL] Diagnose write_only image3d when extension is disabled
Anastasia closed this revision. Anastasia added a comment. Committed in r293050! https://reviews.llvm.org/D28860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29123: [Driver] Prevent no-arc-exception-silence.m test from writing output.
mboehme created this revision. This enables the test to run on systems where output cannot be written. https://reviews.llvm.org/D29123 Files: test/Driver/no-arc-exception-silence.m Index: test/Driver/no-arc-exception-silence.m === --- test/Driver/no-arc-exception-silence.m +++ test/Driver/no-arc-exception-silence.m @@ -1,2 +1,2 @@ -// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s +// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c -o /dev/null %s // expected-no-diagnostics Index: test/Driver/no-arc-exception-silence.m === --- test/Driver/no-arc-exception-silence.m +++ test/Driver/no-arc-exception-silence.m @@ -1,2 +1,2 @@ -// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s +// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c -o /dev/null %s // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293051 - [Driver] Prevent no-arc-exception-silence.m test from writing output.
Author: mboehme Date: Wed Jan 25 06:55:53 2017 New Revision: 293051 URL: http://llvm.org/viewvc/llvm-project?rev=293051&view=rev Log: [Driver] Prevent no-arc-exception-silence.m test from writing output. Summary: This enables the test to run on systems where output cannot be written. Reviewers: compnerd Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29123 Modified: cfe/trunk/test/Driver/no-arc-exception-silence.m Modified: cfe/trunk/test/Driver/no-arc-exception-silence.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/no-arc-exception-silence.m?rev=293051&r1=293050&r2=293051&view=diff == --- cfe/trunk/test/Driver/no-arc-exception-silence.m (original) +++ cfe/trunk/test/Driver/no-arc-exception-silence.m Wed Jan 25 06:55:53 2017 @@ -1,2 +1,2 @@ -// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s +// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c -o /dev/null %s // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29123: [Driver] Prevent no-arc-exception-silence.m test from writing output.
This revision was automatically updated to reflect the committed changes. Closed by commit rL293051: [Driver] Prevent no-arc-exception-silence.m test from writing output. (authored by mboehme). Changed prior to commit: https://reviews.llvm.org/D29123?vs=85734&id=85735#toc Repository: rL LLVM https://reviews.llvm.org/D29123 Files: cfe/trunk/test/Driver/no-arc-exception-silence.m Index: cfe/trunk/test/Driver/no-arc-exception-silence.m === --- cfe/trunk/test/Driver/no-arc-exception-silence.m +++ cfe/trunk/test/Driver/no-arc-exception-silence.m @@ -1,2 +1,2 @@ -// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s +// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c -o /dev/null %s // expected-no-diagnostics Index: cfe/trunk/test/Driver/no-arc-exception-silence.m === --- cfe/trunk/test/Driver/no-arc-exception-silence.m +++ cfe/trunk/test/Driver/no-arc-exception-silence.m @@ -1,2 +1,2 @@ -// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s +// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c -o /dev/null %s // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293052 - [test] Port clang tests to canonicalized booleans
Author: mgorny Date: Wed Jan 25 07:11:45 2017 New Revision: 293052 URL: http://llvm.org/viewvc/llvm-project?rev=293052&view=rev Log: [test] Port clang tests to canonicalized booleans Use the new llvm_canonicalize_cmake_booleans() function to canonicalize booleans for lit tests. Replace the duplicate ENABLE_CLANG* variables used to hold canonicalized values with in-place canonicalization. Use implicit logic in Python code to avoid overrelying on exact 0/1 values. Differential Revision: https://reviews.llvm.org/D28529 Modified: cfe/trunk/CMakeLists.txt cfe/trunk/test/ARCMT/lit.local.cfg cfe/trunk/test/Analysis/lit.local.cfg cfe/trunk/test/CMakeLists.txt cfe/trunk/test/Rewriter/lit.local.cfg cfe/trunk/test/Tooling/lit.local.cfg cfe/trunk/test/lit.cfg cfe/trunk/test/lit.site.cfg.in Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=293052&r1=293051&r2=293052&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Wed Jan 25 07:11:45 2017 @@ -364,18 +364,7 @@ option(CLANG_BUILD_TOOLS "Build the Clang tools. If OFF, just generate build targets." ON) option(CLANG_ENABLE_ARCMT "Build ARCMT." ON) -if (CLANG_ENABLE_ARCMT) - set(ENABLE_CLANG_ARCMT "1") -else() - set(ENABLE_CLANG_ARCMT "0") -endif() - option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON) -if (CLANG_ENABLE_STATIC_ANALYZER) - set(ENABLE_CLANG_STATIC_ANALYZER "1") -else() - set(ENABLE_CLANG_STATIC_ANALYZER "0") -endif() if (NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT) message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT") @@ -415,11 +404,6 @@ add_subdirectory(tools) add_subdirectory(runtime) option(CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." OFF) -if (CLANG_BUILD_EXAMPLES) - set(ENABLE_CLANG_EXAMPLES "1") -else() - set(ENABLE_CLANG_EXAMPLES "0") -endif() add_subdirectory(examples) if(APPLE) Modified: cfe/trunk/test/ARCMT/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/lit.local.cfg?rev=293052&r1=293051&r2=293052&view=diff == --- cfe/trunk/test/ARCMT/lit.local.cfg (original) +++ cfe/trunk/test/ARCMT/lit.local.cfg Wed Jan 25 07:11:45 2017 @@ -1,2 +1,2 @@ -if config.root.clang_arcmt == 0: +if not config.root.clang_arcmt: config.unsupported = True Modified: cfe/trunk/test/Analysis/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=293052&r1=293051&r2=293052&view=diff == --- cfe/trunk/test/Analysis/lit.local.cfg (original) +++ cfe/trunk/test/Analysis/lit.local.cfg Wed Jan 25 07:11:45 2017 @@ -1,2 +1,2 @@ -if config.root.clang_staticanalyzer == 0: +if not config.root.clang_staticanalyzer: config.unsupported = True Modified: cfe/trunk/test/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=293052&r1=293051&r2=293052&view=diff == --- cfe/trunk/test/CMakeLists.txt (original) +++ cfe/trunk/test/CMakeLists.txt Wed Jan 25 07:11:45 2017 @@ -18,6 +18,12 @@ if(CLANG_BUILT_STANDALONE) endif() endif() +llvm_canonicalize_cmake_booleans( + CLANG_BUILD_EXAMPLES + CLANG_ENABLE_ARCMT + CLANG_ENABLE_STATIC_ANALYZER + ENABLE_BACKTRACES) + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg @@ -55,7 +61,7 @@ if (CLANG_ENABLE_ARCMT) ) endif () -if (ENABLE_CLANG_EXAMPLES) +if (CLANG_BUILD_EXAMPLES) list(APPEND CLANG_TEST_DEPS AnnotateFunctions clang-interpreter @@ -63,7 +69,7 @@ if (ENABLE_CLANG_EXAMPLES) ) endif () -if (ENABLE_CLANG_STATIC_ANALYZER AND ENABLE_CLANG_EXAMPLES) +if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES) list(APPEND CLANG_TEST_DEPS SampleAnalyzerPlugin ) Modified: cfe/trunk/test/Rewriter/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/lit.local.cfg?rev=293052&r1=293051&r2=293052&view=diff == --- cfe/trunk/test/Rewriter/lit.local.cfg (original) +++ cfe/trunk/test/Rewriter/lit.local.cfg Wed Jan 25 07:11:45 2017 @@ -1,3 +1,3 @@ # The Objective-C rewriters are currently grouped with ARCMT. -if config.root.clang_arcmt == 0: +if not config.root.clang_arcmt: config.unsupported = True Modified: cfe/trunk/test/Tooling/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/lit.local.cfg?rev=293052&r1=293051&r2=293052&view=diff == --- cfe/trunk/test/Tooling/lit.local.cfg (original) +++ cfe/trunk/test/Tooling/
[PATCH] D28529: [test] Port clang tests to canonicalized booleans
This revision was automatically updated to reflect the committed changes. Closed by commit rL293052: [test] Port clang tests to canonicalized booleans (authored by mgorny). Changed prior to commit: https://reviews.llvm.org/D28529?vs=83852&id=85736#toc Repository: rL LLVM https://reviews.llvm.org/D28529 Files: cfe/trunk/CMakeLists.txt cfe/trunk/test/ARCMT/lit.local.cfg cfe/trunk/test/Analysis/lit.local.cfg cfe/trunk/test/CMakeLists.txt cfe/trunk/test/Rewriter/lit.local.cfg cfe/trunk/test/Tooling/lit.local.cfg cfe/trunk/test/lit.cfg cfe/trunk/test/lit.site.cfg.in Index: cfe/trunk/test/Analysis/lit.local.cfg === --- cfe/trunk/test/Analysis/lit.local.cfg +++ cfe/trunk/test/Analysis/lit.local.cfg @@ -1,2 +1,2 @@ -if config.root.clang_staticanalyzer == 0: +if not config.root.clang_staticanalyzer: config.unsupported = True Index: cfe/trunk/test/ARCMT/lit.local.cfg === --- cfe/trunk/test/ARCMT/lit.local.cfg +++ cfe/trunk/test/ARCMT/lit.local.cfg @@ -1,2 +1,2 @@ -if config.root.clang_arcmt == 0: +if not config.root.clang_arcmt: config.unsupported = True Index: cfe/trunk/test/Rewriter/lit.local.cfg === --- cfe/trunk/test/Rewriter/lit.local.cfg +++ cfe/trunk/test/Rewriter/lit.local.cfg @@ -1,3 +1,3 @@ # The Objective-C rewriters are currently grouped with ARCMT. -if config.root.clang_arcmt == 0: +if not config.root.clang_arcmt: config.unsupported = True Index: cfe/trunk/test/lit.site.cfg.in === --- cfe/trunk/test/lit.site.cfg.in +++ cfe/trunk/test/lit.site.cfg.in @@ -14,13 +14,13 @@ config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@" config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" -config.have_zlib = "@HAVE_LIBZ@" -config.clang_arcmt = @ENABLE_CLANG_ARCMT@ +config.have_zlib = @HAVE_LIBZ@ +config.clang_arcmt = @CLANG_ENABLE_ARCMT@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" -config.clang_staticanalyzer = @ENABLE_CLANG_STATIC_ANALYZER@ -config.clang_examples = @ENABLE_CLANG_EXAMPLES@ +config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ +config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ -config.enable_backtrace = "@ENABLE_BACKTRACES@" +config.enable_backtrace = @ENABLE_BACKTRACES@ config.host_arch = "@HOST_ARCH@" # Support substitution of the tools and libs dirs with user parameters. This is Index: cfe/trunk/test/lit.cfg === --- cfe/trunk/test/lit.cfg +++ cfe/trunk/test/lit.cfg @@ -202,7 +202,7 @@ # Plugins (loadable modules) # TODO: This should be supplied by Makefile or autoconf. if sys.platform in ['win32', 'cygwin']: -has_plugins = (config.enable_shared == 1) +has_plugins = config.enable_shared else: has_plugins = True @@ -353,7 +353,7 @@ config.available_features.add('default-cxx-stdlib-set') # Enabled/disabled features -if config.clang_staticanalyzer != 0: +if config.clang_staticanalyzer: config.available_features.add("staticanalyzer") # As of 2011.08, crash-recovery tests still do not pass on FreeBSD. @@ -474,10 +474,10 @@ else: config.available_features.add("not_ubsan") -if config.enable_backtrace == "1": +if config.enable_backtrace: config.available_features.add("backtrace") -if config.have_zlib == "1": +if config.have_zlib: config.available_features.add("zlib") else: config.available_features.add("nozlib") Index: cfe/trunk/test/CMakeLists.txt === --- cfe/trunk/test/CMakeLists.txt +++ cfe/trunk/test/CMakeLists.txt @@ -18,6 +18,12 @@ endif() endif() +llvm_canonicalize_cmake_booleans( + CLANG_BUILD_EXAMPLES + CLANG_ENABLE_ARCMT + CLANG_ENABLE_STATIC_ANALYZER + ENABLE_BACKTRACES) + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg @@ -55,15 +61,15 @@ ) endif () -if (ENABLE_CLANG_EXAMPLES) +if (CLANG_BUILD_EXAMPLES) list(APPEND CLANG_TEST_DEPS AnnotateFunctions clang-interpreter PrintFunctionNames ) endif () -if (ENABLE_CLANG_STATIC_ANALYZER AND ENABLE_CLANG_EXAMPLES) +if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES) list(APPEND CLANG_TEST_DEPS SampleAnalyzerPlugin ) Index: cfe/trunk/test/Tooling/lit.local.cfg === --- cfe/trunk/test/Tooling/lit.local.cfg +++ cfe/trunk/test/Tooling/lit.local.cfg @@ -1,2 +1,2 @@ -if config.root.clang_staticanalyzer == 0: +if not config.root.clang_staticanalyzer: config.unsupported = True Index: cfe/trunk/CMakeLists.txt === --- cfe/trunk/CMake
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
krasimir updated this revision to Diff 85737. krasimir marked 3 inline comments as done. krasimir added a comment. - Address comments. Add a bunch of comments about various range computations. https://reviews.llvm.org/D28764 Files: lib/Format/BreakableToken.cpp lib/Format/BreakableToken.h lib/Format/CMakeLists.txt lib/Format/Comments.cpp lib/Format/Comments.h lib/Format/ContinuationIndenter.cpp lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineParser.cpp lib/Format/WhitespaceManager.cpp unittests/Format/FormatTest.cpp unittests/Format/FormatTestSelective.cpp Index: unittests/Format/FormatTestSelective.cpp === --- unittests/Format/FormatTestSelective.cpp +++ unittests/Format/FormatTestSelective.cpp @@ -111,13 +111,19 @@ format("int a; // comment\n" "intb; // comment", 0, 0)); - EXPECT_EQ("int a; // comment\n" -" // line 2\n" + EXPECT_EQ("int a; // comment\n" +" // line 2\n" "int b;", format("int a; // comment\n" "// line 2\n" "int b;", 28, 0)); + EXPECT_EQ("int a; // comment\n" +"// comment 2\n" +"int b;", +format("int a; // comment\n" + "// comment 2\n" + "int b;", 28, 0)); EXPECT_EQ("int aa; // comment\n" "int b;\n" "int c; // unrelated comment", Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1783,6 +1783,463 @@ "0x00, 0x00, 0x00, 0x00};// comment\n"); } +TEST_F(FormatTest, ReflowsComments) { + // Break a long line and reflow with the full next line. + EXPECT_EQ("// long long long\n" +"// long long", +format("// long long long long\n" + "// long", + getLLVMStyleWithColumns(20))); + + // Keep the trailing newline while reflowing. + EXPECT_EQ("// long long long\n" +"// long long\n", +format("// long long long long\n" + "// long\n", + getLLVMStyleWithColumns(20))); + + // Break a long line and reflow with a part of the next line. + EXPECT_EQ("// long long long\n" +"// long long\n" +"// long_long", +format("// long long long long\n" + "// long long_long", + getLLVMStyleWithColumns(20))); + + // Break but do not reflow if the first word from the next line is too long. + EXPECT_EQ("// long long long\n" +"// long\n" +"// long_long_long\n", +format("// long long long long\n" + "// long_long_long\n", + getLLVMStyleWithColumns(20))); + + // Don't break or reflow short lines. + verifyFormat("// long\n" + "// long long long lo\n" + "// long long long lo\n" + "// long", + getLLVMStyleWithColumns(20)); + + // Keep prefixes and decorations while reflowing. + EXPECT_EQ("/// long long long\n" +"/// long long\n", +format("/// long long long long\n" + "/// long\n", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//! long long long\n" +"//! long long\n", +format("//! long long long long\n" + "//! long\n", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("/* long long long\n" +" * long long */", +format("/* long long long long\n" + " * long */", + getLLVMStyleWithColumns(20))); + + // Don't bring leading whitespace up while reflowing. + EXPECT_EQ("/* long long long\n" +" * long long long\n" +" */", +format("/* long long long long\n" + " * long long\n" + " */", + getLLVMStyleWithColumns(20))); + + // Reflow the last line of a block comment with its trailing '*/'. + EXPECT_EQ("/* long long long\n" +" long long */", +format("/* long long long long\n" + " long */", + getLLVMStyleWithColumns(20))); + + // Reflow two short lines; keep the postfix of the last one. + EXPECT_EQ("/* long long long\n" +" * long long long */", +format("/* long long long long\n" + " * long\n" + " * long */", + getLLVMStyleWithColumns(20))); + + // Put the postfix of the last short reflow line on a newline if it doesn't + // fit. + EXPECT_EQ("/* long long long\n" +" * long long longg\n" +" */", +format("/* long long l
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
krasimir added a comment. Tried to add some comments around range computations. Most of the time it's about converting range offsets from local line-based values to start-of-token-based offsets. Comment at: lib/Format/BreakableToken.cpp:279-280 + return Content.size() >= 2 && + Content != "clang-format on" && + Content != "clang-format off" && + !Content.endswith("\\") && klimek wrote: > Can we now use delimitsRegion here? Yep! Actually came up with even better alternative: we use switchesFormatting() below: Comment at: lib/Format/ContinuationIndenter.cpp:1090-1092 +// Checks if Token delimits formatting regions, like /* clang-format off */. +// Token must be a comment. +static bool delimitsRegion(const FormatToken &Token) { klimek wrote: > delimitsRegion seems overly abstract. Perhaps switchesFormatting? Yep. Also moved it to BreakableToken.h/.cpp so it can be used from both ContinuationIndenter::breakProtrudingToken and BreakableComment::mayReflow! https://reviews.llvm.org/D28764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293053 - [test] Add HAVE_LIBZ to canonicalized booleans
Author: mgorny Date: Wed Jan 25 07:31:53 2017 New Revision: 293053 URL: http://llvm.org/viewvc/llvm-project?rev=293053&view=rev Log: [test] Add HAVE_LIBZ to canonicalized booleans Canonicalize HAVE_LIBZ as well to fix buildbot failures. Modified: cfe/trunk/test/CMakeLists.txt Modified: cfe/trunk/test/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=293053&r1=293052&r2=293053&view=diff == --- cfe/trunk/test/CMakeLists.txt (original) +++ cfe/trunk/test/CMakeLists.txt Wed Jan 25 07:31:53 2017 @@ -22,7 +22,8 @@ llvm_canonicalize_cmake_booleans( CLANG_BUILD_EXAMPLES CLANG_ENABLE_ARCMT CLANG_ENABLE_STATIC_ANALYZER - ENABLE_BACKTRACES) + ENABLE_BACKTRACES + HAVE_LIBZ) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
klimek added inline comments. Comment at: lib/Format/BreakableToken.cpp:747 +Split SplitBefore, WhitespaceManager &Whitespaces) { + // If this is the first line of a token, we need to inform Whitespace Manager + // about it: either adapt the whitespace range preceding it, or mark it as an What do you mean by "first line of a token"? Comment at: lib/Format/BreakableToken.h:110-111 + + /// \brief Returns a whitespace range (offset, length) of the content at \p + /// LineIndex such that the content preceding this range needs to be + /// reformatted before any breaks are made to this line. I'd keep \p and LineIndex in the same line... https://reviews.llvm.org/D28764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
krasimir added inline comments. Comment at: lib/Format/BreakableToken.cpp:747 +Split SplitBefore, WhitespaceManager &Whitespaces) { + // If this is the first line of a token, we need to inform Whitespace Manager + // about it: either adapt the whitespace range preceding it, or mark it as an klimek wrote: > What do you mean by "first line of a token"? Sadly, there are multi-line line comment tokens, as in: ``` // line 1 \ // line 2 ``` Add a note about it. Comment at: lib/Format/BreakableToken.h:110-111 + + /// \brief Returns a whitespace range (offset, length) of the content at \p + /// LineIndex such that the content preceding this range needs to be + /// reformatted before any breaks are made to this line. klimek wrote: > I'd keep \p and LineIndex in the same line... Sadly, that's one thing that the reflowing doesn't support yet... https://reviews.llvm.org/D28764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
krasimir updated this revision to Diff 85739. krasimir marked 2 inline comments as done. krasimir added a comment. - Address review comments. https://reviews.llvm.org/D28764 Files: lib/Format/BreakableToken.cpp lib/Format/BreakableToken.h lib/Format/CMakeLists.txt lib/Format/Comments.cpp lib/Format/Comments.h lib/Format/ContinuationIndenter.cpp lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineParser.cpp lib/Format/WhitespaceManager.cpp unittests/Format/FormatTest.cpp unittests/Format/FormatTestSelective.cpp Index: unittests/Format/FormatTestSelective.cpp === --- unittests/Format/FormatTestSelective.cpp +++ unittests/Format/FormatTestSelective.cpp @@ -111,13 +111,19 @@ format("int a; // comment\n" "intb; // comment", 0, 0)); - EXPECT_EQ("int a; // comment\n" -" // line 2\n" + EXPECT_EQ("int a; // comment\n" +" // line 2\n" "int b;", format("int a; // comment\n" "// line 2\n" "int b;", 28, 0)); + EXPECT_EQ("int a; // comment\n" +"// comment 2\n" +"int b;", +format("int a; // comment\n" + "// comment 2\n" + "int b;", 28, 0)); EXPECT_EQ("int aa; // comment\n" "int b;\n" "int c; // unrelated comment", Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1783,6 +1783,463 @@ "0x00, 0x00, 0x00, 0x00};// comment\n"); } +TEST_F(FormatTest, ReflowsComments) { + // Break a long line and reflow with the full next line. + EXPECT_EQ("// long long long\n" +"// long long", +format("// long long long long\n" + "// long", + getLLVMStyleWithColumns(20))); + + // Keep the trailing newline while reflowing. + EXPECT_EQ("// long long long\n" +"// long long\n", +format("// long long long long\n" + "// long\n", + getLLVMStyleWithColumns(20))); + + // Break a long line and reflow with a part of the next line. + EXPECT_EQ("// long long long\n" +"// long long\n" +"// long_long", +format("// long long long long\n" + "// long long_long", + getLLVMStyleWithColumns(20))); + + // Break but do not reflow if the first word from the next line is too long. + EXPECT_EQ("// long long long\n" +"// long\n" +"// long_long_long\n", +format("// long long long long\n" + "// long_long_long\n", + getLLVMStyleWithColumns(20))); + + // Don't break or reflow short lines. + verifyFormat("// long\n" + "// long long long lo\n" + "// long long long lo\n" + "// long", + getLLVMStyleWithColumns(20)); + + // Keep prefixes and decorations while reflowing. + EXPECT_EQ("/// long long long\n" +"/// long long\n", +format("/// long long long long\n" + "/// long\n", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//! long long long\n" +"//! long long\n", +format("//! long long long long\n" + "//! long\n", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("/* long long long\n" +" * long long */", +format("/* long long long long\n" + " * long */", + getLLVMStyleWithColumns(20))); + + // Don't bring leading whitespace up while reflowing. + EXPECT_EQ("/* long long long\n" +" * long long long\n" +" */", +format("/* long long long long\n" + " * long long\n" + " */", + getLLVMStyleWithColumns(20))); + + // Reflow the last line of a block comment with its trailing '*/'. + EXPECT_EQ("/* long long long\n" +" long long */", +format("/* long long long long\n" + " long */", + getLLVMStyleWithColumns(20))); + + // Reflow two short lines; keep the postfix of the last one. + EXPECT_EQ("/* long long long\n" +" * long long long */", +format("/* long long long long\n" + " * long\n" + " * long */", + getLLVMStyleWithColumns(20))); + + // Put the postfix of the last short reflow line on a newline if it doesn't + // fit. + EXPECT_EQ("/* long long long\n" +" * long long longg\n" +" */", +format("/* long long long long\n" + " * long\n" +
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D28764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293055 - [clang-format] Implement comment reflowing.
Author: krasimir Date: Wed Jan 25 07:58:58 2017 New Revision: 293055 URL: http://llvm.org/viewvc/llvm-project?rev=293055&view=rev Log: [clang-format] Implement comment reflowing. Summary: This presents a version of the comment reflowing with less mutable state inside the comment breakable token subclasses. The state has been pushed into the driving breakProtrudingToken method. For this, the API of BreakableToken is enriched by the methods getSplitBefore and getLineLengthAfterSplitBefore. Reviewers: klimek Reviewed By: klimek Subscribers: djasper, klimek, mgorny, cfe-commits, ioeric Differential Revision: https://reviews.llvm.org/D28764 Removed: cfe/trunk/lib/Format/Comments.cpp cfe/trunk/lib/Format/Comments.h Modified: cfe/trunk/lib/Format/BreakableToken.cpp cfe/trunk/lib/Format/BreakableToken.h cfe/trunk/lib/Format/CMakeLists.txt cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/lib/Format/WhitespaceManager.cpp cfe/trunk/unittests/Format/FormatTest.cpp cfe/trunk/unittests/Format/FormatTestSelective.cpp Modified: cfe/trunk/lib/Format/BreakableToken.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=293055&r1=293054&r2=293055&view=diff == --- cfe/trunk/lib/Format/BreakableToken.cpp (original) +++ cfe/trunk/lib/Format/BreakableToken.cpp Wed Jan 25 07:58:58 2017 @@ -14,7 +14,7 @@ //===--===// #include "BreakableToken.h" -#include "Comments.h" +#include "ContinuationIndenter.h" #include "clang/Basic/CharInfo.h" #include "clang/Format/Format.h" #include "llvm/ADT/STLExtras.h" @@ -40,6 +40,21 @@ static bool IsBlank(char C) { } } +static StringRef getLineCommentIndentPrefix(StringRef Comment) { + static const char *const KnownPrefixes[] = {"///", "//", "//!"}; + StringRef LongestPrefix; + for (StringRef KnownPrefix : KnownPrefixes) { +if (Comment.startswith(KnownPrefix)) { + size_t PrefixLength = KnownPrefix.size(); + while (PrefixLength < Comment.size() && Comment[PrefixLength] == ' ') +++PrefixLength; + if (PrefixLength > LongestPrefix.size()) +LongestPrefix = Comment.substr(0, PrefixLength); +} + } + return LongestPrefix; +} + static BreakableToken::Split getCommentSplit(StringRef Text, unsigned ContentStartColumn, unsigned ColumnLimit, @@ -132,12 +147,35 @@ getStringSplit(StringRef Text, unsigned return BreakableToken::Split(StringRef::npos, 0); } +bool switchesFormatting(const FormatToken &Token) { + assert((Token.is(TT_BlockComment) || Token.is(TT_LineComment)) && + "formatting regions are switched by comment tokens"); + StringRef Content = Token.TokenText.substr(2).ltrim(); + return Content.startswith("clang-format on") || + Content.startswith("clang-format off"); +} + +unsigned +BreakableToken::getLineLengthAfterCompression(unsigned RemainingTokenColumns, + Split Split) const { + // Example: consider the content + // lala lala + // - RemainingTokenColumns is the original number of columns, 10; + // - Split is (4, 2), denoting the two spaces between the two words; + // + // We compute the number of columns when the split is compressed into a single + // space, like: + // lala lala + return RemainingTokenColumns + 1 - Split.second; +} + unsigned BreakableSingleLineToken::getLineCount() const { return 1; } unsigned BreakableSingleLineToken::getLineLengthAfterSplit( -unsigned LineIndex, unsigned Offset, StringRef::size_type Length) const { +unsigned LineIndex, unsigned TailOffset, +StringRef::size_type Length) const { return StartColumn + Prefix.size() + Postfix.size() + - encoding::columnWidthWithTabs(Line.substr(Offset, Length), + encoding::columnWidthWithTabs(Line.substr(TailOffset, Length), StartColumn + Prefix.size(), Style.TabWidth, Encoding); } @@ -183,71 +221,123 @@ void BreakableStringLiteral::insertBreak Prefix, InPPDirective, 1, IndentLevel, LeadingSpaces); } -BreakableLineComment::BreakableLineComment( -const FormatToken &Token, unsigned IndentLevel, unsigned StartColumn, -bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) -: BreakableSingleLineToken(Token, IndentLevel, StartColumn, - getLineCommentIndentPrefix(Token.TokenText), "", - InPPDirective, Encoding, Style) { - OriginalPrefix = Prefix; - if (Token.TokenText.size() > Prefix.size() && - isAlphanumeric(Token.TokenText[Prefix.size()])) { -if (Prefix == "//") -
[PATCH] D28764: [clang-format] Implement comment reflowing (v3)
This revision was automatically updated to reflect the committed changes. Closed by commit rL293055: [clang-format] Implement comment reflowing. (authored by krasimir). Changed prior to commit: https://reviews.llvm.org/D28764?vs=85739&id=85740#toc Repository: rL LLVM https://reviews.llvm.org/D28764 Files: cfe/trunk/lib/Format/BreakableToken.cpp cfe/trunk/lib/Format/BreakableToken.h cfe/trunk/lib/Format/CMakeLists.txt cfe/trunk/lib/Format/Comments.cpp cfe/trunk/lib/Format/Comments.h cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/lib/Format/WhitespaceManager.cpp cfe/trunk/unittests/Format/FormatTest.cpp cfe/trunk/unittests/Format/FormatTestSelective.cpp Index: cfe/trunk/lib/Format/BreakableToken.h === --- cfe/trunk/lib/Format/BreakableToken.h +++ cfe/trunk/lib/Format/BreakableToken.h @@ -8,9 +8,10 @@ //===--===// /// /// \file -/// \brief Declares BreakableToken, BreakableStringLiteral, and -/// BreakableBlockComment classes, that contain token type-specific logic to -/// break long lines in tokens. +/// \brief Declares BreakableToken, BreakableStringLiteral, BreakableComment, +/// BreakableBlockComment and BreakableLineCommentSection classes, that contain +/// token type-specific logic to break long lines in tokens and reflow content +/// between tokens. /// //===--===// @@ -25,10 +26,43 @@ namespace clang { namespace format { +/// \brief Checks if \p Token switches formatting, like /* clang-format off */. +/// \p Token must be a comment. +bool switchesFormatting(const FormatToken &Token); + struct FormatStyle; /// \brief Base class for strategies on how to break tokens. /// +/// This is organised around the concept of a \c Split, which is a whitespace +/// range that signifies a position of the content of a token where a +/// reformatting might be done. Operating with splits is divided into 3 +/// operations: +/// - getSplit, for finding a split starting at a position, +/// - getLineLengthAfterSplit, for calculating the size in columns of the rest +/// of the content after a split has been used for breaking, and +/// - insertBreak, for executing the split using a whitespace manager. +/// +/// There is a pair of operations that are used to compress a long whitespace +/// range with a single space if that will bring the line lenght under the +/// column limit: +/// - getLineLengthAfterCompression, for calculating the size in columns of the +/// line after a whitespace range has been compressed, and +/// - compressWhitespace, for executing the whitespace compression using a +/// whitespace manager; note that the compressed whitespace may be in the +/// middle of the original line and of the reformatted line. +/// +/// For tokens where the whitespace before each line needs to be also +/// reformatted, for example for tokens supporting reflow, there are analogous +/// operations that might be executed before the main line breaking occurs: +/// - getSplitBefore, for finding a split such that the content preceding it +/// needs to be specially reflown, +/// - getLineLengthAfterSplitBefore, for calculating the line length in columns +/// of the remainder of the content after the beginning of the content has +/// been reformatted, and +/// - replaceWhitespaceBefore, for executing the reflow using a whitespace +/// manager. +/// /// FIXME: The interface seems set in stone, so we might want to just pull the /// strategy into the class, instead of controlling it from the outside. class BreakableToken { @@ -42,13 +76,13 @@ virtual unsigned getLineCount() const = 0; /// \brief Returns the number of columns required to format the piece of line - /// at \p LineIndex, from byte offset \p Offset with length \p Length. + /// at \p LineIndex, from byte offset \p TailOffset with length \p Length. /// - /// Note that previous breaks are not taken into account. \p Offset is always - /// specified from the start of the (original) line. + /// Note that previous breaks are not taken into account. \p TailOffset is + /// always specified from the start of the (original) line. /// \p Length can be set to StringRef::npos, which means "to the end of line". virtual unsigned - getLineLengthAfterSplit(unsigned LineIndex, unsigned Offset, + getLineLengthAfterSplit(unsigned LineIndex, unsigned TailOffset, StringRef::size_type Length) const = 0; /// \brief Returns a range (offset, length) at which to break the line at @@ -61,16 +95,59 @@ virtual void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces) = 0; + /// \brief Returns the number of columns requi
[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support
delesley added a comment. The big question for me is whether these functions are exposed as part of the public libcxx API, or whether they are only used internally. (Again, I'm not a libcxx expert.) If they are part of the public API, then users may want to switch them on and off in their own code. In that case, I'm happy with the current variant. If they are only used internally, then no_thread_safety_analysis is probably the correct option. (Unless, of course, the libcxx developers want to start using the analysis themselves, but I suspect they don't.) https://reviews.llvm.org/D28520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25674: [Concepts] Class template associated constraints
hubert.reinterpretcast updated this revision to Diff 85752. hubert.reinterpretcast added a comment. Address review comments; update to revision 292996 Fix possibly ill-formed NDR case Test template-dependent cases for class redeclaration Address review comment: use lambda instead of do while(0) Address review comment: use PointerUnion w/struct https://reviews.llvm.org/D25674 Files: include/clang/AST/DeclTemplate.h include/clang/Basic/DiagnosticSemaKinds.td lib/AST/DeclTemplate.cpp lib/Sema/SemaTemplate.cpp lib/Serialization/ASTReaderDecl.cpp test/CXX/concepts-ts/temp/ test/CXX/concepts-ts/temp/temp.constr/ test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/ test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp === --- /dev/null +++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp @@ -0,0 +1,65 @@ +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s + +namespace nodiag { + +template requires bool(T()) +struct A; +template requires bool(U()) +struct A; + +} // end namespace nodiag + +namespace diag { + +template requires true // expected-note{{previous template declaration is here}} +struct A; +template struct A; // expected-error{{associated constraints differ in template redeclaration}} + +template struct B; // expected-note{{previous template declaration is here}} +template requires true // expected-error{{associated constraints differ in template redeclaration}} +struct B; + +template requires true // expected-note{{previous template declaration is here}} +struct C; +template requires !0 // expected-error{{associated constraints differ in template redeclaration}} +struct C; + +} // end namespace diag + +namespace nodiag { + +struct AA { + template requires someFunc(T()) + struct A; +}; + +template requires someFunc(T()) +struct AA::A { }; + +struct AAF { + template requires someFunc(T()) + friend struct AA::A; +}; + +} // end namespace nodiag + +namespace diag { + +template +struct TA { + template class TT> requires TT::happy // expected-note 2{{previous template declaration is here}} + struct A; + + struct AF; +}; + +template +template class TT> struct TA::A { }; // expected-error{{associated constraints differ in template redeclaration}} + +template +struct TA::AF { + template class TT> requires TT::happy // expected-error{{associated constraints differ in template redeclaration}} + friend struct TA::A; +}; + +} // end namespace diag Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1873,6 +1873,7 @@ DeclID PatternID = ReadDeclID(); NamedDecl *TemplatedDecl = cast_or_null(Reader.GetDecl(PatternID)); TemplateParameterList *TemplateParams = Record.readTemplateParameterList(); + // FIXME handle associated constraints D->init(TemplatedDecl, TemplateParams); return PatternID; Index: lib/Sema/SemaTemplate.cpp === --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -45,6 +45,26 @@ return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc()); } +namespace clang { +/// \brief [temp.constr.decl]p2: A template's associated constraints are +/// defined as a single constraint-expression derived from the introduced +/// constraint-expressions [ ... ]. +/// +/// \param Params The template parameter list and optional requires-clause. +/// +/// \param FD The underlying templated function declaration for a function +/// template. +static Expr *formAssociatedConstraints(TemplateParameterList *Params, + FunctionDecl *FD); +} + +static Expr *clang::formAssociatedConstraints(TemplateParameterList *Params, + FunctionDecl *FD) { + // FIXME: Concepts: collect additional introduced constraint-expressions + assert(!FD && "Cannot collect constraints from function declaration yet."); + return Params->getRequiresClause(); +} + /// \brief Determine whether the declaration found is acceptable as the name /// of a template and, if so, return that template declaration. Otherwise, /// returns NULL. @@ -1137,6 +1157,9 @@ } } + // TODO Memory management; associated constraints are not always stored. + Expr *const CurAC = formAssociatedConstraints(TemplateParams, nullptr); + if (PrevClassTemplate) { // Ensure that the template parameter lists are compatible. Skip this check // for a friend in a dependent context: the template parameter list itself @@ -1148,6 +1171,29 @@ TPL_TemplateMatch)) return true; +// Check for matching associated constraints on redeclarat
[PATCH] D25674: [Concepts] Class template associated constraints
hubert.reinterpretcast marked 3 inline comments as done. hubert.reinterpretcast added inline comments. Comment at: include/clang/AST/DeclTemplate.h:355 protected: - // This is probably never used. - TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name) Removed this constructor as a drive-by. Comment at: include/clang/AST/DeclTemplate.h:412-417 + /// \brief The template parameter list and optional requires-clause + /// associated with this declaration. + /// + /// The boolean value indicates whether this particular declaration has an + /// attached \c Expr representing the associated constraints of the template. + llvm::PointerIntPair TemplateParams; rsmith wrote: > Rather than tail-allocating the associated constraints (which will be an > inconvenience for every class that derives from `TemplateDecl`), can you > store this as a `PointerUnion` of a `TemplateParameterList*` and a pointer to > a struct wrapping a `TemplateParameterList*` and the associated constraints > expression? I'm not really concerned about paying one extra pointer per > associated constraints expression we store (and I suspect we may want to > store this as something richer than an expression at some point). As discussed in person, I am using `PointerUnion` in the base class. I am still allocating the proposed struct alongside the `TemplateDecl` instance where it is not too much trouble. Comment at: test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp:9 +struct A; +template requires !!sizeof(MyBool) +struct A; Status of this line is unclear. A conservative user of the language should probably avoid this as ill-formed NDR (functionally equivalent but not equivalent). This line as been replaced. Comment at: test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp:12 + +} // end namespace nodiag + hubert.reinterpretcast wrote: > I should probably add some template-dependent cases. Propagation of associated constraints to instantiated specializations will need to be added later. https://reviews.llvm.org/D25674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28814: [OpenCL] Add missing address spaces in IR generation of Blocks
Anastasia updated this revision to Diff 85753. Anastasia added a comment. Switched to getNullPointer helper. https://reviews.llvm.org/D28814 Files: lib/AST/Expr.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGBuiltin.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaType.cpp test/CodeGenOpenCL/cl20-device-side-enqueue.cl test/SemaOpenCL/invalid-block.cl Index: test/SemaOpenCL/invalid-block.cl === --- test/SemaOpenCL/invalid-block.cl +++ test/SemaOpenCL/invalid-block.cl @@ -4,26 +4,34 @@ void f0(int (^const bl)()); // All blocks declarations must be const qualified and initialized. void f1() { - int (^bl1)() = ^() {return 1;}; - int (^const bl2)() = ^(){return 1;}; + int (^bl1)(void) = ^() { +return 1; + }; + int (^const bl2)(void) = ^() { +return 1; + }; f0(bl1); f0(bl2); - bl1 = bl2; // expected-error{{invalid operands to binary expression ('int (^const)()' and 'int (^const)()')}} + bl1 = bl2; // expected-error{{invalid operands to binary expression ('int (__generic ^const)(void)' and 'int (__generic ^const)(void)')}} int (^const bl3)(); // expected-error{{invalid block variable declaration - must be initialized}} } // A block with extern storage class is not allowed. -extern int (^bl)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} +extern int (^bl)(void) = ^() { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} + return 1; +}; void f2() { - extern int (^bl)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} + extern int (^bl)(void) = ^() { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} +return 1; + }; } // A block cannot be the return value of a function. typedef int (^bl_t)(void); -bl_t f3(bl_t bl); // expected-error{{declaring function return value of type 'bl_t' (aka 'int (^const)(void)') is not allowed}} +bl_t f3(bl_t bl); // expected-error{{declaring function return value of type 'bl_t' (aka 'int (__generic ^const)(void)') is not allowed}} struct bl_s { - int (^bl)(void); // expected-error {{the 'int (^const)(void)' type cannot be used to declare a structure or union field}} + int (^bl)(void); // expected-error {{the 'int (__generic ^const)(void)' type cannot be used to declare a structure or union field}} }; void f4() { @@ -45,16 +53,16 @@ bl2_t bl2 = ^(int i) { return 2; }; - bl2_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl2_t' (aka 'int (^const)(int)') type is invalid in OpenCL}} + bl2_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl2_t' (aka 'int (__generic ^const)(int)') type is invalid in OpenCL}} int tmp = i ? bl1(i) // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}} : bl2(i); // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}} } // A block pointer type and all pointer operations are disallowed -void f6(bl2_t *bl_ptr) { // expected-error{{pointer to type '__generic bl2_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}} +void f6(bl2_t *bl_ptr) { // expected-error{{pointer to type '__generic bl2_t' (aka 'int (__generic ^const __generic)(int)') is invalid in OpenCL}} bl2_t bl = ^(int i) { return 1; }; - bl2_t *p; // expected-error {{pointer to type '__generic bl2_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}} - *bl; // expected-error {{invalid argument type 'bl2_t' (aka 'int (^const)(int)') to unary expression}} - &bl; // expected-error {{invalid argument type 'bl2_t' (aka 'int (^const)(int)') to unary expression}} + bl2_t *p; // expected-error {{pointer to type '__generic bl2_t' (aka 'int (__generic ^const __generic)(int)') is invalid in OpenCL}} + *bl; // expected-error {{invalid argument type 'bl2_t' (aka 'int (__generic ^const)(int)') to unary expression}} + &bl; // expected-error {{invalid argument type 'bl2_t' (aka 'int (__generic ^const)(int)') to unary expression}} } Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl === --- test/CodeGenOpenCL/cl20-device-side-enqueue.cl +++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl @@ -2,9 +2,8 @@ // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B64 typedef void (^bl_t)(local void *); - // N.B. The check here only exists to set BL_GLOBAL -// COMMON: @block_G = {{.*}}bitcast ([[BL_GLOBAL:[^@]+@__block_literal_global(\.[0-9]+)?]] +// COMMON: @block_G = addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i8**, i32, i32
[PATCH] D28814: [OpenCL] Add missing address spaces in IR generation of Blocks
Anastasia added inline comments. Comment at: lib/CodeGen/CGBlocks.cpp:723 +? CGM.getNSConcreteStackBlock() +: llvm::Constant::getNullValue( + CGM.getNSConcreteStackBlock()->getType()); yaxunl wrote: > should use CGM.getNullPointer to create a null pointer. Btw, does it mean we can no longer use generic llvm::Constant::getNullValue helper for PointerTypes? This feels wrong! Is it possible to extend the helper? Also I find it a bit counter intuitive to use getNullPointer with the second argument QualType for the case like this where we don't have an actual AST type. Why is it needed? Some documentation might be helpful here. :) Could we extend this helper to use default second argument or an overload with one argument only. https://reviews.llvm.org/D28814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28814: [OpenCL] Add missing address spaces in IR generation of Blocks
yaxunl added inline comments. Comment at: lib/CodeGen/CGBlocks.cpp:726 + CGM.getNSConcreteStackBlock()->getType()), + QualType()); isa = llvm::ConstantExpr::getBitCast(isa, VoidPtrTy); The QualType needs to be the real QualType corresponding to the LLVM type, otherwise it won't work on targets with non-zero null pointer. Comment at: lib/CodeGen/CGBlocks.cpp:1129 + CGM.getNSConcreteGlobalBlock()->getType()), + QualType())); same issue as above. Comment at: test/CodeGenOpenCL/cl20-device-side-enqueue.cl:3 // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B64 typedef void (^bl_t)(local void *); Can we add a run line for triple amdgcn-amd-amdhsa-opencl to make sure the null pointer is generated correctly? https://reviews.llvm.org/D28814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29077: [lsan] Enable LSan for x86 Linux.
m.ostapenko updated this revision to Diff 85756. m.ostapenko added a comment. Add a test case. Repository: rL LLVM https://reviews.llvm.org/D29077 Files: lib/Driver/ToolChains.cpp test/Driver/fsanitize.c Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -231,6 +231,12 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA // CHECK-SANA-SANL-NO-SANA: "-fsanitize=leak" +// RUN: %clang -target i686-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-X86 +// CHECK-SANL-X86: "-fsanitize=leak" + +// RUN: %clang -target i686-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-X86 +// CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak" + // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN // CHECK-MSAN: "-fno-assume-sane-operator-new" // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN Index: lib/Driver/ToolChains.cpp === --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -4730,7 +4730,7 @@ Res |= SanitizerKind::SafeStack; if (IsX86_64 || IsMIPS64 || IsAArch64) Res |= SanitizerKind::DataFlow; - if (IsX86_64 || IsMIPS64 || IsAArch64) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86) Res |= SanitizerKind::Leak; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64) Res |= SanitizerKind::Thread; Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -231,6 +231,12 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA // CHECK-SANA-SANL-NO-SANA: "-fsanitize=leak" +// RUN: %clang -target i686-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-X86 +// CHECK-SANL-X86: "-fsanitize=leak" + +// RUN: %clang -target i686-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-X86 +// CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak" + // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN // CHECK-MSAN: "-fno-assume-sane-operator-new" // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN Index: lib/Driver/ToolChains.cpp === --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -4730,7 +4730,7 @@ Res |= SanitizerKind::SafeStack; if (IsX86_64 || IsMIPS64 || IsAArch64) Res |= SanitizerKind::DataFlow; - if (IsX86_64 || IsMIPS64 || IsAArch64) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86) Res |= SanitizerKind::Leak; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64) Res |= SanitizerKind::Thread; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28814: [OpenCL] Add missing address spaces in IR generation of Blocks
yaxunl added inline comments. Comment at: lib/CodeGen/CGBlocks.cpp:723 +? CGM.getNSConcreteStackBlock() +: llvm::Constant::getNullValue( + CGM.getNSConcreteStackBlock()->getType()); Anastasia wrote: > yaxunl wrote: > > should use CGM.getNullPointer to create a null pointer. > Btw, does it mean we can no longer use generic llvm::Constant::getNullValue > helper for PointerTypes? This feels wrong! Is it possible to extend the > helper? > > Also I find it a bit counter intuitive to use getNullPointer with the second > argument QualType for the case like this where we don't have an actual AST > type. Why is it needed? Some documentation might be helpful here. :) Could we > extend this helper to use default second argument or an overload with one > argument only. The LLVM type may not have sufficient information, so in general situation QualType is needed. The comment before getNullPointer declaration explains the meaning of the parameters: ``` /// Get target specific null pointer. /// \param T is the LLVM type of the null pointer. /// \param QT is the clang QualType of the null pointer. /// \return ConstantPointerNull with the given type \p T. /// Each target can override it to return its own desired constant value. virtual llvm::Constant *getNullPointer(const CodeGen::CodeGenModule &CGM, llvm::PointerType *T, QualType QT) const; ``` https://reviews.llvm.org/D28814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293065 - Clarify how to forward-declare __llvm_profile symbols.
Author: nico Date: Wed Jan 25 10:01:32 2017 New Revision: 293065 URL: http://llvm.org/viewvc/llvm-project?rev=293065&view=rev Log: Clarify how to forward-declare __llvm_profile symbols. Modified: cfe/trunk/docs/SourceBasedCodeCoverage.rst Modified: cfe/trunk/docs/SourceBasedCodeCoverage.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SourceBasedCodeCoverage.rst?rev=293065&r1=293064&r2=293065&view=diff == --- cfe/trunk/docs/SourceBasedCodeCoverage.rst (original) +++ cfe/trunk/docs/SourceBasedCodeCoverage.rst Wed Jan 25 10:01:32 2017 @@ -256,6 +256,8 @@ without using static initializers, do th otherwise. Calling this function multiple times appends profile data to an existing on-disk raw profile. +In C++ files, declare these as ``extern "C"``. + Collecting coverage reports for the llvm project ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29128: [OpenMP] Support for the proc_bind-clause on 'target parallel' on the NVPTX device.
arpith-jacob created this revision. Herald added a subscriber: jholewinski. This patch adds support for the proc_bind clause on the Spmd construct 'target parallel' on the NVPTX device. Since the parallel region is created upon kernel launch, this clause can be safely ignored on the NVPTX device at codegen time for level 0 parallelism. https://reviews.llvm.org/D29128 Files: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp Index: test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp === --- /dev/null +++ test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp @@ -0,0 +1,106 @@ +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +// Check that the execution mode of all 3 target regions on the gpu is set to SPMD Mode. +// CHECK-DAG: {{@__omp_offloading_.+l22}}_exec_mode = weak constant i8 0 +// CHECK-DAG: {{@__omp_offloading_.+l26}}_exec_mode = weak constant i8 0 +// CHECK-DAG: {{@__omp_offloading_.+l31}}_exec_mode = weak constant i8 0 + +template +tx ftemplate(int n) { + tx a = 0; + short aa = 0; + tx b[10]; + + #pragma omp target parallel proc_bind(master) + { + } + + #pragma omp target parallel proc_bind(spread) + { +aa += 1; + } + + #pragma omp target parallel proc_bind(close) + { +a += 1; +aa += 1; +b[2] += 1; + } + + return a; +} + +int bar(int n){ + int a = 0; + + a += ftemplate(n); + + return a; +} + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l22}}( + // CHECK: call void @__kmpc_spmd_kernel_init( + // CHECK: br label {{%?}}[[EXEC:.+]] + // + // CHECK: [[EXEC]] + // CHECK-NOT: call void @__kmpc_push_proc_bind + // CHECK: {{call|invoke}} void [[OP1:@.+]](i32* null, i32* null + // CHECK: br label {{%?}}[[DONE:.+]] + // + // CHECK: [[DONE]] + // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: br label {{%?}}[[EXIT:.+]] + // + // CHECK: [[EXIT]] + // CHECK: ret void + // CHECK: } + + + + + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}( + // CHECK: call void @__kmpc_spmd_kernel_init( + // CHECK: br label {{%?}}[[EXEC:.+]] + // + // CHECK: [[EXEC]] + // CHECK-NOT: call void @__kmpc_push_proc_bind + // CHECK: {{call|invoke}} void [[OP1:@.+]](i32* null, i32* null + // CHECK: br label {{%?}}[[DONE:.+]] + // + // CHECK: [[DONE]] + // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: br label {{%?}}[[EXIT:.+]] + // + // CHECK: [[EXIT]] + // CHECK: ret void + // CHECK: } + + + + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l31}}( + // CHECK: call void @__kmpc_spmd_kernel_init( + // CHECK: br label {{%?}}[[EXEC:.+]] + // + // CHECK: [[EXEC]] + // CHECK-NOT: call void @__kmpc_push_proc_bind + // CHECK: {{call|invoke}} void [[OP1:@.+]](i32* null, i32* null + // CHECK: br label {{%?}}[[DONE:.+]] + // + // CHECK: [[DONE]] + // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: br label {{%?}}[[EXIT:.+]] + // + // CHECK: [[EXIT]] + // CHECK: ret void + // CHECK: } +#endif Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h === --- lib/CodeGen/CGOpenMPRuntimeNVPTX.h +++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h @@ -170,6 +170,12 @@ public: explicit CGOpenMPRuntimeNVPTX(CodeGenModule &CGM); + /// \brief Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32 + /// global_tid, int proc_bind) to generate code for 'proc_bind' clause. + virtual void emitProcBindClause(CodeGenFunction &CGF, + OpenMPProcBindClauseKind ProcBind, + SourceLocatio
[PATCH] D29128: [OpenMP] Support for the proc_bind-clause on 'target parallel' on the NVPTX device.
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D29128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293069 - [OpenMP] Support for the proc_bind-clause on 'target parallel' on the NVPTX device.
Author: arpith Date: Wed Jan 25 10:55:10 2017 New Revision: 293069 URL: http://llvm.org/viewvc/llvm-project?rev=293069&view=rev Log: [OpenMP] Support for the proc_bind-clause on 'target parallel' on the NVPTX device. This patch adds support for the proc_bind clause on the Spmd construct 'target parallel' on the NVPTX device. Since the parallel region is created upon kernel launch, this clause can be safely ignored on the NVPTX device at codegen time for level 0 parallelism. Reviewers: ABataev Differential Revision: https://reviews.llvm.org/D29128 Added: cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=293069&r1=293068&r2=293069&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Jan 25 10:55:10 2017 @@ -642,6 +642,17 @@ CGOpenMPRuntimeNVPTX::CGOpenMPRuntimeNVP llvm_unreachable("OpenMP NVPTX can only handle device code."); } +void CGOpenMPRuntimeNVPTX::emitProcBindClause(CodeGenFunction &CGF, + OpenMPProcBindClauseKind ProcBind, + SourceLocation Loc) { + // Do nothing in case of Spmd mode and L0 parallel. + // TODO: If in Spmd mode and L1 parallel emit the clause. + if (isInSpmdExecutionMode()) +return; + + CGOpenMPRuntime::emitProcBindClause(CGF, ProcBind, Loc); +} + void CGOpenMPRuntimeNVPTX::emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc) { Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=293069&r1=293068&r2=293069&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Wed Jan 25 10:55:10 2017 @@ -170,6 +170,12 @@ protected: public: explicit CGOpenMPRuntimeNVPTX(CodeGenModule &CGM); + /// \brief Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32 + /// global_tid, int proc_bind) to generate code for 'proc_bind' clause. + virtual void emitProcBindClause(CodeGenFunction &CGF, + OpenMPProcBindClauseKind ProcBind, + SourceLocation Loc) override; + /// \brief Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads' /// clause. Added: cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp?rev=293069&view=auto == --- cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp (added) +++ cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp Wed Jan 25 10:55:10 2017 @@ -0,0 +1,106 @@ +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +// Check that the execution mode of all 3 target regions on the gpu is set to SPMD Mode. +// CHECK-DAG: {{@__omp_offloading_.+l22}}_exec_mode = weak constant i8 0 +// CHECK-DAG: {{@__omp_offloading_.+l26}}_exec_mode = weak constant i8 0 +// C
[PATCH] D29128: [OpenMP] Support for the proc_bind-clause on 'target parallel' on the NVPTX device.
This revision was automatically updated to reflect the committed changes. Closed by commit rL293069: [OpenMP] Support for the proc_bind-clause on 'target parallel' on the NVPTX… (authored by arpith). Changed prior to commit: https://reviews.llvm.org/D29128?vs=85759&id=85765#toc Repository: rL LLVM https://reviews.llvm.org/D29128 Files: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp === --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -642,6 +642,17 @@ llvm_unreachable("OpenMP NVPTX can only handle device code."); } +void CGOpenMPRuntimeNVPTX::emitProcBindClause(CodeGenFunction &CGF, + OpenMPProcBindClauseKind ProcBind, + SourceLocation Loc) { + // Do nothing in case of Spmd mode and L0 parallel. + // TODO: If in Spmd mode and L1 parallel emit the clause. + if (isInSpmdExecutionMode()) +return; + + CGOpenMPRuntime::emitProcBindClause(CGF, ProcBind, Loc); +} + void CGOpenMPRuntimeNVPTX::emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc) { Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h === --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h @@ -170,6 +170,12 @@ public: explicit CGOpenMPRuntimeNVPTX(CodeGenModule &CGM); + /// \brief Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32 + /// global_tid, int proc_bind) to generate code for 'proc_bind' clause. + virtual void emitProcBindClause(CodeGenFunction &CGF, + OpenMPProcBindClauseKind ProcBind, + SourceLocation Loc) override; + /// \brief Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads' /// clause. Index: cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp === --- cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp +++ cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp @@ -0,0 +1,106 @@ +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +// Check that the execution mode of all 3 target regions on the gpu is set to SPMD Mode. +// CHECK-DAG: {{@__omp_offloading_.+l22}}_exec_mode = weak constant i8 0 +// CHECK-DAG: {{@__omp_offloading_.+l26}}_exec_mode = weak constant i8 0 +// CHECK-DAG: {{@__omp_offloading_.+l31}}_exec_mode = weak constant i8 0 + +template +tx ftemplate(int n) { + tx a = 0; + short aa = 0; + tx b[10]; + + #pragma omp target parallel proc_bind(master) + { + } + + #pragma omp target parallel proc_bind(spread) + { +aa += 1; + } + + #pragma omp target parallel proc_bind(close) + { +a += 1; +aa += 1; +b[2] += 1; + } + + return a; +} + +int bar(int n){ + int a = 0; + + a += ftemplate(n); + + return a; +} + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l22}}( + // CHECK: call void @__kmpc_spmd_kernel_init( + // CHECK: br label {{%?}}[[EXEC:.+]] + // + // CHECK: [[EXEC]] + // CHECK-NOT: call void @__kmpc_push_proc_bind + // CHECK: {{call|invoke}} void [[OP1:@.+]](i32* null, i32* null + // CHECK: br label {{%?}}[[DONE:.+]] + //
[libcxx] r293071 - [libcxx] Mentions "targeting C++11 and above" instead of "targeting C++11" in the doc
Author: mehdi_amini Date: Wed Jan 25 11:00:30 2017 New Revision: 293071 URL: http://llvm.org/viewvc/llvm-project?rev=293071&view=rev Log: [libcxx] Mentions "targeting C++11 and above" instead of "targeting C++11" in the doc Modified: libcxx/trunk/docs/index.rst Modified: libcxx/trunk/docs/index.rst URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/index.rst?rev=293071&r1=293070&r2=293071&view=diff == --- libcxx/trunk/docs/index.rst (original) +++ libcxx/trunk/docs/index.rst Wed Jan 25 11:00:30 2017 @@ -7,7 +7,8 @@ Overview -libc++ is a new implementation of the C++ standard library, targeting C++11. +libc++ is a new implementation of the C++ standard library, targeting C++11 and +above. * Features and Goals ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r292990 - Change the return type of emplace_[front|back] back to void when building with C++14 or before. Resolves PR31680.
Should we merge this to 4.0? On Tue, Jan 24, 2017 at 3:09 PM, Marshall Clow via cfe-commits wrote: > Author: marshall > Date: Tue Jan 24 17:09:12 2017 > New Revision: 292990 > > URL: http://llvm.org/viewvc/llvm-project?rev=292990&view=rev > Log: > Change the return type of emplace_[front|back] back to void when building > with C++14 or before. Resolves PR31680. > > Modified: > libcxx/trunk/include/deque > libcxx/trunk/include/forward_list > libcxx/trunk/include/list > libcxx/trunk/include/queue > libcxx/trunk/include/stack > libcxx/trunk/include/vector > > libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp > > libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp > > libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp > > libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp > > libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp > > libcxx/trunk/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp > > libcxx/trunk/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp > > libcxx/trunk/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp > > libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp > libcxx/trunk/www/cxx1z_status.html ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r292991 - PR31742: Don't emit a bogus "zero size array" extwarn when initializing a
Thanks! r293072. On Tue, Jan 24, 2017 at 6:03 PM, Richard Smith wrote: > Hi Hans, > > This is relatively minor, but it's safe and fixes a rejects-valid regression > in some configurations. Might be worth taking for Clang 4. > > On 24 January 2017 at 15:18, Richard Smith via cfe-commits > wrote: >> >> Author: rsmith >> Date: Tue Jan 24 17:18:28 2017 >> New Revision: 292991 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=292991&view=rev >> Log: >> PR31742: Don't emit a bogus "zero size array" extwarn when initializing a >> runtime-sized array from an empty list in an array new. >> >> Modified: >> cfe/trunk/lib/Sema/SemaInit.cpp >> cfe/trunk/test/SemaCXX/new-delete-cxx0x.cpp >> >> Modified: cfe/trunk/lib/Sema/SemaInit.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=292991&r1=292990&r2=292991&view=diff >> >> == >> --- cfe/trunk/lib/Sema/SemaInit.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Jan 24 17:18:28 2017 >> @@ -1684,7 +1684,7 @@ void InitListChecker::CheckArrayType(con >> // If this is an incomplete array type, the actual type needs to >> // be calculated here. >> llvm::APSInt Zero(maxElements.getBitWidth(), >> maxElements.isUnsigned()); >> -if (maxElements == Zero) { >> +if (maxElements == Zero && !Entity.isVariableLengthArrayNew()) { >>// Sizing an array implicitly to zero is not allowed by ISO C, >>// but is supported by GNU. >>SemaRef.Diag(IList->getLocStart(), >> >> Modified: cfe/trunk/test/SemaCXX/new-delete-cxx0x.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/new-delete-cxx0x.cpp?rev=292991&r1=292990&r2=292991&view=diff >> >> == >> --- cfe/trunk/test/SemaCXX/new-delete-cxx0x.cpp (original) >> +++ cfe/trunk/test/SemaCXX/new-delete-cxx0x.cpp Tue Jan 24 17:18:28 2017 >> @@ -1,4 +1,4 @@ >> -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 >> -triple=i686-pc-linux-gnu >> +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 >> -triple=i686-pc-linux-gnu -pedantic >> >> void ugly_news(int *ip) { >>(void)new int[-1]; // expected-error {{array size is negative}} >> @@ -29,6 +29,7 @@ void fn(int n) { >>(void) new int[2] {1, 2}; >>(void) new S[2] {1, 2}; >>(void) new S[3] {1, 2}; >> + (void) new S[n] {}; >>// C++11 [expr.new]p19: >>// If the new-expression creates an object or an array of objects of >> class >>// type, access and ambiguity control are done for the allocation >> function, >> @@ -44,6 +45,7 @@ void fn(int n) { >>(void) new T[2] {1, 2}; // ok >>(void) new T[3] {1, 2}; // expected-error {{no matching constructor}} >> expected-note {{in implicit initialization of array element 2}} >>(void) new T[n] {1, 2}; // expected-error {{no matching constructor}} >> expected-note {{in implicit initialization of trailing array elements in >> runtime-sized array new}} >> + (void) new T[n] {}; // expected-error {{no matching constructor}} >> expected-note {{in implicit initialization of trailing array elements in >> runtime-sized array new}} >> } >> >> struct U { >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant
This breaks all our mac builds with: /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/__threading_support:154:1: error: unknown type name 'mach_port_t' mach_port_t __libcpp_thread_get_port(); On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: asiri > Date: Tue Jan 3 06:59:50 2017 > New Revision: 290889 > > URL: http://llvm.org/viewvc/llvm-project?rev=290889&view=rev > Log: > [libcxx] Add build/test support for the externally threaded libc++abi > variant > > Differential revision: https://reviews.llvm.org/D27576 > > Reviewers: EricWF > > Modified: > libcxx/trunk/CMakeLists.txt > libcxx/trunk/include/__threading_support > libcxx/trunk/test/CMakeLists.txt > libcxx/trunk/test/libcxx/test/config.py > libcxx/trunk/test/lit.site.cfg.in > > Modified: libcxx/trunk/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/ > CMakeLists.txt?rev=290889&r1=290888&r2=290889&view=diff > > == > --- libcxx/trunk/CMakeLists.txt (original) > +++ libcxx/trunk/CMakeLists.txt Tue Jan 3 06:59:50 2017 > @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ >" when LIBCXX_ENABLE_THREADS is also set to OFF.") > endif() > > -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) > - message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" > - " when LIBCXX_ENABLE_THREADS is also set to ON.") > +if(NOT LIBCXX_ENABLE_THREADS) > + if(LIBCXX_HAS_PTHREAD_API) > +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" > +" when LIBCXX_ENABLE_THREADS is also set to ON.") > + endif() > + if(LIBCXX_HAS_EXTERNAL_THREAD_API) > +message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set > to ON" > +" when LIBCXX_ENABLE_THREADS is also set to ON.") > + endif() > endif() > > -if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS) > - message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to > ON" > - " when LIBCXX_ENABLE_THREADS is also set to ON.") > +if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API) > + message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" > + "and LIBCXX_HAS_PTHREAD_API cannot be both" > + "set to ON at the same time.") > endif() > > # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE > > Modified: libcxx/trunk/include/__threading_support > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/_ > _threading_support?rev=290889&r1=290888&r2=290889&view=diff > > == > --- libcxx/trunk/include/__threading_support (original) > +++ libcxx/trunk/include/__threading_support Tue Jan 3 06:59:50 2017 > @@ -67,7 +67,11 @@ typedef pthread_mutex_t __libcpp_mutex_t > typedef pthread_cond_t __libcpp_condvar_t; > #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER > > -// THread ID > +// Execute once > +typedef pthread_once_t __libcpp_exec_once_flag; > +#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT > + > +// Thread id > typedef pthread_t __libcpp_thread_id; > > // Thread > @@ -110,7 +114,17 @@ int __libcpp_condvar_timedwait(__libcpp_ > _LIBCPP_THREAD_ABI_VISIBILITY > int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); > > -// Thread ID > +// Execute once > +_LIBCPP_THREAD_ABI_VISIBILITY > +int __libcpp_execute_once(__libcpp_exec_once_flag *flag, > + void (*init_routine)(void)); > + > +// Thread id > +#if defined(__APPLE__) && !defined(__arm__) > +_LIBCPP_THREAD_ABI_VISIBILITY > +mach_port_t __libcpp_thread_get_port(); > +#endif > + > _LIBCPP_THREAD_ABI_VISIBILITY > bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id > t2); > > @@ -145,7 +159,7 @@ _LIBCPP_THREAD_ABI_VISIBILITY > void *__libcpp_tls_get(__libcpp_tls_key __key); > > _LIBCPP_THREAD_ABI_VISIBILITY > -void __libcpp_tls_set(__libcpp_tls_key __key, void *__p); > +int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); > > #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \ > defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD) > @@ -221,6 +235,19 @@ int __libcpp_condvar_destroy(__libcpp_co >return pthread_cond_destroy(__cv); > } > > +// Execute once > +int __libcpp_execute_once(__libcpp_exec_once_flag *flag, > + void (*init_routine)(void)) { > + return pthread_once(flag, init_routine); > +} > + > +// Thread id > +#if defined(__APPLE__) && !defined(__arm__) > +mach_port_t __libcpp_thread_get_port() { > +return pthread_mach_thread_np(pthread_self()); > +} > +#endif > + > // Returns non-zero if the thread ids are equal, otherwise 0 > bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp
Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant
Is it intentional that this change affects non-LIBCXX_HAS_EXTERNAL_THREAD_API builds at all? On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber wrote: > This breaks all our mac builds with: > > /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/ > Release+Asserts/bin/../include/c++/v1/__threading_support:154:1: error: > unknown type name 'mach_port_t' > mach_port_t __libcpp_thread_get_port(); > > On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: asiri >> Date: Tue Jan 3 06:59:50 2017 >> New Revision: 290889 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=290889&view=rev >> Log: >> [libcxx] Add build/test support for the externally threaded libc++abi >> variant >> >> Differential revision: https://reviews.llvm.org/D27576 >> >> Reviewers: EricWF >> >> Modified: >> libcxx/trunk/CMakeLists.txt >> libcxx/trunk/include/__threading_support >> libcxx/trunk/test/CMakeLists.txt >> libcxx/trunk/test/libcxx/test/config.py >> libcxx/trunk/test/lit.site.cfg.in >> >> Modified: libcxx/trunk/CMakeLists.txt >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. >> txt?rev=290889&r1=290888&r2=290889&view=diff >> >> == >> --- libcxx/trunk/CMakeLists.txt (original) >> +++ libcxx/trunk/CMakeLists.txt Tue Jan 3 06:59:50 2017 >> @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ >>" when LIBCXX_ENABLE_THREADS is also set to OFF.") >> endif() >> >> -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) >> - message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" >> - " when LIBCXX_ENABLE_THREADS is also set to ON.") >> +if(NOT LIBCXX_ENABLE_THREADS) >> + if(LIBCXX_HAS_PTHREAD_API) >> +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" >> +" when LIBCXX_ENABLE_THREADS is also set to ON.") >> + endif() >> + if(LIBCXX_HAS_EXTERNAL_THREAD_API) >> +message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set >> to ON" >> +" when LIBCXX_ENABLE_THREADS is also set to ON.") >> + endif() >> endif() >> >> -if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS) >> - message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set >> to ON" >> - " when LIBCXX_ENABLE_THREADS is also set to ON.") >> +if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API) >> + message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" >> + "and LIBCXX_HAS_PTHREAD_API cannot be both" >> + "set to ON at the same time.") >> endif() >> >> # Ensure LLVM_USE_SANITIZER is not specified when >> LIBCXX_GENERATE_COVERAGE >> >> Modified: libcxx/trunk/include/__threading_support >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__ >> threading_support?rev=290889&r1=290888&r2=290889&view=diff >> >> == >> --- libcxx/trunk/include/__threading_support (original) >> +++ libcxx/trunk/include/__threading_support Tue Jan 3 06:59:50 2017 >> @@ -67,7 +67,11 @@ typedef pthread_mutex_t __libcpp_mutex_t >> typedef pthread_cond_t __libcpp_condvar_t; >> #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER >> >> -// THread ID >> +// Execute once >> +typedef pthread_once_t __libcpp_exec_once_flag; >> +#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT >> + >> +// Thread id >> typedef pthread_t __libcpp_thread_id; >> >> // Thread >> @@ -110,7 +114,17 @@ int __libcpp_condvar_timedwait(__libcpp_ >> _LIBCPP_THREAD_ABI_VISIBILITY >> int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); >> >> -// Thread ID >> +// Execute once >> +_LIBCPP_THREAD_ABI_VISIBILITY >> +int __libcpp_execute_once(__libcpp_exec_once_flag *flag, >> + void (*init_routine)(void)); >> + >> +// Thread id >> +#if defined(__APPLE__) && !defined(__arm__) >> +_LIBCPP_THREAD_ABI_VISIBILITY >> +mach_port_t __libcpp_thread_get_port(); >> +#endif >> + >> _LIBCPP_THREAD_ABI_VISIBILITY >> bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id >> t2); >> >> @@ -145,7 +159,7 @@ _LIBCPP_THREAD_ABI_VISIBILITY >> void *__libcpp_tls_get(__libcpp_tls_key __key); >> >> _LIBCPP_THREAD_ABI_VISIBILITY >> -void __libcpp_tls_set(__libcpp_tls_key __key, void *__p); >> +int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); >> >> #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \ >> defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD) >> @@ -221,6 +235,19 @@ int __libcpp_condvar_destroy(__libcpp_co >>return pthread_cond_destroy(__cv); >> } >> >> +// Execute once >> +int __libcpp_execute_once(__libcpp_exec_once_flag *flag, >> + void (*init_routine)(void)) { >> + return pthread_once(flag, init_routine); >> +} >> + >> +// Thread id >> +#
Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant
(including cfe-commits) On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake < asiri.rathnay...@gmail.com> wrote: > Hi Nico, > > On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Is it intentional that this change affects non-LIBCXX_HAS_EXTERNAL_THREAD_API >> builds at all?# >> > > Nope. But I'm not sure how this got broken on Mac. > > IIRC, defines mach_port_t type on Mac, which gets included > when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we expect > to be the case on Mac, normally). > > I'll have to build this on a Mac tomorrow. Hopefully that's OK? > > Cheers, > > / Asiri > > > >> >> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber wrote: >> >>> This breaks all our mac builds with: >>> >>> /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+ >>> Asserts/bin/../include/c++/v1/__threading_support:154:1: error: unknown >>> type name 'mach_port_t' >>> mach_port_t __libcpp_thread_get_port(); >>> >>> On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Author: asiri Date: Tue Jan 3 06:59:50 2017 New Revision: 290889 URL: http://llvm.org/viewvc/llvm-project?rev=290889&view=rev Log: [libcxx] Add build/test support for the externally threaded libc++abi variant Differential revision: https://reviews.llvm.org/D27576 Reviewers: EricWF Modified: libcxx/trunk/CMakeLists.txt libcxx/trunk/include/__threading_support libcxx/trunk/test/CMakeLists.txt libcxx/trunk/test/libcxx/test/config.py libcxx/trunk/test/lit.site.cfg.in Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. txt?rev=290889&r1=290888&r2=290889&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Tue Jan 3 06:59:50 2017 @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ " when LIBCXX_ENABLE_THREADS is also set to OFF.") endif() -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) - message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" - " when LIBCXX_ENABLE_THREADS is also set to ON.") +if(NOT LIBCXX_ENABLE_THREADS) + if(LIBCXX_HAS_PTHREAD_API) +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" +" when LIBCXX_ENABLE_THREADS is also set to ON.") + endif() + if(LIBCXX_HAS_EXTERNAL_THREAD_API) +message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" +" when LIBCXX_ENABLE_THREADS is also set to ON.") + endif() endif() -if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS) - message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" - " when LIBCXX_ENABLE_THREADS is also set to ON.") +if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API) + message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" + "and LIBCXX_HAS_PTHREAD_API cannot be both" + "set to ON at the same time.") endif() # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE Modified: libcxx/trunk/include/__threading_support URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__t hreading_support?rev=290889&r1=290888&r2=290889&view=diff == --- libcxx/trunk/include/__threading_support (original) +++ libcxx/trunk/include/__threading_support Tue Jan 3 06:59:50 2017 @@ -67,7 +67,11 @@ typedef pthread_mutex_t __libcpp_mutex_t typedef pthread_cond_t __libcpp_condvar_t; #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER -// THread ID +// Execute once +typedef pthread_once_t __libcpp_exec_once_flag; +#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT + +// Thread id typedef pthread_t __libcpp_thread_id; // Thread @@ -110,7 +114,17 @@ int __libcpp_condvar_timedwait(__libcpp_ _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); -// Thread ID +// Execute once +_LIBCPP_THREAD_ABI_VISIBILITY +int __libcpp_execute_once(__libcpp_exec_once_flag *flag, + void (*init_routine)(void)); + +// Thread id +#if defined(__APPLE__) && !defined(__arm__) +_LIBCPP_THREAD_ABI_VISIBILITY +mach_port_t __libcpp_thread_get_port(); +#endif + _LIBCPP_THREAD_ABI_VISIBILITY
[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration
ahatanak updated this revision to Diff 85774. ahatanak marked 2 inline comments as done. ahatanak added a comment. Yes, we can make VarBypassDetector detect variables declared after labels too if we want to put all the logic for disabling lifetime markers in one place. https://reviews.llvm.org/D27680 Files: lib/CodeGen/CGDecl.cpp lib/CodeGen/CodeGenFunction.h test/CodeGen/lifetime2.c Index: test/CodeGen/lifetime2.c === --- test/CodeGen/lifetime2.c +++ test/CodeGen/lifetime2.c @@ -1,7 +1,7 @@ -// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2 -// RUN: %clang -S -emit-llvm -o - -O2 -Xclang -disable-lifetime-markers %s \ +// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,O2 +// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s \ // RUN: | FileCheck %s -check-prefixes=CHECK,O0 -// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0 +// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0 extern int bar(char *A, int n); @@ -25,13 +25,11 @@ char x; l1: bar(&x, 1); - // O2: @llvm.lifetime.start(i64 5 - // O2: @llvm.lifetime.end(i64 5 char y[5]; bar(y, 5); goto l1; // Infinite loop - // O2-NOT: @llvm.lifetime.end(i64 1 + // O2-NOT: @llvm.lifetime.end( } // CHECK-LABEL: @goto_bypass @@ -91,3 +89,24 @@ L: bar(&x, 1); } + +// O2-LABEL: define i32 @jump_backward_over_declaration( +// O2-NOT: call void @llvm.lifetime.{{.*}}(i64 4, + +extern void foo2(int p); + +int jump_backward_over_declaration(int a) { + int *p = 0; +label1: + if (p) { +foo2(*p); +return 0; + } + + int i = 999; + if (a != 2) { +p = &i; +goto label1; + } + return -1; +} Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -212,6 +212,13 @@ /// value. This is invalid iff the function has no return value. Address ReturnValue; + /// Return true if a label was seen in the current scope. + bool hasLabelBeenSeenInCurrentScope() const { +if (CurLexicalScope) + return CurLexicalScope->hasLabels(); +return !LabelMap.empty(); + } + /// AllocaInsertPoint - This is an instruction in the entry block before which /// we prefer to insert allocas. llvm::AssertingVH AllocaInsertPt; @@ -620,6 +627,10 @@ rescopeLabels(); } +bool hasLabels() const { + return !Labels.empty(); +} + void rescopeLabels(); }; Index: lib/CodeGen/CGDecl.cpp === --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -1022,11 +1022,21 @@ // Emit a lifetime intrinsic if meaningful. There's no point in doing this // if we don't have a valid insertion point (?). if (HaveInsertPoint() && !IsMSCatchParam) { -// goto or switch-case statements can break lifetime into several -// regions which need more efforts to handle them correctly. PR28267 -// This is rare case, but it's better just omit intrinsics than have -// them incorrectly placed. -if (!Bypasses.IsBypassed(&D)) { +// If there's a jump into the lifetime of this variable, its lifetime +// gets broken up into several regions in IR, which requires more work +// to handle correctly. For now, just omit the intrinsics; this is a +// rare case, and it's better to just be conservatively correct. +// PR28267. +// +// We have to do this in all language modes if there's a jump past the +// declaration. We also have to do it in C if there's a jump to an +// earlier point in the current block because non-VLA lifetimes begin as +// soon as the containing block is entered, not when its variables +// actually come into scope; suppressing the lifetime annotations +// completely in this case is unnecessarily pessimistic, but again, this +// is rare. +if (!Bypasses.IsBypassed(&D) && +!(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) { uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy); emission.SizeForLifetimeMarkers = EmitLifetimeStart(size, address.getPointer()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29135: [libcxx] [test] Fix Clang -Wunused-local-typedef, part 1/3.
STL_MSFT created this revision. [libcxx] [test] Fix Clang -Wunused-local-typedef, part 1/3. Mark typedefs as LIBCPP_ONLY when their only usage is within LIBCPP_STATIC_ASSERT. test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp Additionally deal with conditional compilation. test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp Additionally deal with typedefs used by other typedefs. https://reviews.llvm.org/D29135 Files: test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration
rjmccall added a comment. In https://reviews.llvm.org/D27680#656453, @ahatanak wrote: > Yes, we can make VarBypassDetector detect variables declared after labels too > if we want to put all the logic for disabling lifetime markers in one place. Okay. If that's straightforward, that does seem better. But feel free to use this approach first if there's time pressure. https://reviews.llvm.org/D27680 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29136: [libcxx] [test] Fix Clang -Wunused-local-typedef, part 2/3.
STL_MSFT created this revision. [libcxx] [test] Fix Clang -Wunused-local-typedef, part 2/3. These typedefs were completely unused. https://reviews.llvm.org/D29136 Files: test/std/containers/sequences/deque/deque.cons/size.pass.cpp test/std/containers/sequences/list/list.cons/size_type.pass.cpp test/std/containers/unord/unord.multimap/bucket_count.pass.cpp test/std/containers/unord/unord.multimap/load_factor.pass.cpp test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp test/std/containers/unord/unord.multimap/swap_member.pass.cpp test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp test/std/containers/unord/unord.multiset/bucket_count.pass.cpp test/std/containers/unord/unord.multiset/load_factor.pass.cpp test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp test/std/containers/unord/unord.multiset/swap_member.pass.cpp test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp test/std/containers/unord/unord.set/bucket_count.pass.cpp test/std/containers/unord/unord.set/load_factor.pass.cpp test/std/containers/unord/unord.set/max_load_factor.pass.cpp test/std/containers/unord/unord.set/swap_member.pass.cpp test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp test/std/strings/basic.string/string.cons/substr.pass.cpp test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp Index: test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp === --- test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp @@ -61,11 +61,9 @@ void test_implicit() { { -using T = long long; static_assert(implicit_conversion(42, 42), ""); } { -using T = long double; static_assert(implicit_conversion(3.14, 3.14), ""); } { @@ -97,18 +95,15 @@ void test_explicit() { { using T = ExplicitTrivialTestTypes::TestType; -using O = optional; static_assert(explicit_conversion(42, 42), ""); } { using T = ExplicitConstexprTestTypes::TestType; -using O = optional; static_assert(explicit_conversion(42, 42), ""); static_assert(!std::is_convertible::value, ""); } { using T = ExplicitTestTypes::TestType; -using O = optional; T::reset(); { assert(explicit_conversion(42, 42)); Index: test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp === --- test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp +++ test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp @@ -31,7 +31,6 @@ // OUTERMOST_ALLOC_TRAITS(*this)::construct( // OUTERMOST (*this), p, std::forward(args)...). void test_bullet_one() { -using VoidAlloc1 = CountingAllocator; using VoidAlloc2 = CountingAllocator; AllocController POuter; @@ -41,7 +40,6 @@ using Outer = CountingAllocator; using Inner = CountingAllocator; using SA = std::scoped_allocator_adaptor; -using SAInner = std::scoped_allocator_adaptor; static_assert(!std::uses_allocator::value, ""); static_assert(!std::
[PATCH] D29137: [libcxx] [test] Fix Clang -Wunused-local-typedef, part 3/3.
STL_MSFT created this revision. [libcxx] [test] Fix Clang -Wunused-local-typedef, part 3/3. test/std/strings/string.classes/typedefs.pass.cpp Actually test what basic_string's typedefs stand for. test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp NotDerived and ND were completely unused. test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp https://reviews.llvm.org/P2 was mistakenly not being used. Yes, that's right: -Wunused-local-typedef CAUGHT A MISTAKE! AMAZING! https://reviews.llvm.org/D29137 Files: test/std/strings/string.classes/typedefs.pass.cpp test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp Index: test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp === --- test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp +++ test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp @@ -49,7 +49,7 @@ using P = std::pair; static_assert(!std::is_default_constructible::value, ""); using P2 = std::pair; -static_assert(!std::is_default_constructible::value, ""); +static_assert(!std::is_default_constructible::value, ""); } #endif } Index: test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp === --- test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp +++ test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp @@ -26,7 +26,6 @@ struct F {}; struct FD : public F {}; -struct NotDerived {}; template void test_result_of_imp() @@ -43,7 +42,6 @@ int main() { -typedef NotDerived ND; { typedef char F::*PMD; test_result_of_imp(); Index: test/std/strings/string.classes/typedefs.pass.cpp === --- test/std/strings/string.classes/typedefs.pass.cpp +++ test/std/strings/string.classes/typedefs.pass.cpp @@ -18,13 +18,14 @@ // typedef basic_string wstring; #include +#include int main() { -typedef std::string test1; -typedef std::wstring test2; +static_assert((std::is_same >::value), ""); +static_assert((std::is_same >::value), ""); #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS -typedef std::u16string test3; -typedef std::u32string test4; +static_assert((std::is_same >::value), ""); +static_assert((std::is_same >::value), ""); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } Index: test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp === --- test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp +++ test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp @@ -49,7 +49,7 @@ using P = std::pair; static_assert(!std::is_default_constructible::value, ""); using P2 = std::pair; -static_assert(!std::is_default_constructible::value, ""); +static_assert(!std::is_default_constructible::value, ""); } #endif } Index: test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp === --- test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp +++ test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp @@ -26,7 +26,6 @@ struct F {}; struct FD : public F {}; -struct NotDerived {}; template void test_result_of_imp() @@ -43,7 +42,6 @@ int main() { -typedef NotDerived ND; { typedef char F::*PMD; test_result_of_imp(); Index: test/std/strings/string.classes/typedefs.pass.cpp === --- test/std/strings/string.classes/typedefs.pass.cpp +++ test/std/strings/string.classes/typedefs.pass.cpp @@ -18,13 +18,14 @@ // typedef basic_string wstring; #include +#include int main() { -typedef std::string test1; -typedef std::wstring test2; +static_assert((std::is_same >::value), ""); +static_assert((std::is_same >::value), ""); #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS -typedef std::u16string test3; -typedef std::u32string test4; +static_assert((std::is_same >::value), ""); +static_assert((std::is_same >::value), ""); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29138: [libcxx] [test] Fix Clang -Wdeprecated-declarations with MSVC's CRT.
STL_MSFT created this revision. [libcxx] [test] Fix Clang -Wdeprecated-declarations with MSVC's CRT. libcxx's tests use various C Standard Library functions that have been marked by MSVC's CRT as deprecated by Microsoft (not by ISO). libcxx's usage is cromulent (just checking with decltype to see if the functions are being dragged in by various headers as required by the Standard), so defining _CRT_SECURE_NO_WARNINGS will silence the warnings in a targeted manner. This needs to be defined before including any CRT headers. Also, make this file prettier. https://reviews.llvm.org/D29138 Files: test/support/msvc_stdlib_force_include.hpp Index: test/support/msvc_stdlib_force_include.hpp === --- test/support/msvc_stdlib_force_include.hpp +++ test/support/msvc_stdlib_force_include.hpp @@ -13,14 +13,17 @@ // This header is force-included when running the libc++ tests against the // MSVC standard library. +// Silence warnings about CRT machinery. +#define _CRT_SECURE_NO_WARNINGS + // Avoid assertion dialogs. #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort() #include #include #if defined(_LIBCPP_VERSION) -#error This header may not be used when targeting libc++ +#error This header may not be used when targeting libc++ #endif struct AssertionDialogAvoider { @@ -35,27 +38,24 @@ const AssertionDialogAvoider assertion_dialog_avoider{}; - // MSVC frontend only configurations #if !defined(__clang__) - -#define TEST_STD_VER 17 - -// Simulate feature-test macros. -#define __has_feature(X) _MSVC_HAS_FEATURE_ ## X -#define _MSVC_HAS_FEATURE_cxx_exceptions1 -#define _MSVC_HAS_FEATURE_cxx_rtti 1 -#define _MSVC_HAS_FEATURE_address_sanitizer 0 -#define _MSVC_HAS_FEATURE_memory_sanitizer 0 -#define _MSVC_HAS_FEATURE_thread_sanitizer 0 - -// Silence compiler warnings. -#pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored -#pragma warning(disable: 4521) // multiple copy constructors specified -#pragma warning(disable: 4702) // unreachable code -#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. -#pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations. - +#define TEST_STD_VER 17 + +// Simulate feature-test macros. +#define __has_feature(X) _MSVC_HAS_FEATURE_ ## X +#define _MSVC_HAS_FEATURE_cxx_exceptions1 +#define _MSVC_HAS_FEATURE_cxx_rtti 1 +#define _MSVC_HAS_FEATURE_address_sanitizer 0 +#define _MSVC_HAS_FEATURE_memory_sanitizer 0 +#define _MSVC_HAS_FEATURE_thread_sanitizer 0 + +// Silence compiler warnings. +#pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored +#pragma warning(disable: 4521) // multiple copy constructors specified +#pragma warning(disable: 4702) // unreachable code +#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. +#pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations. #endif // !defined(__clang__) // MSVC doesn't have __int128_t. Index: test/support/msvc_stdlib_force_include.hpp === --- test/support/msvc_stdlib_force_include.hpp +++ test/support/msvc_stdlib_force_include.hpp @@ -13,14 +13,17 @@ // This header is force-included when running the libc++ tests against the // MSVC standard library. +// Silence warnings about CRT machinery. +#define _CRT_SECURE_NO_WARNINGS + // Avoid assertion dialogs. #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort() #include #include #if defined(_LIBCPP_VERSION) -#error This header may not be used when targeting libc++ +#error This header may not be used when targeting libc++ #endif struct AssertionDialogAvoider { @@ -35,27 +38,24 @@ const AssertionDialogAvoider assertion_dialog_avoider{}; - // MSVC frontend only configurations #if !defined(__clang__) - -#define TEST_STD_VER 17 - -// Simulate feature-test macros. -#define __has_feature(X) _MSVC_HAS_FEATURE_ ## X -#define _MSVC_HAS_FEATURE_cxx_exceptions1 -#define _MSVC_HAS_FEATURE_cxx_rtti 1 -#define _MSVC_HAS_FEATURE_address_sanitizer 0 -#define _MSVC_HAS_FEATURE_memory_sanitizer 0 -#define _MSVC_HAS_FEATURE_thread_sanitizer 0 - -// Silence compiler warnings. -#pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored -#pragma warning(disable: 4521) // multiple copy constructors specified -#pragma warning(disable: 4702) // unreachable code -#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. -#pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations. - +
[PATCH] D29139: [libcxx] [test] Fix Clang -Wpessimizing-move "moving a temporary object prevents copy elision".
STL_MSFT created this revision. [libcxx] [test] Fix Clang -Wpessimizing-move "moving a temporary object prevents copy elision". N4618 30.6.6 [futures.unique_future]/12 declares "shared_future share() noexcept;". https://reviews.llvm.org/D29139 Files: test/std/thread/futures/futures.unique_future/share.pass.cpp Index: test/std/thread/futures/futures.unique_future/share.pass.cpp === --- test/std/thread/futures/futures.unique_future/share.pass.cpp +++ test/std/thread/futures/futures.unique_future/share.pass.cpp @@ -26,49 +26,49 @@ std::promise p; std::future f0 = p.get_future(); static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int T; std::future f0; static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } { typedef int& T; std::promise p; std::future f0 = p.get_future(); static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int& T; std::future f0; static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } { typedef void T; std::promise p; std::future f0 = p.get_future(); static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef void T; std::future f0; static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } Index: test/std/thread/futures/futures.unique_future/share.pass.cpp === --- test/std/thread/futures/futures.unique_future/share.pass.cpp +++ test/std/thread/futures/futures.unique_future/share.pass.cpp @@ -26,49 +26,49 @@ std::promise p; std::future f0 = p.get_future(); static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int T; std::future f0; static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } { typedef int& T; std::promise p; std::future f0 = p.get_future(); static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int& T; std::future f0; static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } { typedef void T; std::promise p; std::future f0 = p.get_future(); static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef void T; std::future f0; static_assert( noexcept(f0.share()), ""); -std::shared_future f = std::move(f0.share()); +std::shared_future f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29140: [libcxx] [test] Avoid MSVC's non-Standard ABI in underlying_type.pass.cpp.
STL_MSFT created this revision. [libcxx] [test] Avoid MSVC's non-Standard ABI in underlying_type.pass.cpp. When compiled with Clang for Windows, this was emitting "enumerator value evaluates to 4294967295, which cannot be narrowed to type 'int' [-Wc++11-narrowing]". The test should more strenuously avoid poking this ABI deficiency (and it already has coverage for explicitly specified underlying types). https://reviews.llvm.org/D29140 Files: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp Index: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp === --- test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp +++ test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -17,32 +17,40 @@ #include "test_macros.h" enum E { V = INT_MIN }; -enum F { W = UINT_MAX }; -int main() -{ #if !defined(_WIN32) || defined(__MINGW32__) -typedef unsigned ExpectUnsigned; +#define TEST_UNSIGNED_UNDERLYING_TYPE 1 #else -typedef int ExpectUnsigned; // MSVC's ABI doesn't follow the Standard +#define TEST_UNSIGNED_UNDERLYING_TYPE 0 // MSVC's ABI doesn't follow the Standard #endif + +#if TEST_UNSIGNED_UNDERLYING_TYPE +enum F { W = UINT_MAX }; +#endif // TEST_UNSIGNED_UNDERLYING_TYPE + +int main() +{ static_assert((std::is_same::type, int>::value), "E has the wrong underlying type"); -static_assert((std::is_same::type, ExpectUnsigned>::value), +#if TEST_UNSIGNED_UNDERLYING_TYPE +static_assert((std::is_same::type, unsigned>::value), "F has the wrong underlying type"); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE #if TEST_STD_VER > 11 static_assert((std::is_same, int>::value), ""); -static_assert((std::is_same, ExpectUnsigned>::value), ""); -#endif +#if TEST_UNSIGNED_UNDERLYING_TYPE +static_assert((std::is_same, unsigned>::value), ""); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE +#endif // TEST_STD_VER > 11 #if TEST_STD_VER >= 11 enum G : char { }; static_assert((std::is_same::type, char>::value), "G has the wrong underlying type"); #if TEST_STD_VER > 11 static_assert((std::is_same, char>::value), ""); -#endif +#endif // TEST_STD_VER > 11 #endif // TEST_STD_VER >= 11 } Index: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp === --- test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp +++ test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -17,32 +17,40 @@ #include "test_macros.h" enum E { V = INT_MIN }; -enum F { W = UINT_MAX }; -int main() -{ #if !defined(_WIN32) || defined(__MINGW32__) -typedef unsigned ExpectUnsigned; +#define TEST_UNSIGNED_UNDERLYING_TYPE 1 #else -typedef int ExpectUnsigned; // MSVC's ABI doesn't follow the Standard +#define TEST_UNSIGNED_UNDERLYING_TYPE 0 // MSVC's ABI doesn't follow the Standard #endif + +#if TEST_UNSIGNED_UNDERLYING_TYPE +enum F { W = UINT_MAX }; +#endif // TEST_UNSIGNED_UNDERLYING_TYPE + +int main() +{ static_assert((std::is_same::type, int>::value), "E has the wrong underlying type"); -static_assert((std::is_same::type, ExpectUnsigned>::value), +#if TEST_UNSIGNED_UNDERLYING_TYPE +static_assert((std::is_same::type, unsigned>::value), "F has the wrong underlying type"); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE #if TEST_STD_VER > 11 static_assert((std::is_same, int>::value), ""); -static_assert((std::is_same, ExpectUnsigned>::value), ""); -#endif +#if TEST_UNSIGNED_UNDERLYING_TYPE +static_assert((std::is_same, unsigned>::value), ""); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE +#endif // TEST_STD_VER > 11 #if TEST_STD_VER >= 11 enum G : char { }; static_assert((std::is_same::type, char>::value), "G has the wrong underlying type"); #if TEST_STD_VER > 11 static_assert((std::is_same, char>::value), ""); -#endif +#endif // TEST_STD_VER > 11 #endif // TEST_STD_VER >= 11 } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant
@Nico: could you let me know your build configuration? (cmake options) I'm surprised this went unnoticed for so long. Thanks. / Asiri On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" wrote: > (including cfe-commits) > > On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake < > asiri.rathnay...@gmail.com> wrote: > >> Hi Nico, >> >> On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Is it intentional that this change affects >>> non-LIBCXX_HAS_EXTERNAL_THREAD_API >>> builds at all?# >>> >> >> Nope. But I'm not sure how this got broken on Mac. >> >> IIRC, defines mach_port_t type on Mac, which gets included >> when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we expect >> to be the case on Mac, normally). >> >> I'll have to build this on a Mac tomorrow. Hopefully that's OK? >> >> Cheers, >> >> / Asiri >> >> >> >>> >>> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber >>> wrote: >>> This breaks all our mac builds with: /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+ Asserts/bin/../include/c++/v1/__threading_support:154:1: error: unknown type name 'mach_port_t' mach_port_t __libcpp_thread_get_port(); On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: asiri > Date: Tue Jan 3 06:59:50 2017 > New Revision: 290889 > > URL: http://llvm.org/viewvc/llvm-project?rev=290889&view=rev > Log: > [libcxx] Add build/test support for the externally threaded libc++abi > variant > > Differential revision: https://reviews.llvm.org/D27576 > > Reviewers: EricWF > > Modified: > libcxx/trunk/CMakeLists.txt > libcxx/trunk/include/__threading_support > libcxx/trunk/test/CMakeLists.txt > libcxx/trunk/test/libcxx/test/config.py > libcxx/trunk/test/lit.site.cfg.in > > Modified: libcxx/trunk/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. > txt?rev=290889&r1=290888&r2=290889&view=diff > > == > --- libcxx/trunk/CMakeLists.txt (original) > +++ libcxx/trunk/CMakeLists.txt Tue Jan 3 06:59:50 2017 > @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ >" when LIBCXX_ENABLE_THREADS is also set to > OFF.") > endif() > > -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) > - message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" > - " when LIBCXX_ENABLE_THREADS is also set to > ON.") > +if(NOT LIBCXX_ENABLE_THREADS) > + if(LIBCXX_HAS_PTHREAD_API) > +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" > +" when LIBCXX_ENABLE_THREADS is also set to > ON.") > + endif() > + if(LIBCXX_HAS_EXTERNAL_THREAD_API) > +message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be > set to ON" > +" when LIBCXX_ENABLE_THREADS is also set to > ON.") > + endif() > endif() > > -if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS) > - message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be > set to ON" > - " when LIBCXX_ENABLE_THREADS is also set to > ON.") > +if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API) > + message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" > + "and LIBCXX_HAS_PTHREAD_API cannot be both" > + "set to ON at the same time.") > endif() > > # Ensure LLVM_USE_SANITIZER is not specified when > LIBCXX_GENERATE_COVERAGE > > Modified: libcxx/trunk/include/__threading_support > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__t > hreading_support?rev=290889&r1=290888&r2=290889&view=diff > > == > --- libcxx/trunk/include/__threading_support (original) > +++ libcxx/trunk/include/__threading_support Tue Jan 3 06:59:50 2017 > @@ -67,7 +67,11 @@ typedef pthread_mutex_t __libcpp_mutex_t > typedef pthread_cond_t __libcpp_condvar_t; > #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER > > -// THread ID > +// Execute once > +typedef pthread_once_t __libcpp_exec_once_flag; > +#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT > + > +// Thread id > typedef pthread_t __libcpp_thread_id; > > // Thread > @@ -110,7 +114,17 @@ int __libcpp_condvar_timedwait(__libcpp_ > _LIBCPP_THREAD_ABI_VISIBILITY > int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); > > -// Thread ID > +// Execute once > +_LIBCPP_THREAD_ABI_VISIBILIT
Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant
Sure! https://build.chromium.org/p/chromium.fyi/builders/ClangToTMacASan/builds/8565/steps/gclient%20runhooks/logs/stdio has the invocations to build llvm/clang/compiler/rt, and https://build.chromium.org/p/chromium.fyi/builders/ClangToTMacASan/builds/8565/steps/compile/logs/stdio is the actual build using that setup. On Wed, Jan 25, 2017 at 1:57 PM, Asiri Rathnayake < asiri.rathnay...@gmail.com> wrote: > @Nico: could you let me know your build configuration? (cmake options) > > I'm surprised this went unnoticed for so long. > > Thanks. > > / Asiri > > On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" > wrote: > >> (including cfe-commits) >> >> On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake < >> asiri.rathnay...@gmail.com> wrote: >> >>> Hi Nico, >>> >>> On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Is it intentional that this change affects non-LIBCXX_HAS_EXTERNAL_THREAD_API builds at all?# >>> >>> Nope. But I'm not sure how this got broken on Mac. >>> >>> IIRC, defines mach_port_t type on Mac, which gets included >>> when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we expect >>> to be the case on Mac, normally). >>> >>> I'll have to build this on a Mac tomorrow. Hopefully that's OK? >>> >>> Cheers, >>> >>> / Asiri >>> >>> >>> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber wrote: > This breaks all our mac builds with: > > /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+ > Asserts/bin/../include/c++/v1/__threading_support:154:1: error: > unknown type name 'mach_port_t' > mach_port_t __libcpp_thread_get_port(); > > On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: asiri >> Date: Tue Jan 3 06:59:50 2017 >> New Revision: 290889 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=290889&view=rev >> Log: >> [libcxx] Add build/test support for the externally threaded libc++abi >> variant >> >> Differential revision: https://reviews.llvm.org/D27576 >> >> Reviewers: EricWF >> >> Modified: >> libcxx/trunk/CMakeLists.txt >> libcxx/trunk/include/__threading_support >> libcxx/trunk/test/CMakeLists.txt >> libcxx/trunk/test/libcxx/test/config.py >> libcxx/trunk/test/lit.site.cfg.in >> >> Modified: libcxx/trunk/CMakeLists.txt >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. >> txt?rev=290889&r1=290888&r2=290889&view=diff >> >> == >> --- libcxx/trunk/CMakeLists.txt (original) >> +++ libcxx/trunk/CMakeLists.txt Tue Jan 3 06:59:50 2017 >> @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ >>" when LIBCXX_ENABLE_THREADS is also set to >> OFF.") >> endif() >> >> -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) >> - message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" >> - " when LIBCXX_ENABLE_THREADS is also set to >> ON.") >> +if(NOT LIBCXX_ENABLE_THREADS) >> + if(LIBCXX_HAS_PTHREAD_API) >> +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to >> ON" >> +" when LIBCXX_ENABLE_THREADS is also set to >> ON.") >> + endif() >> + if(LIBCXX_HAS_EXTERNAL_THREAD_API) >> +message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be >> set to ON" >> +" when LIBCXX_ENABLE_THREADS is also set to >> ON.") >> + endif() >> endif() >> >> -if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS) >> - message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be >> set to ON" >> - " when LIBCXX_ENABLE_THREADS is also set to >> ON.") >> +if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API) >> + message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" >> + "and LIBCXX_HAS_PTHREAD_API cannot be both" >> + "set to ON at the same time.") >> endif() >> >> # Ensure LLVM_USE_SANITIZER is not specified when >> LIBCXX_GENERATE_COVERAGE >> >> Modified: libcxx/trunk/include/__threading_support >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__t >> hreading_support?rev=290889&r1=290888&r2=290889&view=diff >> >> == >> --- libcxx/trunk/include/__threading_support (original) >> +++ libcxx/trunk/include/__threading_support Tue Jan 3 06:59:50 2017 >> @@ -67,7 +67,11 @@ typedef pthread_mutex_t __libcpp_mutex_t >> typedef pthread_cond_t __libcpp_condvar_t; >> #define _LIBCPP_CONDVAR_INITIALI
[libcxx] r293079 - Fixed a typo in the synopsis (noecept -> noexcept). Thanks to Kim for the catch
Author: marshall Date: Wed Jan 25 14:14:03 2017 New Revision: 293079 URL: http://llvm.org/viewvc/llvm-project?rev=293079&view=rev Log: Fixed a typo in the synopsis (noecept -> noexcept). Thanks to Kim for the catch Modified: libcxx/trunk/include/future Modified: libcxx/trunk/include/future URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=293079&r1=293078&r2=293079&view=diff == --- libcxx/trunk/include/future (original) +++ libcxx/trunk/include/future Wed Jan 25 14:14:03 2017 @@ -156,7 +156,7 @@ public: ~future(); future& operator=(const future& rhs) = delete; future& operator=(future&&) noexcept; -shared_future share() noecept; +shared_future share() noexcept; // retrieving the value R get(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant
Hi Nico, Thanks for the links. I may have a clue to what is going on. I think in your Mac environment, does not provide either pthread_mach_thread_np() function or define the type mach_port_t (is there a way for you to check this btw? just to make sure). This was not a problem before (for your builds) because this function was only used in libcxxabi sources. In my eagerness to get rid of all pthread dependencies in libcxx/libcxxabi, I have lifted this out into __threading_support header in libcxx (which is our new threading API for both libcxx and libcxxabi). @Eric: would it be OK to leave this Mac-specific pthread dependency in libcxxabi sources as it was? In that way, libcxx builds like Nico's won't be affected. Another option is to try and detect the conditions (on Mac environments) where pthread_mach_thread_np/mach_port_t is available, and only define the corresponding libcxx thread-api function (__libcpp_thread_get_port) when this condition is true. Unfortunately I'm not familiar with Mac enough to know this. Any thoughts? Side note:- Btw, if I'm correct with the above analysis, it won't be possible to build libcxxabi in Nico's environment (even before my changes). The dependency on pthread_mach_thread_np() was already there in __cxa_guard_acquire(). Thanks. / Asiri On Wed, Jan 25, 2017 at 7:34 PM, Nico Weber wrote: > Sure! https://build.chromium.org/p/chromium.fyi/builders/ > ClangToTMacASan/builds/8565/steps/gclient%20runhooks/logs/stdio has the > invocations to build llvm/clang/compiler/rt, and https://build.chromium. > org/p/chromium.fyi/builders/ClangToTMacASan/builds/8565/ > steps/compile/logs/stdio is the actual build using that setup. > > On Wed, Jan 25, 2017 at 1:57 PM, Asiri Rathnayake < > asiri.rathnay...@gmail.com> wrote: > >> @Nico: could you let me know your build configuration? (cmake options) >> >> I'm surprised this went unnoticed for so long. >> >> Thanks. >> >> / Asiri >> >> On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" >> wrote: >> >>> (including cfe-commits) >>> >>> On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake < >>> asiri.rathnay...@gmail.com> wrote: >>> Hi Nico, On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Is it intentional that this change affects > non-LIBCXX_HAS_EXTERNAL_THREAD_API builds at all?# > Nope. But I'm not sure how this got broken on Mac. IIRC, defines mach_port_t type on Mac, which gets included when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we expect to be the case on Mac, normally). I'll have to build this on a Mac tomorrow. Hopefully that's OK? Cheers, / Asiri > > On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber > wrote: > >> This breaks all our mac builds with: >> >> /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+ >> Asserts/bin/../include/c++/v1/__threading_support:154:1: error: >> unknown type name 'mach_port_t' >> mach_port_t __libcpp_thread_get_port(); >> >> On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: asiri >>> Date: Tue Jan 3 06:59:50 2017 >>> New Revision: 290889 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=290889&view=rev >>> Log: >>> [libcxx] Add build/test support for the externally threaded >>> libc++abi variant >>> >>> Differential revision: https://reviews.llvm.org/D27576 >>> >>> Reviewers: EricWF >>> >>> Modified: >>> libcxx/trunk/CMakeLists.txt >>> libcxx/trunk/include/__threading_support >>> libcxx/trunk/test/CMakeLists.txt >>> libcxx/trunk/test/libcxx/test/config.py >>> libcxx/trunk/test/lit.site.cfg.in >>> >>> Modified: libcxx/trunk/CMakeLists.txt >>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. >>> txt?rev=290889&r1=290888&r2=290889&view=diff >>> >>> == >>> --- libcxx/trunk/CMakeLists.txt (original) >>> +++ libcxx/trunk/CMakeLists.txt Tue Jan 3 06:59:50 2017 >>> @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ >>>" when LIBCXX_ENABLE_THREADS is also set to >>> OFF.") >>> endif() >>> >>> -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) >>> - message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" >>> - " when LIBCXX_ENABLE_THREADS is also set to >>> ON.") >>> +if(NOT LIBCXX_ENABLE_THREADS) >>> + if(LIBCXX_HAS_PTHREAD_API) >>> +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to >>> ON" >>> +" when LIBCXX_ENABLE_THREADS is also set to >>> ON.") >>> + endif() >>> + if(LIBCXX_HAS_EXTERNAL_THRE
[PATCH] D29143: [OpenMP] Codegen support for 'target teams' on the NVPTX device.
arpith-jacob created this revision. Herald added a subscriber: jholewinski. This is a simple patch to teach OpenMP codegen to emit the construct in Generic mode. https://reviews.llvm.org/D29143 Files: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp test/OpenMP/nvptx_target_teams_codegen.cpp Index: test/OpenMP/nvptx_target_teams_codegen.cpp === --- /dev/null +++ test/OpenMP/nvptx_target_teams_codegen.cpp @@ -0,0 +1,222 @@ +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +// Check that the execution mode of all 2 target regions is set to Generic Mode. +// CHECK-DAG: {{@__omp_offloading_.+l26}}_exec_mode = weak constant i8 1 +// CHECK-DAG: {{@__omp_offloading_.+l31}}_exec_mode = weak constant i8 1 + +template +tx ftemplate(int n) { + tx a = 0; + short aa = 0; + tx b[10]; + + #pragma omp target teams if(0) + { +b[2] += 1; + } + + #pragma omp target teams if(1) + { +a = '1'; + } + + #pragma omp target teams if(n>40) + { +aa = 1; + } + + return a; +} + +int bar(int n){ + int a = 0; + + a += ftemplate(n); + + return a; +} + + // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l21}}_worker() + + + + + + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker() + // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8, + // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*, + // CHECK: store i8* null, i8** [[OMP_WORK_FN]], + // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]], + // CHECK: br label {{%?}}[[AWAIT_WORK:.+]] + // + // CHECK: [[AWAIT_WORK]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) + // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8 + // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1 + // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null + // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]] + // + // CHECK: [[SEL_WORKERS]] + // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]] + // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0 + // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]] + // + // CHECK: [[EXEC_PARALLEL]] + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[TERM_PARALLEL]] + // CHECK: call void @__kmpc_kernel_end_parallel() + // CHECK: br label {{%?}}[[BAR_PARALLEL]] + // + // CHECK: [[BAR_PARALLEL]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: br label {{%?}}[[AWAIT_WORK]] + // + // CHECK: [[EXIT]] + // CHECK: ret void + + // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+template.+l26]](i[[SZ:32|64]] [[A:%[^)]+]]) + // CHECK: store i[[SZ]] [[A]], i[[SZ]]* [[A_ADDR:%.+]], align + // CHECK: [[CONV:%.+]] = bitcast i[[SZ]]* [[A_ADDR]] to i8* + + // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x() + // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x() + // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize() + // CHECK-DAG: [[TH_LIMIT:%.+]] = sub i32 [[NTH]], [[WS]] + // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[TH_LIMIT]] + // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[CHECK_MASTER:.+]] + // + // CHECK: [[WORKER]] + // CHECK: {{call|invoke}} void [[T1]]_worker() + // CHECK: br label {{%?}}[[EXIT:.+]] + // + // CHECK: [[CHECK_MASTER]] + // CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x() + // CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x() + // CHECK-DAG: [[CMWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize() + // CHECK: [[IS_MASTER:%.+]] = icmp eq i32 [[CMTID]], + // CHECK: br i1 [[IS_MASTER]], label {{%?}}[[MASTE
[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support
dim added a comment. In https://reviews.llvm.org/D28520#656202, @delesley wrote: > The big question for me is whether these functions are exposed as part of the > public libcxx API, or whether they are only used internally. As far as I can see, they are only used internally, in `src/algorithm.cpp` and `src/mutex.cpp`. Of course they aren't "hidden" in any way in the `include/__thread_support` header, but obviously functions starting with double underscores are not meant as a public API. > If they are only used internally, then no_thread_safety_analysis is probably > the correct option. (Unless, of course, the libcxx developers want to start > using the analysis themselves, but I suspect they don't.) Yes, and since @EricWF also prefers this, I going to switch this review back to the previous form again. https://reviews.llvm.org/D28520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support
dim updated this revision to Diff 85794. dim added a comment. Back to the previous version, using `no_thread_safety_analysis` for FreeBSD only. Optionally, we could delete the `defined(__FreeBSD__)` part, and disable the analysis for all platforms. https://reviews.llvm.org/D28520 Files: include/__threading_support Index: include/__threading_support === --- include/__threading_support +++ include/__threading_support @@ -40,6 +40,12 @@ #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY #endif +#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis) +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) +#else +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS +#endif + _LIBCPP_BEGIN_NAMESPACE_STD #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) @@ -102,25 +108,25 @@ _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY @@ -133,10 +139,10 @@ _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, timespec *__ts); Index: include/__threading_support === --- include/__threading_support +++ include/__threading_support @@ -40,6 +40,12 @@ #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY #endif +#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis) +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) +#else +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS +#endif + _LIBCPP_BEGIN_NAMESPACE_STD #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) @@ -102,25 +108,25 @@ _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY @@ -133,10 +139,10 @@ _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); -_LIBCPP_THREAD_ABI_VISIBILITY +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, timespec *__ts); __
r293097 - [CodeGen] [CUDA] Add the ability set default attrs on functions in linked modules.
Author: jlebar Date: Wed Jan 25 15:29:48 2017 New Revision: 293097 URL: http://llvm.org/viewvc/llvm-project?rev=293097&view=rev Log: [CodeGen] [CUDA] Add the ability set default attrs on functions in linked modules. Summary: Now when you ask clang to link in a bitcode module, you can tell it to set attributes on that module's functions to match what we would have set if we'd emitted those functions ourselves. This is particularly important for fast-math attributes in CUDA compilations. Each CUDA compilation links in libdevice, a bitcode library provided by nvidia as part of the CUDA distribution. Without this patch, if we have a user-function F that is compiled with -ffast-math that calls a function G from libdevice, F will have the unsafe-fp-math=true (etc.) attributes, but G will have no attributes. Since F calls G, the inliner will merge G's attributes into F's. It considers the lack of an unsafe-fp-math=true attribute on G to be tantamount to unsafe-fp-math=false, so it "merges" these by setting unsafe-fp-math=false on F. This then continues up the call graph, until every function that (transitively) calls something in libdevice gets unsafe-fp-math=false set, thus disabling fastmath in almost all CUDA code. Reviewers: echristo Subscribers: hfinkel, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D28538 Added: cfe/trunk/test/CodeGenCUDA/propagate-metadata.cu Modified: cfe/trunk/include/clang/CodeGen/CodeGenAction.h cfe/trunk/include/clang/Frontend/CodeGenOptions.h cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/CodeGen/CodeGenAction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenAction.h?rev=293097&r1=293096&r2=293097&view=diff == --- cfe/trunk/include/clang/CodeGen/CodeGenAction.h (original) +++ cfe/trunk/include/clang/CodeGen/CodeGenAction.h Wed Jan 25 15:29:48 2017 @@ -23,11 +23,28 @@ class BackendConsumer; class CodeGenAction : public ASTFrontendAction { private: + // Let BackendConsumer access LinkModule. + friend class BackendConsumer; + + /// Info about module to link into a module we're generating. + struct LinkModule { +/// The module to link in. +std::unique_ptr Module; + +/// If true, we set attributes on Module's functions according to our +/// CodeGenOptions and LangOptions, as though we were generating the +/// function ourselves. +bool PropagateAttrs; + +/// Bitwise combination of llvm::LinkerFlags used when we link the module. +unsigned LinkFlags; + }; + unsigned Act; std::unique_ptr TheModule; - // Vector of {Linker::Flags, Module*} pairs to specify bitcode - // modules to link in using corresponding linker flags. - SmallVector, 4> LinkModules; + + /// Bitcode modules to link in to our module. + SmallVector LinkModules; llvm::LLVMContext *VMContext; bool OwnsVMContext; @@ -51,13 +68,6 @@ protected: public: ~CodeGenAction() override; - /// setLinkModule - Set the link module to be used by this action. If a link - /// module is not provided, and CodeGenOptions::LinkBitcodeFile is non-empty, - /// the action will load it from the specified file. - void addLinkModule(llvm::Module *Mod, unsigned LinkFlags) { -LinkModules.push_back(std::make_pair(LinkFlags, Mod)); - } - /// Take the generated LLVM module, for use after the action has been run. /// The result may be null on failure. std::unique_ptr takeModule(); Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=293097&r1=293096&r2=293097&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Wed Jan 25 15:29:48 2017 @@ -130,8 +130,19 @@ public: /// The float precision limit to use, if non-empty. std::string LimitFloatPrecision; - /// The name of the bitcode file to link before optzns. - std::vector> LinkBitcodeFiles; + struct BitcodeFileToLink { +/// The filename of the bitcode file to link in. +std::string Filename; +/// If true, we set attributes functions in the bitcode library according to +/// our CodeGenOptions, much as we set attrs on functions that we generate +/// ourselves. +bool PropagateAttrs = false; +/// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker. +unsigned LinkFlags = 0; + }; + + /// The files specified here are linked in to the module before optimizations. + std::vector LinkBitcodeFiles; /// The user provided name for the "main file", if non-empty. This is useful /// in situations where the
[PATCH] D21675: New ODR checker for modules
rtrieu added a comment. In https://reviews.llvm.org/D21675#654659, @teemperor wrote: > I feel like we have a really similar use case in the > Analysis/CloneDetection{.h/.cpp} with the hashing of statements. I tried > substituting the call to the statement hashing with a call to the > CloneDetection API and it seems that most tests pass and the remaining fails > are just minor fixable differences (like `::foo()` and `foo()` having > different hash codes). > > Would be nice if we could make Stmt::Profile, ODRHash and the CloneDetection > use the same backend. We improved a few things that we no longer have the > periodic `realloc`s from the vector inside NodeIDSet and that we use MD5. > Also there are are some future plans on how we can better prevent regressions > when we add/extend AST nodes. Thoughts? It would help to understand your use case better. Does CloneDetection care about ::foo versus foo? How about different types with the same name? ODR checking assumes identical token sequences, so it does care about extra "::". ODR checking also will process information about type while CloneDetection looks like it only uses the type name. I see that CloneDetector uses both llvm::MD5 and llvm::FoldingSetNodeID, and only adds data via StringRef. MD5 will add the bytes as data, while FoldingSetNodeID will add the size of the string, then the bytes as data. This means MD5 may have collisions when two strings are added back to back while FoldingSetNodeID will store extra data for every integer processed. FoldingSetNodeID doesn't have this problem if AddInteger is used. Were the reallocs a big problem for CloneDetection? I don't thinking merging Stmt::Profile, ODRHash, and CloneDetection would be a good idea unless the hashes needed are very similar. Stmt::Profile and ODRHash already share a base for Stmt processing, which might be extendable to CloneDetection as well, but a full merge may be difficult. Sadly, we don't have a good story for when an AST node gets changed with new properties. The Stmt profiler does declare all the visit methods in the class definition, so that will catch any new Stmt nodes without a new visit method. https://reviews.llvm.org/D21675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21675: New ODR checker for modules
rsmith added a comment. In https://reviews.llvm.org/D21675#654659, @teemperor wrote: > Would be nice if we could make Stmt::Profile, ODRHash and the CloneDetection > use the same backend. This code is *already* reusing the Stmt::Profile code for hashing of statements. Why was a different mechanism invented for `CloneDetection`? If it doesn't have different requirements, maybe it should be rewritten in terms of the `Stmt::Profile` implementation too. https://reviews.llvm.org/D21675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25208: [libc++] Make _LIBCPP_TYPE_VIS export members
smeenai updated this revision to Diff 85816. smeenai edited the summary of this revision. smeenai removed a reviewer: compnerd. smeenai added a comment. Folding https://reviews.llvm.org/D27430 and addressing comments from that diff. https://reviews.llvm.org/D25208 Files: docs/DesignDocs/VisibilityMacros.rst include/__config include/__locale include/__mutex_base include/condition_variable include/future include/mutex include/thread Index: include/thread === --- include/thread +++ include/thread @@ -300,7 +300,9 @@ > explicit thread(_Fp&& __f, _Args&&... __args); #else // _LIBCPP_HAS_NO_VARIADICS -template explicit thread(_Fp __f); +template +inline _LIBCPP_INLINE_VISIBILITY +explicit thread(_Fp __f); #endif ~thread(); Index: include/mutex === --- include/mutex +++ include/mutex @@ -248,6 +248,7 @@ bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {return try_lock_until(chrono::steady_clock::now() + __d);} template +_LIBCPP_HIDDEN bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); void unlock() _NOEXCEPT; }; @@ -291,6 +292,7 @@ bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {return try_lock_until(chrono::steady_clock::now() + __d);} template +_LIBCPP_HIDDEN bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); void unlock() _NOEXCEPT; }; Index: include/future === --- include/future +++ include/future @@ -582,7 +582,7 @@ _LIBCPP_INLINE_VISIBILITY wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const; template -future_status +_LIBCPP_HIDDEN future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const; virtual void __execute(); @@ -1674,6 +1674,7 @@ public: promise(); template +_LIBCPP_HIDDEN promise(allocator_arg_t, const _Allocator& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY Index: include/condition_variable === --- include/condition_variable +++ include/condition_variable @@ -133,13 +133,14 @@ void notify_all() _NOEXCEPT; template +_LIBCPP_HIDDEN void wait(_Lock& __lock); template _LIBCPP_INLINE_VISIBILITY void wait(_Lock& __lock, _Predicate __pred); template -cv_status +_LIBCPP_HIDDEN cv_status wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t); Index: include/__mutex_base === --- include/__mutex_base +++ include/__mutex_base @@ -316,21 +316,22 @@ void wait(unique_lock& __lk) _NOEXCEPT; template +inline _LIBCPP_INLINE_VISIBILITY void wait(unique_lock& __lk, _Predicate __pred); template -cv_status +_LIBCPP_HIDDEN cv_status wait_until(unique_lock& __lk, const chrono::time_point<_Clock, _Duration>& __t); template -bool +_LIBCPP_HIDDEN bool wait_until(unique_lock& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred); template -cv_status +_LIBCPP_HIDDEN cv_status wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d); Index: include/__locale === --- include/__locale +++ include/__locale @@ -92,13 +92,16 @@ const locale& operator=(const locale&) _NOEXCEPT; -template locale combine(const locale&) const; +template + inline _LIBCPP_INLINE_VISIBILITY + locale combine(const locale&) const; // locale operations: string name() const; bool operator==(const locale&) const; bool operator!=(const locale& __y) const {return !(*this == __y);} template + inline _LIBCPP_INLINE_VISIBILITY bool operator()(const basic_string<_CharT, _Traits, _Allocator>&, const basic_string<_CharT, _Traits, _Allocator>&) const; Index: include/__config === --- include/__config +++ include/__config @@ -632,18 +632,22 @@ #ifndef _LIBCPP_TYPE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -#if __has_attribute(__type_visibility__) -# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) -#else -# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) -#endif +#define _LIBCPP_TYPE_VI
r293106 - [CodeGen] Suppress emission of lifetime markers if a label has been seen
Author: ahatanak Date: Wed Jan 25 16:55:13 2017 New Revision: 293106 URL: http://llvm.org/viewvc/llvm-project?rev=293106&view=rev Log: [CodeGen] Suppress emission of lifetime markers if a label has been seen in the current lexical scope. clang currently emits the lifetime.start marker of a variable when the variable comes into scope even though a variable's lifetime starts at the entry of the block with which it is associated, according to the C standard. This normally doesn't cause any problems, but in the rare case where a goto jumps backwards past the variable declaration to an earlier point in the block (see the test case added to lifetime2.c), it can cause mis-compilation. To prevent such mis-compiles, this commit conservatively disables emitting lifetime variables when a label has been seen in the current block. This problem was discussed on cfe-dev here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html rdar://problem/30153946 Differential Revision: https://reviews.llvm.org/D27680 Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/test/CodeGen/lifetime2.c Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=293106&r1=293105&r2=293106&view=diff == --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jan 25 16:55:13 2017 @@ -1022,11 +1022,21 @@ CodeGenFunction::EmitAutoVarAlloca(const // Emit a lifetime intrinsic if meaningful. There's no point in doing this // if we don't have a valid insertion point (?). if (HaveInsertPoint() && !IsMSCatchParam) { -// goto or switch-case statements can break lifetime into several -// regions which need more efforts to handle them correctly. PR28267 -// This is rare case, but it's better just omit intrinsics than have -// them incorrectly placed. -if (!Bypasses.IsBypassed(&D)) { +// If there's a jump into the lifetime of this variable, its lifetime +// gets broken up into several regions in IR, which requires more work +// to handle correctly. For now, just omit the intrinsics; this is a +// rare case, and it's better to just be conservatively correct. +// PR28267. +// +// We have to do this in all language modes if there's a jump past the +// declaration. We also have to do it in C if there's a jump to an +// earlier point in the current block because non-VLA lifetimes begin as +// soon as the containing block is entered, not when its variables +// actually come into scope; suppressing the lifetime annotations +// completely in this case is unnecessarily pessimistic, but again, this +// is rare. +if (!Bypasses.IsBypassed(&D) && +!(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) { uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy); emission.SizeForLifetimeMarkers = EmitLifetimeStart(size, address.getPointer()); Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=293106&r1=293105&r2=293106&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Jan 25 16:55:13 2017 @@ -212,6 +212,13 @@ public: /// value. This is invalid iff the function has no return value. Address ReturnValue; + /// Return true if a label was seen in the current scope. + bool hasLabelBeenSeenInCurrentScope() const { +if (CurLexicalScope) + return CurLexicalScope->hasLabels(); +return !LabelMap.empty(); + } + /// AllocaInsertPoint - This is an instruction in the entry block before which /// we prefer to insert allocas. llvm::AssertingVH AllocaInsertPt; @@ -620,6 +627,10 @@ public: rescopeLabels(); } +bool hasLabels() const { + return !Labels.empty(); +} + void rescopeLabels(); }; Modified: cfe/trunk/test/CodeGen/lifetime2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime2.c?rev=293106&r1=293105&r2=293106&view=diff == --- cfe/trunk/test/CodeGen/lifetime2.c (original) +++ cfe/trunk/test/CodeGen/lifetime2.c Wed Jan 25 16:55:13 2017 @@ -1,7 +1,7 @@ -// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2 -// RUN: %clang -S -emit-llvm -o - -O2 -Xclang -disable-lifetime-markers %s \ +// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,O2 +// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s \ // RUN: | FileCheck %s -ch
[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration
This revision was automatically updated to reflect the committed changes. Closed by commit rL293106: [CodeGen] Suppress emission of lifetime markers if a label has been seen (authored by ahatanak). Changed prior to commit: https://reviews.llvm.org/D27680?vs=85774&id=85817#toc Repository: rL LLVM https://reviews.llvm.org/D27680 Files: cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/test/CodeGen/lifetime2.c Index: cfe/trunk/test/CodeGen/lifetime2.c === --- cfe/trunk/test/CodeGen/lifetime2.c +++ cfe/trunk/test/CodeGen/lifetime2.c @@ -1,7 +1,7 @@ -// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2 -// RUN: %clang -S -emit-llvm -o - -O2 -Xclang -disable-lifetime-markers %s \ +// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,O2 +// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s \ // RUN: | FileCheck %s -check-prefixes=CHECK,O0 -// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0 +// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0 extern int bar(char *A, int n); @@ -25,13 +25,11 @@ char x; l1: bar(&x, 1); - // O2: @llvm.lifetime.start(i64 5 - // O2: @llvm.lifetime.end(i64 5 char y[5]; bar(y, 5); goto l1; // Infinite loop - // O2-NOT: @llvm.lifetime.end(i64 1 + // O2-NOT: @llvm.lifetime.end( } // CHECK-LABEL: @goto_bypass @@ -91,3 +89,24 @@ L: bar(&x, 1); } + +// O2-LABEL: define i32 @jump_backward_over_declaration( +// O2-NOT: call void @llvm.lifetime.{{.*}}(i64 4, + +extern void foo2(int p); + +int jump_backward_over_declaration(int a) { + int *p = 0; +label1: + if (p) { +foo2(*p); +return 0; + } + + int i = 999; + if (a != 2) { +p = &i; +goto label1; + } + return -1; +} Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h === --- cfe/trunk/lib/CodeGen/CodeGenFunction.h +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h @@ -212,6 +212,13 @@ /// value. This is invalid iff the function has no return value. Address ReturnValue; + /// Return true if a label was seen in the current scope. + bool hasLabelBeenSeenInCurrentScope() const { +if (CurLexicalScope) + return CurLexicalScope->hasLabels(); +return !LabelMap.empty(); + } + /// AllocaInsertPoint - This is an instruction in the entry block before which /// we prefer to insert allocas. llvm::AssertingVH AllocaInsertPt; @@ -620,6 +627,10 @@ rescopeLabels(); } +bool hasLabels() const { + return !Labels.empty(); +} + void rescopeLabels(); }; Index: cfe/trunk/lib/CodeGen/CGDecl.cpp === --- cfe/trunk/lib/CodeGen/CGDecl.cpp +++ cfe/trunk/lib/CodeGen/CGDecl.cpp @@ -1022,11 +1022,21 @@ // Emit a lifetime intrinsic if meaningful. There's no point in doing this // if we don't have a valid insertion point (?). if (HaveInsertPoint() && !IsMSCatchParam) { -// goto or switch-case statements can break lifetime into several -// regions which need more efforts to handle them correctly. PR28267 -// This is rare case, but it's better just omit intrinsics than have -// them incorrectly placed. -if (!Bypasses.IsBypassed(&D)) { +// If there's a jump into the lifetime of this variable, its lifetime +// gets broken up into several regions in IR, which requires more work +// to handle correctly. For now, just omit the intrinsics; this is a +// rare case, and it's better to just be conservatively correct. +// PR28267. +// +// We have to do this in all language modes if there's a jump past the +// declaration. We also have to do it in C if there's a jump to an +// earlier point in the current block because non-VLA lifetimes begin as +// soon as the containing block is entered, not when its variables +// actually come into scope; suppressing the lifetime annotations +// completely in this case is unnecessarily pessimistic, but again, this +// is rare. +if (!Bypasses.IsBypassed(&D) && +!(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) { uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy); emission.SizeForLifetimeMarkers = EmitLifetimeStart(size, address.getPointer()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27430: [libc++] Annotate template methods with visibility
smeenai abandoned this revision. smeenai added a comment. Folded into https://reviews.llvm.org/D25208 https://reviews.llvm.org/D27430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29152: Drop 'dllimport' when redeclaring inline function template without the attribute (PR31695)
hans created this revision. For non-template `dllimport` functions, MSVC allows providing an inline definition without spelling out the attribute again. In the example below, `f` remains a `dllimport` function. __declspec(dllimport) int f(); inline int f() { return 42; } int useit() { return f(); } However, for a function //template//, not putting `dllimport` on the redeclaration causes it to be dropped. In the example below, `f` is not `dllimport`. template __declspec(dllimport) int f(); template inline int f() { return 42; } int useit() { return f(); } This patch makes Clang match MSVC for the second example. MSVC does not warn about the attribute being dropped in the example above, but I think we should. (MSVC does warn if the `inline` keyword isn't used.) https://reviews.llvm.org/D29152 Files: lib/Sema/SemaDecl.cpp test/CodeGenCXX/dllimport.cpp test/SemaCXX/dllimport.cpp Index: test/SemaCXX/dllimport.cpp === --- test/SemaCXX/dllimport.cpp +++ test/SemaCXX/dllimport.cpp @@ -396,20 +396,28 @@ template __declspec(dllimport) void funcTmplDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} // Import inline function template. -#ifdef GNU -// expected-warning@+5{{'dllimport' attribute ignored on inline function}} -// expected-warning@+5{{'dllimport' attribute ignored on inline function}} -// expected-warning@+6{{'dllimport' attribute ignored on inline function}} -// expected-warning@+9{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}} -#endif -template __declspec(dllimport) inline void inlineFuncTmpl1() {} -template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} +#ifdef GNU // MinGW always ignores dllimport on inline functions. -template __declspec(dllimport) inline void inlineFuncTmplDecl(); +template __declspec(dllimport) inline void inlineFuncTmpl1() {} // expected-warning{{'dllimport' attribute ignored on inline function}} +template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} // expected-warning{{'dllimport' attribute ignored on inline function}} + +template __declspec(dllimport) inline void inlineFuncTmplDecl(); // expected-warning{{'dllimport' attribute ignored on inline function}} template void inlineFuncTmplDecl() {} template __declspec(dllimport) void inlineFuncTmplDef(); -templateinline void inlineFuncTmplDef() {} +templateinline void inlineFuncTmplDef() {} // expected-warning{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}} + +#else // MSVC drops dllimport when the function template is redeclared without it. (It doesn't warn, but we do.) + +template __declspec(dllimport) inline void inlineFuncTmpl1() {} +template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} + +template __declspec(dllimport) inline void inlineFuncTmplDecl(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} +template void inlineFuncTmplDecl() {} // expected-warning{{'inlineFuncTmplDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} + +template __declspec(dllimport) void inlineFuncTmplDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} +templateinline void inlineFuncTmplDef() {} // expected-warning{{'inlineFuncTmplDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} +#endif // Redeclarations template __declspec(dllimport) void funcTmplRedecl1(); @@ -436,14 +444,19 @@ template friend __declspec(dllimport) void funcTmplFriend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template friend void funcTmplFriend4(); // expected-note{{previous declaration is here}} #ifdef GNU -// expected-warning@+2{{'dllimport' attribute ignored on inline function}} +// expected-warning@+4{{'dllimport' attribute ignored on inline function}} +#else +// expected-note@+2{{previous declaration is here}} expected-note@+2{{previous attribute is here}} #endif template friend __declspec(dllimport) inline void funcTmplFriend5(); }; template __declspec(dllimport) void funcTmplFriend1(); template void funcTmplFriend2(); // expected-warning{{'funcTmplFriend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void funcTmplFriend3() {} // expected-warning{{'funcTmplFriend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) void funcTmplFriend4(); // expected-error{{redeclaration of 'funcTmplFriend4' cannot add 'dllimport' attribute}} +#ifdef MS +// expected-warning@+2{{'funcTmplFriend5' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} +#
[PATCH] D29152: Drop 'dllimport' when redeclaring inline function template without the attribute (PR31695)
hans added a reviewer: rsmith. hans added a comment. +Richard in case you have any theories on why they do it like this. https://reviews.llvm.org/D29152 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293108 - Remove the return type from the check string in test case.
Author: ahatanak Date: Wed Jan 25 17:16:32 2017 New Revision: 293108 URL: http://llvm.org/viewvc/llvm-project?rev=293108&view=rev Log: Remove the return type from the check string in test case. Bots were failing because some targets emit signext before i32. Modified: cfe/trunk/test/CodeGen/lifetime2.c Modified: cfe/trunk/test/CodeGen/lifetime2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime2.c?rev=293108&r1=293107&r2=293108&view=diff == --- cfe/trunk/test/CodeGen/lifetime2.c (original) +++ cfe/trunk/test/CodeGen/lifetime2.c Wed Jan 25 17:16:32 2017 @@ -90,7 +90,7 @@ L: bar(&x, 1); } -// O2-LABEL: define i32 @jump_backward_over_declaration( +// O2-LABEL: @jump_backward_over_declaration( // O2-NOT: call void @llvm.lifetime.{{.*}}(i64 4, extern void foo2(int p); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29151: [clang-tidy] Add misc-invalidated-iterators check.
Eugene.Zelenko added a comment. General question: isn't Static Analyzer is better place for such workflow checks? Repository: rL LLVM https://reviews.llvm.org/D29151 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29151: [clang-tidy] Add misc-invalidated-iterators check.
Prazek added inline comments. Comment at: clang-tidy/misc/InvalidatedIteratorsCheck.cpp:61 + cxxMemberCallExpr(has(memberExpr(hasDeclaration(cxxMethodDecl(hasAnyName( + "push_back", "emplace_back", "clear", + "insert", "emplace"))), Please tests for all of this functions Comment at: clang-tidy/misc/InvalidatedIteratorsCheck.cpp:92 + const auto InsertResult = + CanFuncInvalidateMemo.insert(std::make_pair(MemoTuple, false)); + assert(InsertResult.second); .insert({MemoTuple, false}) Comment at: clang-tidy/misc/InvalidatedIteratorsCheck.cpp:99 +// body; it possibly invalidates our iterators. +return (MemoIter->second = true); + } I guess this might be to optimistic assumption. Normally we should be pesimistic to not introduce false positives. I will run thi check on llvm code base with SmallVector instead of std::vector and will see. Comment at: clang-tidy/misc/InvalidatedIteratorsCheck.cpp:175-179 + const std::unique_ptr TheCFG = + CFG::buildCFG(nullptr, FuncBody, Result.Context, Options); + const std::unique_ptr BlockMap( + new StmtToBlockMap(TheCFG.get(), Result.Context)); + const std::unique_ptr Sequence( const auto BlockMap = std::make_unique(TheCFG.get(), Result.Context) etc. Comment at: clang-tidy/misc/InvalidatedIteratorsCheck.cpp:182-184 + if (!Block) { +return; + } remove extra braces Comment at: docs/clang-tidy/checks/misc-invalidated-iterators.rst:18 + vec.push_back(2017); + ref++; // Incorrect - 'ref' might have been invalidated at 'push_back'. + suggest changing it to ref = 42; When first reading I thought that it is iterator Comment at: test/clang-tidy/misc-invalidated-iterators.cpp:11-17 + class iterator { +Type *data; + + public: +iterator(Type *ptr) : data(ptr) {} +Type &operator*() { return *data; } + }; iterator in vector is just raw pointer, so I guess you can replace it with using iterator = Type*; Comment at: test/clang-tidy/misc-invalidated-iterators.cpp:29 +} + +// Correct std::vector use. Few testcases: - passing vector as pointer - passing vector as copy, it shouldn't care what happens to modyfied vector. - modyfing vector inside loop - does it finds it? like: for (auto &ref : vec) { vec.push_back(42); ref = 42; } Comment at: test/clang-tidy/misc-invalidated-iterators.cpp:125 + // CHECK-MESSAGES: :[[@LINE-4]]:5: note: possible place of invalidation +} add new line to file end Repository: rL LLVM https://reviews.llvm.org/D29151 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293111 - Fix test case committed in r293106 so that it passes on targets whose
Author: ahatanak Date: Wed Jan 25 17:36:15 2017 New Revision: 293111 URL: http://llvm.org/viewvc/llvm-project?rev=293111&view=rev Log: Fix test case committed in r293106 so that it passes on targets whose pointers are 4-bytes instead of 8-bytes. Modified: cfe/trunk/test/CodeGen/lifetime2.c Modified: cfe/trunk/test/CodeGen/lifetime2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime2.c?rev=293111&r1=293110&r2=293111&view=diff == --- cfe/trunk/test/CodeGen/lifetime2.c (original) +++ cfe/trunk/test/CodeGen/lifetime2.c Wed Jan 25 17:36:15 2017 @@ -91,7 +91,10 @@ L: } // O2-LABEL: @jump_backward_over_declaration( -// O2-NOT: call void @llvm.lifetime.{{.*}}(i64 4, +// O2: %[[p:.*]] = alloca i32* +// O2: %[[v0:.*]] = bitcast i32** %[[p]] to i8* +// O2: call void @llvm.lifetime.start(i64 {{.*}}, i8* %[[v0]]) +// O2-NOT: call void @llvm.lifetime.start( extern void foo2(int p); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members
smeenai created this revision. When building libc++ with hidden visibility, we want explicit template instantiations to export members. This is consistent with existing Windows behavior, and is necessary for clients to be able to link against a hidden visibility built libc++ without running into lots of missing symbols. An unfortunate side effect, however, is that any template methods of a class with an explicit instantiation will get default visibility when instantiated, unless the methods are explicitly marked inline or hidden visibility. This is not desirable for clients of libc++ headers who wish to control their visibility, and led to PR30642. Annotate all problematic methods with an explicit visibility specifier to avoid this. The problematic methods were found by running https://github.com/smeenai/bad-visibility-finder against the libc++ headers after making the _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS change. The small methods were marked for inlining; the larger ones hidden. It should be noted that _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS was originally intended to expand to default visibility, and was changed to expanding to default type visibility to fix PR30642. The visibility macro documentation was not updated accordingly, however, so this change makes the macro consistent with its documentation again, while explicitly fixing the methods which resulted in that PR. https://reviews.llvm.org/D29157 Files: include/__config include/locale include/string Index: include/string === --- include/string +++ include/string @@ -792,6 +792,7 @@ basic_string(const basic_string& __str, size_type __pos, const allocator_type& __a = allocator_type()); template +_LIBCPP_HIDDEN basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type(), typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0); @@ -927,6 +928,7 @@ basic_string& append(__self_view __sv) { return append(__sv.data(), __sv.size()); } basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); template +_LIBCPP_HIDDEN typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, @@ -988,6 +990,7 @@ #endif basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); template +_LIBCPP_HIDDEN typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, @@ -998,14 +1001,16 @@ basic_string& assign(const value_type* __s); basic_string& assign(size_type __n, value_type __c); template +_LIBCPP_HIDDEN typename enable_if < __is_exactly_input_iterator<_InputIterator>::value || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string& >::type assign(_InputIterator __first, _InputIterator __last); template +_LIBCPP_HIDDEN typename enable_if < __is_forward_iterator<_ForwardIterator>::value @@ -1023,6 +1028,7 @@ _LIBCPP_INLINE_VISIBILITY basic_string& insert(size_type __pos1, __self_view __sv) { return insert(__pos1, __sv.data(), __sv.size()); } template +_LIBCPP_HIDDEN typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, @@ -1037,14 +1043,16 @@ _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __pos, size_type __n, value_type __c); template +_LIBCPP_HIDDEN typename enable_if < __is_exactly_input_iterator<_InputIterator>::value || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, iterator >::type insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); template +_LIBCPP_HIDDEN typename enable_if < __is_forward_iterator<_ForwardIterator>::value @@ -1070,6 +1078,7 @@ basic_string& replace(size_type __pos1, size_type __n1, __self_view __sv) { return replace(__pos1, __n1, __sv.data(), __sv.size()); } basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); template +_LIBCPP_HIDDEN typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, @@ -1090,6 +1099,7 @@ _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); template +inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_input_iterator<_InputIterator>::value, Index: include/
r293123 - Remove and replace DiagStatePoint tracking and lookup data structure.
Author: rsmith Date: Wed Jan 25 19:01:01 2017 New Revision: 293123 URL: http://llvm.org/viewvc/llvm-project?rev=293123&view=rev Log: Remove and replace DiagStatePoint tracking and lookup data structure. Rather than storing a single flat list of SourceLocations where the diagnostic state changes (in source order), we now store a separate list for each FileID in which there is a diagnostic state transition. (State for other files is built and cached lazily, on demand.) This has two consequences: 1) We can now sensibly support modules, and properly track the diagnostic state for modular headers (this matters when, for instance, triggering instantiation of a template defined within a module triggers diagnostics). 2) It's much faster than the old approach, since we can now just do a binary search on the offsets within the FileID rather than needing to call isBeforeInTranslationUnit to determine source order (which is surprisingly slow). For some pathological (but real world) files, this reduces total compilation time by more than 10%. For now, the diagnostic state points for modules are loaded eagerly. It seems feasible to defer this until diagnostic state information for one of the module's files is needed, but that's not part of this patch. Added: cfe/trunk/test/Modules/diag-pragma.cpp Modified: cfe/trunk/include/clang/Basic/Diagnostic.h cfe/trunk/lib/Basic/Diagnostic.cpp cfe/trunk/lib/Basic/DiagnosticIDs.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/test/Modules/Inputs/diag_pragma.h Modified: cfe/trunk/include/clang/Basic/Diagnostic.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=293123&r1=293122&r2=293123&view=diff == --- cfe/trunk/include/clang/Basic/Diagnostic.h (original) +++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Jan 25 19:01:01 2017 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -232,40 +233,97 @@ private: /// \brief Keeps and automatically disposes all DiagStates that we create. std::list DiagStates; - /// \brief Represents a point in source where the diagnostic state was - /// modified because of a pragma. - /// - /// 'Loc' can be null if the point represents the diagnostic state - /// modifications done through the command-line. - struct DiagStatePoint { -DiagState *State; -SourceLocation Loc; -DiagStatePoint(DiagState *State, SourceLocation Loc) - : State(State), Loc(Loc) { } + /// A mapping from files to the diagnostic states for those files. Lazily + /// built on demand for files in which the diagnostic state has not changed. + class DiagStateMap { + public: +/// Add an initial diagnostic state. +void appendFirst(DiagState *State); +/// Add a new latest state point. +void append(SourceManager &SrcMgr, SourceLocation Loc, DiagState *State); +/// Look up the diagnostic state at a given source location. +DiagState *lookup(SourceManager &SrcMgr, SourceLocation Loc) const; +/// Determine whether this map is empty. +bool empty() const { return Files.empty(); } +/// Clear out this map. +void clear() { + Files.clear(); + FirstDiagState = CurDiagState = nullptr; + CurDiagStateLoc = SourceLocation(); +} + +/// Grab the most-recently-added state point. +DiagState *getCurDiagState() const { return CurDiagState; } +/// Get the location at which a diagnostic state was last added. +SourceLocation getCurDiagStateLoc() const { return CurDiagStateLoc; } + + private: +/// \brief Represents a point in source where the diagnostic state was +/// modified because of a pragma. +/// +/// 'Loc' can be null if the point represents the diagnostic state +/// modifications done through the command-line. +struct DiagStatePoint { + DiagState *State; + unsigned Offset; + DiagStatePoint(DiagState *State, unsigned Offset) +: State(State), Offset(Offset) { } +}; + +/// Description of the diagnostic states and state transitions for a +/// particular FileID. +struct File { + /// The diagnostic state for the parent file. This is strictly redundant, + /// as looking up the DecomposedIncludedLoc for the FileID in the Files + /// map would give us this, but we cache it here for performance. + File *Parent = nullptr; + /// The offset of this file within its parent. + unsigned ParentOffset = 0; + /// Whether this file has any local (not imported from an AST file) + /// diagnostic state transitions. + bool HasLocalTransitions = false; + /// The points within the file where the state changes. There will always + /// be at least one of these (the state on entry to the file). + llvm::SmallVector StateTransitions; + + DiagState *lookup(unsigned Off
[PATCH] D29162: AMDGPU: Add a test checking alignments of emitted globals/allocas
arsenm created this revision. Herald added a reviewer: tstellarAMD. Herald added subscribers: tony-tye, nhaehnle, wdng, kzhuravl. Make sure the spec required type alignments are used in preparation for a possible change which may break this. https://reviews.llvm.org/D29162 Files: test/CodeGenOpenCL/amdgpu-alignment.cl Index: test/CodeGenOpenCL/amdgpu-alignment.cl === --- /dev/null +++ test/CodeGenOpenCL/amdgpu-alignment.cl @@ -0,0 +1,524 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +typedef char __attribute__((ext_vector_type(2))) char2; +typedef char __attribute__((ext_vector_type(3))) char3; +typedef char __attribute__((ext_vector_type(4))) char4; +typedef char __attribute__((ext_vector_type(8))) char8; +typedef char __attribute__((ext_vector_type(16))) char16; + +typedef short __attribute__((ext_vector_type(2))) short2; +typedef short __attribute__((ext_vector_type(3))) short3; +typedef short __attribute__((ext_vector_type(4))) short4; +typedef short __attribute__((ext_vector_type(8))) short8; +typedef short __attribute__((ext_vector_type(16))) short16; + +typedef int __attribute__((ext_vector_type(2))) int2; +typedef int __attribute__((ext_vector_type(3))) int3; +typedef int __attribute__((ext_vector_type(4))) int4; +typedef int __attribute__((ext_vector_type(8))) int8; +typedef int __attribute__((ext_vector_type(16))) int16; + +typedef long __attribute__((ext_vector_type(2))) long2; +typedef long __attribute__((ext_vector_type(3))) long3; +typedef long __attribute__((ext_vector_type(4))) long4; +typedef long __attribute__((ext_vector_type(8))) long8; +typedef long __attribute__((ext_vector_type(16))) long16; + +typedef half __attribute__((ext_vector_type(2))) half2; +typedef half __attribute__((ext_vector_type(3))) half3; +typedef half __attribute__((ext_vector_type(4))) half4; +typedef half __attribute__((ext_vector_type(8))) half8; +typedef half __attribute__((ext_vector_type(16))) half16; + +typedef float __attribute__((ext_vector_type(2))) float2; +typedef float __attribute__((ext_vector_type(3))) float3; +typedef float __attribute__((ext_vector_type(4))) float4; +typedef float __attribute__((ext_vector_type(8))) float8; +typedef float __attribute__((ext_vector_type(16))) float16; + +typedef double __attribute__((ext_vector_type(2))) double2; +typedef double __attribute__((ext_vector_type(3))) double3; +typedef double __attribute__((ext_vector_type(4))) double4; +typedef double __attribute__((ext_vector_type(8))) double8; +typedef double __attribute__((ext_vector_type(16))) double16; + +// CHECK: @local_memory_alignment_global.lds_i8 = internal addrspace(3) global [4 x i8] undef, align 1 +// CHECK: @local_memory_alignment_global.lds_v2i8 = internal addrspace(3) global [4 x <2 x i8>] undef, align 2 +// CHECK: @local_memory_alignment_global.lds_v3i8 = internal addrspace(3) global [4 x <3 x i8>] undef, align 4 +// CHECK: @local_memory_alignment_global.lds_v4i8 = internal addrspace(3) global [4 x <4 x i8>] undef, align 4 +// CHECK: @local_memory_alignment_global.lds_v8i8 = internal addrspace(3) global [4 x <8 x i8>] undef, align 8 +// CHECK: @local_memory_alignment_global.lds_v16i8 = internal addrspace(3) global [4 x <16 x i8>] undef, align 16 +// CHECK: @local_memory_alignment_global.lds_i16 = internal addrspace(3) global [4 x i16] undef, align 2 +// CHECK: @local_memory_alignment_global.lds_v2i16 = internal addrspace(3) global [4 x <2 x i16>] undef, align 4 +// CHECK: @local_memory_alignment_global.lds_v3i16 = internal addrspace(3) global [4 x <3 x i16>] undef, align 8 +// CHECK: @local_memory_alignment_global.lds_v4i16 = internal addrspace(3) global [4 x <4 x i16>] undef, align 8 +// CHECK: @local_memory_alignment_global.lds_v8i16 = internal addrspace(3) global [4 x <8 x i16>] undef, align 16 +// CHECK: @local_memory_alignment_global.lds_v16i16 = internal addrspace(3) global [4 x <16 x i16>] undef, align 32 +// CHECK: @local_memory_alignment_global.lds_i32 = internal addrspace(3) global [4 x i32] undef, align 4 +// CHECK: @local_memory_alignment_global.lds_v2i32 = internal addrspace(3) global [4 x <2 x i32>] undef, align 8 +// CHECK: @local_memory_alignment_global.lds_v3i32 = internal addrspace(3) global [4 x <3 x i32>] undef, align 16 +// CHECK: @local_memory_alignment_global.lds_v4i32 = internal addrspace(3) global [4 x <4 x i32>] undef, align 16 +// CHECK: @local_memory_alignment_global.lds_v8i32 = internal addrspace(3) global [4 x <8 x i32>] undef, align 32 +// CHECK: @local_memory_alignment_global.lds_v16i32 = internal addrspace(3) global [4 x <16 x i32>] undef, align 64 +// CHECK: @local_memory_alignment_global.lds_i64 = internal addrspace(3) global [4 x i64] undef, align 8 +// CHECK: @local_memory_alignment_global.lds_v2i
r293134 - [index] When indexing an ObjC method declaration use its base name for the location.
Author: akirtzidis Date: Wed Jan 25 20:11:50 2017 New Revision: 293134 URL: http://llvm.org/viewvc/llvm-project?rev=293134&view=rev Log: [index] When indexing an ObjC method declaration use its base name for the location. Instead of using the location of the beginning '-'/'+'. This is consistent with location used for function decls and ObjC method calls where we use the base name as the location as well. Modified: cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/test/Index/Core/index-source.m cfe/trunk/test/Index/Core/index-subkinds.m cfe/trunk/test/Index/index-decls.m cfe/trunk/test/Index/index-module.m cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp cfe/trunk/tools/libclang/CXIndexDataConsumer.h Modified: cfe/trunk/lib/Index/IndexDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=293134&r1=293133&r2=293134&view=diff == --- cfe/trunk/lib/Index/IndexDecl.cpp (original) +++ cfe/trunk/lib/Index/IndexDecl.cpp Wed Jan 25 20:11:50 2017 @@ -92,7 +92,13 @@ public: Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf, AssociatedProp); -if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations)) +// getLocation() returns beginning token of a method declaration, but for +// indexing purposes we want to point to the base name. +SourceLocation MethodLoc = D->getSelectorStartLoc(); +if (MethodLoc.isInvalid()) + MethodLoc = D->getLocation(); + +if (!IndexCtx.handleDecl(D, MethodLoc, (unsigned)SymbolRole::Dynamic, Relations)) return false; IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D); bool hasIBActionAndFirst = D->hasAttr(); Modified: cfe/trunk/test/Index/Core/index-source.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=293134&r1=293133&r2=293134&view=diff == --- cfe/trunk/test/Index/Core/index-source.m (original) +++ cfe/trunk/test/Index/Core/index-source.m Wed Jan 25 20:11:50 2017 @@ -3,10 +3,10 @@ @interface Base // CHECK: [[@LINE-1]]:12 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Decl | rel: 0 -(void)meth; -// CHECK: [[@LINE-1]]:1 | instance-method/ObjC | meth | c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1 +// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | meth | c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1 // CHECK-NEXT: RelChild | Base | c:objc(cs)Base +(Base*)class_meth; -// CHECK: [[@LINE-1]]:1 | class-method/ObjC | class_meth | c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 1 +// CHECK: [[@LINE-1]]:9 | class-method/ObjC | class_meth | c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 1 // CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1 // CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth @@ -92,7 +92,7 @@ extern int setjmp(jmp_buf); @class I1; @interface I1 -// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | meth | c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:8 | instance-method/ObjC | meth | c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1 -(void)meth; @end @@ -117,7 +117,7 @@ extern int setjmp(jmp_buf); // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2 @synthesize prop = _prop; -// CHECK: [[@LINE+5]]:1 | instance-method(IB)/ObjC | doAction:foo: | c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | rel: 1 +// CHECK: [[@LINE+5]]:12 | instance-method(IB)/ObjC | doAction:foo: | c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | rel: 1 // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2 // CHECK: [[@LINE+3]]:22 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 | Ref,RelCont,RelIBType | rel: 1 // CHECK-NEXT: RelCont,RelIBType | doAction:foo: | c:objc(cs)I2(im)doAction:foo: @@ -127,11 +127,11 @@ extern int setjmp(jmp_buf); @interface I3 @property (readwrite) id prop; -// CHECK: [[@LINE+3]]:1 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2 +// CHECK: [[@LINE+3]]:6 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2 // CHECK-NEXT: RelChild | I3 | c:objc(cs)I3 // CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop -(id)prop; -// CHECK: [[@LINE+3]]:1 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Decl,Dyn,RelChild,RelAcc | rel: 2 +// CHECK: [[@LINE+3]]:8 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Decl,Dyn,RelChild,RelAcc | rel: 2 // CHECK-NEXT: RelChild | I3 | c:objc(cs)I3 // CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop -(voi
Re: r293134 - [index] When indexing an ObjC method declaration use its base name for the location.
Hi Hans, Could this go into the stable branch ? > On Jan 25, 2017, at 6:11 PM, Argyrios Kyrtzidis via cfe-commits > wrote: > > Author: akirtzidis > Date: Wed Jan 25 20:11:50 2017 > New Revision: 293134 > > URL: http://llvm.org/viewvc/llvm-project?rev=293134&view=rev > Log: > [index] When indexing an ObjC method declaration use its base name for the > location. > > Instead of using the location of the beginning '-'/'+'. > This is consistent with location used for function decls and ObjC method > calls where we use the base name as the location as well. > > Modified: >cfe/trunk/lib/Index/IndexDecl.cpp >cfe/trunk/test/Index/Core/index-source.m >cfe/trunk/test/Index/Core/index-subkinds.m >cfe/trunk/test/Index/index-decls.m >cfe/trunk/test/Index/index-module.m >cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp >cfe/trunk/tools/libclang/CXIndexDataConsumer.h > > Modified: cfe/trunk/lib/Index/IndexDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=293134&r1=293133&r2=293134&view=diff > == > --- cfe/trunk/lib/Index/IndexDecl.cpp (original) > +++ cfe/trunk/lib/Index/IndexDecl.cpp Wed Jan 25 20:11:50 2017 > @@ -92,7 +92,13 @@ public: > Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf, > AssociatedProp); > > -if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations)) > +// getLocation() returns beginning token of a method declaration, but for > +// indexing purposes we want to point to the base name. > +SourceLocation MethodLoc = D->getSelectorStartLoc(); > +if (MethodLoc.isInvalid()) > + MethodLoc = D->getLocation(); > + > +if (!IndexCtx.handleDecl(D, MethodLoc, (unsigned)SymbolRole::Dynamic, > Relations)) > return false; > IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D); > bool hasIBActionAndFirst = D->hasAttr(); > > Modified: cfe/trunk/test/Index/Core/index-source.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=293134&r1=293133&r2=293134&view=diff > == > --- cfe/trunk/test/Index/Core/index-source.m (original) > +++ cfe/trunk/test/Index/Core/index-source.m Wed Jan 25 20:11:50 2017 > @@ -3,10 +3,10 @@ > @interface Base > // CHECK: [[@LINE-1]]:12 | class/ObjC | Base | c:objc(cs)Base | > _OBJC_CLASS_$_Base | Decl | rel: 0 > -(void)meth; > -// CHECK: [[@LINE-1]]:1 | instance-method/ObjC | meth | > c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1 > +// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | meth | > c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1 > // CHECK-NEXT: RelChild | Base | c:objc(cs)Base > +(Base*)class_meth; > -// CHECK: [[@LINE-1]]:1 | class-method/ObjC | class_meth | > c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 1 > +// CHECK: [[@LINE-1]]:9 | class-method/ObjC | class_meth | > c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 1 > // CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | > _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1 > // CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth > > @@ -92,7 +92,7 @@ extern int setjmp(jmp_buf); > > @class I1; > @interface I1 > -// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | meth | c:objc(cs)I1(im)meth > | -[I1 meth] | Decl,Dyn,RelChild | rel: 1 > +// CHECK: [[@LINE+1]]:8 | instance-method/ObjC | meth | c:objc(cs)I1(im)meth > | -[I1 meth] | Decl,Dyn,RelChild | rel: 1 > -(void)meth; > @end > > @@ -117,7 +117,7 @@ extern int setjmp(jmp_buf); > // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2 > @synthesize prop = _prop; > > -// CHECK: [[@LINE+5]]:1 | instance-method(IB)/ObjC | doAction:foo: | > c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | rel: > 1 > +// CHECK: [[@LINE+5]]:12 | instance-method(IB)/ObjC | doAction:foo: | > c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | rel: > 1 > // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2 > // CHECK: [[@LINE+3]]:22 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 > | Ref,RelCont,RelIBType | rel: 1 > // CHECK-NEXT: RelCont,RelIBType | doAction:foo: | > c:objc(cs)I2(im)doAction:foo: > @@ -127,11 +127,11 @@ extern int setjmp(jmp_buf); > > @interface I3 > @property (readwrite) id prop; > -// CHECK: [[@LINE+3]]:1 | instance-method/acc-get/ObjC | prop | > c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2 > +// CHECK: [[@LINE+3]]:6 | instance-method/acc-get/ObjC | prop | > c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2 > // CHECK-NEXT: RelChild | I3 | c:objc(cs)I3 > // CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop > -(id)prop; > -// CHECK: [[@LINE+3]]:1 | instance-method/acc-set/ObjC | setProp: | > c:objc(cs)I3(im)set
r293146 - Support MIR opt-remarks with -fsave-optimization-record
Author: anemet Date: Wed Jan 25 22:07:11 2017 New Revision: 293146 URL: http://llvm.org/viewvc/llvm-project?rev=293146&view=rev Log: Support MIR opt-remarks with -fsave-optimization-record The handler that deals with IR passed/missed/analysis remarks is extended to also handle the corresponding MIR remarks. The more thorough testing in done via llc (rL293113, rL293121). Here we just make sure that the functionality is accessible through clang. Added: cfe/trunk/test/CodeGen/opt-record-MIR.c Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=293146&r1=293145&r2=293146&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Wed Jan 25 22:07:11 2017 @@ -23,6 +23,7 @@ #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Lex/Preprocessor.h" #include "llvm/Bitcode/BitcodeReader.h" +#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" @@ -306,9 +307,8 @@ namespace clang { /// them. void EmitOptimizationMessage(const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID); -void OptimizationRemarkHandler(const llvm::OptimizationRemark &D); -void OptimizationRemarkHandler(const llvm::OptimizationRemarkMissed &D); -void OptimizationRemarkHandler(const llvm::OptimizationRemarkAnalysis &D); +void +OptimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationBase &D); void OptimizationRemarkHandler( const llvm::OptimizationRemarkAnalysisFPCommute &D); void OptimizationRemarkHandler( @@ -576,36 +576,34 @@ void BackendConsumer::EmitOptimizationMe } void BackendConsumer::OptimizationRemarkHandler( -const llvm::OptimizationRemark &D) { - // Optimization remarks are active only if the -Rpass flag has a regular - // expression that matches the name of the pass name in \p D. - if (CodeGenOpts.OptimizationRemarkPattern && - CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName())) -EmitOptimizationMessage(D, diag::remark_fe_backend_optimization_remark); -} - -void BackendConsumer::OptimizationRemarkHandler( -const llvm::OptimizationRemarkMissed &D) { - // Missed optimization remarks are active only if the -Rpass-missed - // flag has a regular expression that matches the name of the pass - // name in \p D. - if (CodeGenOpts.OptimizationRemarkMissedPattern && - CodeGenOpts.OptimizationRemarkMissedPattern->match(D.getPassName())) -EmitOptimizationMessage(D, - diag::remark_fe_backend_optimization_remark_missed); -} - -void BackendConsumer::OptimizationRemarkHandler( -const llvm::OptimizationRemarkAnalysis &D) { - // Optimization analysis remarks are active if the pass name is set to - // llvm::DiagnosticInfo::AlwasyPrint or if the -Rpass-analysis flag has a - // regular expression that matches the name of the pass name in \p D. - - if (D.shouldAlwaysPrint() || - (CodeGenOpts.OptimizationRemarkAnalysisPattern && - CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName( -EmitOptimizationMessage( -D, diag::remark_fe_backend_optimization_remark_analysis); +const llvm::DiagnosticInfoOptimizationBase &D) { + if (D.isPassed()) { +// Optimization remarks are active only if the -Rpass flag has a regular +// expression that matches the name of the pass name in \p D. +if (CodeGenOpts.OptimizationRemarkPattern && +CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName())) + EmitOptimizationMessage(D, diag::remark_fe_backend_optimization_remark); + } else if (D.isMissed()) { +// Missed optimization remarks are active only if the -Rpass-missed +// flag has a regular expression that matches the name of the pass +// name in \p D. +if (CodeGenOpts.OptimizationRemarkMissedPattern && +CodeGenOpts.OptimizationRemarkMissedPattern->match(D.getPassName())) + EmitOptimizationMessage( + D, diag::remark_fe_backend_optimization_remark_missed); + } else { +assert(D.isAnalysis() && "Unknown remark type"); + +bool ShouldAlwaysPrint = false; +if (auto *ORA = dyn_cast(&D)) + ShouldAlwaysPrint = ORA->shouldAlwaysPrint(); + +if (ShouldAlwaysPrint || +(CodeGenOpts.OptimizationRemarkAnalysisPattern && + CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName( + EmitOptimizationMessage( + D, diag::remark_fe_backend_optimization_remark_analysis); + } } void BackendConsumer::OptimizationRemarkHandler( @@ -688,6 +686,21 @@ void BackendConsumer::DiagnosticHandlerI // handler. There is no generic way of emitting them.
r293147 - Fix test from r293146
Author: anemet Date: Wed Jan 25 22:14:04 2017 New Revision: 293147 URL: http://llvm.org/viewvc/llvm-project?rev=293147&view=rev Log: Fix test from r293146 Modified: cfe/trunk/test/CodeGen/opt-record-MIR.c Modified: cfe/trunk/test/CodeGen/opt-record-MIR.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/opt-record-MIR.c?rev=293147&r1=293146&r2=293147&view=diff == --- cfe/trunk/test/CodeGen/opt-record-MIR.c (original) +++ cfe/trunk/test/CodeGen/opt-record-MIR.c Wed Jan 25 22:14:04 2017 @@ -20,7 +20,7 @@ void foo(float *p, int i) { // YAML: --- !Missed // YAML: Pass:regalloc // YAML: Name:LoopSpillReload -// YAML: DebugLoc:{ File: /Users/adam/proj/org/llvm/tools/clang/test/CodeGen/opt-record-MIR.c, +// YAML: DebugLoc:{ File: {{.*}}opt-record-MIR.c, // YAML:Line: 9, Column: 11 } // YAML: Function:foo // YAML: Args: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r293149 - Further fixes to test from r293146
Author: anemet Date: Wed Jan 25 22:34:07 2017 New Revision: 293149 URL: http://llvm.org/viewvc/llvm-project?rev=293149&view=rev Log: Further fixes to test from r293146 Require aarch64 and avoid filename in YAML since it may require quotation. Modified: cfe/trunk/test/CodeGen/opt-record-MIR.c Modified: cfe/trunk/test/CodeGen/opt-record-MIR.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/opt-record-MIR.c?rev=293149&r1=293148&r2=293149&view=diff == --- cfe/trunk/test/CodeGen/opt-record-MIR.c (original) +++ cfe/trunk/test/CodeGen/opt-record-MIR.c Wed Jan 25 22:34:07 2017 @@ -1,3 +1,4 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple arm64-apple-ios -S -o /dev/null %s -O2 -dwarf-column-info -Rpass-missed=regalloc 2>&1 | FileCheck -check-prefix=REMARK %s // RUN: %clang_cc1 -triple arm64-apple-ios -S -o /dev/null %s -O2 -dwarf-column-info 2>&1 | FileCheck -allow-empty -check-prefix=NO_REMARK %s // RUN: %clang_cc1 -triple arm64-apple-ios -S -o /dev/null %s -O2 -dwarf-column-info -opt-record-file %t.yaml @@ -14,14 +15,14 @@ void foo(float *p, int i) { } } -// REMARK: opt-record-MIR.c:9:11: remark: {{.}} spills {{.}} reloads generated in loop +// REMARK: opt-record-MIR.c:10:11: remark: {{.}} spills {{.}} reloads generated in loop // NO_REMARK-NOT: remark: // YAML: --- !Missed // YAML: Pass:regalloc // YAML: Name:LoopSpillReload -// YAML: DebugLoc:{ File: {{.*}}opt-record-MIR.c, -// YAML:Line: 9, Column: 11 } +// YAML: DebugLoc:{ File: {{.*}}, +// YAML:Line: 10, Column: 11 } // YAML: Function:foo // YAML: Args: // YAML: - NumSpills: '{{.}}' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r293154 - Use the new __has_feature(cxx_constexpr_string_builtins) for detection of the C-string intrinsics for constexpr support in std::char_traits. Thanks to Richard for the intrisic suppo
Author: marshall Date: Thu Jan 26 00:58:29 2017 New Revision: 293154 URL: http://llvm.org/viewvc/llvm-project?rev=293154&view=rev Log: Use the new __has_feature(cxx_constexpr_string_builtins) for detection of the C-string intrinsics for constexpr support in std::char_traits. Thanks to Richard for the intrisic support. Modified: libcxx/trunk/include/__config libcxx/trunk/include/__string Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=293154&r1=293153&r2=293154&view=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Thu Jan 26 00:58:29 2017 @@ -411,15 +411,6 @@ namespace std { #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif -// A constexpr version of __builtin_memcmp was added in clang 4.0 -#if __has_builtin(__builtin_memcmp) -# ifdef __apple_build_version__ -// No shipping version of Apple's clang has constexpr __builtin_memcmp -# elif __clang_major__ > 3 -# define _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR -# endif -#endif - #elif defined(_LIBCPP_COMPILER_GCC) #define _ALIGNAS(x) __attribute__((__aligned__(x))) Modified: libcxx/trunk/include/__string URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__string?rev=293154&r1=293153&r2=293154&view=diff == --- libcxx/trunk/include/__string (original) +++ libcxx/trunk/include/__string Thu Jan 26 00:58:29 2017 @@ -243,7 +243,7 @@ char_traits::compare(const char_ty { if (__n == 0) return 0; -#ifdef _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_memcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 return memcmp(__s1, __s2, __n); @@ -265,7 +265,9 @@ char_traits::find(const char_type* { if (__n == 0) return NULL; -#if _LIBCPP_STD_VER <= 14 +#if __has_feature(cxx_constexpr_string_builtins) +return __builtin_char_memchr(__s, to_int_type(__a), __n); +#elif _LIBCPP_STD_VER <= 14 return (const char_type*) memchr(__s, to_int_type(__a), __n); #else for (; __n; --__n) @@ -331,7 +333,7 @@ char_traits::compare(const char { if (__n == 0) return 0; -#if __has_builtin(__builtin_wmemcmp) +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 return wmemcmp(__s1, __s2, __n); @@ -351,7 +353,7 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX14 size_t char_traits::length(const char_type* __s) _NOEXCEPT { -#if __has_builtin(__builtin_wcslen) +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_wcslen(__s); #elif _LIBCPP_STD_VER <= 14 return wcslen(__s); @@ -369,7 +371,7 @@ char_traits::find(const char_ty { if (__n == 0) return NULL; -#if __has_builtin(__builtin_wmemchr) +#if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemchr(__s, __a, __n); #elif _LIBCPP_STD_VER <= 14 return wmemchr(__s, __a, __n); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits