Skip to content

Conversation

@Vipul-Cariappa
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.57%. Comparing base (826be78) to head (1d4a678).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/Interpreter/CppInterOp.cpp 88.88% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #351      +/-   ##
==========================================
+ Coverage   74.45%   74.57%   +0.12%     
==========================================
  Files           8        8              
  Lines        3206     3214       +8     
==========================================
+ Hits         2387     2397      +10     
+ Misses        819      817       -2     
Files with missing lines Coverage Δ
lib/Interpreter/CppInterOp.cpp 80.10% <88.88%> (+0.08%) ⬆️

... and 1 file with indirect coverage changes

Files with missing lines Coverage Δ
lib/Interpreter/CppInterOp.cpp 80.10% <88.88%> (+0.08%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

(VD->isConstexpr() || VD->getType().isConstQualified())) {
if (const APValue* val = VD->evaluateValue()) {
if (VD->getType()->isIntegralType(C)) {
return (intptr_t)val->getInt().getRawData();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]

              return (intptr_t)val->getInt().getRawData();
                     ^

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@Vipul-Cariappa Vipul-Cariappa force-pushed the tuple-fix branch 2 times, most recently from 64b70fd to a99f1a0 Compare November 13, 2024 04:32
@Vipul-Cariappa
Copy link
Collaborator Author

Hi @vgvassilev, please look at the new changes. I am now using Sema::InstantiateVariableDefinition instead of Cpp::Declare to initialize the static constexpr.

I see some failing tests, that are due to the OSX dependency thing, rerunning them should fix it. I do not have the necessary permissions to rerun them.

@vgvassilev
Copy link
Contributor

Hi @vgvassilev, please look at the new changes. I am now using Sema::InstantiateVariableDefinition instead of Cpp::Declare to initialize the static constexpr.

I see some failing tests, that are due to the OSX dependency thing, rerunning them should fix it. I do not have the necessary permissions to rerun them.

Can you accept the invite and retry?

llvm::logAllUnhandledErrors(VDAorErr.takeError(), llvm::errs(),
"Failed to GetVariableOffset:");

if (VD->isConstexpr() && !VD->hasInit())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t here the check be if the VD is a template, implicitly instantiated with no init?

Looks like we don’t have test coverage for this case though…

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t here the check be if the VD is a template, implicitly instantiated with no init?

!VD->hasInit() satisfies the "no init" part. Checking for template may not be required.


Looks like we don’t have test coverage for this case though…

Yes. The test case does not cover it. Running the cppyy test suit, it gets covered there. But I am not able to reproduce that here.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@Vipul-Cariappa Vipul-Cariappa marked this pull request as ready for review November 13, 2024 14:35
@Vipul-Cariappa
Copy link
Collaborator Author

Looks like cppyy-cling backend fails.

llvm::logAllUnhandledErrors(VDAorErr.takeError(), llvm::errs(),
"Failed to GetVariableOffset:");
return 0;
if (VDAorErr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inversion seems wrong. Later, unconditionally we call logAllUnhandledErrors.

getSema().InstantiateVariableDefinition(SourceLocation(), VD);
if (VD->hasInit() &&
(VD->isConstexpr() || VD->getType().isConstQualified())) {
if (const APValue* val = VD->evaluateValue()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These operations are cheaper and probably should go before the heavy getSymbolAddress?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the same with 24c82c5 commit.
This change happened to resolve things sooner and getSymbolAddress was never executed. Please look at the code coverage results of the same commit.

Sorry for the force pushes

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

EXPECT_EQ(datamembers.size(), 1);

intptr_t offset = Cpp::GetVariableOffset(datamembers[0]);
EXPECT_EQ(3, *(int*)offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]

  EXPECT_EQ(3, *(int*)offset);
                ^

EXPECT_EQ(datamembers.size(), 1);

intptr_t offset = Cpp::GetVariableOffset(datamembers[0]);
EXPECT_EQ(3, *(int*)offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]

  EXPECT_EQ(3, *(int*)offset);
                ^

EXPECT_EQ(datamembers.size(), 1);

offset = Cpp::GetVariableOffset(datamembers[0]);
EXPECT_EQ(5, *(int*)offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]

  EXPECT_EQ(5, *(int*)offset);
                ^

EXPECT_EQ(datamembers.size(), 1);

offset = Cpp::GetVariableOffset(datamembers[0]);
EXPECT_EQ(5, *(int*)offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]

  EXPECT_EQ(5, *(int*)offset);
                ^

EXPECT_EQ(datamembers.size(), 1);

offset = Cpp::GetVariableOffset(datamembers[0]);
EXPECT_EQ(2, *(int*)offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]

  EXPECT_EQ(2, *(int*)offset);
                ^

EXPECT_EQ(datamembers.size(), 1);

offset = Cpp::GetVariableOffset(datamembers[0]);
EXPECT_EQ(2, *(int*)offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]

  EXPECT_EQ(2, *(int*)offset);
                ^

by explicitly initializing constexpr with `Sema::InstantiateVariableDefinition`
fix for the osx dependency issue
Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vgvassilev vgvassilev merged commit e4adda3 into compiler-research:main Nov 16, 2024
55 checks passed
@Vipul-Cariappa Vipul-Cariappa deleted the tuple-fix branch November 17, 2024 03:46
Vipul-Cariappa added a commit to Vipul-Cariappa/cppyy-compiler-research that referenced this pull request Nov 28, 2024
aaronj0 pushed a commit to compiler-research/cppyy that referenced this pull request Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants