Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang hangs when compile a large c file. #25790

Closed
llvmbot opened this issue Nov 5, 2015 · 6 comments
Closed

clang hangs when compile a large c file. #25790

llvmbot opened this issue Nov 5, 2015 · 6 comments
Labels
bugzilla Issues migrated from bugzilla clang:codegen IR generation bugs: mangling, exceptions, etc.

Comments

@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2015

Bugzilla Link 25416
Resolution FIXED
Resolved on Sep 09, 2016 15:17
Version unspecified
OS Linux
Blocks #24719
Reporter LLVM Bugzilla Contributor

Extended Description

We have a c file like this
It contains a jmp statement for every 4K nop. There are over
4M instructions in the asm. gcc compile it within one second.
Clang hangs.
The command line is
clang iTLB_benchmark_function.c -c -o iTLB_benchmark_function.o

void iTLB_bechmark_function() {
asm (
"1:jmp 1f\n\t"
"nop\n\t"
"nop\n\t"
.
.
.
"1:nop\n\t"
);
}

@llvmbot
Copy link
Member Author

llvmbot commented Nov 5, 2015

Is clang -S slow too or just clang -c?

Can you attach the file?

@llvmbot
Copy link
Member Author

llvmbot commented Nov 5, 2015

test case for it.
The test c file is generated by the script attached.
One may run
./generateBenchmarkFunction.sh 4096 1024 > test.c

after that, one can run
clang -c test.c to reproduce this problem.

@llvmbot
Copy link
Member Author

llvmbot commented Nov 5, 2015

Is clang -S slow too or just clang -c?

Can you attach the file?

The -S is slow too. gcc actually compile it within 3 seconds.

@llvmbot
Copy link
Member Author

llvmbot commented Nov 5, 2015

reduced test
This is really a clang bug. In this "small" version of the test:

  • clang -cc1 test.c -emit-llvm -o t.ll: takes about 3s
  • llvm-as/llvm-dis/llc/llvm-mc are "instantaneous"
  • gcc/gas are "instantaneous"

@llvmbot
Copy link
Member Author

llvmbot commented Nov 6, 2015

Most of time is spend on
static llvm::MDNode *getAsmSrcLocInfo

in the loop
if (!StrVal.empty()) {
const SourceManager &SM = CGF.CGM.getContext().getSourceManager();
const LangOptions &LangOpts = CGF.CGM.getLangOpts();

// Add the location of the start of each subsequent line of the asm to the
// MDNode.

for (unsigned i = 0, e = StrVal.size()-1; i != e; ++i) {

@llvmbot
Copy link
Member Author

llvmbot commented Sep 9, 2016

This was fixed by the reporter back in r255198. Thanks for the patch!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:codegen IR generation bugs: mangling, exceptions, etc.
Projects
None yet
Development

No branches or pull requests

1 participant