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" ); }
Is clang -S slow too or just clang -c? Can you attach the file?
Created attachment 15227 [details] 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.
(In reply to comment #1) > 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.
Created attachment 15229 [details] 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"
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) {
This was fixed by the reporter back in r255198. Thanks for the patch!