This patch checks that an argument passed to either of the builtins __builtin_frame_address or __builtin_return_address is at least 0. This patch resolves the issue where these builtins would cause an infinite loop ( 25497 ).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 47220 Build 50056: arc lint + arc unit
Event Timeline
clang/test/Sema/builtin-stackaddress.c | ||
---|---|---|
10 | For some reason lit was still erroring here. |
We usually prefer to generate error messages for incorrect parameters to builtins in SemaChecking.cpp.
I don't think there's really an infinite loop here. The parameter to __builtin_frame_address is an unsigned integer; values greater than 0x7FFFFFFU aren't special. The reason it takes a very long time is that we try to unroll the implied loop; generating an object file with four billion load instructions takes essentially forever. We could impose a smaller limit, but it would be sort of arbitrary.
Thanks for the explanation. Should I then not try to "fix" the issue? Or should I update sema checking?
In the context of __builtin_frame_address, an arbitrary limit is probably okay. Maybe something like 0xFFFF, which is larger than anyone would realistically use, but doesn't take a crazy amount of time to compile.
I was using SemaBuiltinConstantArgRange incorrectly. I was returning an error for !SemaBuiltinConstantArgRange instead of SemaBuiltinConstantArgRange. Also, I only modified the fail tests so I wasn't able to catch the error. Updated and am running both the Sema and CodeGen tests now. Should fix the error.
For some reason lit was still erroring here.